Skip to content

Commit

Permalink
Update coord conver (#692)
Browse files Browse the repository at this point in the history
Modification in ARC/ipython/Tools/coordinates conversions.ipynb

1. Improved path of example for xyz_to_str
2. Replaced wrong zmat_to_xyz in conversions example 
3. Added test_coordinates_converter_tools_notebook to converter
  • Loading branch information
alongd authored Aug 21, 2023
2 parents c4b41cc + 15dd158 commit 8be4bf4
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 343 deletions.
72 changes: 71 additions & 1 deletion arc/species/converter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from rmgpy.statmech import Conformer

import arc.species.converter as converter
from arc.common import ARC_PATH, almost_equal_coords_lists, almost_equal_lists
from arc.common import ARC_PATH, almost_equal_coords, almost_equal_coords_lists, almost_equal_lists
from arc.exceptions import ConverterError
from arc.species.species import ARCSpecies
from arc.species.vectors import calculate_dihedral_angle
Expand Down Expand Up @@ -566,6 +566,76 @@ def setUpClass(cls):

cls.spc4 = ARCSpecies(label='NCN(T)', smiles='[N]=C=[N]', multiplicity=3, charge=0)

def test_coordinates_converter_tools_notebook(self):
"""
Test examples from the coordinates conversion jupyter notebooks (coordinates conversions.ipynb)
Note: If these tests fail, we should update the notebook as well
"""
zmat = {'symbols': ('N', 'C', 'C', 'C', 'N', 'O', 'C', 'O', 'X', 'C', 'X', 'C', 'X', 'N', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H'),
'coords': ((None, None, None), ('R_1_0', None, None), ('R_2_1', 'A_2_1_0', None),
('R_3_2', 'A_3_2_1', 'D_3_2_1_0'), ('R_4_3', 'A_4_3_2', 'D_4_3_2_1'),
('R_5_3', 'A_5_3_2', 'D_5_3_2_1'), ('R_6_4', 'A_6_4_3', 'D_6_4_3_2'),
('R_7_5', 'A_7_5_3', 'D_7_5_3_2'),
('RX_8|10|12_6|9|11', 'AX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12', 'DX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12_7|4|7|6|7|9'),
('R_9_6', 'AX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12', 'DX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12_7|4|7|6|7|9'),
('RX_8|10|12_6|9|11', 'AX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12', 'DX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12_7|4|7|6|7|9'),
('R_11_9', 'AX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12', 'DX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12_7|4|7|6|7|9'),
('RX_8|10|12_6|9|11', 'AX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12', 'DX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12_7|4|7|6|7|9'),
('R_13_11', 'AX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12', 'DX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12_7|4|7|6|7|9'),
('R_14_0', 'A_14_0_1', 'D_14_0_1_2'), ('R_15_0', 'A_15_0_1', 'D_15_0_1_2'),
('R_16_1', 'A_16_1_2', 'D_16_1_2_15'), ('R_17_1', 'A_17_1_2', 'D_17_1_2_16'), ('R_18_2', 'A_18_2_1', 'D_18_2_1_17'),
('R_19_2', 'A_19_2_1', 'D_19_2_1_18'), ('R_20_3', 'A_20_3_2', 'D_20_3_2_1'), ('R_21_7', 'A_21_7_5', 'D_21_7_5_3'),
('R_22_4', 'A_22_4_6', 'D_22_4_6_21')),
'vars': {'R_1_0': 1.4604942751011212, 'R_2_1': 1.527922849799549, 'A_2_1_0': 110.3065082939501,
'R_3_2': 1.528953932777341, 'A_3_2_1': 111.18144649602384, 'D_3_2_1_0': 182.82580139682537,
'R_4_3': 1.4513236745554712, 'A_4_3_2': 110.1816515421551, 'D_4_3_2_1': 178.77234190887103,
'R_5_3': 1.4324895363736756, 'A_5_3_2': 108.87342377052293, 'D_5_3_2_1': 296.5360670758954,
'R_6_4': 1.45471039292036, 'A_6_4_3': 119.52044799360947, 'D_6_4_3_2': 267.385789076988,
'R_7_5': 1.463961241323698, 'A_7_5_3': 106.24609505276611, 'D_7_5_3_2': 169.47632562217643,
'R_9_6': 1.2003625639923046, 'R_11_9': 1.5409261196430282, 'R_13_11': 1.1601896955504991,
'R_14_0': 1.0199706201435979, 'A_14_0_1': 109.82434650817126, 'D_14_0_1_2': 298.4471183049676,
'R_15_0': 1.0203338036642535, 'A_15_0_1': 109.29256268947609, 'D_15_0_1_2': 182.748124244299,
'R_16_1': 1.0953359821757327, 'A_16_1_2': 110.03394606716385, 'D_16_1_2_15': 121.92752893614716,
'R_17_1': 1.095192530179795, 'A_17_1_2': 110.84866373393122, 'D_17_1_2_16': 119.08345045450586,
'R_18_2': 1.098313538677341, 'A_18_2_1': 109.08968835777581, 'D_18_2_1_17': 300.70048659688996,
'R_19_2': 1.0975897283522487, 'A_19_2_1': 109.86987657387881, 'D_19_2_1_18': 242.83679879428865,
'R_20_3': 1.0977229848103394, 'A_20_3_2': 110.25024873242359, 'D_20_3_2_1': 55.735631534996074,
'R_21_7': 0.9770937580834932, 'A_21_7_5': 96.48404094647259, 'D_21_7_5_3': 73.0418671453161,
'R_22_4': 1.0156335096736346, 'A_22_4_6': 120.95423666407609, 'D_22_4_6_21': 114.47617942015948,
'RX_8|10|12_6|9|11': 1.0,
'AX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12': 90.0,
'DX_8|9|10|11|12|13_6|6|9|9|11|11_4|8|6|10|9|12_7|4|7|6|7|9': 180.0},
'map': {0: 0, 1: 1, 2: 2, 3: 3, 4: 6, 5: 4, 6: 7, 7: 5, 8: 'X20', 9: 8, 10: 'X21', 11: 9, 12: 'X22',
13: 10, 14: 11, 15: 12, 16: 13, 17: 14, 18: 15, 19: 16, 20: 17, 21: 18, 22: 19}}

expected_xyz = {'coords': ((-0.8213900082688513, -2.10323641901248, -3.4787571562478665),
(-0.8213900082688513, -2.10323641901248, -2.0182628811467453),
(-0.8213900082688513, -0.6702747081300946, -1.488009196497028),
(-0.7511056606312965, -0.6463260304165002, 0.03914066513025549),
(-1.9302208652935824, -1.2652250395530855, 0.5670399191968216),
(-1.6927285008528772, -1.4428384494817925, 2.000648432544829),
(-0.7231984752846139, 0.723554468209771, 0.5176686338161609),
(0.5562014818647295, 1.3755934078469356, 0.750398730953616),
(1.6119056415445083, 1.9136270516668845, 0.9424372957962519),
(2.9671312734201747, 2.6043101168330085, 1.1889605125488498),
(3.9875038877881535, 3.1243372387579753, 1.3745720692252879),
(-1.6650581935584636, -1.6461696893457916, -3.8246676413708913),
(-0.8675631710827836, -3.065164667823984, -3.8158671591759243),
(0.07005429983630573, -2.63356184648041, -1.666349681086344),
(-1.699192721587011, -2.6514360053406123, -1.6599525572617608),
(-1.7347813877290457, -0.1623294553942829, -1.82564870454207),
(0.02949305460104612, -0.1175918761382122, -1.9066294448450238),
(0.1267903103519551, -1.2054874590807871, 0.3878997685331744),
(-1.7846512257051166, -0.5013198675867678, 2.245199418410446),
(-1.5597949093202201, 1.267298212020659, 0.3280359003616984)),
'isotopes': (14,12,12,12,16,16,14,12,12,12,14,
1,1,1,1,1,1,1,1,1),
'symbols': ('N','C','C','C','O',
'O','N','C','C','C',
'N','H','H','H','H',
'H','H','H','H','H')}
self.assertTrue(almost_equal_coords(converter.zmat_to_xyz(converter.check_zmat_dict(zmat)),expected_xyz))

def test_str_to_xyz(self):
"""Test converting a string xyz format to the ARC xyz format"""
xyz1 = converter.str_to_xyz(xyz_str=self.xyz1['str'])
Expand Down
Loading

0 comments on commit 8be4bf4

Please sign in to comment.