Skip to content

Commit 2aec255

Browse files
committed
Tests: zmat update_zmat_by_xyz()
1 parent 1e23803 commit 2aec255

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

arc/species/zmat_test.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import arc.species.zmat as zmat
1111
from arc.exceptions import ZMatError
12+
from arc.species.converter import str_to_xyz
1213
from arc.species.species import ARCSpecies
1314

1415

@@ -2121,6 +2122,47 @@ def test_check_ordered_zmats(self):
21212122
self.assertFalse(zmat.check_ordered_zmats(zmat_2, zmat_3))
21222123
self.assertTrue(zmat.check_ordered_zmats(zmat_1, zmat_3))
21232124

2125+
def test_update_zmat_by_xyz(self):
2126+
"""Test the update_zmat_by_xyz() function."""
2127+
xyz_1 = str_to_xyz("""C -2.02459021 0.31147541 0.00000000
2128+
H -1.66791737 0.81587360 0.87365150
2129+
H -3.09459021 0.31148859 0.00000000
2130+
N -1.53460703 -1.07445983 0.00000000
2131+
H -1.86794423 -1.54585934 0.81649790
2132+
H -1.86794803 -1.54586068 -0.81649557
2133+
O -1.54791529 0.98557766 -1.16759033
2134+
H -1.82476883 1.90445028 -1.14258591""")
2135+
zmat_1 = zmat.xyz_to_zmat(xyz=xyz_1, mol=ARCSpecies(label='NCO', xyz=xyz_1).mol, consolidate=False)
2136+
xyz_2 = str_to_xyz("""C -2.12697003 0.60106045 0.00000000
2137+
H -1.77029719 1.10545864 0.87365150
2138+
H -3.19697003 0.60107363 0.00000000
2139+
N -1.43222721 -1.36404487 0.00000000
2140+
H -1.76556441 -1.83544438 0.81649790
2141+
H -1.76556821 -1.83544572 -0.81649557
2142+
O -1.65029511 1.27516270 -1.16759033
2143+
H -1.11689351 0.67210652 -1.69047270""")
2144+
zmat_2 = zmat.update_zmat_by_xyz(zmat_1, xyz_2)
2145+
expected_zmat_2 = {'symbols': ('N', 'C', 'O', 'H', 'H', 'H', 'H', 'H'),
2146+
'coords': ((None, None, None),
2147+
('R_1_0', None, None),
2148+
('R_2_1', 'A_2_1_0', None),
2149+
('R_3_1', 'A_3_1_0', 'D_3_1_0_2'),
2150+
('R_4_1', 'A_4_1_0', 'D_4_1_0_3'),
2151+
('R_5_0', 'A_5_0_1', 'D_5_0_1_4'),
2152+
('R_6_0', 'A_6_0_1', 'D_6_0_1_5'),
2153+
('R_7_2', 'A_7_2_1', 'D_7_2_1_0')),
2154+
'vars': {'A_2_1_0': 109.47120138885585, 'A_3_1_0': 109.47119974631076,
2155+
'A_4_1_0': 109.47123024500976, 'A_5_0_1': 109.47119888440865,
2156+
'A_6_0_1': 109.47120176378891, 'A_7_2_1': 109.49999787419641,
2157+
'D_3_1_0_2': 239.9999860097654, 'D_4_1_0_3': 240.00000689317258,
2158+
'D_5_0_1_4': 299.9998481421676, 'D_6_0_1_5': 120.00001661106755,
2159+
'D_7_2_1_0': 359.9999980909041, 'R_1_0': 2.084299994953611,
2160+
'R_2_1': 1.4300000625556986, 'R_3_1': 1.0700000390382562,
2161+
'R_4_1': 1.0699999276277037, 'R_5_0': 0.9999999701976772,
2162+
'R_6_0': 1.000000059604643, 'R_7_2': 0.9599999917546908},
2163+
'map': {0: 3, 1: 0, 2: 6, 3: 1, 4: 2, 5: 4, 6: 5, 7: 7}}
2164+
self.assertEqual(zmat_2, expected_zmat_2)
2165+
21242166

21252167
if __name__ == '__main__':
21262168
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))

0 commit comments

Comments
 (0)