Пример #1
0
    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)
Пример #2
0
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
Пример #3
0
    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)