Skip to content

Commit

Permalink
f! converter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alongd committed Feb 13, 2025
1 parent d2c7d5d commit dc2296b
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions arc/species/converter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5150,7 +5150,7 @@ def test_add_atom_to_xyz_using_internal_coords(self):
(-3.17488405, 0.21042224, 1.24128129), (-3.53487445, 1.21797729, 1.25310144),
(-3.56603419, -0.31800758, 2.08547528), (-1.63624745, 0.21425655, 1.30595531),
(-1.24509731, 0.74268637, 0.46176133), (-1.3183353, 0.6960459, 2.20690531),
(-1.0399130826377951, -1.4521481683234707, 1.2864453881141027))}
(-1.039912604216098, -1.452147996238371, 1.2864453361731114))}
self.assertEqual(new_xyz_1, expected_xyz_1)
self.assertAlmostEqual(calculate_param(coords=new_xyz_1['coords'], atoms=[7, 10]), 1.77, places=2)
self.assertAlmostEqual(calculate_param(coords=new_xyz_1['coords'], atoms=[4, 7, 10]), 109.5, places=1)
Expand All @@ -5164,9 +5164,8 @@ def test_add_atom_to_xyz_using_internal_coords(self):
r_value=2.70,
a_value=61.46,
d_value=-60.0,
opt_method='BFGS',
)
self.assertEqual(new_xyz_2['coords'][-1], (-1.0966631688164716, -1.5123640474266677, 1.296181153302943))
self.assertEqual(new_xyz_2['coords'][-1], (-1.0397636319111052, -1.4416335009202348, 1.2856955291862382))
self.assertAlmostEqual(calculate_param(coords=new_xyz_1['coords'], atoms=[4, 10]), 2.70, places=1)
self.assertAlmostEqual(calculate_param(coords=new_xyz_1['coords'], atoms=[4, 0, 10]), 61.46, places=0)
self.assertAlmostEqual(calculate_param(coords=new_xyz_1['coords'], atoms=[0, 4, 7, 10]), 300, places=1)
Expand Down Expand Up @@ -5194,7 +5193,7 @@ def test_add_atom_to_xyz_using_internal_coords(self):
(0.35773087, -1.66017412, -0.9786309), (-0.45608483, -1.87500387, -1.86208833),
(-1.82486467, -0.81522856, 0.14629516), (-1.06962462, 0.60119223, 0.90442455),
(-1.14968688, 0.45844916, -0.88969505), (1.33643417, -2.15859899, -0.90083808),
(1.4828269120297688, -2.3770289575185632, 0.3030781302151979))}
(1.4828289681716378, -2.3770210854217706, 0.303080727235734))}
self.assertEqual(new_xyz_3, expected_xyz)
self.assertAlmostEqual(calculate_param(coords=new_xyz_3['coords'], atoms=[2, 8]), 1.85, places=2)
self.assertAlmostEqual(calculate_param(coords=new_xyz_3['coords'], atoms=[1, 2, 8]), 77.4, places=1)
Expand Down Expand Up @@ -5223,11 +5222,32 @@ def test_add_atom_to_xyz_using_internal_coords(self):
a_value=77.4,
d_value=140,
)
self.assertEqual(new_xyz_4['coords'][-1], (1.89932405279869, 0.9989208520839763, 0.8144268165647406))
self.assertEqual(new_xyz_4['coords'][-1], (1.8993241065114546, 0.9989208721112074, 0.8144267234280602))
self.assertAlmostEqual(calculate_param(coords=new_xyz_4['coords'], atoms=[1, 14]), 1.85, places=2)
self.assertAlmostEqual(calculate_param(coords=new_xyz_4['coords'], atoms=[3, 1, 14]), 77.4, places=1)
self.assertAlmostEqual(calculate_param(coords=new_xyz_4['coords'], atoms=[2, 0, 1, 14]), 140, places=1)

xyz_5 = """C -1.01765390 -0.08355112 0.05206009
O 0.22303684 -0.79051481 0.05294172
C 0.35773087 -1.66017412 -0.97863090
O -0.45608483 -1.87500387 -1.86208833
H -1.82486467 -0.81522856 0.14629516
H -1.06962462 0.60119223 0.90442455
H -1.14968688 0.45844916 -0.88969505
H 1.33643417 -2.15859899 -0.90083808"""
new_xyz_5 = converter.add_atom_to_xyz_using_internal_coords(xyz=xyz_5,
element='O',
r_index=2,
a_indices=(1, 2),
d_indices=(3, 7, 2),
r_value=1.8,
a_value=77,
d_value=140,
)
self.assertAlmostEqual(calculate_param(coords=new_xyz_5['coords'], atoms=[2, 8]), 1.8, places=2)
self.assertAlmostEqual(calculate_param(coords=new_xyz_5['coords'], atoms=[1, 2, 8]), 77, places=1)
self.assertAlmostEqual(calculate_param(coords=new_xyz_5['coords'], atoms=[3, 7, 2, 8]), 140, places=1)


@classmethod
def tearDownClass(cls):
Expand Down

0 comments on commit dc2296b

Please sign in to comment.