How to use the qcelemental.periodictable.to_E function in qcelemental

To help you get started, we’ve selected a few qcelemental 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 psi4 / psi4 / psi4 / driver / qcdb / cfour.py View on Github external
def harvest_GRD(grd):
    """Parses the contents *grd* of the Cfour GRD file into the gradient
    array and coordinate information. The coordinate info is converted
    into a rather dinky Molecule (no charge, multiplicity, or fragment),
    but this is these coordinates that govern the reading of molecule
    orientation by Cfour. Return qcdb.Molecule and gradient array.

    """
    grd = grd.splitlines()
    Nat = int(grd[0].split()[0])
    molxyz = '%d bohr\n\n' % (Nat)

    grad = []
    for at in range(Nat):
        mline = grd[at + 1].split()
        el = 'GH' if int(float(mline[0])) == 0 else qcel.periodictable.to_E(int(float(mline[0])))
        molxyz += '%s %16s %16s %16s\n' % (el, mline[-3], mline[-2], mline[-1])
        lline = grd[at + 1 + Nat].split()
        grad.append([float(lline[-3]), float(lline[-2]), float(lline[-1])])
    mol = Molecule.from_string(molxyz, dtype='xyz+', fix_com=True, fix_orientation=True)

    return mol, grad
github chemreps / chemreps / chemreps / utils / molecule.py View on Github external
cclib parsable output file name
        """
        try:
            self.ftype = 'cclib'
            data = cclib.io.ccread(fname)
            self.n_atom = data.natom
            self.at_num = data.atomnos
            # This gets the atomic symbols by looking up the keys of the
            # atomic numbers. It looks somewhat crazy but it is looking
            # through a list of the values stored in the dictionary,
            # matching the value to the atomic number and returning
            # the key that corresponds to that atomic number. It works
            # with this dictionary because the keys to values are 1 to 1.
            self.sym = []
            for i in data.atomnos:
                self.sym.append(qcel.periodictable.to_E(i))
            # cclib stores the atomic coordinates in a array of shape
            # [molecule, num atoms, 3 for xyz] because I think they might
            # have many "molecules" from each step of an optimization or
            # something. Here we are taking just the last one.
            self.xyz = data.atomcoords[-1]
            return True
        except:
            return False
github psi4 / psi4 / psi4 / driver / qcdb / molparse / nucleus.py View on Github external
def offer_atomic_number(z):
        """Given an atomic number, what can be suggested and asserted about Z, A, mass?"""

        z = int(z)

        z_symbol = qcel.periodictable.to_E(z)
        z_mass = qcel.periodictable.to_mass(z)
        re_eliso = re.compile(z_symbol + '[0-9]{1,3}')  # lone symbol (val equals most common isotope) will not match
        z_a2mass = {int(k[len(z_symbol):]): float(v) for k, v in qcel.periodictable._eliso2mass.items() if re_eliso.match(k)}
        z_a2mass_min = min(z_a2mass.keys())
        z_a2mass_max = max(z_a2mass.keys())
        z_mass2a = {v: k for k, v in z_a2mass.items()}
        z_mass2a_min = min(z_mass2a.keys())
        z_mass2a_max = max(z_mass2a.keys())
        z_a = z_mass2a[z_mass]

        Z_exact.append(z)
        Z_range.append(lambda x, z=z: x == z)

        A_exact.append(z_a)
        if nonphysical:
            A_range.append(lambda x: x == -1 or x >= 1)
github psi4 / psi4 / psi4 / driver / qcdb / molparse / nucleus.py View on Github external
def offer_mass_value(z, m):
        """Given a mass and element, what can be suggested and asserted about A, mass?"""

        m = float(m)
        m_a = int(round(m, 0))
        m_eliso = qcel.periodictable.to_E(z) + str(m_a)

        try:
            if abs(qcel.periodictable.to_mass(m_eliso) - m) > mtol:
                # only offer A if known nuclide. C@12.4 != 12C
                m_a = -1
        except qcel.NotAnElementError:
            m_a = -1

        A_exact.append(m_a)
        A_range.append(lambda x, m_a=m_a: x == m_a)
        text.append("""For A, inputs Z: {}, m: {} require A == {}""".format(z, m, m_a))

        m_exact.append(m)
        m_range.append(lambda x, m=m: x == m)
        text.append("""For mass, inputs Z: {}, m: {} require m == {}""".format(z, m, m))