def test_load_number_scans(self): """ Ensures proper scan angle found in Gaussian scan job """ log = GaussianLog( os.path.join(self.data_path, 'isobutanolQOOH_scan.log')) self.assertAlmostEqual(log._load_number_scans(), 36)
def test_load_ethylene_from_gaussian_log_cbsqb3(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(self.data_path, 'ethylene.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.59622e3, delta=1e-2) self.assertAlmostEqual(vib.get_partition_function(t_list), 1.0481e0, delta=1e-4) self.assertAlmostEqual(e0 / constants.Na / constants.E_h, -78.467452, 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(self.data_path, '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 test_load_scan_with_freq(self): """ Ensures that the length of enegies with hr scans and freq calc is correct """ log = GaussianLog(os.path.join(self.data_path, 'hr_scan_with_freq.log')) self.assertAlmostEqual(log._load_number_scans(), 36) self.assertAlmostEqual(log._load_scan_angle(), 10.0) vlist, _ = log.load_scan_energies() self.assertEqual(len(vlist), 37)
def test_gaussian_log_error_termination(self): """ Ensures that error termination gaussian log file raises an logError """ file_path = os.path.join(self.data_path, 'error_termination.out') log = GaussianLog(file_path) with self.assertRaises(LogError) as log_error: log.load_conformer() self.assertTrue(f'The Gaussian job in {file_path} did not converge.' in str(log_error.exception))
def test_check_for_errors(self): """ Uses Gaussian log files that had various errors to test if errors are properly parsed. """ with self.assertRaises(LogError): GaussianLog(os.path.join(self.data_path, 'l913.out')) with self.assertRaises(LogError): GaussianLog(os.path.join(self.data_path, 'l9999.out')) with self.assertRaises(LogError): GaussianLog(os.path.join(self.data_path, 'error_termination.out'))
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', 'gaussian', '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(self.data_path, 'gaussian', '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(self.data_path, '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)
def test_gaussian_energies(self): """ test parsing double hydride, MP2, CCSD, CCSD(T) form Gaussian log """ log_doublehybrid = GaussianLog( os.path.join(self.data_path, 'B2PLYP.LOG')) log_mp2 = GaussianLog(os.path.join(self.data_path, 'UMP2_C_ATOM.LOG')) log_ccsd = GaussianLog(os.path.join(self.data_path, 'UCCSD_C_ATOM.LOG')) log_ccsdt = GaussianLog( os.path.join(self.data_path, 'UCCSDT_C_ATOM.LOG')) log_qb3 = GaussianLog( os.path.join(os.path.dirname(os.path.dirname(__file__)), '../examples/arkane/species/C2H5/', 'ethyl_cbsqb3.log')) self.assertAlmostEqual(log_doublehybrid.load_energy() / constants.Na / constants.E_h, -0.40217794572194e+02, delta=1e-6) self.assertAlmostEqual(log_mp2.load_energy() / constants.Na / constants.E_h, -0.37504683723025e+02, delta=1e-6) self.assertAlmostEqual(log_ccsd.load_energy() / constants.Na / constants.E_h, -37.517151426, delta=1e-6) self.assertAlmostEqual(log_ccsdt.load_energy() / constants.Na / constants.E_h, -0.37517454469e+02, delta=1e-6) self.assertAlmostEqual(log_qb3.load_energy() / constants.Na / constants.E_h, -79.029798, delta=1e-6)