Skip to content

Commit 7e18559

Browse files
committed
fix: generate MEAM and EAM-alloy commands
Fixes #1896 Coding-Agent: Codex Codex-Version: codex-cli 0.149.0 Model: gpt-5.6-sol Reasoning-Effort: xhigh
1 parent d5ce577 commit 7e18559

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

dpgen/auto_test/Lammps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def set_model_param(self):
5454
}
5555
elif self.inter_type == "meam":
5656
model_name = list(map(os.path.basename, self.model))
57-
self.model_param = {"model_name": [model_name], "param_type": self.type_map}
57+
self.model_param = {"model_name": model_name, "param_type": self.type_map}
5858
else:
5959
model_name = os.path.basename(self.model)
6060
self.model_param = {"model_name": [model_name], "param_type": self.type_map}

dpgen/auto_test/lib/lammps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def inter_eam_fs(param): # 06/08 eam.fs interaction
148148
def inter_eam_alloy(param): # 06/08 eam.alloy interaction
149149
ret = ""
150150
line = "pair_style eam/alloy \n"
151-
line += "pair_coeff * * {} ".format(param["model_name"])
151+
line += "pair_coeff * * {} ".format(param["model_name"][0])
152152
for ii in param["param_type"]:
153153
line += ii + " "
154154
line += "\n"

tests/auto_test/test_lammps.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from dpgen.auto_test.common_equi import make_equi, run_equi
1313
from dpgen.auto_test.Lammps import Lammps
14-
from dpgen.auto_test.lib.lammps import inter_deepmd
14+
from dpgen.auto_test.lib.lammps import inter_deepmd, inter_eam_alloy, inter_meam
1515

1616
from .context import setUpModule # noqa: F401
1717

@@ -72,6 +72,32 @@ def test_set_model_param(self):
7272
}
7373
self.assertEqual(model_param, self.Lammps.model_param)
7474

75+
def test_meam_model_parameters_generate_two_file_command(self):
76+
interaction = {
77+
"type": "meam",
78+
"model": ["lammps_input/meam.lib", "lammps_input/Al.meam"],
79+
"type_map": {"Al": 0},
80+
}
81+
calculator = Lammps(interaction, self.source_path + "/Al-fcc.vasp")
82+
calculator.set_model_param()
83+
84+
self.assertEqual(calculator.model_param["model_name"], ["meam.lib", "Al.meam"])
85+
command = inter_meam(calculator.model_param)
86+
self.assertIn("pair_coeff * * meam.lib Al Al.meam Al", command)
87+
88+
def test_eam_alloy_command_uses_plain_filename(self):
89+
interaction = {
90+
"type": "eam_alloy",
91+
"model": "lammps_input/Al.eam.alloy",
92+
"type_map": {"Al": 0},
93+
}
94+
calculator = Lammps(interaction, self.source_path + "/Al-fcc.vasp")
95+
calculator.set_model_param()
96+
97+
command = inter_eam_alloy(calculator.model_param)
98+
self.assertIn("pair_coeff * * Al.eam.alloy Al", command)
99+
self.assertNotIn("['Al.eam.alloy']", command)
100+
75101
def test_make_potential_files(self):
76102
cwd = os.getcwd()
77103
abs_equi_path = os.path.abspath(self.equi_path)

0 commit comments

Comments
 (0)