Skip to content
Open
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
2 changes: 1 addition & 1 deletion dpgen/auto_test/Lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def set_model_param(self):
}
elif self.inter_type == "meam":
model_name = list(map(os.path.basename, self.model))
self.model_param = {"model_name": [model_name], "param_type": self.type_map}
self.model_param = {"model_name": model_name, "param_type": self.type_map}
else:
model_name = os.path.basename(self.model)
self.model_param = {"model_name": [model_name], "param_type": self.type_map}
Expand Down
2 changes: 1 addition & 1 deletion dpgen/auto_test/lib/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def inter_eam_fs(param): # 06/08 eam.fs interaction
def inter_eam_alloy(param): # 06/08 eam.alloy interaction
ret = ""
line = "pair_style eam/alloy \n"
line += "pair_coeff * * {} ".format(param["model_name"])
line += "pair_coeff * * {} ".format(param["model_name"][0])
for ii in param["param_type"]:
line += ii + " "
line += "\n"
Expand Down
28 changes: 27 additions & 1 deletion tests/auto_test/test_lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from dpgen.auto_test.common_equi import make_equi, run_equi
from dpgen.auto_test.Lammps import Lammps
from dpgen.auto_test.lib.lammps import inter_deepmd
from dpgen.auto_test.lib.lammps import inter_deepmd, inter_eam_alloy, inter_meam

from .context import setUpModule # noqa: F401

Expand Down Expand Up @@ -72,6 +72,32 @@ def test_set_model_param(self):
}
self.assertEqual(model_param, self.Lammps.model_param)

def test_meam_model_parameters_generate_two_file_command(self):
interaction = {
"type": "meam",
"model": ["lammps_input/meam.lib", "lammps_input/Al.meam"],
"type_map": {"Al": 0},
}
calculator = Lammps(interaction, self.source_path + "/Al-fcc.vasp")
calculator.set_model_param()

self.assertEqual(calculator.model_param["model_name"], ["meam.lib", "Al.meam"])
command = inter_meam(calculator.model_param)
self.assertIn("pair_coeff * * meam.lib Al Al.meam Al", command)

def test_eam_alloy_command_uses_plain_filename(self):
interaction = {
"type": "eam_alloy",
"model": "lammps_input/Al.eam.alloy",
"type_map": {"Al": 0},
}
calculator = Lammps(interaction, self.source_path + "/Al-fcc.vasp")
calculator.set_model_param()

command = inter_eam_alloy(calculator.model_param)
self.assertIn("pair_coeff * * Al.eam.alloy Al", command)
self.assertNotIn("['Al.eam.alloy']", command)

def test_make_potential_files(self):
cwd = os.getcwd()
abs_equi_path = os.path.abspath(self.equi_path)
Expand Down