def test_get_t1_diagnostic(self): """ Ensure molpro can retrieve the T1 diagnostic from CCSD calculations """ log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'ethylene_f12_dz.out')) t1_diagnostic = log.get_T1_diagnostic() self.assertAlmostEqual(t1_diagnostic, 0.01152184)
def testLoadHOSIFromMolpro_log(self): """ Uses a molpro log file for HOSI to test that its molecular degrees of freedom can be properly read. """ log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'HOSI_ccsd_t1.out')) conformer, unscaled_frequencies = log.loadConformer(spinMultiplicity=1) e0 = log.loadEnergy() 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 = numpy.array([298.15], numpy.float64) self.assertAlmostEqual(trans.getPartitionFunction(t_list), 9.175364e7, delta=1e1) self.assertAlmostEqual(rot.getPartitionFunction(t_list), 1.00005557e5, delta=1e-2) self.assertAlmostEqual(vib.getPartitionFunction(t_list), 1.9734989e0, delta=1e-4) self.assertAlmostEqual(e0 / constants.Na / constants.E_h, -768.275662, 4) self.assertEqual(conformer.spinMultiplicity, 1) self.assertEqual(conformer.opticalIsomers, 1)
def test_load_non_f12_e0(self): """ Load E0 for CCSD(T) (without F12) from a molpro output file """ molpro_log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'TS_CCSD(T)_no_F12_sp_molpro.out')) e0 = molpro_log.loadEnergy() self.assertAlmostEqual(e0, -301585968.58196217, places=7)
def test_load_hosi_from_molpro_log(self): """ Uses a molpro log file for HOSI to test that its molecular degrees of freedom can be properly read. """ log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'HOSI_ccsd_t1.out')) conformer, unscaled_frequencies = log.load_conformer(spin_multiplicity=1) 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), 9.175364e7, delta=1e1) self.assertAlmostEqual(rot.get_partition_function(t_list), 1.00005557e5, delta=1e-2) self.assertAlmostEqual(vib.get_partition_function(t_list), 1.9734989e0, delta=1e-4) self.assertAlmostEqual(e0 / constants.Na / constants.E_h, -768.275662, 4) self.assertEqual(conformer.spin_multiplicity, 1) self.assertEqual(conformer.optical_isomers, 1)
def test_load_negative_frequency(self): """ Load an imaginary frequency from a molpro output file """ freq_log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'molpro_TS.out')) imaginary_freq = freq_log.load_negative_frequency() self.assertEqual(imaginary_freq, -1997.98)
def test_load_non_f12_e0(self): """ Load E0 for CCSD(T) (without F12) from a molpro output file """ molpro_log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'TS_CCSD(T)_no_F12_sp_molpro.out')) e0 = molpro_log.load_energy() self.assertAlmostEqual(e0, -301585968.58196217, places=7)
def testLoadRadFromMolproLog_F12(self): """ Uses a Molpro log file for OH (C2H4) to test that radical energy can be properly read. """ log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'OH_f12.out')) e0 = log.loadEnergy() self.assertAlmostEqual(e0 / constants.Na / constants.E_h, -75.663696424380, 5)
def testLoadQzFromMolproLog_F12(self): """ Uses a Molpro log file for ethylene_qz (C2H4) to test that F12b energy can be properly read. """ log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'ethylene_f12_qz.out')) e0 = log.loadEnergy() self.assertAlmostEqual(e0 / constants.Na / constants.E_h, -78.472682755635, 5)
def test_load_mrci_e0(self): """ Load the MRCI and MRCI+Davidson energies from a molpro output file """ mrci_log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'molpro_mrci.out')) mrciq_log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'molpro_mrci+q.out')) mrci_e0 = mrci_log.loadEnergy() mrciq_e0 = mrciq_log.loadEnergy() self.assertAlmostEqual(mrci_e0, -293217091.0381712, places=7) self.assertAlmostEqual(mrciq_e0, -293284017.3925107, places=7)
def test_load_rad_from_molpro_log_f12(self): """ Uses a Molpro log file for OH (C2H4) to test that radical energy can be properly read. """ log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'OH_f12.out')) e0 = log.load_energy() self.assertAlmostEqual(e0 / constants.Na / constants.E_h, -75.663696424380, 5)
def test_load_qz_from_molpro_log_f12(self): """ Uses a Molpro log file for ethylene_qz (C2H4) to test that F12b energy can be properly read. """ log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'ethylene_f12_qz.out')) e0 = log.load_energy() self.assertAlmostEqual(e0 / constants.Na / constants.E_h, -78.472682755635, 5)
def testLoadDzFromMolproLog_F12(self): """ Uses a Molpro log file for ethylene_dz (C2H4) to test that F12a energy can be properly read. """ log=MolproLog(os.path.join(os.path.dirname(__file__),'data','ethylene_f12_dz.out')) E0=log.loadEnergy() self.assertAlmostEqual(E0 / constants.Na / constants.E_h, -78.474353559604, 5)
def determine_qm_software(fullpath): """ Given a path to the log file of a QM software, determine whether it is Gaussian, Molpro, or QChem """ with open(fullpath, 'r') as f: line = f.readline() software_log = None while line != '': if 'gaussian' in line.lower(): f.close() software_log = GaussianLog(fullpath) break elif 'qchem' in line.lower(): f.close() software_log = QChemLog(fullpath) break elif 'molpro' in line.lower(): f.close() software_log = MolproLog(fullpath) break line = f.readline() else: raise InputError( 'File at {0} could not be identified as a Gaussian, ' 'QChem or Molpro log file.'.format(fullpath)) return software_log
def test_load_mrci_e0(self): """ Load the MRCI and MRCI+Davidson energies from a molpro output file """ mrci_log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'molpro_mrci.out')) mrciq_log = MolproLog(os.path.join(os.path.dirname(__file__), 'data', 'molpro_mrci+q.out')) mrci_e0 = mrci_log.load_energy() mrciq_e0 = mrciq_log.load_energy() self.assertAlmostEqual(mrci_e0, -293217091.0381712, places=7) self.assertAlmostEqual(mrciq_e0, -293284017.3925107, places=7)
def testLoadHOSIFromMolpro_log(self): """ Uses a molpro log file for HOSI to test that its molecular degrees of freedom can be properly read. """ log = MolproLog( os.path.join(os.path.dirname(__file__), 'data', 'HOSI_ccsd_t1.out')) conformer = log.loadConformer(symfromlog=True, spinMultiplicity=1) E0 = log.loadEnergy() 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] Tlist = numpy.array([298.15], numpy.float64) self.assertAlmostEqual(trans.getPartitionFunction(Tlist), 9.175364e7, delta=1e1) self.assertAlmostEqual(rot.getPartitionFunction(Tlist), 1.00005557e5, delta=1e-2) self.assertAlmostEqual(vib.getPartitionFunction(Tlist), 1.9734989e0, delta=1e-4) self.assertAlmostEqual(E0 / constants.Na / constants.E_h, -768.275662, 4) self.assertEqual(conformer.spinMultiplicity, 1) self.assertEqual(conformer.opticalIsomers, 1)