def test_determine_family(self): """Test the determine_family() function.""" rxn = ARCReaction(r_species=[ARCSpecies(label='CH2CH2CH3', smiles='[CH2]CC')], p_species=[ARCSpecies(label='CH3CHCH3', smiles='C[CH]C')]) self.assertIsNone(rxn.family) rmgdb.determine_family(rxn, db=None) self.assertEqual(rxn.family.label, 'intra_H_migration') rxn = ARCReaction(r_species=[ARCSpecies(label='C2H6', smiles='CC'), ARCSpecies(label='OH', smiles='[OH]')], p_species=[ARCSpecies(label='water', smiles='O'), ARCSpecies(label='C2H5', smiles='[CH2]C')]) self.assertIsNone(rxn.family) rmgdb.determine_family(rxn, db=self.rmgdb) self.assertEqual(rxn.family.label, 'H_Abstraction') r_1 = ARCSpecies(label='C3H6O', smiles='CCC=O') r_2 = ARCSpecies(label='C4H9O', smiles='[CH2]C(C)CO') p_1 = ARCSpecies(label='C3H5O', smiles='CC=C[O]') # This is the "wrong" resonance structure on purpose. p_2 = ARCSpecies(label='C4H10O', smiles='CC(C)CO') rxn = ARCReaction(reactants=['C3H6O', 'C4H9O'], products=['C3H5O', 'C4H10O'], r_species=[r_1, r_2], p_species=[p_1, p_2]) self.assertIsNone(rxn.family) rmgdb.determine_family(rxn, db=self.rmgdb) self.assertEqual(rxn.family.label, 'H_Abstraction')
def test_parse_xyz_from_file(self): """Test parsing xyz from a file""" path1 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'CH3C(O)O.gjf') path2 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'CH3C(O)O.xyz') path3 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'AIBN.gjf') path4 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'molpro.in') path5 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'qchem.in') path6 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'qchem_output.out') path7 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'TS.gjf') xyz1 = parser.parse_xyz_from_file(path1) xyz2 = parser.parse_xyz_from_file(path2) xyz3 = parser.parse_xyz_from_file(path3) xyz4 = parser.parse_xyz_from_file(path4) xyz5 = parser.parse_xyz_from_file(path5) xyz6 = parser.parse_xyz_from_file(path6) xyz7 = parser.parse_xyz_from_file(path7) self.assertEqual(xyz1.rstrip(), xyz2.rstrip()) self.assertTrue( 'C 1.40511900 0.21728200 0.07675200' in xyz1) self.assertTrue( 'O -0.79314200 1.04818800 0.18134200' in xyz1) self.assertTrue( 'H -0.43701200 -1.34990600 0.92900600' in xyz2) self.assertTrue( 'C 2.12217963 -0.66843078 1.04808732' in xyz3) self.assertTrue( 'N 2.41731872 -1.07916417 2.08039935' in xyz3) spc3 = ARCSpecies(label='AIBN', xyz=xyz3) self.assertEqual(len(spc3.mol.atoms), 24) self.assertTrue( 'S -0.4204682221 -0.3909949822 0.0245352116' in xyz4) self.assertTrue( 'N -1.99742564 0.38106573 0.09139807' in xyz5) self.assertTrue( 'N -1.17538406 0.34366165 0.03265021' in xyz6) self.assertEqual(len(xyz7.strip().splitlines()), 34)
def test_process_conformers_file(self): """Test processing ARC conformer files""" path1 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'conformers_before_optimization.txt') path2 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'conformers_after_optimization.txt') path3 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'conformers_file.txt') xyzs, energies = parser.process_conformers_file(path1) self.assertEqual(len(xyzs), 3) self.assertEqual(len(energies), 3) self.assertTrue(all([e is None for e in energies])) spc1 = ARCSpecies(label='tst1', xyz=xyzs[0]) self.assertEqual(len(spc1.conformers), 1) xyzs, energies = parser.process_conformers_file(path2) self.assertEqual(len(xyzs), 3) self.assertEqual(len(energies), 3) self.assertEqual(energies, [0.0, 10.271, 10.288]) spc2 = ARCSpecies(label='tst2', xyz=xyzs[:2]) self.assertEqual(len(spc2.conformers), 2) self.assertEqual(len(spc2.conformer_energies), 2) xyzs, energies = parser.process_conformers_file(path3) self.assertEqual(len(xyzs), 4) self.assertEqual(len(energies), 4) self.assertEqual(energies, [0.0, 0.005, None, 0.005]) spc3 = ARCSpecies(label='tst3', xyz=xyzs) self.assertEqual(len(spc3.conformers), 4) self.assertEqual(len(spc3.conformer_energies), 4) spc4 = ARCSpecies(label='tst4', xyz=path1) self.assertEqual(len(spc4.conformers), 3) self.assertTrue(all([e is None for e in spc4.conformer_energies])) spc5 = ARCSpecies(label='tst5', xyz=path2) self.assertEqual(len(spc5.conformers), 3) self.assertTrue(all([e is not None for e in spc5.conformer_energies])) spc6 = ARCSpecies(label='tst6', xyz=path3) self.assertEqual(len(spc6.conformers), 4)
def test_parse_xyz_from_file(self): """Test parsing xyz from a file""" path1 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'CH3C(O)O.gjf') path2 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'CH3C(O)O.xyz') path3 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'AIBN.gjf') path4 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'molpro.in') path5 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'qchem.in') path6 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'qchem_output.out') path7 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'TS.gjf') path8 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'formaldehyde_coords.xyz') path9 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'optim_traj_terachem.xyz') # test trajectories path10 = os.path.join(arc_path, 'arc', 'testing', 'xyz', 'ethane_minimize_terachem_output.out') path11 = os.path.join(arc_path, 'arc', 'testing', 'orca_example_opt.log') xyz1 = parser.parse_xyz_from_file(path1) xyz2 = parser.parse_xyz_from_file(path2) xyz3 = parser.parse_xyz_from_file(path3) xyz4 = parser.parse_xyz_from_file(path4) xyz5 = parser.parse_xyz_from_file(path5) xyz6 = parser.parse_xyz_from_file(path6) xyz7 = parser.parse_xyz_from_file(path7) xyz8 = parser.parse_xyz_from_file(path8) xyz9 = parser.parse_xyz_from_file(path9) xyz10 = parser.parse_xyz_from_file(path10) xyz11 = parser.parse_xyz_from_file(path11) self.assertEqual(xyz1, xyz2) xyz1_str = xyz_to_str(xyz1) xyz2_str = xyz_to_str(xyz2) xyz3_str = xyz_to_str(xyz3) xyz4_str = xyz_to_str(xyz4) xyz5_str = xyz_to_str(xyz5) xyz6_str = xyz_to_str(xyz6) xyz9_str = xyz_to_str(xyz9) xyz11_str = xyz_to_str(xyz11) self.assertTrue( 'C 1.40511900 0.21728200 0.07675200' in xyz1_str) self.assertTrue( 'O -0.79314200 1.04818800 0.18134200' in xyz1_str) self.assertTrue( 'H -0.43701200 -1.34990600 0.92900600' in xyz2_str) self.assertTrue( 'C 2.12217963 -0.66843078 1.04808732' in xyz3_str) self.assertTrue( 'N 2.41731872 -1.07916417 2.08039935' in xyz3_str) spc3 = ARCSpecies(label='AIBN', xyz=xyz3) self.assertEqual(len(spc3.mol.atoms), 24) self.assertTrue( 'S -0.42046822 -0.39099498 0.02453521' in xyz4_str) self.assertTrue( 'N -1.99742564 0.38106573 0.09139807' in xyz5_str) self.assertTrue( 'N -1.17538406 0.34366165 0.03265021' in xyz6_str) self.assertEqual(len(xyz7['symbols']), 34) self.assertEqual(len(xyz8['symbols']), 4) expected_xyz_9 = """N -0.67665958 0.74524340 -0.41319355 H -1.26179357 1.52577220 -0.13687665 H 0.28392722 1.06723640 -0.44163375 N -0.75345799 -0.33268278 0.51180786 H -0.97153041 -0.02416219 1.45398654 H -1.48669570 -0.95874053 0.20627423 N 2.28178508 -0.42455356 0.14404399 H 1.32677989 -0.80557411 0.33156013""" self.assertEqual(xyz9_str, expected_xyz_9) self.assertIsNone(xyz10) expected_xyz_11 = """C 0.00917900 -0.00000000 -0.00000000 O 1.20814900 -0.00000000 0.00000000 H -0.59436200 0.94730400 0.00000000 H -0.59436200 -0.94730400 0.00000000""" self.assertEqual(xyz11_str, expected_xyz_11)