From fe6374a971aaf6e4444f3ad010b165dbdc3a6037 Mon Sep 17 00:00:00 2001 From: Raynol Dsouza Date: Tue, 15 Mar 2022 22:06:45 +0100 Subject: [PATCH 1/9] modify where number of bond types is chosen from --- pyiron_atomistics/lammps/structure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyiron_atomistics/lammps/structure.py b/pyiron_atomistics/lammps/structure.py index d987bd6b6..c0374316a 100644 --- a/pyiron_atomistics/lammps/structure.py +++ b/pyiron_atomistics/lammps/structure.py @@ -341,7 +341,7 @@ def structure_bond(self): + " \n" + "{0} atom types".format(self._structure.get_number_of_species()) + " \n" - + "{0} bond types".format(np.max(bond_type)) + + "{0} bond types".format(np.max(bonds[:, 2])) + " \n" ) From f13a4144a5e549a164e6aaf3a11975b6b4fb88f6 Mon Sep 17 00:00:00 2001 From: Raynol Dsouza Date: Tue, 15 Mar 2022 23:44:43 +0100 Subject: [PATCH 2/9] revert to check if change is really the issue --- pyiron_atomistics/lammps/structure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyiron_atomistics/lammps/structure.py b/pyiron_atomistics/lammps/structure.py index c0374316a..d987bd6b6 100644 --- a/pyiron_atomistics/lammps/structure.py +++ b/pyiron_atomistics/lammps/structure.py @@ -341,7 +341,7 @@ def structure_bond(self): + " \n" + "{0} atom types".format(self._structure.get_number_of_species()) + " \n" - + "{0} bond types".format(np.max(bonds[:, 2])) + + "{0} bond types".format(np.max(bond_type)) + " \n" ) From 54cc6e667bb83fd44a884230eea912e38296d88f Mon Sep 17 00:00:00 2001 From: Raynol Dsouza Date: Wed, 16 Mar 2022 06:34:33 +0100 Subject: [PATCH 3/9] change is NOT the issue --- pyiron_atomistics/lammps/structure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyiron_atomistics/lammps/structure.py b/pyiron_atomistics/lammps/structure.py index d987bd6b6..c0374316a 100644 --- a/pyiron_atomistics/lammps/structure.py +++ b/pyiron_atomistics/lammps/structure.py @@ -341,7 +341,7 @@ def structure_bond(self): + " \n" + "{0} atom types".format(self._structure.get_number_of_species()) + " \n" - + "{0} bond types".format(np.max(bond_type)) + + "{0} bond types".format(np.max(bonds[:, 2])) + " \n" ) From 175ad66b6cb407023e9e63d32d533e931cb6cb98 Mon Sep 17 00:00:00 2001 From: Raynol Dsouza Date: Sun, 20 Mar 2022 23:33:09 +0100 Subject: [PATCH 4/9] make bonds into array to avoid slice error --- pyiron_atomistics/lammps/structure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyiron_atomistics/lammps/structure.py b/pyiron_atomistics/lammps/structure.py index c0374316a..fd4607754 100644 --- a/pyiron_atomistics/lammps/structure.py +++ b/pyiron_atomistics/lammps/structure.py @@ -341,7 +341,7 @@ def structure_bond(self): + " \n" + "{0} atom types".format(self._structure.get_number_of_species()) + " \n" - + "{0} bond types".format(np.max(bonds[:, 2])) + + "{0} bond types".format(np.max(np.array(bonds)[:, 2])) + " \n" ) From 2fc24faaf0733f24faa0f495e4a3e8fdbc087795 Mon Sep 17 00:00:00 2001 From: Raynol Dsouza Date: Sun, 20 Mar 2022 23:33:30 +0100 Subject: [PATCH 5/9] add a simple test --- tests/lammps/test_base.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/lammps/test_base.py b/tests/lammps/test_base.py index cedb77595..c859aed67 100644 --- a/tests/lammps/test_base.py +++ b/tests/lammps/test_base.py @@ -678,3 +678,22 @@ def test_units(self): def setter(x): self.job.units = x self.assertRaises(ValueError, setter, "nonsense") + + def test_bonds_input(self): + potential = pd.DataFrame({'Name': ['Morse'], + 'Filename': [[]], + 'Model' : ['Morse'], + 'Species' : [['Al']], + 'Config' : [['bond_coeff 1 0.1 1.5 2.856\n', + 'bond_coeff 2 0.1 1.5 2.856']]}) + cell = Atoms(elements=4*['Al'], positions=[[0., 0., 0.], + [0., 2., 2.], + [2., 0., 2.], + [2., 2., 0.]], + cell=4*np.eye(3)) + self.job.structure = cell.repeat(2) + self.job.structure.bonds = [[1, 2, 1], [1, 3, 2]] + self.job.potential = potential + self.job.calc_static() + self.job.run() + From 074c68c9b4f473c7c960d5496be270b4561fd2b3 Mon Sep 17 00:00:00 2001 From: Raynol Dsouza Date: Mon, 21 Mar 2022 00:16:15 +0100 Subject: [PATCH 6/9] wrong script for potential --- tests/lammps/test_base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/lammps/test_base.py b/tests/lammps/test_base.py index c859aed67..8aaa23adb 100644 --- a/tests/lammps/test_base.py +++ b/tests/lammps/test_base.py @@ -684,8 +684,10 @@ def test_bonds_input(self): 'Filename': [[]], 'Model' : ['Morse'], 'Species' : [['Al']], - 'Config' : [['bond_coeff 1 0.1 1.5 2.856\n', - 'bond_coeff 2 0.1 1.5 2.856']]}) + 'Config' : [['atom_style bond\n', + 'bond_style morse\n', + 'bond_coeff 1 0.1 1.5 2.0\n', + 'bond_coeff 2 0.1 1.5 2.0']]}) cell = Atoms(elements=4*['Al'], positions=[[0., 0., 0.], [0., 2., 2.], [2., 0., 2.], From 078cceac658ba0030016a251cb01ef6ca42bf9c1 Mon Sep 17 00:00:00 2001 From: Raynol Dsouza Date: Mon, 21 Mar 2022 00:32:54 +0100 Subject: [PATCH 7/9] debug job fail --- tests/lammps/test_base.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/lammps/test_base.py b/tests/lammps/test_base.py index 8aaa23adb..293a4b2c3 100644 --- a/tests/lammps/test_base.py +++ b/tests/lammps/test_base.py @@ -697,5 +697,16 @@ def test_bonds_input(self): self.job.structure.bonds = [[1, 2, 1], [1, 3, 2]] self.job.potential = potential self.job.calc_static() + file_directory = os.path.join( + self.execution_path, "..", "static", "lammps_test_files" + ) + self.job.restart_file_list.append( + os.path.join(file_directory, "dump.out") + ) + self.job.restart_file_list.append( + os.path.join(file_directory, "log.lammps") + ) + self.job.run(run_mode="manual") + self.job.status.collect = True self.job.run() From 156776a1f4d31551d920f12137cf565c62826364 Mon Sep 17 00:00:00 2001 From: Raynol Dsouza Date: Mon, 21 Mar 2022 11:35:01 +0100 Subject: [PATCH 8/9] check for correct entry in the structure.inp file --- tests/lammps/test_base.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/lammps/test_base.py b/tests/lammps/test_base.py index 293a4b2c3..eec9d7bb6 100644 --- a/tests/lammps/test_base.py +++ b/tests/lammps/test_base.py @@ -697,16 +697,12 @@ def test_bonds_input(self): self.job.structure.bonds = [[1, 2, 1], [1, 3, 2]] self.job.potential = potential self.job.calc_static() - file_directory = os.path.join( - self.execution_path, "..", "static", "lammps_test_files" - ) - self.job.restart_file_list.append( - os.path.join(file_directory, "dump.out") - ) - self.job.restart_file_list.append( - os.path.join(file_directory, "log.lammps") - ) self.job.run(run_mode="manual") - self.job.status.collect = True - self.job.run() + + bond_str = "2 bond types\n" + struct_file = open(self.job.get_workdir_file('structure.inp'), 'r') + struct_lines = struct_file.readlines()[4] + struct_file.close() + self.assertTrue(struct_lines[-1], bond_str) + From 3491a9f4732bf90a77449f0113da33fade023ba7 Mon Sep 17 00:00:00 2001 From: Raynol Dsouza Date: Mon, 21 Mar 2022 11:57:18 +0100 Subject: [PATCH 9/9] simplify Co-authored-by: Sudarsan Surendralal --- tests/lammps/test_base.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/lammps/test_base.py b/tests/lammps/test_base.py index eec9d7bb6..185c47e35 100644 --- a/tests/lammps/test_base.py +++ b/tests/lammps/test_base.py @@ -700,9 +700,6 @@ def test_bonds_input(self): self.job.run(run_mode="manual") bond_str = "2 bond types\n" - struct_file = open(self.job.get_workdir_file('structure.inp'), 'r') - struct_lines = struct_file.readlines()[4] - struct_file.close() - self.assertTrue(struct_lines[-1], bond_str) + self.assertTrue(self.job["structure.inp"][4][-1], bond_str)