Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warn for too small energies in train/test.xyz #378

Merged
merged 2 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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