How to use the pymatgen.core.periodic_table.get_el_sp function in pymatgen

To help you get started, we’ve selected a few pymatgen 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 hackingmaterials / robocrystallographer / robocrys / condense / site.py View on Github external
def order_elements(el):
            if self.use_iupac_formula:
                return [get_el_sp(el).X, el]
            else:
                return [get_el_sp(el).iupac_ordering, el]
github materialsproject / pymatgen / pymatgen / analysis / structure_prediction / substitution_probability.py View on Github external
def get_lambda(self, s1, s2):
        k = frozenset([get_el_sp(s1),
                       get_el_sp(s2)])
        return self._l.get(k, self.alpha)
github materialsproject / pymatgen / pymatgen / io / cif.py View on Github external
num_h = get_num_implicit_hydrogens(data["_atom_site_label"][i])
            if not symbol:
                continue

            if oxi_states is not None:
                o_s = oxi_states.get(symbol, 0)
                # use _atom_site_type_symbol if possible for oxidation state
                if "_atom_site_type_symbol" in data.data.keys():
                    oxi_symbol = data["_atom_site_type_symbol"][i]
                    o_s = oxi_states.get(oxi_symbol, o_s)
                try:
                    el = Specie(symbol, o_s)
                except:
                    el = DummySpecie(symbol, o_s)
            else:
                el = get_el_sp(symbol)

            x = str2float(data["_atom_site_fract_x"][i])
            y = str2float(data["_atom_site_fract_y"][i])
            z = str2float(data["_atom_site_fract_z"][i])
            magmom = magmoms.get(data["_atom_site_label"][i],
                                 np.array([0, 0, 0]))

            try:
                occu = str2float(data["_atom_site_occupancy"][i])
            except (KeyError, ValueError):
                occu = 1

            if occu > 0:
                coord = (x, y, z)
                match = get_matching_coord(coord)
                comp_d = {el: occu}
github materialsvirtuallab / mlearn / mlearn / describers.py View on Github external
                               key=lambda sym: get_el_sp(sym).X)
        self.quadratic = quadratic
github hackingmaterials / robocrystallographer / robocrys / condense / site.py View on Github external
Returns:
            A :obj:`list` of indices mapping each site in the structure to a
            structurally equivalent site. For example, if the first two sites
            are equivalent and the last two are both inequivalent, the data will
            be formatted as::

                [0, 0, 2, 3]

        """
        # TODO: Use site fingerprint rather than geometry type.
        inequiv_sites = {}
        equivalent_sites = []

        for site_index, site in enumerate(self.bonded_structure.structure):
            element = get_el_sp(site.specie)
            geometry = self.get_site_geometry(site_index)
            nn_sites = self.get_nearest_neighbors(
                site_index, inc_inequivalent_site_index=False)
            nnn_sites = self.get_next_nearest_neighbors(
                site_index, inc_inequivalent_site_index=False)

            matched = False
            for inequiv_index, inequiv_site in inequiv_sites.items():
                elem_match = element == inequiv_site['element']
                geom_match = geometries_match(
                    geometry, inequiv_site['geometry'],
                    likeness_tol=likeness_tol)
                nn_match = nn_summaries_match(
                    nn_sites, inequiv_site['nn_sites'],
                    bond_dist_tol=bond_dist_tol)
                nnn_match = nnn_summaries_match(
github materialsproject / pymatgen / dev_scripts / update_pt_data.py View on Github external
order = sum([list(product(x, y)) for x, y in order], [])
    iupac_ordering_dict = dict(zip(
        [Element.from_row_and_group(row, group) for group, row in order],
        range(len(order))))

    # first clean periodic table of any IUPAC ordering
    for el in periodic_table:
        periodic_table[el].pop('IUPAC ordering', None)

    # now add iupac ordering
    for el in periodic_table:
        if 'IUPAC ordering' in periodic_table[el]:
            # sanity check that we don't cover the same element twice
            raise KeyError("IUPAC ordering already exists for {}".format(el))

        periodic_table[el]['IUPAC ordering'] = iupac_ordering_dict[get_el_sp(el)]
github hackingmaterials / robocrystallographer / robocrys / util.py View on Github external
def get_el(obj: Union[Element, Specie, str, int]) -> str:
    """Utility method to get an element str from a symbol, Element, or Specie.

    Args:
        obj: An arbitrary object. Spported objects are Element/Specie objects,
            integers (representing atomic numbers), or strings (element
            symbols or species strings).

    Returns:
        The element as a string.
    """
    if isinstance(obj, str):
        obj = get_el_sp(obj)

    if isinstance(obj, Element):
        return obj.name
    elif isinstance(obj, Specie):
        return obj.element.name
    elif isinstance(obj, int):
        return Element.from_Z(obj).name
    else:
        raise ValueError("Unsupported element type: {}.".format(type(obj)))
github hackingmaterials / robocrystallographer / robocrys / describe / adapter.py View on Github external
def _site_order(self, s: Union[SiteGroup,
                                   NeighborSiteDetails,
                                   NextNeighborSiteDetails]):
        """Utility function to help sort NeighborSiteDetails and SiteGroups."""
        specie = get_el_sp(s.element)
        x = specie.iupac_ordering if self.use_iupac_ordering else specie.X

        if isinstance(s, NeighborSiteDetails):
            return [x, s.count, s.sym_label, s.sites]
        elif isinstance(s, NextNeighborSiteDetails):
            return [s.connectivity, s.geometry, s.count, x, s.poly_formula,
                    s.sym_label, s.sites]
        else:
            return [x, s.count, s.sites]
github materialsproject / pymatgen / pymatgen / analysis / structure_prediction / substitution_probability.py View on Github external
def get_lambda(self, s1, s2):
        k = frozenset([get_el_sp(s1),
                       get_el_sp(s2)])
        return self._l.get(k, self.alpha)