diff --git a/.ci_support/environment.yml b/.ci_support/environment.yml index 636aa96..b020dd2 100644 --- a/.ci_support/environment.yml +++ b/.ci_support/environment.yml @@ -4,7 +4,7 @@ dependencies: - coveralls - coverage - codacy-coverage - - lammps >=2020.12.24 + - lammps >=2021.05.27 - mpi4py =3.0.3 - openmpi - numpy diff --git a/README.md b/README.md index a26bd98..22f6984 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ lmp.mass(1, 20) ```python -lmp.extract_global("boxxhi", 1) +lmp.extract_global("boxxhi") ``` diff --git a/binder/environment.yml b/binder/environment.yml index 2622f94..1880c64 100644 --- a/binder/environment.yml +++ b/binder/environment.yml @@ -4,7 +4,7 @@ dependencies: - openmpi - mpi4py - numpy -- lammps >=2020.12.24 +- lammps >=2021.05.27 - pytest - distributed - dask-jobqueue diff --git a/notebooks/lammps_local.ipynb b/notebooks/lammps_local.ipynb index b5fbef1..0affdf3 100644 --- a/notebooks/lammps_local.ipynb +++ b/notebooks/lammps_local.ipynb @@ -185,7 +185,7 @@ } ], "source": [ - "lmp.extract_global(\"boxxhi\", 1)" + "lmp.extract_global(\"boxxhi\")" ] }, { @@ -542,6 +542,7 @@ "metadata": {}, "outputs": [], "source": [ + "lmp.delete_atoms(\"group\", \"all\")\n", "lmp.reset_box([0.0,0.0,0.0], [8.0,8.0,8.0], 0.0,0.0,0.0)" ] } diff --git a/notebooks/lammps_local_cluster.ipynb b/notebooks/lammps_local_cluster.ipynb index 8886a85..a43f41f 100644 --- a/notebooks/lammps_local_cluster.ipynb +++ b/notebooks/lammps_local_cluster.ipynb @@ -292,7 +292,7 @@ } ], "source": [ - "lmp.extract_global(\"boxxhi\", 1)" + "lmp.extract_global(\"boxxhi\")" ] }, { @@ -649,6 +649,7 @@ "metadata": {}, "outputs": [], "source": [ + "lmp.delete_atoms(\"group\", \"all\")\n", "lmp.reset_box([0.0,0.0,0.0], [8.0,8.0,8.0], 0.0,0.0,0.0)" ] } diff --git a/notebooks/lammps_slurm_cluster.ipynb b/notebooks/lammps_slurm_cluster.ipynb index 5290f7b..42542e2 100644 --- a/notebooks/lammps_slurm_cluster.ipynb +++ b/notebooks/lammps_slurm_cluster.ipynb @@ -297,7 +297,7 @@ } ], "source": [ - "lmp.extract_global(\"boxxhi\", 1)" + "lmp.extract_global(\"boxxhi\")" ] }, { @@ -654,6 +654,7 @@ "metadata": {}, "outputs": [], "source": [ + "lmp.delete_atoms(\"group\", \"all\")\n", "lmp.reset_box([0.0,0.0,0.0], [8.0,8.0,8.0], 0.0,0.0,0.0)" ] }, diff --git a/pylammpsmpi/utils/lammps.py b/pylammpsmpi/utils/lammps.py index d931b9a..332d67f 100644 --- a/pylammpsmpi/utils/lammps.py +++ b/pylammpsmpi/utils/lammps.py @@ -112,7 +112,7 @@ def extract_setting(self, *args): self._send(command="extract_setting", data=list(args)) return self._receive() - def extract_global(self, name, type): + def extract_global(self, name): """ Extract value of global simulation parameters @@ -121,10 +121,6 @@ def extract_global(self, name, type): name : string see notes for a set of possible options - type : {0, 1} - 0 if output value is integer - 1 if output value is float - Notes ----- The possible options for `name` are- @@ -142,7 +138,7 @@ def extract_global(self, name, type): "mvh2r", "angstrom", "femtosecond", "qelectron" """ - self._send(command="extract_global", data=[name, type]) + self._send(command="extract_global", data=[name]) return self._receive() def extract_box(self): diff --git a/tests/test_pylammpsmpi_cluster.py b/tests/test_pylammpsmpi_cluster.py index 62196f0..d4a80ed 100644 --- a/tests/test_pylammpsmpi_cluster.py +++ b/tests/test_pylammpsmpi_cluster.py @@ -12,11 +12,11 @@ class TestLocalLammpsLibrary(unittest.TestCase): @classmethod def setUpClass(cls): - execution_path = os.path.dirname(os.path.abspath(__file__)) + cls.execution_path = os.path.dirname(os.path.abspath(__file__)) cluster = LocalCluster(n_workers=1, threads_per_worker=2) client = Client(cluster) cls.lmp = LammpsLibrary(cores=2, mode='dask', client=client) - cls.lmp.file(os.path.join(execution_path, "in.simple")) + cls.lmp.file(os.path.join(cls.execution_path, "in.simple")) @classmethod def tearDownClass(cls): @@ -40,18 +40,6 @@ def test_gather_atoms(self): ids = self.lmp.extract_atom("id") self.assertEqual(len(ids), 256) - def test_extract_box(self): - box = self.lmp.extract_box() - self.assertEqual(len(box), 7) - - self.assertEqual(box[0][0], 0.0) - self.assertEqual(np.round(box[1][0], 2), 6.72) - - self.lmp.reset_box([0.0,0.0,0.0], [8.0,8.0,8.0], 0.0,0.0,0.0) - box = self.lmp.extract_box() - self.assertEqual(box[0][0], 0.0) - self.assertEqual(np.round(box[1][0], 2), 8.0) - def test_extract_fix(self): x = self.lmp.extract_fix("2", 0, 1, 1) self.assertEqual(np.round(x, 2), -2.61) @@ -79,6 +67,21 @@ def test_scatter_atoms(self): f1 = self.lmp.gather_atoms("f", ids=[1,2]) self.assertEqual(f1[1][1], val) + def test_extract_box(self): + box = self.lmp.extract_box() + self.assertEqual(len(box), 7) + + self.assertEqual(box[0][0], 0.0) + self.assertEqual(np.round(box[1][0], 2), 6.72) + + self.lmp.delete_atoms("group", "all") + self.lmp.reset_box([0.0,0.0,0.0], [8.0,8.0,8.0], 0.0,0.0,0.0) + box = self.lmp.extract_box() + self.assertEqual(box[0][0], 0.0) + self.assertEqual(np.round(box[1][0], 2), 8.0) + self.lmp.clear() + self.lmp.file(os.path.join(self.execution_path, "in.simple")) + if __name__ == "__main__": unittest.main() diff --git a/tests/test_pylammpsmpi_local.py b/tests/test_pylammpsmpi_local.py index ecfe707..1fc9891 100644 --- a/tests/test_pylammpsmpi_local.py +++ b/tests/test_pylammpsmpi_local.py @@ -11,9 +11,9 @@ class TestLocalLammpsLibrary(unittest.TestCase): @classmethod def setUpClass(cls): - execution_path = os.path.dirname(os.path.abspath(__file__)) + cls.execution_path = os.path.dirname(os.path.abspath(__file__)) cls.lmp = LammpsLibrary(cores=2, mode='local') - cls.lmp.file(os.path.join(execution_path, "in.simple")) + cls.lmp.file(os.path.join(cls.execution_path, "in.simple")) @classmethod def tearDownClass(cls): @@ -37,19 +37,6 @@ def test_gather_atoms(self): ids = self.lmp.extract_atom("id") self.assertEqual(len(ids), 256) - def test_extract_box(self): - - box = self.lmp.extract_box() - self.assertEqual(len(box), 7) - - self.assertEqual(box[0][0], 0.0) - self.assertEqual(np.round(box[1][0], 2), 6.72) - - self.lmp.reset_box([0.0, 0.0, 0.0], [8.0, 8.0, 8.0], 0.0, 0.0, 0.0) - box = self.lmp.extract_box() - self.assertEqual(box[0][0], 0.0) - self.assertEqual(np.round(box[1][0], 2), 8.0) - def test_extract_fix(self): x = self.lmp.extract_fix("2", 0, 1, 1) self.assertEqual(np.round(x, 2), -2.61) @@ -77,6 +64,22 @@ def test_scatter_atoms(self): f1 = self.lmp.gather_atoms("f", ids=[1, 2]) self.assertEqual(f1[1][1], val) + def test_extract_box(self): + + box = self.lmp.extract_box() + self.assertEqual(len(box), 7) + + self.assertEqual(box[0][0], 0.0) + self.assertEqual(np.round(box[1][0], 2), 6.72) + + self.lmp.delete_atoms("group", "all") + self.lmp.reset_box([0.0, 0.0, 0.0], [8.0, 8.0, 8.0], 0.0, 0.0, 0.0) + box = self.lmp.extract_box() + self.assertEqual(box[0][0], 0.0) + self.assertEqual(np.round(box[1][0], 2), 8.0) + self.lmp.clear() + self.lmp.file(os.path.join(self.execution_path, "in.simple")) + if __name__ == "__main__": unittest.main()