How to use the qcfractal.interface.constants function in qcfractal

To help you get started, we’ve selected a few qcfractal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MolSSI / QCFractal / qcfractal / interface / molecule.py View on Github external
entries = re.split(r'\s+|\s*,\s*', line.strip())
                atomm = atom.match(line.split()[0].strip().upper())
                atomLabel = atomm.group('label')
                atomSym = atomm.group('symbol')

                # We don't know whether the @C or Gh(C) notation matched. Do a quick check.
                ghostAtom = False if (atomm.group('gh1') is None and atomm.group('gh2') is None) else True

                # Check that the atom symbol is valid
                if not atomSym in constants.el2z:
                    raise TypeError(
                        'Molecule:create_molecule_from_string: Illegal atom symbol in geometry specification: %s' %
                        atomSym)

                symbols.append(atomSym)
                zVal = constants.el2z[atomSym]
                if atomm.group('mass') is None:
                    atomMass = constants.el2masses[atomSym]
                else:
                    custom_mass = True
                    atomMass = float(atomm.group('mass'))
                tmpMass.append(atomMass)

                charge = float(zVal)
                if ghostAtom:
                    zVal = 0
                    charge = 0.0

                # handle cartesians
                if len(entries) == 4:
                    tempfrag.append(iatom)
                    if realNumber.match(entries[1]):
github MolSSI / QCFractal / qcfractal / interface / molecule.py View on Github external
bohr = re.compile(r'^\s*units?[\s=]+(bohr|au|a.u.)\s*$', re.IGNORECASE)
        ang = re.compile(r'^\s*units?[\s=]+(ang|angstrom)\s*$', re.IGNORECASE)
        atom = re.compile(
            r'^(?:(?P@)|(?PGh\())?(?P<label>(?P</label>
github MolSSI / QCFractal / qcfractal / interface / database.py View on Github external
if (not ignore_db_type) and (self.data["db_type"].lower() == "ie"):
            monomer_stoich = ''.join([x for x in stoich if not x.isdigit()]) + '1'
            tmp_idx_complex = self._unroll_query(keys, stoich, field=field)
            tmp_idx_monomers = self._unroll_query(keys, monomer_stoich, field=field)

            # Combine
            tmp_idx = tmp_idx_complex - tmp_idx_monomers

        else:
            tmp_idx = self._unroll_query(keys, stoich, field=field)
        tmp_idx.columns = [prefix + x + postfix for x in tmp_idx.columns]

        # scale
        tmp_idx = tmp_idx.apply(lambda x: pd.to_numeric(x, errors='ignore'))
        tmp_idx[tmp_idx.select_dtypes(include=['number']).columns] *= constants.get_scale(scale)

        # Apply to df
        self.df[tmp_idx.columns] = tmp_idx

        return True
github MolSSI / QCFractal / qcfractal / interface / database.py View on Github external
if query_packet_hash not in self._queries:
            self._queries[query_packet_hash] = query_packet

        # If reaction results
        if reaction_results:
            tmp_idx = pd.DataFrame(index=self.df.index, columns=keys)
            for rxn in self.data["reactions"]:
                for col in keys:
                    try:
                        tmp_idx.ix[rxn["name"], col] = rxn["reaction_results"][stoich][col]
                    except:
                        pass

            # Convert to numeric
            tmp_idx = tmp_idx.apply(lambda x: pd.to_numeric(x, errors='ignore'))
            tmp_idx[tmp_idx.select_dtypes(include=['number']).columns] *= constants.get_scale(scale)

            tmp_idx.columns = [prefix + x + postfix for x in tmp_idx.columns]
            self.df[tmp_idx.columns] = tmp_idx
            return True

        # if self.data["db_type"].lower() == "ie":
        #     _ie_helper(..)

        if (not ignore_db_type) and (self.data["db_type"].lower() == "ie"):
            monomer_stoich = ''.join([x for x in stoich if not x.isdigit()]) + '1'
            tmp_idx_complex = self._unroll_query(keys, stoich, field=field)
            tmp_idx_monomers = self._unroll_query(keys, monomer_stoich, field=field)

            # Combine
            tmp_idx = tmp_idx_complex - tmp_idx_monomers
github MolSSI / QCFractal / qcfractal / interface / molecule.py View on Github external
atomLabel = atomm.group('label')
                atomSym = atomm.group('symbol')

                # We don't know whether the @C or Gh(C) notation matched. Do a quick check.
                ghostAtom = False if (atomm.group('gh1') is None and atomm.group('gh2') is None) else True

                # Check that the atom symbol is valid
                if not atomSym in constants.el2z:
                    raise TypeError(
                        'Molecule:create_molecule_from_string: Illegal atom symbol in geometry specification: %s' %
                        atomSym)

                symbols.append(atomSym)
                zVal = constants.el2z[atomSym]
                if atomm.group('mass') is None:
                    atomMass = constants.el2masses[atomSym]
                else:
                    custom_mass = True
                    atomMass = float(atomm.group('mass'))
                tmpMass.append(atomMass)

                charge = float(zVal)
                if ghostAtom:
                    zVal = 0
                    charge = 0.0

                # handle cartesians
                if len(entries) == 4:
                    tempfrag.append(iatom)
                    if realNumber.match(entries[1]):
                        xval = float(entries[1])
                    else:
github MolSSI / QCFractal / qcfractal / interface / molecule.py View on Github external
atomLabel = atomm.group('label')
                atomSym = atomm.group('symbol')

                # We don't know whether the @C or Gh(C) notation matched. Do a quick check.
                ghostAtom = False if (atomm.group('gh1') is None and atomm.group('gh2') is None) else True

                # Check that the atom symbol is valid
                if not atomSym in constants.el2z:
                    raise TypeError(
                        'Molecule:create_molecule_from_string: Illegal atom symbol in geometry specification: %s' %
                        atomSym)

                symbols.append(atomSym)
                zVal = constants.el2z[atomSym]
                if atomm.group('mass') is None:
                    atomMass = constants.el2masses[atomSym]
                else:
                    custom_mass = True
                    atomMass = float(atomm.group('mass'))
                tmpMass.append(atomMass)

                charge = float(zVal)
                if ghostAtom:
                    zVal = 0
                    charge = 0.0

                # handle cartesians
                if len(entries) == 4:
                    tempfrag.append(iatom)
                    if realNumber.match(entries[1]):
                        xval = float(entries[1])
                    else:
github MolSSI / QCFractal / qcfractal / interface / molecule.py View on Github external
Given a NumPy array of shape (N, 4) where each row is (Z_nuclear, X, Y, Z).

        Frags represents the splitting pattern for molecular fragments. Geometry must be in
        Angstroms.
        """

        print("I am here")
        arr = np.array(arr)

        if arr.shape[1] != 4:
            raise AttributeError("Molecule: Molecule should be shape (N, 4) not %d." % arr.shape[1])

        if units == "bohr":
            const = 1
        elif units == "angstrom":
            const = 1 / constants.physconst["bohr2angstroms"]
        else:
            raise KeyError("Unit '%s' not understood" % units)

        self.geometry = arr[:, 1:].copy() * const
        self.real = [True for x in arr[:, 0]]
        self.symbols = [constants.z2el[x] for x in arr[:, 0]]

        if len(frags) and (frags[-1] != arr.shape[0]):
            frags.append(arr.shape[0])

        start = 0
        for fsplit in frags:
            self.fragments.append(list(range(start, fsplit)))
            self.fragment_charges.append(0.0)
            self.fragment_multiplicities.append(1)
            start = fsplit
github MolSSI / QCFractal / qcfractal / interface / molecule.py View on Github external
"""
        Given a NumPy array of shape (N, 4) where each row is (Z_nuclear, X, Y, Z).

        Frags represents the splitting pattern for molecular fragments. Geometry must be in
        Angstroms.
        """

        arr = np.array(arr)

        if arr.shape[1] != 4:
            raise AttributeError("Molecule: Molecule should be shape (N, 4) not %d." % arr.shape[1])

        if units == "bohr":
            const = 1
        elif units == "angstrom":
            const = 1 / constants.physconst["bohr2angstroms"]
        else:
            raise KeyError("Unit '%s' not understood" % units)

        self.geometry = arr[:, 1:].copy() * const
        self.real = [True for x in arr[:, 0]]
        self.symbols = [constants.z2el[x] for x in arr[:, 0]]

        if len(frags) and (frags[-1] != arr.shape[0]):
            frags.append(arr.shape[0])

        start = 0
        for fsplit in frags:
            self.fragments.append(list(range(start, fsplit)))
            self.fragment_charges.append(0.0)
            self.fragment_multiplicities.append(1)
            start = fsplit