Skip to content
Merged
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 .ci_support/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependencies:
- coveralls
- coverage
- codacy-coverage
- lammps >=2020.12.24
- lammps >=2021.05.27
- mpi4py =3.0.3
- openmpi
- numpy
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ lmp.mass(1, 20)


```python
lmp.extract_global("boxxhi", 1)
lmp.extract_global("boxxhi")
```


Expand Down
2 changes: 1 addition & 1 deletion binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependencies:
- openmpi
- mpi4py
- numpy
- lammps >=2020.12.24
- lammps >=2021.05.27
- pytest
- distributed
- dask-jobqueue
3 changes: 2 additions & 1 deletion notebooks/lammps_local.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
}
],
"source": [
"lmp.extract_global(\"boxxhi\", 1)"
"lmp.extract_global(\"boxxhi\")"
]
},
{
Expand Down Expand Up @@ -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)"
]
}
Expand Down
3 changes: 2 additions & 1 deletion notebooks/lammps_local_cluster.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
}
],
"source": [
"lmp.extract_global(\"boxxhi\", 1)"
"lmp.extract_global(\"boxxhi\")"
]
},
{
Expand Down Expand Up @@ -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)"
]
}
Expand Down
3 changes: 2 additions & 1 deletion notebooks/lammps_slurm_cluster.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
}
],
"source": [
"lmp.extract_global(\"boxxhi\", 1)"
"lmp.extract_global(\"boxxhi\")"
]
},
{
Expand Down Expand Up @@ -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)"
]
},
Expand Down
8 changes: 2 additions & 6 deletions pylammpsmpi/utils/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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-
Expand All @@ -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):
Expand Down
31 changes: 17 additions & 14 deletions tests/test_pylammpsmpi_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
33 changes: 18 additions & 15 deletions tests/test_pylammpsmpi_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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()