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

fix(lmp): call model deviation interface without atomic properties when they are not requested #4012

Merged
merged 2 commits into from
Jul 24, 2024
Merged
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
27 changes: 19 additions & 8 deletions source/lmp/pair_deepmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,12 +662,23 @@
vector<double> all_energy;
vector<vector<double>> all_atom_energy;
vector<vector<double>> all_atom_virial;
try {
deep_pot_model_devi.compute(
all_energy, all_force, all_virial, all_atom_energy, all_atom_virial,
dcoord, dtype, dbox, nghost, lmp_list, ago, fparam, daparam);
} catch (deepmd_compat::deepmd_exception &e) {
error->one(FLERR, e.what());
if (!(eflag_atom || cvflag_atom)) {
try {
deep_pot_model_devi.compute(all_energy, all_force, all_virial, dcoord,
dtype, dbox, nghost, lmp_list, ago,
fparam, daparam);
} catch (deepmd_compat::deepmd_exception &e) {
error->one(FLERR, e.what());

Check warning on line 671 in source/lmp/pair_deepmd.cpp

View check run for this annotation

Codecov / codecov/patch

source/lmp/pair_deepmd.cpp#L670-L671

Added lines #L670 - L671 were not covered by tests
}
} else {
try {
deep_pot_model_devi.compute(all_energy, all_force, all_virial,
all_atom_energy, all_atom_virial, dcoord,
dtype, dbox, nghost, lmp_list, ago,
fparam, daparam);
} catch (deepmd_compat::deepmd_exception &e) {
error->one(FLERR, e.what());

Check warning on line 680 in source/lmp/pair_deepmd.cpp

View check run for this annotation

Codecov / codecov/patch

source/lmp/pair_deepmd.cpp#L679-L680

Added lines #L679 - L680 were not covered by tests
}
}
// deep_pot_model_devi.compute_avg (dener, all_energy);
// deep_pot_model_devi.compute_avg (dforce, all_force);
Expand All @@ -677,9 +688,8 @@
dener = all_energy[0];
dforce = all_force[0];
dvirial = all_virial[0];
deatom = all_atom_energy[0];
dvatom = all_atom_virial[0];
if (eflag_atom) {
deatom = all_atom_energy[0];

Check warning on line 692 in source/lmp/pair_deepmd.cpp

View check run for this annotation

Codecov / codecov/patch

source/lmp/pair_deepmd.cpp#L692

Added line #L692 was not covered by tests
for (int ii = 0; ii < nlocal; ++ii) {
eatom[ii] += scale[1][1] * deatom[ii] * ener_unit_cvt_factor;
}
Expand All @@ -688,6 +698,7 @@
// interface the atomic virial computed by DeepMD
// with the one used in centroid atoms
if (cvflag_atom) {
dvatom = all_atom_virial[0];
for (int ii = 0; ii < nall; ++ii) {
// vatom[ii][0] += 1.0 * dvatom[9*ii+0];
// vatom[ii][1] += 1.0 * dvatom[9*ii+4];
Expand Down