From 8df7f34a45b8189aa31c3d49e37e94b770f05662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Sat, 29 Nov 2025 11:46:41 +0100 Subject: [PATCH 01/14] Fixes for manually specified potentials --- pyiron_lammps/compatibility/file.py | 30 +++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/pyiron_lammps/compatibility/file.py b/pyiron_lammps/compatibility/file.py index fd3a5c1..afdb59e 100644 --- a/pyiron_lammps/compatibility/file.py +++ b/pyiron_lammps/compatibility/file.py @@ -98,8 +98,33 @@ def lammps_file_interface_function( potential_dataframe = potential else: raise TypeError() - lmp_str_lst = lammps_file_initialization(structure=structure) - lmp_str_lst += potential_dataframe["Config"] + + potential_replace = {} + potential_lst = [] + for l in potential_dataframe["Config"]: + if l.startswith("units"): + potential_replace["units"] = l + elif l.startswith("atom_style"): + potential_replace["atom_style"] = l + elif l.startswith("dimension"): + potential_replace["dimension"] = l + else: + potential_lst.append(l) + + lmp_str_lst = [] + atom_type = "atomic" + for l in lammps_file_initialization(structure=structure): + if l.startswith("units") and "units" in potential_replace: + lmp_str_lst.append(potential_replace["units"]) + elif l.startswith("atom_style") and "atom_style" in potential_replace: + lmp_str_lst.append(potential_replace["atom_style"]) + atom_type = potential_replace["atom_style"].split()[-1] + elif l.startswith("dimension") and "dimension" in potential_replace: + lmp_str_lst.append(potential_replace["dimension"]) + else: + lmp_str_lst.append(l) + + lmp_str_lst += potential_lst lmp_str_lst += ["variable dumptime equal {} ".format(calc_kwargs.get("n_print", 1))] lmp_str_lst += [ "dump 1 all custom ${dumptime} dump.out id type xsu ysu zsu fx fy fz vx vy vz", @@ -166,6 +191,7 @@ def lammps_file_interface_function( units=units, file_name="lammps.data", working_directory=working_directory, + atom_type=atom_type, ) shell = subprocess.check_output( From 96b5efd0f0c5aa3bc3dcba6df480a7ae2d18b8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Sat, 29 Nov 2025 12:04:14 +0100 Subject: [PATCH 02/14] add tests --- pyiron_lammps/compatibility/file.py | 50 ++++++++++++++++------------- tests/test_compatibility_file.py | 45 +++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 23 deletions(-) diff --git a/pyiron_lammps/compatibility/file.py b/pyiron_lammps/compatibility/file.py index afdb59e..b49ea03 100644 --- a/pyiron_lammps/compatibility/file.py +++ b/pyiron_lammps/compatibility/file.py @@ -88,28 +88,7 @@ def lammps_file_interface_function( calc_kwargs = {} os.makedirs(working_directory, exist_ok=True) - if isinstance(potential, str): - potential_dataframe = get_potential_by_name( - potential_name=potential, resource_path=resource_path - ) - elif isinstance(potential, pandas.DataFrame): - potential_dataframe = potential.iloc[0] - elif isinstance(potential, pandas.Series): - potential_dataframe = potential - else: - raise TypeError() - - potential_replace = {} - potential_lst = [] - for l in potential_dataframe["Config"]: - if l.startswith("units"): - potential_replace["units"] = l - elif l.startswith("atom_style"): - potential_replace["atom_style"] = l - elif l.startswith("dimension"): - potential_replace["dimension"] = l - else: - potential_lst.append(l) + potential_lst, potential_replace = _get_potential(potential=potential) lmp_str_lst = [] atom_type = "atomic" @@ -248,3 +227,30 @@ def _modify_input_dict( return lmp_tmp_lst else: return lmp_str_lst + + +def _get_potential(potential): + if isinstance(potential, str): + potential_dataframe = get_potential_by_name( + potential_name=potential, resource_path=resource_path + ) + elif isinstance(potential, pandas.DataFrame): + potential_dataframe = potential.iloc[0] + elif isinstance(potential, pandas.Series): + potential_dataframe = potential + else: + raise TypeError() + + potential_replace = {} + potential_lst = [] + for l in potential_dataframe["Config"]: + if l.startswith("units"): + potential_replace["units"] = l + elif l.startswith("atom_style"): + potential_replace["atom_style"] = l + elif l.startswith("dimension"): + potential_replace["dimension"] = l + else: + potential_lst.append(l) + + return potential_lst, potential_replace diff --git a/tests/test_compatibility_file.py b/tests/test_compatibility_file.py index 57dde17..e850b57 100644 --- a/tests/test_compatibility_file.py +++ b/tests/test_compatibility_file.py @@ -3,7 +3,7 @@ import shutil from ase.build import bulk import pandas -from pyiron_lammps.compatibility.file import lammps_file_interface_function +from pyiron_lammps.compatibility.file import lammps_file_interface_function, _get_potential from pyiron_lammps.potential import get_potential_by_name @@ -460,3 +460,46 @@ def test_calc_minimize_pressure_3d(self): ] for line in content_expected: self.assertIn(line, content) + + +class TestGlassPotential(unittest.TestCase): + def test_bouhadja(self): + potential = [ + '# Bouhadja et al., J. Chem. Phys. 138, 224510 (2013) \n', + 'units metal\n', + 'dimension 3\n', + 'atom_style charge\n', + '\n', + '# create groups ###\n', + 'group Al type 1\n', + 'group Ca type 2\n', + 'group O type 3\n', + 'group Si type 4\n', + '\n### set charges ###\n', + 'set type 1 charge 1.8\n', + 'set type 2 charge 1.2\n', + 'set type 3 charge -1.2\n', + 'set type 4 charge 2.4\n', + '\n### Bouhadja Born-Mayer-Huggins + Coulomb Potential Parameters ###\n', + 'pair_style born/coul/dsf 0.25 8.0\n', + 'pair_coeff 1 1 0.002900 0.068000 1.570400 14.049800 0.000000\n', + 'pair_coeff 1 2 0.003200 0.074000 1.957200 17.171000 0.000000\n', + 'pair_coeff 1 3 0.007500 0.164000 2.606700 34.574700 0.000000\n', + 'pair_coeff 1 4 0.002500 0.057000 1.505600 18.811600 0.000000\n', + 'pair_coeff 2 2 0.003500 0.080000 2.344000 20.985600 0.000000\n', + 'pair_coeff 2 3 0.007700 0.178000 2.993500 42.255600 0.000000\n', + 'pair_coeff 2 4 0.002700 0.063000 1.892400 22.990700 0.000000\n', + 'pair_coeff 3 3 0.012000 0.263000 3.643000 85.084000 0.000000\n', + 'pair_coeff 3 4 0.007000 0.156000 2.541900 46.293000 0.000000\n', + 'pair_coeff 4 4 0.001200 0.046000 1.440800 25.187300 0.000000\n', + '\npair_modify shift yes\n' + ] + potential_lst, potential_replace = _get_potential(potential=pandas.DataFrame({"Config": [potential]})) + for i, l in enumerate(potential): + if i in [1,2,3]: + self.assertTrue(l not in potential_lst) + else: + self.assertFalse(l in potential_lst) + + for k, v in {"units": 'units metal\n', "dimension": 'dimension 3\n', "atom_style": 'atom_style charge\n'}.items(): + self.assertEqual(potential_replace[k], v) From 9ebb26a90a1833d0b4e6fbf4ca6eaea152e2e0f6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 29 Nov 2025 11:04:25 +0000 Subject: [PATCH 03/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_compatibility_file.py | 73 ++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/tests/test_compatibility_file.py b/tests/test_compatibility_file.py index e850b57..071e036 100644 --- a/tests/test_compatibility_file.py +++ b/tests/test_compatibility_file.py @@ -3,7 +3,10 @@ import shutil from ase.build import bulk import pandas -from pyiron_lammps.compatibility.file import lammps_file_interface_function, _get_potential +from pyiron_lammps.compatibility.file import ( + lammps_file_interface_function, + _get_potential, +) from pyiron_lammps.potential import get_potential_by_name @@ -465,41 +468,47 @@ def test_calc_minimize_pressure_3d(self): class TestGlassPotential(unittest.TestCase): def test_bouhadja(self): potential = [ - '# Bouhadja et al., J. Chem. Phys. 138, 224510 (2013) \n', - 'units metal\n', - 'dimension 3\n', - 'atom_style charge\n', - '\n', - '# create groups ###\n', - 'group Al type 1\n', - 'group Ca type 2\n', - 'group O type 3\n', - 'group Si type 4\n', - '\n### set charges ###\n', - 'set type 1 charge 1.8\n', - 'set type 2 charge 1.2\n', - 'set type 3 charge -1.2\n', - 'set type 4 charge 2.4\n', - '\n### Bouhadja Born-Mayer-Huggins + Coulomb Potential Parameters ###\n', - 'pair_style born/coul/dsf 0.25 8.0\n', - 'pair_coeff 1 1 0.002900 0.068000 1.570400 14.049800 0.000000\n', - 'pair_coeff 1 2 0.003200 0.074000 1.957200 17.171000 0.000000\n', - 'pair_coeff 1 3 0.007500 0.164000 2.606700 34.574700 0.000000\n', - 'pair_coeff 1 4 0.002500 0.057000 1.505600 18.811600 0.000000\n', - 'pair_coeff 2 2 0.003500 0.080000 2.344000 20.985600 0.000000\n', - 'pair_coeff 2 3 0.007700 0.178000 2.993500 42.255600 0.000000\n', - 'pair_coeff 2 4 0.002700 0.063000 1.892400 22.990700 0.000000\n', - 'pair_coeff 3 3 0.012000 0.263000 3.643000 85.084000 0.000000\n', - 'pair_coeff 3 4 0.007000 0.156000 2.541900 46.293000 0.000000\n', - 'pair_coeff 4 4 0.001200 0.046000 1.440800 25.187300 0.000000\n', - '\npair_modify shift yes\n' + "# Bouhadja et al., J. Chem. Phys. 138, 224510 (2013) \n", + "units metal\n", + "dimension 3\n", + "atom_style charge\n", + "\n", + "# create groups ###\n", + "group Al type 1\n", + "group Ca type 2\n", + "group O type 3\n", + "group Si type 4\n", + "\n### set charges ###\n", + "set type 1 charge 1.8\n", + "set type 2 charge 1.2\n", + "set type 3 charge -1.2\n", + "set type 4 charge 2.4\n", + "\n### Bouhadja Born-Mayer-Huggins + Coulomb Potential Parameters ###\n", + "pair_style born/coul/dsf 0.25 8.0\n", + "pair_coeff 1 1 0.002900 0.068000 1.570400 14.049800 0.000000\n", + "pair_coeff 1 2 0.003200 0.074000 1.957200 17.171000 0.000000\n", + "pair_coeff 1 3 0.007500 0.164000 2.606700 34.574700 0.000000\n", + "pair_coeff 1 4 0.002500 0.057000 1.505600 18.811600 0.000000\n", + "pair_coeff 2 2 0.003500 0.080000 2.344000 20.985600 0.000000\n", + "pair_coeff 2 3 0.007700 0.178000 2.993500 42.255600 0.000000\n", + "pair_coeff 2 4 0.002700 0.063000 1.892400 22.990700 0.000000\n", + "pair_coeff 3 3 0.012000 0.263000 3.643000 85.084000 0.000000\n", + "pair_coeff 3 4 0.007000 0.156000 2.541900 46.293000 0.000000\n", + "pair_coeff 4 4 0.001200 0.046000 1.440800 25.187300 0.000000\n", + "\npair_modify shift yes\n", ] - potential_lst, potential_replace = _get_potential(potential=pandas.DataFrame({"Config": [potential]})) + potential_lst, potential_replace = _get_potential( + potential=pandas.DataFrame({"Config": [potential]}) + ) for i, l in enumerate(potential): - if i in [1,2,3]: + if i in [1, 2, 3]: self.assertTrue(l not in potential_lst) else: self.assertFalse(l in potential_lst) - for k, v in {"units": 'units metal\n', "dimension": 'dimension 3\n', "atom_style": 'atom_style charge\n'}.items(): + for k, v in { + "units": "units metal\n", + "dimension": "dimension 3\n", + "atom_style": "atom_style charge\n", + }.items(): self.assertEqual(potential_replace[k], v) From 1bd0a3f51b2f796b4d6c3aadf956ff28e3a28929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Sat, 29 Nov 2025 12:09:12 +0100 Subject: [PATCH 04/14] fixes --- pyiron_lammps/compatibility/file.py | 10 +++++----- pyiron_lammps/potential.py | 4 ++-- tests/test_compatibility_file.py | 8 +++++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pyiron_lammps/compatibility/file.py b/pyiron_lammps/compatibility/file.py index b49ea03..30bfc75 100644 --- a/pyiron_lammps/compatibility/file.py +++ b/pyiron_lammps/compatibility/file.py @@ -88,7 +88,7 @@ def lammps_file_interface_function( calc_kwargs = {} os.makedirs(working_directory, exist_ok=True) - potential_lst, potential_replace = _get_potential(potential=potential) + potential_lst, potential_replace, species = _get_potential(potential=potential, resource_path=resource_path) lmp_str_lst = [] atom_type = "atomic" @@ -165,7 +165,7 @@ def lammps_file_interface_function( write_lammps_datafile( structure=structure, - potential_elements=potential_dataframe["Species"], + potential_elements=species, bond_dict=None, units=units, file_name="lammps.data", @@ -183,7 +183,7 @@ def lammps_file_interface_function( output = parse_lammps_output( working_directory=working_directory, structure=structure, - potential_elements=potential_dataframe["Species"], + potential_elements=species, units=units, prism=None, dump_h5_file_name="dump.h5", @@ -229,7 +229,7 @@ def _modify_input_dict( return lmp_str_lst -def _get_potential(potential): +def _get_potential(potential, resource_path: Optional[str]=None): if isinstance(potential, str): potential_dataframe = get_potential_by_name( potential_name=potential, resource_path=resource_path @@ -253,4 +253,4 @@ def _get_potential(potential): else: potential_lst.append(l) - return potential_lst, potential_replace + return potential_lst, potential_replace, potential_dataframe["Species"] diff --git a/pyiron_lammps/potential.py b/pyiron_lammps/potential.py index e9df255..43c7d26 100644 --- a/pyiron_lammps/potential.py +++ b/pyiron_lammps/potential.py @@ -1,6 +1,6 @@ import os from pathlib import Path -from typing import Union +from typing import Union, Optional import pandas from ase.atoms import Atoms @@ -346,7 +346,7 @@ def get_potential_dataframe(structure: Atoms, resource_path=None): ) -def get_potential_by_name(potential_name: str, resource_path=None): +def get_potential_by_name(potential_name: str, resource_path: Optional[str]=None): if resource_path is None: resource_path = get_resource_path_from_conda() df = LammpsPotentialFile(resource_path=resource_path).list() diff --git a/tests/test_compatibility_file.py b/tests/test_compatibility_file.py index 071e036..965790a 100644 --- a/tests/test_compatibility_file.py +++ b/tests/test_compatibility_file.py @@ -466,6 +466,11 @@ def test_calc_minimize_pressure_3d(self): class TestGlassPotential(unittest.TestCase): + def setUp(self): + self.static_path = os.path.abspath( + os.path.join("..", os.path.dirname(__file__), "static") + ) + def test_bouhadja(self): potential = [ "# Bouhadja et al., J. Chem. Phys. 138, 224510 (2013) \n", @@ -498,7 +503,8 @@ def test_bouhadja(self): "\npair_modify shift yes\n", ] potential_lst, potential_replace = _get_potential( - potential=pandas.DataFrame({"Config": [potential]}) + potential=pandas.DataFrame({"Config": [potential]}), + resource_path=os.path.join(self.static_path, "potential"), ) for i, l in enumerate(potential): if i in [1, 2, 3]: From a558f1bb0ccdcb97a1595dd12758f0cd4a95b22e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 29 Nov 2025 11:09:23 +0000 Subject: [PATCH 05/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyiron_lammps/compatibility/file.py | 6 ++++-- pyiron_lammps/potential.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pyiron_lammps/compatibility/file.py b/pyiron_lammps/compatibility/file.py index 30bfc75..709b873 100644 --- a/pyiron_lammps/compatibility/file.py +++ b/pyiron_lammps/compatibility/file.py @@ -88,7 +88,9 @@ def lammps_file_interface_function( calc_kwargs = {} os.makedirs(working_directory, exist_ok=True) - potential_lst, potential_replace, species = _get_potential(potential=potential, resource_path=resource_path) + potential_lst, potential_replace, species = _get_potential( + potential=potential, resource_path=resource_path + ) lmp_str_lst = [] atom_type = "atomic" @@ -229,7 +231,7 @@ def _modify_input_dict( return lmp_str_lst -def _get_potential(potential, resource_path: Optional[str]=None): +def _get_potential(potential, resource_path: Optional[str] = None): if isinstance(potential, str): potential_dataframe = get_potential_by_name( potential_name=potential, resource_path=resource_path diff --git a/pyiron_lammps/potential.py b/pyiron_lammps/potential.py index 43c7d26..2f338f1 100644 --- a/pyiron_lammps/potential.py +++ b/pyiron_lammps/potential.py @@ -1,6 +1,6 @@ import os from pathlib import Path -from typing import Union, Optional +from typing import Optional, Union import pandas from ase.atoms import Atoms @@ -346,7 +346,7 @@ def get_potential_dataframe(structure: Atoms, resource_path=None): ) -def get_potential_by_name(potential_name: str, resource_path: Optional[str]=None): +def get_potential_by_name(potential_name: str, resource_path: Optional[str] = None): if resource_path is None: resource_path = get_resource_path_from_conda() df = LammpsPotentialFile(resource_path=resource_path).list() From 6659365043d701fce67260c4d9090f079f8630ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Sat, 29 Nov 2025 12:11:29 +0100 Subject: [PATCH 06/14] fix test --- tests/test_compatibility_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_compatibility_file.py b/tests/test_compatibility_file.py index 965790a..17047c0 100644 --- a/tests/test_compatibility_file.py +++ b/tests/test_compatibility_file.py @@ -503,7 +503,7 @@ def test_bouhadja(self): "\npair_modify shift yes\n", ] potential_lst, potential_replace = _get_potential( - potential=pandas.DataFrame({"Config": [potential]}), + potential=pandas.DataFrame({"Config": [potential], "Species": ["Al", "Ca", "O", "Si"]}), resource_path=os.path.join(self.static_path, "potential"), ) for i, l in enumerate(potential): From 0864c159b1cc6275d55780ebef95bac8012ea80c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 29 Nov 2025 11:11:40 +0000 Subject: [PATCH 07/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_compatibility_file.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_compatibility_file.py b/tests/test_compatibility_file.py index 17047c0..c1f9b91 100644 --- a/tests/test_compatibility_file.py +++ b/tests/test_compatibility_file.py @@ -503,7 +503,9 @@ def test_bouhadja(self): "\npair_modify shift yes\n", ] potential_lst, potential_replace = _get_potential( - potential=pandas.DataFrame({"Config": [potential], "Species": ["Al", "Ca", "O", "Si"]}), + potential=pandas.DataFrame( + {"Config": [potential], "Species": ["Al", "Ca", "O", "Si"]} + ), resource_path=os.path.join(self.static_path, "potential"), ) for i, l in enumerate(potential): From aa8964c7a3106136905de4f16b65c167a939df70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Sat, 29 Nov 2025 12:13:18 +0100 Subject: [PATCH 08/14] again --- tests/test_compatibility_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_compatibility_file.py b/tests/test_compatibility_file.py index c1f9b91..b6251bd 100644 --- a/tests/test_compatibility_file.py +++ b/tests/test_compatibility_file.py @@ -504,7 +504,7 @@ def test_bouhadja(self): ] potential_lst, potential_replace = _get_potential( potential=pandas.DataFrame( - {"Config": [potential], "Species": ["Al", "Ca", "O", "Si"]} + {"Config": [potential], "Species": [["Al", "Ca", "O", "Si"]]} ), resource_path=os.path.join(self.static_path, "potential"), ) From 03119406e3c086b14e25607fbb956ff9fdfffd8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Sat, 29 Nov 2025 12:15:20 +0100 Subject: [PATCH 09/14] test species --- tests/test_compatibility_file.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_compatibility_file.py b/tests/test_compatibility_file.py index b6251bd..d9a30c5 100644 --- a/tests/test_compatibility_file.py +++ b/tests/test_compatibility_file.py @@ -502,9 +502,10 @@ def test_bouhadja(self): "pair_coeff 4 4 0.001200 0.046000 1.440800 25.187300 0.000000\n", "\npair_modify shift yes\n", ] - potential_lst, potential_replace = _get_potential( + element_lst = ["Al", "Ca", "O", "Si"] + potential_lst, potential_replace, species = _get_potential( potential=pandas.DataFrame( - {"Config": [potential], "Species": [["Al", "Ca", "O", "Si"]]} + {"Config": [potential], "Species": [element_lst]} ), resource_path=os.path.join(self.static_path, "potential"), ) @@ -520,3 +521,5 @@ def test_bouhadja(self): "atom_style": "atom_style charge\n", }.items(): self.assertEqual(potential_replace[k], v) + + self.assertEqual(species, element_lst) From 36921f255abc192a3b0927b5ac73c5cfa51451f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Sat, 29 Nov 2025 12:18:05 +0100 Subject: [PATCH 10/14] remove empty line --- tests/test_compatibility_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_compatibility_file.py b/tests/test_compatibility_file.py index d9a30c5..44cd32a 100644 --- a/tests/test_compatibility_file.py +++ b/tests/test_compatibility_file.py @@ -510,7 +510,7 @@ def test_bouhadja(self): resource_path=os.path.join(self.static_path, "potential"), ) for i, l in enumerate(potential): - if i in [1, 2, 3]: + if i in [1, 2, 3, 4]: self.assertTrue(l not in potential_lst) else: self.assertFalse(l in potential_lst) From 0d529f8f6217da3b68f7d98b8c0368b6090920f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Sat, 29 Nov 2025 12:19:54 +0100 Subject: [PATCH 11/14] fix validation --- tests/test_compatibility_file.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_compatibility_file.py b/tests/test_compatibility_file.py index 44cd32a..3c91191 100644 --- a/tests/test_compatibility_file.py +++ b/tests/test_compatibility_file.py @@ -511,9 +511,9 @@ def test_bouhadja(self): ) for i, l in enumerate(potential): if i in [1, 2, 3, 4]: - self.assertTrue(l not in potential_lst) - else: self.assertFalse(l in potential_lst) + else: + self.assertTrue(l in potential_lst) for k, v in { "units": "units metal\n", From e6350099c4c7dd69d1577968fa5762b738bfe60e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Sat, 29 Nov 2025 12:21:46 +0100 Subject: [PATCH 12/14] include empty line --- tests/test_compatibility_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_compatibility_file.py b/tests/test_compatibility_file.py index 3c91191..fe7f7d6 100644 --- a/tests/test_compatibility_file.py +++ b/tests/test_compatibility_file.py @@ -510,7 +510,7 @@ def test_bouhadja(self): resource_path=os.path.join(self.static_path, "potential"), ) for i, l in enumerate(potential): - if i in [1, 2, 3, 4]: + if i in [1, 2, 3]: self.assertFalse(l in potential_lst) else: self.assertTrue(l in potential_lst) From 189059dd3fdfba415b23730c355826ff276369bc Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Sat, 29 Nov 2025 12:34:43 +0100 Subject: [PATCH 13/14] add new test --- tests/test_compatibility_file.py | 88 ++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 16 deletions(-) diff --git a/tests/test_compatibility_file.py b/tests/test_compatibility_file.py index fe7f7d6..7cdc6dd 100644 --- a/tests/test_compatibility_file.py +++ b/tests/test_compatibility_file.py @@ -274,10 +274,41 @@ def test_calc_md_nvt_langevin(self): def test_calc_md_nve(self): calc_kwargs = {"n_print": 100, "langevin": True} + potential = [ + "# Bouhadja et al., J. Chem. Phys. 138, 224510 (2013) \n", + "units metal\n", + "dimension 3\n", + "atom_style charge\n", + "\n", + "# create groups ###\n", + "group Al type 1\n", + "group Ca type 2\n", + "group O type 3\n", + "group Si type 4\n", + "\n### set charges ###\n", + "set type 1 charge 1.8\n", + "set type 2 charge 1.2\n", + "set type 3 charge -1.2\n", + "set type 4 charge 2.4\n", + "\n### Bouhadja Born-Mayer-Huggins + Coulomb Potential Parameters ###\n", + "pair_style born/coul/dsf 0.25 8.0\n", + "pair_coeff 1 1 0.002900 0.068000 1.570400 14.049800 0.000000\n", + "pair_coeff 1 2 0.003200 0.074000 1.957200 17.171000 0.000000\n", + "pair_coeff 1 3 0.007500 0.164000 2.606700 34.574700 0.000000\n", + "pair_coeff 1 4 0.002500 0.057000 1.505600 18.811600 0.000000\n", + "pair_coeff 2 2 0.003500 0.080000 2.344000 20.985600 0.000000\n", + "pair_coeff 2 3 0.007700 0.178000 2.993500 42.255600 0.000000\n", + "pair_coeff 2 4 0.002700 0.063000 1.892400 22.990700 0.000000\n", + "pair_coeff 3 3 0.012000 0.263000 3.643000 85.084000 0.000000\n", + "pair_coeff 3 4 0.007000 0.156000 2.541900 46.293000 0.000000\n", + "pair_coeff 4 4 0.001200 0.046000 1.440800 25.187300 0.000000\n", + "\npair_modify shift yes\n", + ] + element_lst = ["Al", "Ca", "O", "Si"] shell_output, parsed_output, job_crashed = lammps_file_interface_function( working_directory=self.working_dir, structure=self.structure, - potential=self.potential, + potential=pandas.DataFrame({"Config": [potential], "Species": [element_lst]}), calc_mode="md", calc_kwargs=calc_kwargs, units=self.units, @@ -292,22 +323,47 @@ def test_calc_md_nve(self): with open(self.working_dir + "/lmp.in", "r") as f: content = f.readlines() content_expected = [ - "units metal\n", - "dimension 3\n", - "boundary p p p\n", - "atom_style atomic\n", - "read_data lammps.data\n", - "pair_style eam/alloy\n", - "variable dumptime equal 100 \n", - "dump 1 all custom ${dumptime} dump.out id type xsu ysu zsu fx fy fz vx vy vz\n", + 'units metal\n', + 'dimension 3\n', + 'boundary p p p\n', + 'atom_style charge\n', + '\n', + 'read_data lammps.data\n', + '# Bouhadja et al., J. Chem. Phys. 138, 224510 (2013) \n', + '# create groups ###\n', + 'group Al type 1\n', + 'group Ca type 2\n', + 'group O type 3\n', + 'group Si type 4\n', + '### set charges ###\n', + 'set type 1 charge 1.8\n', + 'set type 2 charge 1.2\n', + 'set type 3 charge -1.2\n', + 'set type 4 charge 2.4\n', + '### Bouhadja Born-Mayer-Huggins + Coulomb Potential Parameters ###\n', + 'pair_style born/coul/dsf 0.25 8.0\n', + 'pair_coeff 1 1 0.002900 0.068000 1.570400 14.049800 0.000000\n', + 'pair_coeff 1 2 0.003200 0.074000 1.957200 17.171000 0.000000\n', + 'pair_coeff 1 3 0.007500 0.164000 2.606700 34.574700 0.000000\n', + 'pair_coeff 1 4 0.002500 0.057000 1.505600 18.811600 0.000000\n', + 'pair_coeff 2 2 0.003500 0.080000 2.344000 20.985600 0.000000\n', + 'pair_coeff 2 3 0.007700 0.178000 2.993500 42.255600 0.000000\n', + 'pair_coeff 2 4 0.002700 0.063000 1.892400 22.990700 0.000000\n', + 'pair_coeff 3 3 0.012000 0.263000 3.643000 85.084000 0.000000\n', + 'pair_coeff 3 4 0.007000 0.156000 2.541900 46.293000 0.000000\n', + 'pair_coeff 4 4 0.001200 0.046000 1.440800 25.187300 0.000000\n', + 'pair_modify shift yes\n', + 'variable dumptime equal 100 \n', + 'dump 1 all custom ${dumptime} dump.out id type xsu ysu zsu fx fy fz vx vy vz\n', 'dump_modify 1 sort id format line "%d %d %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g"\n', - "fix ensemble all nve\n", - "variable thermotime equal 100 \n", - "timestep 0.001\n", - "thermo_style custom step temp pe etotal pxx pxy pxz pyy pyz pzz vol\n", - "thermo_modify format float %20.15g\n", - "thermo ${thermotime}\n", - "run 1 \n", + 'fix ensemble all nve\n', + 'variable thermotime equal 100 \n', + 'timestep 0.001\n', + 'velocity all create None 80996 dist gaussian\n', + 'thermo_style custom step temp pe etotal pxx pxy pxz pyy pyz pzz vol\n', + 'thermo_modify format float %20.15g\n', + 'thermo ${thermotime}\n', + 'run 1 \n' ] for line in content_expected: self.assertIn(line, content) From 1bb9297b27d2c928d00c9377cfb31d8124a66d66 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 29 Nov 2025 11:34:52 +0000 Subject: [PATCH 14/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_compatibility_file.py | 84 ++++++++++++++++---------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/tests/test_compatibility_file.py b/tests/test_compatibility_file.py index 7cdc6dd..93cef2b 100644 --- a/tests/test_compatibility_file.py +++ b/tests/test_compatibility_file.py @@ -308,7 +308,9 @@ def test_calc_md_nve(self): shell_output, parsed_output, job_crashed = lammps_file_interface_function( working_directory=self.working_dir, structure=self.structure, - potential=pandas.DataFrame({"Config": [potential], "Species": [element_lst]}), + potential=pandas.DataFrame( + {"Config": [potential], "Species": [element_lst]} + ), calc_mode="md", calc_kwargs=calc_kwargs, units=self.units, @@ -323,47 +325,47 @@ def test_calc_md_nve(self): with open(self.working_dir + "/lmp.in", "r") as f: content = f.readlines() content_expected = [ - 'units metal\n', - 'dimension 3\n', - 'boundary p p p\n', - 'atom_style charge\n', - '\n', - 'read_data lammps.data\n', - '# Bouhadja et al., J. Chem. Phys. 138, 224510 (2013) \n', - '# create groups ###\n', - 'group Al type 1\n', - 'group Ca type 2\n', - 'group O type 3\n', - 'group Si type 4\n', - '### set charges ###\n', - 'set type 1 charge 1.8\n', - 'set type 2 charge 1.2\n', - 'set type 3 charge -1.2\n', - 'set type 4 charge 2.4\n', - '### Bouhadja Born-Mayer-Huggins + Coulomb Potential Parameters ###\n', - 'pair_style born/coul/dsf 0.25 8.0\n', - 'pair_coeff 1 1 0.002900 0.068000 1.570400 14.049800 0.000000\n', - 'pair_coeff 1 2 0.003200 0.074000 1.957200 17.171000 0.000000\n', - 'pair_coeff 1 3 0.007500 0.164000 2.606700 34.574700 0.000000\n', - 'pair_coeff 1 4 0.002500 0.057000 1.505600 18.811600 0.000000\n', - 'pair_coeff 2 2 0.003500 0.080000 2.344000 20.985600 0.000000\n', - 'pair_coeff 2 3 0.007700 0.178000 2.993500 42.255600 0.000000\n', - 'pair_coeff 2 4 0.002700 0.063000 1.892400 22.990700 0.000000\n', - 'pair_coeff 3 3 0.012000 0.263000 3.643000 85.084000 0.000000\n', - 'pair_coeff 3 4 0.007000 0.156000 2.541900 46.293000 0.000000\n', - 'pair_coeff 4 4 0.001200 0.046000 1.440800 25.187300 0.000000\n', - 'pair_modify shift yes\n', - 'variable dumptime equal 100 \n', - 'dump 1 all custom ${dumptime} dump.out id type xsu ysu zsu fx fy fz vx vy vz\n', + "units metal\n", + "dimension 3\n", + "boundary p p p\n", + "atom_style charge\n", + "\n", + "read_data lammps.data\n", + "# Bouhadja et al., J. Chem. Phys. 138, 224510 (2013) \n", + "# create groups ###\n", + "group Al type 1\n", + "group Ca type 2\n", + "group O type 3\n", + "group Si type 4\n", + "### set charges ###\n", + "set type 1 charge 1.8\n", + "set type 2 charge 1.2\n", + "set type 3 charge -1.2\n", + "set type 4 charge 2.4\n", + "### Bouhadja Born-Mayer-Huggins + Coulomb Potential Parameters ###\n", + "pair_style born/coul/dsf 0.25 8.0\n", + "pair_coeff 1 1 0.002900 0.068000 1.570400 14.049800 0.000000\n", + "pair_coeff 1 2 0.003200 0.074000 1.957200 17.171000 0.000000\n", + "pair_coeff 1 3 0.007500 0.164000 2.606700 34.574700 0.000000\n", + "pair_coeff 1 4 0.002500 0.057000 1.505600 18.811600 0.000000\n", + "pair_coeff 2 2 0.003500 0.080000 2.344000 20.985600 0.000000\n", + "pair_coeff 2 3 0.007700 0.178000 2.993500 42.255600 0.000000\n", + "pair_coeff 2 4 0.002700 0.063000 1.892400 22.990700 0.000000\n", + "pair_coeff 3 3 0.012000 0.263000 3.643000 85.084000 0.000000\n", + "pair_coeff 3 4 0.007000 0.156000 2.541900 46.293000 0.000000\n", + "pair_coeff 4 4 0.001200 0.046000 1.440800 25.187300 0.000000\n", + "pair_modify shift yes\n", + "variable dumptime equal 100 \n", + "dump 1 all custom ${dumptime} dump.out id type xsu ysu zsu fx fy fz vx vy vz\n", 'dump_modify 1 sort id format line "%d %d %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g"\n', - 'fix ensemble all nve\n', - 'variable thermotime equal 100 \n', - 'timestep 0.001\n', - 'velocity all create None 80996 dist gaussian\n', - 'thermo_style custom step temp pe etotal pxx pxy pxz pyy pyz pzz vol\n', - 'thermo_modify format float %20.15g\n', - 'thermo ${thermotime}\n', - 'run 1 \n' + "fix ensemble all nve\n", + "variable thermotime equal 100 \n", + "timestep 0.001\n", + "velocity all create None 80996 dist gaussian\n", + "thermo_style custom step temp pe etotal pxx pxy pxz pyy pyz pzz vol\n", + "thermo_modify format float %20.15g\n", + "thermo ${thermotime}\n", + "run 1 \n", ] for line in content_expected: self.assertIn(line, content)