Beispiel #1
0
    def setUp(self):
        """
        A function run before each unit test in this class.
        """
        self.nC4H10O = Species(
            label = 'n-C4H10O',
            conformer = Conformer(
                E0 = (-317.807,'kJ/mol'),
                modes = [
                    IdealGasTranslation(mass=(74.07,"g/mol")),
                    NonlinearRotor(inertia=([41.5091,215.751,233.258],"amu*angstrom^2"), symmetry=1),
                    HarmonicOscillator(frequencies=([240.915,341.933,500.066,728.41,809.987,833.93,926.308,948.571,1009.3,1031.46,1076,1118.4,1184.66,1251.36,1314.36,1321.42,1381.17,1396.5,1400.54,1448.08,1480.18,1485.34,1492.24,1494.99,1586.16,2949.01,2963.03,2986.19,2988.1,2995.27,3026.03,3049.05,3053.47,3054.83,3778.88],"cm^-1")),
                    HinderedRotor(inertia=(0.854054,"amu*angstrom^2"), symmetry=1, fourier=([[0.25183,-1.37378,-2.8379,0.0305112,0.0028088], [0.458307,0.542121,-0.599366,-0.00283925,0.0398529]],"kJ/mol")),
                    HinderedRotor(inertia=(8.79408,"amu*angstrom^2"), symmetry=1, fourier=([[0.26871,-0.59533,-8.15002,-0.294325,-0.145357], [1.1884,0.99479,-0.940416,-0.186538,0.0309834]],"kJ/mol")),
                    HinderedRotor(inertia=(7.88153,"amu*angstrom^2"), symmetry=1, fourier=([[-4.67373,2.03735,-6.25993,-0.27325,-0.048748], [-0.982845,1.76637,-1.57619,0.474364,-0.000681718]],"kJ/mol")),
                    HinderedRotor(inertia=(2.81525,"amu*angstrom^2"), symmetry=3, barrier=(2.96807,"kcal/mol")),
                ],
                spinMultiplicity = 1,
                opticalIsomers = 1,
            ),
            molecularWeight = (74.07,"g/mol"),
            transportData=TransportData(sigma=(5.94, 'angstrom'), epsilon=(559, 'K')),
            energyTransferModel = SingleExponentialDown(alpha0=(447.5*0.011962,"kJ/mol"), T0=(300,"K"), n=0.85),
        )
        
        self.nC4H8 = Species(
            label = 'n-C4H8',
            conformer = Conformer(
                E0 = (-17.8832,'kJ/mol'),
                modes = [
                    IdealGasTranslation(mass=(56.06,"g/mol")),
                    NonlinearRotor(inertia=([22.2748,122.4,125.198],"amu*angstrom^2"), symmetry=1),
                    HarmonicOscillator(frequencies=([308.537,418.67,636.246,788.665,848.906,936.762,979.97,1009.48,1024.22,1082.96,1186.38,1277.55,1307.65,1332.87,1396.67,1439.09,1469.71,1484.45,1493.19,1691.49,2972.12,2994.31,3018.48,3056.87,3062.76,3079.38,3093.54,3174.52],"cm^-1")),
                    HinderedRotor(inertia=(5.28338,"amu*angstrom^2"), symmetry=1, fourier=([[-0.579364,-0.28241,-4.46469,0.143368,0.126756], [1.01804,-0.494628,-0.00318651,-0.245289,0.193728]],"kJ/mol")),
                    HinderedRotor(inertia=(2.60818,"amu*angstrom^2"), symmetry=3, fourier=([[0.0400372,0.0301986,-6.4787,-0.0248675,-0.0324753], [0.0312541,0.0538,-0.493785,0.0965968,0.125292]],"kJ/mol")),
                ],
                spinMultiplicity = 1,
                opticalIsomers = 1,
            ),
        )
        
        self.H2O = Species(
            label = 'H2O',
            conformer = Conformer(
                E0 = (-269.598,'kJ/mol'),
                modes = [
                    IdealGasTranslation(mass=(18.01,"g/mol")),
                    NonlinearRotor(inertia=([0.630578,1.15529,1.78586],"amu*angstrom^2"), symmetry=2),
                    HarmonicOscillator(frequencies=([1622.09,3771.85,3867.85],"cm^-1")),
                ],
                spinMultiplicity = 1,
                opticalIsomers = 1,
            ),
        )

        self.configuration = Configuration(self.nC4H8, self.H2O)
Beispiel #2
0
    def generate_statmech(self):
        """
        Generate molecular degree of freedom data for the species. You must
        have already provided a thermodynamics model using e.g.
        :meth:`generate_thermo_data()`.
        """
        logging.debug("Generating statmech for species {}".format(self.label))
        from rmgpy.data.rmg import get_db
        try:
            statmech_db = get_db('statmech')
            if not statmech_db: raise Exception
        except Exception:
            logging.debug(
                'Could not obtain the stat. mech database. Not generating stat. mech...'
            )
            raise

        molecule = self.molecule[0]
        conformer = statmech_db.get_statmech_data(molecule,
                                                  self.get_thermo_data())

        if self.conformer is None:
            self.conformer = Conformer()

        if self.conformer.E0 is None:
            self.set_e0_with_thermo()

        self.conformer.modes = conformer.modes
        self.conformer.spin_multiplicity = conformer.spin_multiplicity
        if self.conformer.E0 is None or not self.has_statmech():
            logging.error('The conformer in question is {}'.format(
                self.conformer))
            raise StatmechError(
                'Species {0} does not have stat mech after generate_statmech called'
                .format(self.label))
Beispiel #3
0
def transitionState(label, *args, **kwargs):
    """Load a transition state from an input file"""
    global transition_state_dict
    if label in transition_state_dict:
        raise ValueError(
            'Multiple occurrences of transition state with label {0!r}.'.
            format(label))
    logging.info('Loading transition state {0}...'.format(label))
    ts = TransitionState(label=label)
    transition_state_dict[label] = ts

    if len(args) == 1 and len(kwargs) == 0:
        # The argument is a path to a conformer input file
        path = args[0]
        job = StatMechJob(species=ts, path=path)
        job_list.append(job)

    elif len(args) == 0:
        # The species parameters are given explicitly
        E0 = None
        modes = []
        spin_multiplicity = 1
        optical_isomers = 1
        frequency = None
        for key, value in kwargs.items():
            if key == 'E0':
                E0 = value
            elif key == 'modes':
                modes = value
            elif key == 'spinMultiplicity':
                spin_multiplicity = value
            elif key == 'opticalIsomers':
                optical_isomers = value
            elif key == 'frequency':
                frequency = value
            else:
                raise TypeError(
                    'transition_state() got an unexpected keyword argument {0!r}.'
                    .format(key))

        ts.conformer = Conformer(E0=E0,
                                 modes=modes,
                                 spin_multiplicity=spin_multiplicity,
                                 optical_isomers=optical_isomers)
        ts.frequency = frequency
    else:
        if len(args) == 0 and len(kwargs) == 0:
            raise InputError(
                'The transition_state needs to reference a quantum job file or contain kinetic information.'
            )
        raise InputError(
            'The transition_state can only link a quantum job or directly input information, not both.'
        )

    return ts
def transitionState(label, *args, **kwargs):
    global transitionStateDict
    if label in transitionStateDict:
        raise ValueError(
            'Multiple occurrences of transition state with label {0!r}.'.
            format(label))
    logging.info('Loading transition state {0}...'.format(label))
    ts = TransitionState(label=label)
    transitionStateDict[label] = ts

    if len(args) == 1 and len(kwargs) == 0:
        # The argument is a path to a conformer input file
        path = args[0]
        job = StatMechJob(species=ts, path=path)
        jobList.append(job)

    elif len(args) == 0 and len(kwargs) > 0:
        # The species parameters are given explicitly
        E0 = None
        modes = []
        spinMultiplicity = 1
        opticalIsomers = 1
        frequency = None
        for key, value in kwargs.items():
            if key == 'E0':
                E0 = value
            elif key == 'modes':
                modes = value
            elif key == 'spinMultiplicity':
                spinMultiplicity = value
            elif key == 'opticalIsomers':
                opticalIsomers = value
            elif key == 'frequency':
                frequency = value
            else:
                raise TypeError(
                    'transitionState() got an unexpected keyword argument {0!r}.'
                    .format(key))

        ts.conformer = Conformer(E0=E0,
                                 modes=modes,
                                 spinMultiplicity=spinMultiplicity,
                                 opticalIsomers=opticalIsomers)
        ts.frequency = frequency

    return ts
Beispiel #5
0
    def setUp(self):
        """
        A function run before each unit test in this class.
        """
        self.nC4H10O = Species(
            label='n-C4H10O',
            conformer=Conformer(
                E0=(-317.807, 'kJ/mol'),
                modes=[
                    IdealGasTranslation(mass=(74.07, "g/mol")),
                    NonlinearRotor(inertia=([41.5091, 215.751,
                                             233.258], "amu*angstrom^2"),
                                   symmetry=1),
                    HarmonicOscillator(frequencies=([
                        240.915, 341.933, 500.066, 728.41, 809.987, 833.93,
                        926.308, 948.571, 1009.3, 1031.46, 1076, 1118.4,
                        1184.66, 1251.36, 1314.36, 1321.42, 1381.17, 1396.5,
                        1400.54, 1448.08, 1480.18, 1485.34, 1492.24, 1494.99,
                        1586.16, 2949.01, 2963.03, 2986.19, 2988.1, 2995.27,
                        3026.03, 3049.05, 3053.47, 3054.83, 3778.88
                    ], "cm^-1")),
                    HinderedRotor(inertia=(0.854054, "amu*angstrom^2"),
                                  symmetry=1,
                                  fourier=([[
                                      0.25183, -1.37378, -2.8379, 0.0305112,
                                      0.0028088
                                  ],
                                            [
                                                0.458307, 0.542121, -0.599366,
                                                -0.00283925, 0.0398529
                                            ]], "kJ/mol")),
                    HinderedRotor(
                        inertia=(8.79408, "amu*angstrom^2"),
                        symmetry=1,
                        fourier=([[
                            0.26871, -0.59533, -8.15002, -0.294325, -0.145357
                        ], [1.1884, 0.99479, -0.940416, -0.186538,
                            0.0309834]], "kJ/mol")),
                    HinderedRotor(inertia=(7.88153, "amu*angstrom^2"),
                                  symmetry=1,
                                  fourier=([[
                                      -4.67373, 2.03735, -6.25993, -0.27325,
                                      -0.048748
                                  ],
                                            [
                                                -0.982845, 1.76637, -1.57619,
                                                0.474364, -0.000681718
                                            ]], "kJ/mol")),
                    HinderedRotor(inertia=(2.81525, "amu*angstrom^2"),
                                  symmetry=3,
                                  barrier=(2.96807, "kcal/mol")),
                ],
                spin_multiplicity=1,
                optical_isomers=1,
            ),
            molecular_weight=(74.07, "g/mol"),
            transport_data=TransportData(sigma=(5.94, 'angstrom'),
                                         epsilon=(559, 'K')),
            energy_transfer_model=SingleExponentialDown(
                alpha0=(447.5 * 0.011962, "kJ/mol"), T0=(300, "K"), n=0.85),
        )

        self.nC4H8 = Species(
            label='n-C4H8',
            conformer=Conformer(
                E0=(-17.8832, 'kJ/mol'),
                modes=[
                    IdealGasTranslation(mass=(56.06, "g/mol")),
                    NonlinearRotor(inertia=([22.2748, 122.4,
                                             125.198], "amu*angstrom^2"),
                                   symmetry=1),
                    HarmonicOscillator(frequencies=([
                        308.537, 418.67, 636.246, 788.665, 848.906, 936.762,
                        979.97, 1009.48, 1024.22, 1082.96, 1186.38, 1277.55,
                        1307.65, 1332.87, 1396.67, 1439.09, 1469.71, 1484.45,
                        1493.19, 1691.49, 2972.12, 2994.31, 3018.48, 3056.87,
                        3062.76, 3079.38, 3093.54, 3174.52
                    ], "cm^-1")),
                    HinderedRotor(inertia=(5.28338, "amu*angstrom^2"),
                                  symmetry=1,
                                  fourier=([[
                                      -0.579364, -0.28241, -4.46469, 0.143368,
                                      0.126756
                                  ],
                                            [
                                                1.01804, -0.494628,
                                                -0.00318651, -0.245289,
                                                0.193728
                                            ]], "kJ/mol")),
                    HinderedRotor(
                        inertia=(2.60818, "amu*angstrom^2"),
                        symmetry=3,
                        fourier=([[
                            0.0400372, 0.0301986, -6.4787, -0.0248675,
                            -0.0324753
                        ], [0.0312541, 0.0538, -0.493785, 0.0965968,
                            0.125292]], "kJ/mol")),
                ],
                spin_multiplicity=1,
                optical_isomers=1,
            ),
        )

        self.H2O = Species(
            label='H2O',
            conformer=Conformer(
                E0=(-269.598, 'kJ/mol'),
                modes=[
                    IdealGasTranslation(mass=(18.01, "g/mol")),
                    NonlinearRotor(inertia=([0.630578, 1.15529,
                                             1.78586], "amu*angstrom^2"),
                                   symmetry=2),
                    HarmonicOscillator(
                        frequencies=([1622.09, 3771.85, 3867.85], "cm^-1")),
                ],
                spin_multiplicity=1,
                optical_isomers=1,
            ),
        )

        self.N2 = Species(
            label='N2',
            molecular_weight=(28.04, "g/mol"),
            transport_data=TransportData(sigma=(3.41, "angstrom"),
                                         epsilon=(124, "K")),
            energy_transfer_model=None,
        )

        self.TS = TransitionState(
            label='TS',
            conformer=Conformer(
                E0=(-42.4373, "kJ/mol"),
                modes=[
                    IdealGasTranslation(mass=(74.07, "g/mol")),
                    NonlinearRotor(inertia=([40.518, 232.666,
                                             246.092], "u*angstrom**2"),
                                   symmetry=1,
                                   quantum=False),
                    HarmonicOscillator(frequencies=([
                        134.289, 302.326, 351.792, 407.986, 443.419, 583.988,
                        699.001, 766.1, 777.969, 829.671, 949.753, 994.731,
                        1013.59, 1073.98, 1103.79, 1171.89, 1225.91, 1280.67,
                        1335.08, 1373.9, 1392.32, 1417.43, 1469.51, 1481.61,
                        1490.16, 1503.73, 1573.16, 2972.85, 2984.3, 3003.67,
                        3045.78, 3051.77, 3082.37, 3090.44, 3190.73, 3708.52
                    ], "kayser")),
                    HinderedRotor(inertia=(2.68206, "amu*angstrom^2"),
                                  symmetry=3,
                                  barrier=(3.35244, "kcal/mol")),
                    HinderedRotor(inertia=(9.77669, "amu*angstrom^2"),
                                  symmetry=1,
                                  fourier=([[
                                      0.208938, -1.55291, -4.05398, -0.105798,
                                      -0.104752
                                  ],
                                            [
                                                2.00518, -0.020767, -0.333595,
                                                0.137791, -0.274578
                                            ]], "kJ/mol")),
                ],
                spin_multiplicity=1,
                optical_isomers=1,
            ),
            frequency=(-2038.34, 'cm^-1'),
        )

        self.reaction = Reaction(
            label='dehydration',
            reactants=[self.nC4H10O],
            products=[self.nC4H8, self.H2O],
            transition_state=self.TS,
        )

        self.network = Network(
            label='n-butanol',
            isomers=[Configuration(self.nC4H10O)],
            reactants=[],
            products=[Configuration(self.nC4H8, self.H2O)],
            path_reactions=[self.reaction],
            bath_gas={self.N2: 1.0},
        )
Beispiel #6
0
    def read_scan(self):
        """
        Read quantum optimization job files at self.calc_path to determine
        vectors of angles self.phis, xyz coordinates (self.xyzs)
        energies (self.Es) and atom numbers (self.atnums) for each point
        """
        from arkane.util import determine_qm_software
        if os.path.isdir(self.calc_path):
            massdict = {
                el.number: el.mass
                for el in element_list if el.isotope == -1
            }
            N = len(self.pivots)
            phis = []
            xyzs = []
            Es = []
            atnums = []
            for f in os.listdir(self.calc_path):
                name, identifier = '.'.join(
                    f.split('.')[:-1]), f.split('.')[-1]
                if identifier != 'out':
                    continue
                outs = name.split('_')
                phivals = [float(x) for x in outs[-N:]]
                phivals = fill360s(phivals)

                fpath = os.path.join(self.calc_path, f)
                lg = determine_qm_software(fpath)
                E = lg.load_energy()
                xyz, atnum, _ = lg.load_geometry()

                for phival in phivals:
                    phis.append(np.array(phival))
                    Es.append(lg.load_energy())
                    xyzs.append(xyz)
                    if not self.atnums:
                        atnums.append(atnum)

            if atnums:
                self.atnums = atnums

            q = len(phis)
            for i in range(
                    N):  # add the negative values to improve fit near 0.0
                for j in range(q):
                    phi = phis[j]
                    if np.isclose(phi[i], 360.0):
                        continue
                    nvec = deepcopy(phi)
                    nvec[i] -= 360.0
                    if any([np.array_equal(nvec, x) for x in phis]):
                        continue
                    phis.append(nvec)
                    Es.append(Es[j])
                    xyzs.append(xyzs[j])
                    atnums.append(atnums[j])

            self.xyzs = np.array(xyzs)

            self.Es = np.array(Es)
            self.E0 = self.Es.min()
            self.Es -= self.E0

            self.phis = np.array(phis)
            self.phis *= np.pi / 180.0

            inds = None
            if len(self.phis[0]) == 1:
                self.phis = np.array([phi[0] for phi in self.phis])
                inds = np.argsort(self.phis)

            self.confs = [
                Conformer(number=self.atnums,
                          coordinates=(self.xyzs[k], "angstrom"),
                          mass=(np.array([massdict[x]
                                          for x in self.atnums]), "amu"))
                for k in range(len(self.xyzs))
            ]

            self.rootDs = np.array([
                np.prod([
                    conf.get_internal_reduced_moment_of_inertia(self.pivots[k],
                                                                self.tops[k],
                                                                option=3)
                    for k in range(len(self.pivots))
                ])**0.5 for conf in self.confs
            ])

            if inds is not None:
                self.rootDs = self.rootDs[inds]
                self.phis = self.phis[inds]
                self.Es = self.Es[inds]
                self.xyzs = self.xyzs[inds]
        elif os.path.isfile(
                self.calc_path
        ):  # reading a 1-D scan file, assume internal reduced moment of inertia is constant
            N = len(self.pivots)
            lg = determine_qm_software(self.calc_path)
            self.Es, self.phis = lg.load_scan_energies()
            self.atnums = self.conformer.number
            rootD = self.conformer.get_internal_reduced_moment_of_inertia(
                self.pivots[0], self.tops[0])**0.5
            self.rootDs = [rootD for i in range(len(self.Es))]

            phis = self.phis.tolist()

            for j, phi in enumerate(
                    self.phis
            ):  # add the negative values to improve fit near 0.0
                if phi != 2.0 * np.pi:
                    phis.append(phi - 2.0 * np.pi)

            phis = np.array(phis)
            inds = np.argsort(phis)
            self.phis = phis[inds]
            Es = self.Es.tolist()
            Es.extend(Es[1:])
            self.Es = np.array(Es)[inds]
            self.rootDs.extend(self.rootDs[1:])
            self.rootDs = np.array(self.rootDs)[inds].tolist()

        else:
            raise IOError("path {} is not a file or a directory".format(
                self.calc_path))
Beispiel #7
0
def species(label, *args, **kwargs):
    """Load a species from an input file"""
    global species_dict, job_list
    if label in species_dict:
        raise ValueError(
            'Multiple occurrences of species with label {0!r}.'.format(label))
    logging.info('Loading species {0}...'.format(label))

    spec = Species(label=label)
    species_dict[label] = spec

    path = None
    if len(args) == 1:
        # The argument is a path to a conformer input file
        path = args[0]
        job = StatMechJob(species=spec, path=path)
        logging.debug('Added species {0} to a stat mech job.'.format(label))
        job_list.append(job)
    elif len(args) > 1:
        raise InputError('species {0} can only have two non-keyword argument '
                         'which should be the species label and the '
                         'path to a quantum file.'.format(spec.label))

    if len(kwargs) > 0:
        # The species parameters are given explicitly
        structure = None
        E0 = None
        modes = []
        spin_multiplicity = 0
        optical_isomers = 1
        molecular_weight = None
        collision_model = None
        energy_transfer_model = None
        thermo = None
        reactive = True
        for key, value in kwargs.items():
            if key == 'structure':
                structure = value
            elif key == 'E0':
                E0 = value
            elif key == 'modes':
                modes = value
            elif key == 'spinMultiplicity':
                spin_multiplicity = value
            elif key == 'opticalIsomers':
                optical_isomers = value
            elif key == 'molecularWeight':
                molecular_weight = value
            elif key == 'collisionModel':
                collision_model = value
            elif key == 'energyTransferModel':
                energy_transfer_model = value
            elif key == 'thermo':
                thermo = value
            elif key == 'reactive':
                reactive = value
            else:
                raise TypeError(
                    'species() got an unexpected keyword argument {0!r}.'.
                    format(key))

        if structure:
            spec.molecule = [structure]
        spec.conformer = Conformer(E0=E0,
                                   modes=modes,
                                   spin_multiplicity=spin_multiplicity,
                                   optical_isomers=optical_isomers)
        if molecular_weight is not None:
            spec.molecular_weight = molecular_weight
        elif spec.molecular_weight is None and is_pdep(job_list):
            # If a structure was given, simply calling spec.molecular_weight will calculate the molecular weight
            # If one of the jobs is pdep and no molecular weight is given or calculated, raise an error
            raise ValueError(
                "No molecularWeight was entered for species {0}. Since a structure wasn't given"
                " as well, the molecularWeight, which is important for pressure dependent jobs,"
                " cannot be reconstructed.".format(spec.label))
        spec.transport_data = collision_model
        spec.energy_transfer_model = energy_transfer_model
        spec.thermo = thermo
        spec.reactive = reactive

        if spec.reactive and path is None and spec.thermo is None and spec.conformer.E0 is None:
            if not spec.molecule:
                raise InputError(
                    'Neither thermo, E0, species file path, nor structure specified, cannot estimate'
                    ' thermo properties of species {0}'.format(spec.label))
            try:
                db = get_db('thermo')
                if db is None:
                    raise DatabaseError('Thermo database is None.')
            except DatabaseError:
                logging.warning(
                    "The database isn't loaded, cannot estimate thermo for {0}. "
                    "If it is a bath gas, set reactive = False to avoid generating "
                    "thermo.".format(spec.label))
            else:
                logging.info(
                    'No E0 or thermo found, estimating thermo and E0 of species {0} using'
                    ' RMG-Database...'.format(spec.label))
                spec.thermo = db.get_thermo_data(spec)
                if spec.thermo.E0 is None:
                    th = spec.thermo.to_wilhoit()
                    spec.conformer.E0 = th.E0
                    spec.thermo.E0 = th.E0
                else:
                    spec.conformer.E0 = spec.thermo.E0

        if spec.reactive and spec.thermo and not spec.has_statmech(
        ) and structure is not None:
            # generate stat mech info if it wasn't provided before
            spec.generate_statmech()

        if not energy_transfer_model:
            # default to RMG's method of generating energy_transfer_model
            spec.generate_energy_transfer_model()

    return spec
def species(label, *args, **kwargs):
    global speciesDict, jobList
    if label in speciesDict:
        raise ValueError(
            'Multiple occurrences of species with label {0!r}.'.format(label))
    logging.info('Loading species {0}...'.format(label))

    spec = Species(label=label)
    speciesDict[label] = spec

    if len(args) == 1:
        # The argument is a path to a conformer input file
        path = args[0]
        job = StatMechJob(species=spec, path=path)
        jobList.append(job)

    if len(kwargs) > 0:
        # The species parameters are given explicitly
        structure = None
        E0 = None
        modes = []
        spinMultiplicity = 1
        opticalIsomers = 1
        molecularWeight = None
        collisionModel = None
        energyTransferModel = None
        thermo = None
        for key, value in kwargs.items():
            if key == 'structure':
                structure = value
            elif key == 'E0':
                E0 = value
            elif key == 'modes':
                modes = value
            elif key == 'spinMultiplicity':
                spinMultiplicity = value
            elif key == 'opticalIsomers':
                opticalIsomers = value
            elif key == 'molecularWeight':
                molecularWeight = value
            elif key == 'collisionModel':
                collisionModel = value
            elif key == 'energyTransferModel':
                energyTransferModel = value
            elif key == 'thermo':
                thermo = value
            else:
                raise TypeError(
                    'species() got an unexpected keyword argument {0!r}.'.
                    format(key))

        if structure: spec.molecule = [structure]
        spec.conformer = Conformer(E0=E0,
                                   modes=modes,
                                   spinMultiplicity=spinMultiplicity,
                                   opticalIsomers=opticalIsomers)
        spec.molecularWeight = molecularWeight
        spec.transportData = collisionModel
        spec.energyTransferModel = energyTransferModel
        spec.thermo = thermo

    return spec
Beispiel #9
0
def transitionState(label, *args, **kwargs):
    """Load a transition state from an input file"""
    global transition_state_dict, job_list, directory
    if label in transition_state_dict:
        raise ValueError(
            'Multiple occurrences of transition state with label {0!r}.'.
            format(label))
    logging.info('Loading transition state {0}...'.format(label))
    ts = TransitionState(label=label)
    transition_state_dict[label] = ts

    if len(args) == 1:
        # The argument is a path to a conformer input file
        path = os.path.join(directory, args[0])
        ts.path = path
        job = SamplingJob(label=label,
                          input_file=path,
                          output_directory=output_directory,
                          is_ts=True)
        Log = QChemLog(path)
        ts.conformer, unscaled_frequencies = Log.load_conformer()
        ts.frequency = (Log.load_negative_frequency(), "cm^-1")
        job_list.append(job)

    elif len(args) == 0:
        # The species parameters are given explicitly
        E0 = None
        modes = []
        spin_multiplicity = 1
        optical_isomers = 1
        frequency = None
        for key, value in kwargs.items():
            if key == 'E0':
                E0 = value
            elif key == 'modes':
                modes = value
            elif key == 'spinMultiplicity':
                spin_multiplicity = value
            elif key == 'opticalIsomers':
                optical_isomers = value
            elif key == 'frequency':
                frequency = value
            else:
                raise TypeError(
                    'transition_state() got an unexpected keyword argument {0!r}.'
                    .format(key))

        ts.conformer = Conformer(E0=E0,
                                 modes=modes,
                                 spin_multiplicity=spin_multiplicity,
                                 optical_isomers=optical_isomers)
        ts.frequency = frequency
    else:
        if len(args) == 0 and len(kwargs) == 0:
            raise InputError(
                'The transition_state needs to reference a quantum job file or contain kinetic information.'
            )
        raise InputError(
            'The transition_state can only link a quantum job or directly input information, not both.'
        )

    if len(kwargs) > 0:
        # The species parameters are given explicitly
        protocol = 'UMVT'
        E0 = None
        rotors = None
        for key, value in kwargs.items():
            if key == 'protocol':
                protocol = value.upper()
            elif key == 'E0':
                E0 = value
            elif key == 'rotors':
                rotors = value
            else:
                raise TypeError(
                    'species() got an unexpected keyword argument {0!r}.'.
                    format(key))

        if protocol == 'UMVT' and rotors is None:
            raise InputError(
                'If the transition state is sampled by using UMVT algorithm, the rotors are needed to be specified.'
            )

        job.protocol = protocol
        ts.conformer.E0 = E0
        job.rotors = rotors

    return ts
Beispiel #10
0
    elif number[i] == 7:
        mass[i] = 14.0030740048
    elif number[i] == 8:
        mass[i] = 15.99491461956
    elif number[i] == 15:
        mass[i] = 30.97376163
    elif number[i] == 16:
        mass[i] = 31.97207100
    elif number[i] == 17:
        mass[i] = 35.4527
    else:
        print 'Atomic number {0:d} not yet supported in loadGeometry().'.format(
            number[i])

conformer = Conformer(number=number,
                      mass=(mass, "amu"),
                      coordinates=(coord, "angstroms"))
"""
Define rotors
"""

pivots = [2, 3]

top = [2, 4, 7, 9]

symmetry = 1

linear = False

TS = False
Beispiel #11
0
    def setUp(self):
        """
        A method that is called prior to each unit test in this class.
        """
        ethylene = Species(
            label='C2H4',
            conformer=Conformer(
                E0=(44.7127, 'kJ/mol'),
                modes=[
                    IdealGasTranslation(mass=(28.0313, 'amu'), ),
                    NonlinearRotor(
                        inertia=(
                            [3.41526, 16.6498, 20.065],
                            'amu*angstrom^2',
                        ),
                        symmetry=4,
                    ),
                    HarmonicOscillator(frequencies=(
                        [
                            828.397, 970.652, 977.223, 1052.93, 1233.55,
                            1367.56, 1465.09, 1672.25, 3098.46, 3111.7,
                            3165.79, 3193.54
                        ],
                        'cm^-1',
                    ), ),
                ],
                spinMultiplicity=1,
                opticalIsomers=1,
            ),
        )

        hydrogen = Species(
            label='H',
            conformer=Conformer(
                E0=(211.794, 'kJ/mol'),
                modes=[
                    IdealGasTranslation(mass=(1.00783, 'amu'), ),
                ],
                spinMultiplicity=2,
                opticalIsomers=1,
            ),
        )

        ethyl = Species(
            label='C2H5',
            conformer=Conformer(
                E0=(111.603, 'kJ/mol'),
                modes=[
                    IdealGasTranslation(mass=(29.0391, 'amu'), ),
                    NonlinearRotor(
                        inertia=(
                            [4.8709, 22.2353, 23.9925],
                            'amu*angstrom^2',
                        ),
                        symmetry=1,
                    ),
                    HarmonicOscillator(frequencies=(
                        [
                            482.224, 791.876, 974.355, 1051.48, 1183.21,
                            1361.36, 1448.65, 1455.07, 1465.48, 2688.22,
                            2954.51, 3033.39, 3101.54, 3204.73
                        ],
                        'cm^-1',
                    ), ),
                    HinderedRotor(
                        inertia=(1.11481, 'amu*angstrom^2'),
                        symmetry=6,
                        barrier=(0.244029, 'kJ/mol'),
                        semiclassical=None,
                    ),
                ],
                spinMultiplicity=2,
                opticalIsomers=1,
            ),
        )

        TS = TransitionState(
            label='TS',
            conformer=Conformer(
                E0=(266.694, 'kJ/mol'),
                modes=[
                    IdealGasTranslation(mass=(29.0391, 'amu'), ),
                    NonlinearRotor(
                        inertia=(
                            [6.78512, 22.1437, 22.2114],
                            'amu*angstrom^2',
                        ),
                        symmetry=1,
                    ),
                    HarmonicOscillator(frequencies=(
                        [
                            412.75, 415.206, 821.495, 924.44, 982.714, 1024.16,
                            1224.21, 1326.36, 1455.06, 1600.35, 3101.46,
                            3110.55, 3175.34, 3201.88
                        ],
                        'cm^-1',
                    ), ),
                ],
                spinMultiplicity=2,
                opticalIsomers=1,
            ),
            frequency=(-750.232, 'cm^-1'),
        )

        self.reaction = Reaction(
            reactants=[hydrogen, ethylene],
            products=[ethyl],
            kinetics=Arrhenius(
                A=(501366000.0, 'cm^3/(mol*s)'),
                n=1.637,
                Ea=(4.32508, 'kJ/mol'),
                T0=(1, 'K'),
                Tmin=(300, 'K'),
                Tmax=(2500, 'K'),
            ),
            transitionState=TS,
        )

        # CC(=O)O[O]
        acetylperoxy = Species(
            label='acetylperoxy',
            thermo=Wilhoit(Cp0=(4.0 * constants.R, "J/(mol*K)"),
                           CpInf=(21.0 * constants.R, "J/(mol*K)"),
                           a0=-3.95,
                           a1=9.26,
                           a2=-15.6,
                           a3=8.55,
                           B=(500.0, "K"),
                           H0=(-6.151e+04, "J/mol"),
                           S0=(-790.2, "J/(mol*K)")),
        )

        # C[C]=O
        acetyl = Species(
            label='acetyl',
            thermo=Wilhoit(Cp0=(4.0 * constants.R, "J/(mol*K)"),
                           CpInf=(15.5 * constants.R, "J/(mol*K)"),
                           a0=0.2541,
                           a1=-0.4712,
                           a2=-4.434,
                           a3=2.25,
                           B=(500.0, "K"),
                           H0=(-1.439e+05, "J/mol"),
                           S0=(-524.6, "J/(mol*K)")),
        )

        # [O][O]
        oxygen = Species(
            label='oxygen',
            thermo=Wilhoit(Cp0=(3.5 * constants.R, "J/(mol*K)"),
                           CpInf=(4.5 * constants.R, "J/(mol*K)"),
                           a0=-0.9324,
                           a1=26.18,
                           a2=-70.47,
                           a3=44.12,
                           B=(500.0, "K"),
                           H0=(1.453e+04, "J/mol"),
                           S0=(-12.19, "J/(mol*K)")),
        )

        self.reaction2 = Reaction(
            reactants=[acetyl, oxygen],
            products=[acetylperoxy],
            kinetics=Arrhenius(
                A=(2.65e12, 'cm^3/(mol*s)'),
                n=0.0,
                Ea=(0.0, 'kJ/mol'),
                T0=(1, 'K'),
                Tmin=(300, 'K'),
                Tmax=(2000, 'K'),
            ),
        )