当前位置: 首页>>代码示例>>Python>>正文


Python periodic_table.get_el_sp函数代码示例

本文整理汇总了Python中pymatgen.core.periodic_table.get_el_sp函数的典型用法代码示例。如果您正苦于以下问题:Python get_el_sp函数的具体用法?Python get_el_sp怎么用?Python get_el_sp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_el_sp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, atoms_n_occu, coords, properties=None):
        """
        Create a *non-periodic* site.

        Args:
            atoms_n_occu: Species on the site. Can be:

                i.  A sequence of element / specie specified either as string
                    symbols, e.g. ["Li", "Fe2+", "P", ...] or atomic numbers,
                    e.g., (3, 56, ...) or actual Element or Specie objects.
                ii. List of dict of elements/species and occupancies, e.g.,
                    [{"Fe" : 0.5, "Mn":0.5}, ...]. This allows the setup of
                    disordered structures.
            coords: Cartesian coordinates of site.
            properties: Properties associated with the site as a dict, e.g.
                {"magmom": 5}. Defaults to None.
        """
        if issubclass(atoms_n_occu.__class__, collections.Mapping):
            self._species = Composition({get_el_sp(k): v
                                         for k, v in atoms_n_occu.items()})
            totaloccu = self._species.num_atoms
            if totaloccu > 1 + Composition.amount_tolerance:
                raise ValueError("Species occupancies sum to more than 1!")
            self._is_ordered = (totaloccu == 1 and len(self._species) == 1)
        else:
            self._species = Composition(
                {get_el_sp(atoms_n_occu): 1})
            self._is_ordered = True

        self._coords = coords
        self._properties = properties if properties else {}
开发者ID:mathematicus,项目名称:pymatgen,代码行数:31,代码来源:sites.py

示例2: _get_c_ranges

 def _get_c_ranges(self, bonds):
     c_ranges = set()
     bonds = {(get_el_sp(s1), get_el_sp(s2)): dist for (s1, s2), dist in
              bonds.items()}
     for (sp1, sp2), bond_dist in bonds.items():
         for site in self.oriented_unit_cell:
             if sp1 in site.species_and_occu:
                 for nn, d in self.oriented_unit_cell.get_neighbors(
                         site, bond_dist):
                     if sp2 in nn.species_and_occu:
                         c_range = tuple(sorted([site.frac_coords[2],
                                                 nn.frac_coords[2]]))
                         if c_range[1] > 1:
                             # Takes care of PBC when c coordinate of site
                             # goes beyond the upper boundary of the cell
                             c_ranges.add((c_range[0], 1))
                             c_ranges.add((0, c_range[1] - 1))
                         elif c_range[0] < 0:
                             # Takes care of PBC when c coordinate of site
                             # is below the lower boundary of the unit cell
                             c_ranges.add((0, c_range[1]))
                             c_ranges.add((c_range[0] + 1, 1))
                         elif c_range[0] != c_range[1]:
                             c_ranges.add(c_range)
     return c_ranges
开发者ID:adozier,项目名称:pymatgen,代码行数:25,代码来源:surface.py

示例3: get_bond_length

def get_bond_length(sp1, sp2, bond_order=1):
    """
    Get the bond length between two species.

    Args:
        sp1 (Specie): First specie.
        sp2 (Specie): Second specie.
        bond_order: For species with different possible bond orders,
            this allows one to obtain the bond length for a particular bond
            order. For example, to get the C=C bond length instead of the
            C-C bond length, this should be set to 2. Defaults to 1.

    Returns:
        Bond length in Angstrom. If no data is available, the sum of the atomic
        radii is used.
    """
    sp1 = get_el_sp(sp1)
    sp2 = get_el_sp(sp2)
    syms = tuple(sorted([sp1.symbol, sp2.symbol]))
    if syms in bond_lengths:
        all_lengths = bond_lengths[syms]
        if bond_order:
            return all_lengths.get(bond_order)
        else:
            return all_lengths.get(1)
    warnings.warn("No bond lengths for %s-%s found in database. Returning sum"
                  "of atomic radius." % (sp1, sp2))
    return sp1.atomic_radius + sp2.atomic_radius
开发者ID:bocklund,项目名称:pymatgen,代码行数:28,代码来源:bonds.py

示例4: get_bond_length

def get_bond_length(sp1, sp2, bond_order=1):
    """
    Get the bond length between two species.

    Args:
        sp1 (Specie): First specie.
        sp2 (Specie): Second specie.
        bond_order: For species with different possible bond orders,
            this allows one to obtain the bond length for a particular bond
            order. For example, to get the C=C bond length instead of the
            C-C bond length, this should be set to 2. Defaults to 1.

    Returns:
        Bond length in Angstrom. None if no data is available.
    """

    syms = tuple(sorted([get_el_sp(sp1).symbol,
                         get_el_sp(sp2).symbol]))
    if syms in bond_lengths:
        all_lengths = bond_lengths[syms]
        if bond_order:
            return all_lengths.get(bond_order)
        else:
            return all_lengths.get(1)
    return None
开发者ID:ATNDiaye,项目名称:pymatgen,代码行数:25,代码来源:bonds.py

示例5: __init__

    def __init__(
        self,
        sp,
        num=None,
        bond_lengths=None,
        interior_only=False,
        midpoints=True,
        min_solid_angle=0,
        site_distance_tol=0.1,
    ):
        """
        Args:
            sp:
                specie to add
            num:
                number to add (will end up with a disordered structure)
            bond_lengths:
                dictionary of bond lengths. For example, if {'O' : 1} is
                used, all points will be scaled from their voronoi locations
                to be exactly 1 angstrom from the oxygen (if the oxygen is
                at the center of the voronoi region). In the case of a point
                neighboring 2 oxygen atoms, 2 points will be added - one for
                each oxygen
            interior_only:
                only uses voronoi points that are inside the tetrahedra
                formed by their 4 nearest neighbors. This is useful because
                when this is not true, there is another point accessible
                without going through a bottleneck that is strictly larger.
                Currently this doesn't work well with bond lengths because 
                finding the correct association between sites and voronoi 
                points is difficult. Doesn't affect the delaunay midpoints
            midpoints:
                whether to add the points at the center of the voronoi
                faces (midpoints of the delaunay triangulation)
            min_solid_angle:
                Threshold for creating points at the delaunay midpoints. The
                solid angle is a metric for how much two sites are neighbors of
                each other (the solid angle swept out by the voronoi face 
                corresponding to the two sites). Typical values are 0 to Pi, with
                Pi corresponding to a tetrahedrally coordinated site.
            site_distance_tol:
                Tolerance passed to to_unit_cell(). When there are multiple
                sites within this tolerance, only one is used
        """
        self._sp = get_el_sp(sp)
        self._n = num
        self._interior = interior_only
        self._midpoints = midpoints
        self._msa = min_solid_angle
        self._sdt = site_distance_tol

        # transform keys to species
        if bond_lengths:
            self._bl = dict(zip(map(lambda x: get_el_sp(x), bond_lengths.keys()), bond_lengths.values()))
        else:
            self._bl = {}
开发者ID:tchen0965,项目名称:structural_descriptors_repo,代码行数:56,代码来源:voronoi.py

示例6: apply_transformation

 def apply_transformation(self, structure):
     species_map = {}
     for k, v in self._species_map.items():
         if isinstance(v, dict):
             value = {get_el_sp(x): y for x, y in v.items()}
         else:
             value = get_el_sp(v)
         species_map[get_el_sp(k)] = value
     s = Structure.from_sites(structure.sites)
     s.replace_species(species_map)
     return s
开发者ID:ATNDiaye,项目名称:pymatgen,代码行数:11,代码来源:standard_transformations.py

示例7: reduce_formula

def reduce_formula(sym_amt, iupac_ordering=False):
    """
    Helper method to reduce a sym_amt dict to a reduced formula and factor.

    Args:
        sym_amt (dict): {symbol: amount}.
        iupac_ordering (bool, optional): Whether to order the
            formula by the iupac "electronegativity" series, defined in
            Table VI of "Nomenclature of Inorganic Chemistry (IUPAC
            Recommendations 2005)". This ordering effectively follows
            the groups and rows of the periodic table, except the
            Lanthanides, Actanides and hydrogen. Note that polyanions
            will still be determined based on the true electronegativity of
            the elements.

    Returns:
        (reduced_formula, factor).
    """
    syms = sorted(sym_amt.keys(), key=lambda x: [get_el_sp(x).X, x])

    syms = list(filter(
        lambda x: abs(sym_amt[x]) > Composition.amount_tolerance, syms))

    factor = 1
    # Enforce integers for doing gcd.
    if all((int(i) == i for i in sym_amt.values())):
        factor = abs(gcd(*(int(i) for i in sym_amt.values())))

    polyanion = []
    # if the composition contains a poly anion
    if len(syms) >= 3 and get_el_sp(syms[-1]).X - get_el_sp(syms[-2]).X < 1.65:
        poly_sym_amt = {syms[i]: sym_amt[syms[i]] / factor
                        for i in [-2, -1]}
        (poly_form, poly_factor) = reduce_formula(
            poly_sym_amt, iupac_ordering=iupac_ordering)

        if poly_factor != 1:
            polyanion.append("({}){}".format(poly_form, int(poly_factor)))

    syms = syms[:len(syms) - 2 if polyanion else len(syms)]

    if iupac_ordering:
        syms = sorted(syms,
                      key=lambda x: [get_el_sp(x).iupac_ordering, x])

    reduced_form = []
    for s in syms:
        normamt = sym_amt[s] * 1.0 / factor
        reduced_form.append(s)
        reduced_form.append(formula_double_format(normamt))

    reduced_form = "".join(reduced_form + polyanion)
    return reduced_form, factor
开发者ID:ExpHP,项目名称:pymatgen,代码行数:53,代码来源:composition.py

示例8: __getitem__

 def __getitem__(self, item):
     try:
         sp = get_el_sp(item)
         return self._data.get(sp, 0)
     except ValueError as ex:
         raise TypeError("Invalid key {}, {} for Composition\n"
                         "ValueError exception:\n{}".format(item, type(item), ex))
开发者ID:adozier,项目名称:pymatgen,代码行数:7,代码来源:composition.py

示例9: __contains__

 def __contains__(self, item):
     try:
         sp = get_el_sp(item)
         return sp in self._data
     except ValueError:
         raise TypeError("Invalid key {}, {} for Composition\n"
                         "ValueError exception:\n{}".format(item, type(item), ex))
开发者ID:adozier,项目名称:pymatgen,代码行数:7,代码来源:composition.py

示例10: get_conversion_factor

def get_conversion_factor(structure, species, temperature):
    """
    Conversion factor to convert between cm^2/s diffusivity measurements and
    mS/cm conductivity measurements based on number of atoms of diffusing
    species. Note that the charge is based on the oxidation state of the
    species (where available), or else the number of valence electrons
    (usually a good guess, esp for main group ions).

    Args:
        structure (Structure): Input structure.
        species (Element/Specie): Diffusing species.
        temperature (float): Temperature of the diffusion run in Kelvin.

    Returns:
        Conversion factor.
        Conductivity (in mS/cm) = Conversion Factor * Diffusivity (in cm^2/s)
    """
    df_sp = get_el_sp(species)
    if hasattr(df_sp, "oxi_state"):
        z = df_sp.oxi_state
    else:
        z = df_sp.full_electronic_structure[-1][2]

    n = structure.composition[species]

    vol = structure.volume * 1e-24  # units cm^3
    return 1000 * n / (vol * const.N_A) * z ** 2 * (const.N_A * const.e) ** 2 \
        / (const.R * temperature)
开发者ID:bocklund,项目名称:pymatgen,代码行数:28,代码来源:diffusion_analyzer.py

示例11: get_element_spd_dos

    def get_element_spd_dos(self, el):
        """
        Get element and spd projected Dos


        Args:
            el: Element in Structure.composition associated with LobsterCompleteDos

        Returns:
            dict of {Element: {"S": densities, "P": densities, "D": densities}}
        """
        el = get_el_sp(el)
        el_dos = {}
        for site, atom_dos in self.pdos.items():
            if site.specie == el:
                for orb, pdos in atom_dos.items():
                    orbital_type = _get_orb_type_lobster(orb)
                    if orbital_type not in el_dos:
                        el_dos[orbital_type] = pdos
                    else:
                        el_dos[orbital_type] = \
                            add_densities(el_dos[orbital_type], pdos)

        return {orb: Dos(self.efermi, self.energies, densities)
                for orb, densities in el_dos.items()}
开发者ID:materialsproject,项目名称:pymatgen,代码行数:25,代码来源:dos.py

示例12: __init__

    def __init__(self, atoms_n_occu, coords, properties=None):
        """
        Create a *non-periodic* site.

        Args:
            atoms_n_occu: Species on the site. Can be:
                i.  A Composition object (preferred)
                ii. An  element / specie specified either as a string
                    symbols, e.g. "Li", "Fe2+", "P" or atomic numbers,
                    e.g., 3, 56, or actual Element or Specie objects.
                iii.Dict of elements/species and occupancies, e.g.,
                    {"Fe" : 0.5, "Mn":0.5}. This allows the setup of
                    disordered structures.
            coords: Cartesian coordinates of site.
            properties: Properties associated with the site as a dict, e.g.
                {"magmom": 5}. Defaults to None.
        """
        if isinstance(atoms_n_occu, Composition):
            # Compositions are immutable, so don't need to copy (much faster)
            species = atoms_n_occu
        else:
            try:
                species = Composition({get_el_sp(atoms_n_occu): 1})
            except TypeError:
                species = Composition(atoms_n_occu)
        totaloccu = species.num_atoms
        if totaloccu > 1 + Composition.amount_tolerance:
            raise ValueError("Species occupancies sum to more than 1!")
        self._species = species
        self.coords = np.array(coords)
        self.properties = properties or {}
开发者ID:blondegeek,项目名称:pymatgen,代码行数:31,代码来源:sites.py

示例13: get_magnitude_of_effect_from_species

    def get_magnitude_of_effect_from_species(self, species, spin_state, motif):
        """
        Get magnitude of Jahn-Teller effect from provided species, spin state and motife.

        :param species: e.g. Fe2+
        :param spin_state (str): "high" or "low"
        :param motif (str): "oct" or "tet"

        :return (str):
        """

        magnitude = "none"

        sp = get_el_sp(species)

        # has to be Specie; we need to know the oxidation state
        if isinstance(sp, Specie) and sp.element.is_transition_metal:

            d_electrons = self._get_number_of_d_electrons(sp)

            if motif in self.spin_configs:
                if spin_state not in self.spin_configs[motif][d_electrons]:
                    spin_state = self.spin_configs[motif][d_electrons]['default']
                spin_config = self.spin_configs[motif][d_electrons][spin_state]
                magnitude = JahnTellerAnalyzer.get_magnitude_of_effect_from_spin_config(motif,
                                                                                        spin_config)
        else:
            warnings.warn("No data for this species.")

        return magnitude
开发者ID:navnidhirajput,项目名称:pymatgen,代码行数:30,代码来源:jahnteller.py

示例14: __init__

    def __init__(self, *args, **kwargs):
        """
        Very flexible Composition construction, similar to the built-in Python
        dict(). Also extended to allow simple string init.

        Args:
            Any form supported by the Python built-in dict() function.

            1. A dict of either {Element/Specie: amount},

               {string symbol:amount}, or {atomic number:amount} or any mixture
               of these. E.g., {Element("Li"):2 ,Element("O"):1},
               {"Li":2, "O":1}, {3:2, 8:1} all result in a Li2O composition.
            2. Keyword arg initialization, similar to a dict, e.g.,

               Compostion(Li = 2, O = 1)

            In addition, the Composition constructor also allows a single
            string as an input formula. E.g., Composition("Li2O").
        """
        if len(args) == 1 and isinstance(args[0], basestring):
            elmap = self._parse_formula(args[0])
        else:
            elmap = dict(*args, **kwargs)
        for k, v in elmap.items():
            if v < -Composition.amount_tolerance:
                raise CompositionError("Amounts in Composition cannot be "
                                       "negative!")
            elif v < 0:
                del elmap[k]
        self._elmap = {get_el_sp(k): v for k, v in elmap.items()}
        self._natoms = sum(self._elmap.values())
开发者ID:zacharygibbs,项目名称:pymatgen,代码行数:32,代码来源:composition.py

示例15: __init__

    def __init__(self, entries, chempots, elements=None):
        """
        Standard constructor for grand potential phase diagram.

        Args:
            entries ([PDEntry]): A list of PDEntry-like objects having an
                energy, energy_per_atom and composition.
            chempots {Element: float}: Specify the chemical potentials
                of the open elements.
            elements ([Element]): Optional list of elements in the phase
                diagram. If set to None, the elements are determined from
                the the entries themselves.
        """
        if elements is None:
            elements = set()
            map(elements.update, [entry.composition.elements
                                  for entry in entries])
        self.chempots = {get_el_sp(el): u for el, u in chempots.items()}
        elements = set(elements).difference(self.chempots.keys())
        all_entries = [GrandPotPDEntry(e, self.chempots)
                       for e in entries
                       if (not e.is_element) or
                       e.composition.elements[0] in elements]

        super(GrandPotentialPhaseDiagram, self).__init__(all_entries, elements)
开发者ID:artemcpp,项目名称:pymatgen,代码行数:25,代码来源:pdmaker.py


注:本文中的pymatgen.core.periodic_table.get_el_sp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。