Skip to content

Commit

Permalink
fix(lmp): add pair_deepmd_index key to is_key function in dplr (#…
Browse files Browse the repository at this point in the history
…4313)

Fix #4273. Tests are added in this PR.

* 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

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new key, `pair_deepmd_index`, enhancing the `FixDPLR`
class for improved pair validation in simulations.
  
- **Bug Fixes**
- Updated error handling to ensure robustness when the new
`pair_deepmd_index` is not provided.

- **Tests**
- Modified test parameters to include `pair_deepmd_index 0`, ensuring
compatibility with the new functionality while maintaining existing
validations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
njzjz and pre-commit-ci[bot] authored Nov 6, 2024
1 parent 914b1f9 commit 65aac64
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions source/lmp/fix_dplr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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
4 changes: 3 additions & 1 deletion source/lmp/tests/test_dplr.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ 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 Down

0 comments on commit 65aac64

Please sign in to comment.