Skip to content

Commit

Permalink
fix(lmp): add pair_deepmd_index key to is_key function in `fix_dp…
Browse files Browse the repository at this point in the history
…lr.cpp`

Fix deepmodeling#4273.

* Modify `is_key` function to include `keys.push_back("pair_deepmd_index")`

Update tests in `test_dplr.py` to include `pair_deepmd_index` command

* Add `pair_deepmd_index 0` to various `lammps.fix` commands in the test cases
  • Loading branch information
njzjz committed Nov 5, 2024
1 parent 9ed0397 commit a559e28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/lmp/fix_dplr.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
#include "fix_dplr.h"

#include <iomanip>
Expand Down Expand Up @@ -30,6 +29,7 @@ static bool is_key(const string &input) {
keys.push_back("type_associate");
keys.push_back("bond_type");
keys.push_back("efield");
keys.push_back("pair_deepmd_index");
for (int ii = 0; ii < keys.size(); ++ii) {
if (input == keys[ii]) {
return true;
Expand Down
12 changes: 6 additions & 6 deletions source/lmp/tests/test_dplr.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def test_pair_deepmd_lr(lammps):
lammps.special_bonds("lj/coul 1 1 1 angle no")
lammps.kspace_style("pppm/dplr 1e-5")
lammps.kspace_modify(f"gewald {beta:.2f} diff ik mesh {mesh:d} {mesh:d} {mesh:d}")
lammps.fix(f"0 all dplr model {pb_file.resolve()} type_associate 1 3 bond_type 1")
lammps.fix(f"0 all dplr model {pb_file.resolve()} type_associate 1 3 bond_type 1 pair_deepmd_index 0")
lammps.fix_modify("0 virial yes")
lammps.run(0)
for ii in range(8):
Expand All @@ -412,7 +412,7 @@ def test_pair_deepmd_lr_efield_constant(lammps):
lammps.bond_coeff("*")
lammps.special_bonds("lj/coul 1 1 1 angle no")
lammps.fix(
f"0 all dplr model {pb_file.resolve()} type_associate 1 3 bond_type 1 efield 0 0 1"
f"0 all dplr model {pb_file.resolve()} type_associate 1 3 bond_type 1 efield 0 0 1 pair_deepmd_index 0"
)
lammps.fix_modify("0 energy yes virial yes")
lammps.run(0)
Expand Down Expand Up @@ -448,7 +448,7 @@ def test_pair_deepmd_lr_efield_variable(lammps):
lammps.bond_coeff("*")
lammps.special_bonds("lj/coul 1 1 1 angle no")
lammps.fix(
f"0 all dplr model {pb_file.resolve()} type_associate 1 3 bond_type 1 efield 0 0 v_EFIELD_Z"
f"0 all dplr model {pb_file.resolve()} type_associate 1 3 bond_type 1 efield 0 0 v_EFIELD_Z pair_deepmd_index 0"
)
lammps.fix_modify("0 energy yes virial yes")
lammps.run(0)
Expand Down Expand Up @@ -484,7 +484,7 @@ def test_min_dplr(lammps):
lammps.special_bonds("lj/coul 1 1 1 angle no")
lammps.kspace_style("pppm/dplr 1e-5")
lammps.kspace_modify(f"gewald {beta:.2f} diff ik mesh {mesh:d} {mesh:d} {mesh:d}")
lammps.fix(f"0 all dplr model {pb_file.resolve()} type_associate 1 3 bond_type 1")
lammps.fix(f"0 all dplr model {pb_file.resolve()} type_associate 1 3 bond_type 1 pair_deepmd_index 0")
lammps.fix_modify("0 virial yes")
lammps.min_style("cg")
lammps.minimize("0 1.0e-6 2 2")
Expand All @@ -511,7 +511,7 @@ def test_pair_deepmd_lr_type_map(lammps_type_map):
f"gewald {beta:.2f} diff ik mesh {mesh:d} {mesh:d} {mesh:d}"
)
lammps_type_map.fix(
f"0 all dplr model {pb_file.resolve()} type_associate 2 3 bond_type 1"
f"0 all dplr model {pb_file.resolve()} type_associate 2 3 bond_type 1 pair_deepmd_index 0"
)
lammps_type_map.fix_modify("0 virial yes")
lammps_type_map.run(0)
Expand Down Expand Up @@ -541,7 +541,7 @@ def test_pair_deepmd_lr_si(lammps_si):
f"gewald {beta / constants.dist_metal2si:.6e} diff ik mesh {mesh:d} {mesh:d} {mesh:d}"
)
lammps_si.fix(
f"0 all dplr model {pb_file.resolve()} type_associate 1 3 bond_type 1"
f"0 all dplr model {pb_file.resolve()} type_associate 1 3 bond_type 1 pair_deepmd_index 0"
)
lammps_si.fix_modify("0 virial yes")
lammps_si.run(0)
Expand Down

0 comments on commit a559e28

Please sign in to comment.