def test_load_ethylene_from_gaussian_log_g3(self): """ Uses a Gaussian03 log file for ethylene (C2H4) to test that its molecular degrees of freedom can be properly read. """ log = GaussianLog( os.path.join(os.path.dirname(__file__), 'data', 'ethylene_G3.log')) conformer, unscaled_frequencies = log.load_conformer() e0 = log.load_energy() self.assertTrue( len([ mode for mode in conformer.modes if isinstance(mode, IdealGasTranslation) ]) == 1) self.assertTrue( len([ mode for mode in conformer.modes if isinstance(mode, NonlinearRotor) ]) == 1) self.assertTrue( len([ mode for mode in conformer.modes if isinstance(mode, HarmonicOscillator) ]) == 1) self.assertTrue( len([ mode for mode in conformer.modes if isinstance(mode, HinderedRotor) ]) == 0) trans = [ mode for mode in conformer.modes if isinstance(mode, IdealGasTranslation) ][0] rot = [ mode for mode in conformer.modes if isinstance(mode, NonlinearRotor) ][0] vib = [ mode for mode in conformer.modes if isinstance(mode, HarmonicOscillator) ][0] t_list = np.array([298.15], np.float64) self.assertAlmostEqual(trans.get_partition_function(t_list), 5.83338e6, delta=1e1) self.assertAlmostEqual(rot.get_partition_function(t_list), 2.53410e3, delta=1e-2) self.assertAlmostEqual(vib.get_partition_function(t_list), 1.0304e0, delta=1e-4) self.assertAlmostEqual(e0 / constants.Na / constants.E_h, -78.562189, 4) self.assertEqual(conformer.spin_multiplicity, 1) self.assertEqual(conformer.optical_isomers, 1)
def test_load_oxygen_from_gaussian_log(self): """ Uses a Gaussian03 log file for oxygen (O2) to test that its molecular degrees of freedom can be properly read. """ log = GaussianLog( os.path.join(os.path.dirname(__file__), 'data', 'oxygen.log')) conformer, unscaled_frequencies = log.load_conformer() e0 = log.load_energy() self.assertTrue( len([ mode for mode in conformer.modes if isinstance(mode, IdealGasTranslation) ]) == 1) self.assertTrue( len([ mode for mode in conformer.modes if isinstance(mode, LinearRotor) ]) == 1) self.assertTrue( len([ mode for mode in conformer.modes if isinstance(mode, HarmonicOscillator) ]) == 1) self.assertTrue( len([ mode for mode in conformer.modes if isinstance(mode, HinderedRotor) ]) == 0) trans = [ mode for mode in conformer.modes if isinstance(mode, IdealGasTranslation) ][0] rot = [ mode for mode in conformer.modes if isinstance(mode, LinearRotor) ][0] vib = [ mode for mode in conformer.modes if isinstance(mode, HarmonicOscillator) ][0] t_list = np.array([298.15], np.float64) self.assertAlmostEqual(trans.get_partition_function(t_list), 7.11169e6, delta=1e1) self.assertAlmostEqual(rot.get_partition_function(t_list), 7.13316e1, delta=1e-4) self.assertAlmostEqual(vib.get_partition_function(t_list), 1.00037e0, delta=1e-4) self.assertAlmostEqual(e0 / constants.Na / constants.E_h, -150.3784877, 4) self.assertEqual(conformer.spin_multiplicity, 3) self.assertEqual(conformer.optical_isomers, 1)
def setUp(cls): """A method that is run before each unit test in this class""" spc = Species().from_smiles('CCO') log = GaussianLog( os.path.join(os.path.dirname(__file__), 'data', 'ethylene.log')) spc.conformer = log.load_conformer()[0] coords, numbers, masses = log.load_geometry() spc.conformer.coordinates = coords, 'angstroms' spc.conformer.number = numbers spc.conformer.mass = masses, 'amu' cls.thermo_job = ThermoJob(species=spc, thermo_class='NASA')
def test_get_str_xyz(self): """Test generating an xyz string from the species.conformer object""" log = GaussianLog( os.path.join(os.path.dirname(__file__), 'data', 'ethylene_G3.log')) conformer = log.load_conformer()[0] coords, number, mass = log.load_geometry() conformer.coordinates, conformer.number, conformer.mass = ( coords, "angstroms"), number, (mass, "amu") spc1 = Species(smiles='C=C') spc1.conformer = conformer xyz_str = get_str_xyz(spc1) expected_xyz_str = """C 0.00545100 0.00000000 0.00339700 H 0.00118700 0.00000000 1.08823200 H 0.97742900 0.00000000 -0.47841600 C -1.12745800 0.00000000 -0.70256500 H -1.12319800 0.00000000 -1.78740100 H -2.09943900 0.00000000 -0.22075700""" self.assertEqual(xyz_str, expected_xyz_str)
def test_load_symmetry_and_optics(self): """ Uses a Gaussian03 log file for oxygen (O2) to test that its molecular degrees of freedom can be properly read. """ log = GaussianLog( os.path.join(os.path.dirname(__file__), 'data', 'oxygen.log')) optical, symmetry, _ = log.get_symmetry_properties() self.assertEqual(optical, 1) self.assertEqual(symmetry, 2) conf = log.load_conformer()[0] self.assertEqual(conf.optical_isomers, 1) found_rotor = False for mode in conf.modes: if isinstance(mode, LinearRotor): self.assertEqual(mode.symmetry, 2) found_rotor = True self.assertTrue(found_rotor)