コード例 #1
0
ファイル: gaussian.py プロジェクト: xiaoruiDong/RMG-tools
def classify_gauss_outputs(gauss_files, only_converged=False):
    """
    Classify the gaussian output files into single point ('sp'), frequency 
    ('freq') and scan ('scan')

    Args:
        gauss_files (list): A list of paths to gaussian output file

    Returns:
        classified (dict): A dict indicates the files and some properties
    """
    classified = {'sp': [], 'freq': [], 'scan': []}
    for gauss_file in gauss_files:
        options = parse_gauss_options(gauss_file)
        job_type = get_gauss_job_type(options)
        converged = get_gauss_termination_status(gauss_file)
        if job_type in ['opt', 'opt+freq', 'composite']:
            if not only_converged or converged:
                log = GaussianLog(gauss_file)
                energy = log.load_energy() / Na / E_h
                ts = 'TS' if 'opt' in options.keys() and 'ts' in options['opt'] else 'nonTS'
                classified['sp'].append((gauss_file, converged,
                                         options['method'][0], energy, ts))
        if job_type in ['freq', 'opt+freq', 'composite']:
            if not only_converged or converged:
                freqs = get_gauss_frequencies(gauss_file)
                classified['freq'].append((gauss_file, converged, 
                                           options['method'][0], freqs))
        if job_type == 'scan':
            if not only_converged or converged:
                scan_info = parse_gauss_scan_info(gauss_file)
                classified['scan'].append((gauss_file, converged, 
                                           options['method'][0], scan_info))
    return classified
コード例 #2
0
    def testLoadEthyleneFromGaussianLog_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.loadConformer()
        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),
                               5.83338e6,
                               delta=1e1)
        self.assertAlmostEqual(rot.getPartitionFunction(Tlist),
                               2.53410e3,
                               delta=1e-2)
        self.assertAlmostEqual(vib.getPartitionFunction(Tlist),
                               1.0304e0,
                               delta=1e-4)

        self.assertAlmostEqual(E0 / constants.Na / constants.E_h, -78.562189,
                               4)
        self.assertEqual(conformer.spinMultiplicity, 1)
        self.assertEqual(conformer.opticalIsomers, 1)
コード例 #3
0
    def testLoadOxygenFromGaussianLog(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 = log.loadConformer(symfromlog=True)
        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,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]
        Tlist = numpy.array([298.15], numpy.float64)
        self.assertAlmostEqual(trans.getPartitionFunction(Tlist), 7.11169e6, delta=1e1)
        self.assertAlmostEqual(rot.getPartitionFunction(Tlist), 7.13316e1, delta=1e-4)
        self.assertAlmostEqual(vib.getPartitionFunction(Tlist), 1.00037e0, delta=1e-4)
        
        self.assertAlmostEqual(E0 / constants.Na / constants.E_h, -150.3784877, 4)
        self.assertEqual(conformer.spinMultiplicity, 3)
        self.assertEqual(conformer.opticalIsomers, 1)
コード例 #4
0
    def testLoadOxygenFromGaussianLog(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.loadConformer()
        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,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]
        Tlist = numpy.array([298.15], numpy.float64)
        self.assertAlmostEqual(trans.getPartitionFunction(Tlist), 7.11169e6, delta=1e1)
        self.assertAlmostEqual(rot.getPartitionFunction(Tlist), 7.13316e1, delta=1e-4)
        self.assertAlmostEqual(vib.getPartitionFunction(Tlist), 1.00037e0, delta=1e-4)
        
        self.assertAlmostEqual(E0 / constants.Na / constants.E_h, -150.3784877, 4)
        self.assertEqual(conformer.spinMultiplicity, 3)
        self.assertEqual(conformer.opticalIsomers, 1)
コード例 #5
0
    def testLoadEthyleneFromGaussianLog_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(os.path.dirname(__file__),'data','ethylene.log'))
        conformer, unscaled_frequencies = log.loadConformer()
        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), 5.83338e6, delta=1e1)
        self.assertAlmostEqual(rot.getPartitionFunction(Tlist), 2.59622e3, delta=1e-2)
        self.assertAlmostEqual(vib.getPartitionFunction(Tlist), 1.0481e0, delta=1e-4)

        self.assertAlmostEqual(E0 / constants.Na / constants.E_h, -78.467452, 4)
        self.assertEqual(conformer.spinMultiplicity, 1)
        self.assertEqual(conformer.opticalIsomers, 1)
コード例 #6
0
ファイル: gaussianTest.py プロジェクト: saud3001/RMG-Py
    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(os.path.dirname(__file__), 'data', '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)
コード例 #7
0
ファイル: gaussianTest.py プロジェクト: saud3001/RMG-Py
    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)
コード例 #8
0
 def setUp(cls):
     """A method that is run before each unit test in this class"""
     spc = Species().fromSMILES('CCO')
     log = GaussianLog(os.path.join(os.path.dirname(__file__), 'data', 'ethylene.log'))
     spc.conformer = log.loadConformer()[0]
     coords, numbers, masses = log.loadGeometry()
     spc.conformer.coordinates = coords, 'angstroms'
     spc.conformer.number = numbers
     spc.conformer.mass = masses, 'amu'
     cls.thermo_job = ThermoJob(species=spc, thermoClass='NASA')
コード例 #9
0
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
コード例 #10
0
ファイル: outputTest.py プロジェクト: saud3001/RMG-Py
    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)
コード例 #11
0
    def testLoadSymmetryAndOptics(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_optical_isomers_and_symmetry_number()
        self.assertEqual(optical,1)
        self.assertEqual(symmetry,2)

        conf = log.loadConformer()[0]
        self.assertEqual(conf.opticalIsomers, 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)
コード例 #12
0
    def testLoadSymmetryAndOptics(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_optical_isomers_and_symmetry_number()
        self.assertEqual(optical, 1)
        self.assertEqual(symmetry, 2)

        conf = log.loadConformer()[0]
        self.assertEqual(conf.opticalIsomers, 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)