-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
beb125b
commit 0fd56db
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
import numpy as np | ||
from libcasm.xtal import Occupant | ||
|
||
|
||
def test_occupant_from_xyz(session_shared_datadir): | ||
"""Test making xtal.Occupant.from_xyz_string() | ||
method | ||
Parameters | ||
---------- | ||
shared_datadir : str | ||
Returns | ||
------- | ||
None | ||
""" | ||
|
||
with open( | ||
os.path.join(session_shared_datadir, "input_molecules", "water.xyz"), "r" | ||
) as f: | ||
water_xyz_string = f.read() | ||
|
||
water = Occupant.from_xyz_string(water_xyz_string) | ||
|
||
assert water.name() == "Water" | ||
|
||
expected_atom_names = ["O", "H", "H"] | ||
expected_atom_coords = [ | ||
np.array([0.0, 0.0, 0.11779]), | ||
np.array([0.0, 0.75545, -0.47116]), | ||
np.array([0.0, -0.75545, -0.47116]), | ||
] | ||
|
||
for atom, expected_atom_name, expected_atom_coord in zip( | ||
water.atoms(), expected_atom_names, expected_atom_coords | ||
): | ||
|
||
assert atom.name() == expected_atom_name | ||
assert np.allclose(atom.coordinate(), expected_atom_coord) |