Ejemplo n.º 1
0
    def setUp(cls):
        """A method that is run before each unit test in this class"""
        freqpath = os.path.join(
            os.path.dirname(
                os.path.split(os.path.split(os.path.abspath(__file__))[0])[0]),
            'arkane', 'data', 'TolueneFreq.log')
        rotpath = os.path.join(
            os.path.dirname(
                os.path.split(os.path.split(os.path.abspath(__file__))[0])[0]),
            'arkane', 'data', 'TolueneRot1.log')
        lg = determine_qm_software(freqpath)

        conf, unscaled_freqs = lg.loadConformer(symmetry=1,
                                                spinMultiplicity=1,
                                                opticalIsomers=1,
                                                label='Toulene')
        coordinates, number, mass = lg.loadGeometry()
        conf.coordinates = (coordinates, "angstroms")
        conf.number = number
        conf.mass = (mass, "amu")

        F = lg.loadForceConstantMatrix()

        cls.hdnd = HinderedRotorClassicalND(pivots=[[3, 12]],
                                            tops=[[12, 13, 14, 15]],
                                            sigmas=[6.0],
                                            calcPath=rotpath,
                                            conformer=conf,
                                            F=F,
                                            semiclassical=True)
Ejemplo n.º 2
0
    def setUp(cls):
        """A method that is run before each unit test in this class"""
        freqpath = os.path.join(RMG_PATH, 'arkane', 'data', 'TolueneFreq.log')
        rotpath = os.path.join(RMG_PATH, 'arkane', 'data', 'TolueneRot1.log')
        log = determine_qm_software(freqpath)

        conf, unscaled_freqs = log.load_conformer(symmetry=1, spin_multiplicity=1, optical_isomers=1, label='Toulene')
        coordinates, number, mass = log.load_geometry()
        conf.coordinates = (coordinates, "angstroms")
        conf.number = number
        conf.mass = (mass, "amu")

        hessian = log.load_force_constant_matrix()

        cls.hdnd = HinderedRotorClassicalND(pivots=[[3, 12]], tops=[[12, 13, 14, 15]], sigmas=[6.0],
                                            calc_path=rotpath, conformer=conf, F=hessian, semiclassical=True)
Ejemplo n.º 3
0
def determine_ess(log_file):
    """
    Determine the ESS to which the log file belongs.

    Args:
        log_file (str): The ESS log file path.

    Returns:
        str: The ESS (either 'gaussian', 'qchem', or 'molpro'.
    """
    log = determine_qm_software(log_file)
    if isinstance(log, GaussianLog):
        return 'gaussian'
    if isinstance(log, QChemLog):
        return 'qchem'
    if isinstance(log, MolproLog):
        return 'molpro'
    raise InputError('Could not identify the log file in {0} as belonging to Gaussian, QChem, or Molpro.')
Ejemplo n.º 4
0
    def read_scan(self):
        """
        Read quantum optimization job files at self.calc_path to determine
        vectors of angles (self.phi1s, self.phi2s), xyz coordinates (self.xyzs)
        energies (self.Es) and atom numbers (self.atnums) for each point
        """
        from arkane.util import determine_qm_software
        from arkane.common import symbol_by_number
        phi1s = []
        phi2s = []
        xyzs = []
        Es = []
        atnums = []
        for f in os.listdir(self.calc_path):
            if len(f.split('_')) != 4:
                continue
            s, name, phi1, phi2 = f.split('_')  # scangeom_r0_0.0_360.0.log
            phi2, identifier = '.'.join(
                phi2.split('.')[:-1]), phi2.split('.')[-1]
            if identifier != 'out':
                continue
            phi1s.append(float(phi1))
            phi2s.append(float(phi2.split(".")[0]))

            fpath = os.path.join(self.calc_path, f)
            lg = determine_qm_software(fpath)

            Es.append(lg.load_energy())
            xyz, atnums, _ = lg.load_geometry()
            xyzs.append(xyz)

        self.xyzs = xyzs
        self.phi1s = phi1s
        self.phi2s = phi2s
        self.Es = Es
        self.atnums = atnums
        self.element_names = [symbol_by_number[k] for k in self.atnums]
Ejemplo n.º 5
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))
Ejemplo n.º 6
0
    def test_determine_qm_software(self):
        """Test identifying the electronic structure software from the log file"""
        gaussian_log_path1 = os.path.join(self.data_path, 'gaussian',
                                          'ethylene_G3.log')
        gaussian_log_path2 = os.path.join(self.data_path, 'gaussian',
                                          'oxygen.log')
        molpro_log_path1 = os.path.join(self.data_path, 'molpro',
                                        'HOSI_ccsd_t1.out')
        molpro_log_path2 = os.path.join(self.data_path, 'molpro',
                                        'molpro_mrci+q.out')
        qchem_log_path1 = os.path.join(self.data_path, 'qchem', 'CH4_sp.out')
        qchem_log_path2 = os.path.join(self.data_path, 'qchem', 'co.out')
        terachem_log_path_1 = os.path.join(self.data_path, 'terachem',
                                           'ethane_minimize_output.out')
        terachem_log_path_2 = os.path.join(
            self.data_path, 'terachem', 'formaldehyde_sp_terachem_output.out')
        terachem_log_path_3 = os.path.join(
            self.data_path, 'terachem', 'formaldehyde_sp_terachem_results.dat')
        terachem_log_path_4 = os.path.join(self.data_path, 'terachem',
                                           'formaldehyde_coords.xyz')
        terachem_log_path_5 = os.path.join(self.data_path, 'terachem',
                                           'formaldehyde_output.geometry')
        non_ess_log_path = os.path.join(os.path.dirname(__file__), 'data',
                                        'methoxy.py')

        self.assertIsInstance(determine_qm_software(gaussian_log_path1),
                              GaussianLog)
        self.assertIsInstance(determine_qm_software(gaussian_log_path2),
                              GaussianLog)
        self.assertIsInstance(determine_qm_software(molpro_log_path1),
                              MolproLog)
        self.assertIsInstance(determine_qm_software(molpro_log_path2),
                              MolproLog)
        self.assertIsInstance(determine_qm_software(qchem_log_path1), QChemLog)
        self.assertIsInstance(determine_qm_software(qchem_log_path2), QChemLog)
        self.assertIsInstance(determine_qm_software(terachem_log_path_1),
                              TeraChemLog)
        self.assertIsInstance(determine_qm_software(terachem_log_path_2),
                              TeraChemLog)
        self.assertIsInstance(determine_qm_software(terachem_log_path_3),
                              TeraChemLog)
        self.assertIsInstance(determine_qm_software(terachem_log_path_4),
                              TeraChemLog)
        self.assertIsInstance(determine_qm_software(terachem_log_path_5),
                              TeraChemLog)

        with self.assertRaises(InputError):
            determine_qm_software(non_ess_log_path)