Skip to content

Commit 68d4a31

Browse files
authored
Merge pull request #200 from pyiron/base_test
Add two more tests for LAMMPS base
2 parents 031ea56 + 26c0a10 commit 68d4a31

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

tests/test_ase_interface.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
get_structure_indices,
1313
get_lammps_indicies_from_ase_structure,
1414
set_selective_dynamics,
15+
UnfoldingPrism,
1516
)
1617

1718

@@ -127,6 +128,22 @@ def test_get_lammps_indicies_from_ase_structure(self):
127128
self.assertEqual(len(set(indicies)), 1)
128129
self.assertEqual(set(indicies), {1})
129130

131+
def test_unfolding_prism_cubic(self):
132+
prism = UnfoldingPrism(self.structure_cubic.cell.array)
133+
self.assertEqual(
134+
prism.get_lammps_prism_str(),
135+
('8.1000000000', '8.1000000000', '8.1000000000', '0E-10', '0E-10', '0E-10')
136+
)
137+
self.assertTrue(np.all(np.isclose(prism.pos_to_lammps(position=[[1.0, 1.0, 1.0]]), np.array([1.0, 1.0, 1.0]))))
138+
139+
def test_unfolding_prism_skewed(self):
140+
prism = UnfoldingPrism(self.structure_skewed.cell.array)
141+
self.assertTrue(np.all(np.isclose(
142+
[np.abs(float(s)) for s in prism.get_lammps_prism_str()],
143+
[5.7275649276, 4.9602167291, 4.6765371804, 2.8637824638, 2.8637824638, 1.6534055764]
144+
)))
145+
self.assertTrue(np.all(np.isclose(prism.pos_to_lammps(position=[[1.0, 1.0, 1.0]]), np.array([1.41421356, 0.81649658, 0.57735027]))))
146+
130147

131148
class TestConstraints(unittest.TestCase):
132149
@classmethod
@@ -189,4 +206,4 @@ def test_selective_dynamics_wrong_plane(self):
189206
[2, 1, 0],
190207
))
191208
with self.assertRaises(ValueError):
192-
set_selective_dynamics(structure=atoms, calc_md=False)
209+
set_selective_dynamics(structure=atoms, calc_md=False)

tests/test_base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ def setUpClass(cls):
2626
def tearDownClass(cls):
2727
cls.lmp.close()
2828

29+
def test_file_not_found(self):
30+
lmp = LammpsBase(
31+
cores=1,
32+
oversubscribe=False,
33+
working_directory=".",
34+
cmdargs=["-cite", self.citation_file]
35+
)
36+
with self.assertRaises(FileNotFoundError):
37+
lmp.file("file_does_not_exist.txt")
38+
2939
def test_extract_atom(self):
3040
f = self.lmp.extract_atom("f")
3141
self.assertEqual(len(f), 256)
@@ -52,6 +62,7 @@ def test_gather_atoms(self):
5262
ids = self.lmp.extract_atom("id")
5363
self.assertEqual(len(ids), 256)
5464
self.assertEqual(self.lmp.get_natoms(), 256)
65+
self.assertEqual(self.lmp.natoms, 256)
5566

5667
def test_extract_fix(self):
5768
x = self.lmp.extract_fix("2", 0, 1, 1)

0 commit comments

Comments
 (0)