Skip to content

Commit

Permalink
new tests for posinp angles and conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
OMalenfantThuot committed Apr 29, 2020
1 parent 1d54194 commit 67fb70a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/posinp_files/reduced.xyz
@@ -0,0 +1,4 @@
2 reduced
periodic 8.0 5.0 3.0
C 0.1 0.5 0.6
C 0.9 0.1 0.3
18 changes: 18 additions & 0 deletions tests/test_posinp.py
Expand Up @@ -199,8 +199,26 @@ def test_convert(self):
assert self.periodic_pos.units == "angstroem"
self.periodic_pos.convert_units("angstroem")
assert np.isclose(self.periodic_pos.positions, pos1).all()
red = Posinp.from_file(tests_fol + "reduced.xyz")
red.convert_units("angstroem")
assert np.isclose(
red.positions,
np.array(
[
[0.4233418, 1.32294312, 0.95251905],
[3.81007619, 0.26458862, 0.47625952],
]
),
).all()

def test_periodic_displacement(self):
pos1 = Posinp.from_file(tests_fol + "perio1.xyz")
pos2 = Posinp.from_file(tests_fol + "perio2.xyz")
assert pos1 == pos2

def test_angles(self):
h2o = Posinp.from_file(tests_fol + "H2Orelaxed.xyz")
a = h2o.angle(1, 0, 2) * 180 / np.pi
assert np.isclose(a, 104.1219, atol=10 ** -4)
a1, a2 = h2o.angle(0, 1, 2), h2o.angle(2, 1, 0)
assert a1 == a2

0 comments on commit 67fb70a

Please sign in to comment.