Skip to content

Commit

Permalink
Merge pull request #378 from brucefan1983/warn_too_low_energy
Browse files Browse the repository at this point in the history
warn for too small energies in train/test.xyz
  • Loading branch information
brucefan1983 authored Feb 25, 2023
2 parents 4da77e4 + e9c23b4 commit e6ecb1d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions doc/nep/input_files/train_test_xyz.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ Tips
* The minimal number of atoms in a configuration is 1.
The user is responsible for choosing a sensible reference energy when preparing the energy data.
But this is not crucial as the absolute energies are not relevant in the present context.
However, because NEP training uses single precision, accuracy will be lost if any reference energy is smaller than -100 eV/atom. The code will give a warning message in this case.
* The energy and virial data refer to the total energy and virial for the system.
They are not per-atom but per-cell quantities.
8 changes: 0 additions & 8 deletions src/main_nep/fitness.cu
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ Get the fitness

Fitness::Fitness(Parameters& para)
{
print_line_1();
printf("Started reading train.xyz.\n");
print_line_2();

int deviceCount;
CHECK(cudaGetDeviceCount(&deviceCount));

Expand Down Expand Up @@ -72,10 +68,6 @@ Fitness::Fitness(Parameters& para)
std::vector<Structure> structures_test;
has_test_set = read_structures(false, para, structures_test);
if (has_test_set) {
print_line_1();
printf("Started reading test.xyz.\n");
print_line_2();

test_set.resize(deviceCount);
for (int device_id = 0; device_id < deviceCount; ++device_id) {
print_line_1();
Expand Down
17 changes: 17 additions & 0 deletions src/main_nep/structure.cu
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,20 @@ read_exyz(const Parameters& para, std::ifstream& input, std::vector<Structure>&
++Nc;
}
printf("Number of configurations = %d.\n", Nc);

for (const auto& s : structures) {
if (s.energy < -100.0f) {
std::cout << "Warning: \n";
std::cout << " There is energy < -100 eV/atom in the data set.\n";
std::cout << " Because we use single precision in NEP training\n";
std::cout << " it means that the reference and calculated energies\n";
std::cout << " might only be accurate up to 1 meV/atom\n";
std::cout << " which can effectively introduce noises.\n";
std::cout << " We suggest you preprocess (using double precision)\n";
std::cout << " your data to make the energies closer to 0." << std::endl;
break;
}
}
}

static void find_permuted_indices(std::vector<int>& permuted_indices)
Expand Down Expand Up @@ -474,6 +488,9 @@ bool read_structures(bool is_train, Parameters& para, std::vector<Structure>& st
has_test_set = false;
}
} else {
print_line_1();
is_train ? printf("Started reading train.xyz.\n") : printf("Started reading test.xyz.\n");
print_line_2();
read_exyz(para, input, structures);
input.close();
}
Expand Down

0 comments on commit e6ecb1d

Please sign in to comment.