pymatgen.analysis.local_env module¶

class
JMolNN
(tol=0.001, el_radius_updates=None)[source]¶ Bases:
pymatgen.analysis.local_env.NearNeighbors
Determine nearneighbor sites and coordination number using an emulation of JMol’s default autoBond() algorithm. This version of the algorithm does not take into account any information regarding known charge states.
Parameters:  tol (float) – tolerance parameter for bond determination (default: 1E3).
 el_radius_updates – (dict) symbol>float to override default atomic radii table values

get_max_bond_distance
(el1_sym, el2_sym, constant=0.56)[source]¶ Use JMol algorithm to determine bond length from atomic parameters :param el1_sym: (str) symbol of atom 1 :param el2_sym: (str) symbol of atom 2 :param constant: (float) factor to tune model
Returns: (float) max bond length

get_nn_info
(structure, n)[source]¶ Get all nearneighbor sites as well as the associated image locations and weights of the site with index n using the bond identification algorithm underlying JMol.
Parameters:  structure (Structure) – input structure.
 n (integer) – index of site for which to determine near neighbors.
Returns:  tuples, each one
of which represents a neighbor site, its image location, and its weight.
Return type: siw (list of tuples (Site, array, float))

class
LocalStructOrderParas
(types, parameters=None, cutoff=10.0)[source]¶ Bases:
object
This class permits the calculation of various types of local structure order parameters.
Parameters:  types ([string]) –
list of strings representing the types of order parameters to be calculated. Note that multiple mentions of the same type may occur. Currently available types recognize following environments:
 ”cn”: simple coordination number—normalized
 if desired;
”sgl_bd”: single bonds; “bent”: bent (angular) coordinations
(Zimmermann & Jain, in progress, 2017);”T”: Tshape coordinations; “see_saw_rect”: see sawlike coordinations; “tet”: tetrahedra
(Zimmermann et al., submitted, 2017); ”oct”: octahedra
 (Zimmermann et al., submitted, 2017);
 ”bcc”: bodycentered cubic environments (Peters,
 Chem. Phys., 131, 244103, 2009);
”tri_plan”: trigonal planar environments; “sq_plan”: square planar environments; “pent_plan”: pentagonal planar environments; “tri_pyr”: trigonal pyramids (coordinated atom is in
the center of the basal plane);”sq_pyr”: square pyramids; “pent_pyr”: pentagonal pyramids; “hex_pyr”: hexagonal pyramids; “tri_bipyr”: trigonal bipyramids; “sq_bipyr”: square bipyramids; “pent_bipyr”: pentagonal bipyramids; “hex_bipyr”: hexagonal bipyramids; “cuboct”: cuboctahedra; “q2”: motifunspecific bond orientational order
parameter (BOOP) of weight l=2 (Steinhardt et al., Phys. Rev. B, 28, 784805, 1983);”q4”: BOOP of weight l=4; “q6”: BOOP of weight l=6. “reg_tri”: regular triangle with varying height
to basal plane;”sq”: square coordination (cf., “reg_tri”); “oct_legacy”: original Petersstyle OP recognizing
octahedral coordination environments (Zimmermann et al., J. Am. Chem. Soc., 137, 1335213361, 2015) that can, however, produce small negative values sometimes.”sq_pyr_legacy”: square pyramids (legacy);
 parameters ([dict]) –
list of dictionaries that store floattype parameters associated with the definitions of the different order parameters (length of list = number of OPs). If an entry is None, default values are used that are read from the op_paras.yaml file. With few exceptions, 9 different parameters are used across all OPs:
 ”norm”: normalizing constant (used in “cn”
 (default value: 1)).
 ”TA”: target angle (TA) in fraction of 180 degrees
 (“bent” (1), “tet” (0.6081734479693927), “tri_plan” (0.66666666667), “pent_plan” (0.6), “sq_pyr_legacy” (0.5)).
 ”IGW_TA”: inverse Gaussian width (IGW) for penalizing
 angles away from the target angle in inverse fractions of 180 degrees to (“bent” and “tet” (15), “tri_plan” (13.5), “pent_plan” (18), “sq_pyr_legacy” (30)).
 ”IGW_EP”: IGW for penalizing angles away from the
 equatorial plane (EP) at 90 degrees (“T”, “see_saw_rect”, “oct”, “sq_plan”, “tri_pyr”, “sq_pyr”, “pent_pyr”, “hex_pyr”, “tri_bipyr”, “sq_bipyr”, “pent_bipyr”, “hex_bipyr”, and “oct_legacy” (18)).
 ”fac_AA”: factor applied to azimuth angle (AA) in cosine
 term (“T”, “tri_plan”, and “sq_plan” (1), “tet”, “tri_pyr”, and “tri_bipyr” (1.5), “oct”, “sq_pyr”, “sq_bipyr”, and “oct_legacy” (2), “pent_pyr” and “pent_bipyr” (2.5), “hex_pyr” and “hex_bipyr” (3)).
 ”exp_cos_AA”: exponent applied to cosine term of AA
 (“T”, “tet”, “oct”, “tri_plan”, “sq_plan”, “tri_pyr”, “sq_pyr”, “pent_pyr”, “hex_pyr”, “tri_bipyr”, “sq_bipyr”, “pent_bipyr”, “hex_bipyr”, and “oct_legacy” (2)).
 ”min_SPP”: smallest angle (in radians) to consider
 a neighbor to be at South pole position (“see_saw_rect”, “oct”, “bcc”, “sq_plan”, “tri_bipyr”, “sq_bipyr”, “pent_bipyr”, “hex_bipyr”, “cuboct”, and “oct_legacy” (2.792526803190927)).
 ”IGW_SPP”: IGW for penalizing angles away from South
 pole position (“see_saw_rect”, “oct”, “bcc”, “sq_plan”, “tri_bipyr”, “sq_bipyr”, “pent_bipyr”, “hex_bipyr”, “cuboct”, and “oct_legacy” (15)).
 ”w_SPP”: weight for South pole position relative to
 equatorial positions (“see_saw_rect” and “sq_plan” (1), “cuboct” (1.8), “tri_bipyr” (2), “oct”, “sq_bipyr”, and “oct_legacy” (3), “pent_bipyr” (4), “hex_bipyr” (5), “bcc” (6)).
 cutoff (float) – Cutoff radius to determine which nearest neighbors are supposed to contribute to the order parameters. If the value is negative the neighboring sites found by distance and cutoff radius are further pruned using the get_nn method from the VoronoiNN class.

compute_trigonometric_terms
(thetas, phis)[source]¶ ” Computes trigonometric terms that are required to calculate bond orientational order parameters using internal variables.
Parameters:  thetas ([float]) – polar angles of all neighbors in radians.
 phis ([float]) – azimuth angles of all neighbors in radians. The list of azimuth angles of all neighbors in radians. The list of azimuth angles is expected to have the same size as the list of polar angles; otherwise, a ValueError is raised. Also, the two lists of angles have to be coherent in order. That is, it is expected that the order in the list of azimuth angles corresponds to a distinct sequence of neighbors. And, this sequence has to equal the sequence of neighbors in the list of polar angles.

get_order_parameters
(structure, n, indices_neighs=None, tol=0.0, target_spec=None)[source]¶ Compute all order parameters of site n.
Parameters:  structure (Structure) – input structure.
 n (int) – index of site in input structure, for which OPs are to be calculated. Note that we do not use the sites iterator here, but directly access sites via struct[index].
 indices_neighs ([int]) – list of indices of those neighbors in Structure object structure that are to be considered for OP computation. This optional argument overwrites the way neighbors are to be determined as defined in the constructor (i.e., Voronoi coordination finder via negative cutoff radius vs constant cutoff radius if cutoff was positive). We do not use information about the underlying structure lattice if the neighbor indices are explicitly provided. This has two important consequences. First, the input Structure object can, in fact, be a simple list of Site objects. Second, no nearest images of neighbors are determined when providing an index list. Note furthermore that this neighbor determination type ignores the optional target_spec argument.
 tol (float) – threshold of weight (= solid angle / maximal solid angle) to determine if a particular pair is considered neighbors; this is relevant only in the case when Voronoi polyhedra are used to determine coordination
 target_spec (Specie) – target species to be considered when calculating the order parameters of site n; None includes all species of input structure.
Returns: representing order parameters. Should it not be possible to compute a given OP for a conceptual reason, the corresponding entry is None instead of a float. For Steinhardt et al.’s bond orientational OPs and the other geometric OPs (“tet”, “oct”, “bcc”, etc.), this can happen if there is a single neighbor around site n in the structure because that does not permit calculation of angles between multiple neighbors.
Return type: [floats]

get_parameters
(index)[source]¶ Returns list of floats that represents the parameters associated with calculation of the order parameter that was defined at the index provided. Attention: the parameters do not need to equal those originally inputted because of processing out of efficiency reasons.
Parameters: index (int) – index of order parameter for which associated parameters are to be returned. Returns: parameters of a given OP. Return type: [float]

get_q2
(thetas=None, phis=None)[source]¶ Calculates the value of the bond orientational order parameter of weight l=2. If the function is called with nonempty lists of polar and azimuthal angles the corresponding trigonometric terms are computed afresh. Otherwise, it is expected that the compute_trigonometric_terms function has been just called.
Parameters:  thetas ([float]) – polar angles of all neighbors in radians.
 phis ([float]) – azimuth angles of all neighbors in radians.
Returns:  bond orientational order parameter of weight l=2
corresponding to the input angles thetas and phis.
Return type: float

get_q4
(thetas=None, phis=None)[source]¶ Calculates the value of the bond orientational order parameter of weight l=4. If the function is called with nonempty lists of polar and azimuthal angles the corresponding trigonometric terms are computed afresh. Otherwise, it is expected that the compute_trigonometric_terms function has been just called.
Parameters:  thetas ([float]) – polar angles of all neighbors in radians.
 phis ([float]) – azimuth angles of all neighbors in radians.
Returns:  bond orientational order parameter of weight l=4
corresponding to the input angles thetas and phis.
Return type: float

get_q6
(thetas=None, phis=None)[source]¶ Calculates the value of the bond orientational order parameter of weight l=6. If the function is called with nonempty lists of polar and azimuthal angles the corresponding trigonometric terms are computed afresh. Otherwise, it is expected that the compute_trigonometric_terms function has been just called.
Parameters:  thetas ([float]) – polar angles of all neighbors in radians.
 phis ([float]) – azimuth angles of all neighbors in radians.
Returns:  bond orientational order parameter of weight l=6
corresponding to the input angles thetas and phis.
Return type: float

get_type
(index)[source]¶ Return type of order parameter at the index provided and represented by a short string.
Parameters: index (int) – index of order parameter for which type is to be returned. Returns: OP type. Return type: str

last_nneigh
¶ ” :returns:
 the number of neighbors encountered during the most
 recent order parameter calculation. A value of 1 indicates that no such calculation has yet been performed for this instance.
Return type: int

num_ops
¶ ” :returns:
 the number of different order parameters that are targeted
 to be calculated.
Return type: int
 types ([string]) –

class
MinimumDistanceNN
(tol=0.1, cutoff=10.0)[source]¶ Bases:
pymatgen.analysis.local_env.NearNeighbors
Determine nearneighbor sites and coordination number using the nearest neighbor(s) at distance, d_min, plus all neighbors within a distance (1 + delta) * d_min, where delta is a (relative) distance tolerance parameter.
Parameters:  tol (float) – tolerance parameter for neighbor identification (default: 0.1).
 cutoff (float) – cutoff radius in Angstrom to look for trial nearneighbor sites (default: 10.0).

get_nn_info
(structure, n)[source]¶ Get all nearneighbor sites as well as the associated image locations and weights of the site with index n using the closest neighbor distancebased method.
Parameters:  structure (Structure) – input structure.
 n (integer) – index of site for which to determine near neighbors.
Returns:  tuples, each one
of which represents a neighbor site, its image location, and its weight.
Return type: siw (list of tuples (Site, array, float))

class
MinimumOKeeffeNN
(tol=0.1, cutoff=10.0)[source]¶ Bases:
pymatgen.analysis.local_env.NearNeighbors
Determine nearneighbor sites and coordination number using the neighbor(s) at closest relative distance, d_min_OKeffee, plus some relative tolerance, where bond valence parameters from O’Keeffe’s bond valence method (J. Am. Chem. Soc. 1991, 32263229) are used to calculate relative distances.
Parameters:  tol (float) – tolerance parameter for neighbor identification (default: 0.1).
 cutoff (float) – cutoff radius in Angstrom to look for trial nearneighbor sites (default: 10.0).

get_nn_info
(structure, n)[source]¶ Get all nearneighbor sites as well as the associated image locations and weights of the site with index n using the closest relative neighbor distancebased method with O’Keeffe parameters.
Parameters:  structure (Structure) – input structure.
 n (integer) – index of site for which to determine near neighbors.
Returns:  tuples, each one
of which represents a neighbor site, its image location, and its weight.
Return type: siw (list of tuples (Site, array, float))

class
MinimumVIRENN
(tol=0.1, cutoff=10.0)[source]¶ Bases:
pymatgen.analysis.local_env.NearNeighbors
Determine nearneighbor sites and coordination number using the neighbor(s) at closest relative distance, d_min_VIRE, plus some relative tolerance, where atom radii from the ValenceIonicRadiusEvaluator (VIRE) are used to calculate relative distances.
Parameters:  tol (float) – tolerance parameter for neighbor identification (default: 0.1).
 cutoff (float) – cutoff radius in Angstrom to look for trial nearneighbor sites (default: 10.0).

get_nn_info
(structure, n)[source]¶ Get all nearneighbor sites as well as the associated image locations and weights of the site with index n using the closest relative neighbor distancebased method with VIRE atomic/ionic radii.
Parameters:  structure (Structure) – input structure.
 n (integer) – index of site for which to determine near neighbors.
Returns:  tuples, each one
of which represents a neighbor site, its image location, and its weight.
Return type: siw (list of tuples (Site, array, float))

class
NearNeighbors
[source]¶ Bases:
object
Base class to determine near neighbors that typically include nearest neighbors and others that are within some tolerable distance.

get_cn
(structure, n, use_weights=False)[source]¶ Get coordination number, CN, of site with index n in structure.
Parameters:  structure (Structure) – input structure.
 n (integer) – index of site for which to determine CN.
 use_weights (boolean) – flag indicating whether (True) to use weights for computing the coordination number or not (False, default: each coordinated site has equal weight).
Returns: coordination number.
Return type: cn (integer or float)

get_nn
(structure, n)[source]¶ Get near neighbors of site with index n in structure.
Parameters:  structure (Structure) – input structure.
 n (integer) – index of site in structure for which to determine neighbors.
Returns: near neighbors.
Return type: sites (list of Site objects)

get_nn_images
(structure, n)[source]¶ Get image location of all near neighbors of site with index n in structure.
Parameters:  structure (Structure) – input structure.
 n (integer) – index of site for which to determine the image location of near neighbors.
Returns:  image locations of
near neighbors.
Return type: images (list of 3D integer array)

get_nn_info
(structure, n)[source]¶ Get all nearneighbor sites as well as the associated image locations and weights of the site with index n.
Parameters:  structure (Structure) – input structure.
 n (integer) – index of site for which to determine nearneighbor information.
Returns:  each dictionary provides information
about a single near neighbor, where key ‘site’ gives access to the corresponding Site object, ‘image’ gives the image location, and ‘weight’ provides the weight that a given nearneighbor site contributes to the coordination number (1 or smaller), ‘site_index’ gives index of the corresponding site in the original structure.
Return type: siw (list of dicts)

get_weights_of_nn_sites
(structure, n)[source]¶ Get weight associated with each near neighbor of site with index n in structure.
Parameters:  structure (Structure) – input structure.
 n (integer) – index of site for which to determine the weights.
Returns: nearneighbor weights.
Return type: weights (list of floats)


class
ValenceIonicRadiusEvaluator
(structure)[source]¶ Bases:
object
Computes site valences and ionic radii for a structure using bond valence analyzer
Parameters: structure – pymatgen.core.structure.Structure 
radii
¶ List of ionic radii of elements in the order of sites.

structure
¶ Returns oxidation state decorated structure.

valences
¶ List of oxidation states of elements in the order of sites.


class
VoronoiNN
(tol=0, targets=None, cutoff=10.0, allow_pathological=False)[source]¶ Bases:
pymatgen.analysis.local_env.NearNeighbors
Uses a Voronoi algorithm to determine near neighbors for each site in a structure.
Parameters:  tol (float) – tolerance parameter for nearneighbor finding (default: 0).
 targets (Element or list of Elements) – target element(s).
 cutoff (float) – cutoff radius in Angstrom to look for nearneighbor atoms. Defaults to 10.0.
 allow_pathological (bool) – whether to allow infinite vertices in determination of Voronoi coordination.

get_nn_info
(structure, n)[source]¶ ” Get all nearneighbor sites as well as the associated image locations and weights of the site with index n in structure using Voronoi decomposition.
Parameters:  structure (Structure) – input structure.
 n (integer) – index of site for which to determine nearneighbor sites.
Returns:  tuples, each one
of which represents a coordinated site, its image location, and its weight.
Return type: siw (list of tuples (Site, array, float))

get_voronoi_polyhedra
(structure, n)[source]¶ Gives a weighted polyhedra around a site. This uses the Voronoi construction with solid angle weights. See ref: A Proposed Rigorous Definition of Coordination Number, M. O’Keeffe, Acta Cryst. (1979). A35, 772775
Parameters:  structure (Structure) – structure for which to evaluate the coordination environment.
 n (integer) – site index.
Returns: A dict of sites sharing a common Voronoi facet with the site n and their solid angle weights

get_neighbors_of_site_with_index
(struct, n, approach='min_dist', delta=0.1, cutoff=10.0)[source]¶ Returns the neighbors of a given site using a specific neighborfinding method.
Parameters:  struct (Structure) – input structure.
 n (int) – index of site in Structure object for which motif type is to be determined.
 approach (str) – type of neighborfinding approach, where “min_dist” will use the MinimumDistanceNN class, “voronoi” the VoronoiNN class, “min_OKeeffe” the MinimumOKeeffe class, and “min_VIRE” the MinimumVIRENN class.
 delta (float) – tolerance involved in neighbor finding.
 cutoff (float) – (large) radius to find tentative neighbors.
Returns: neighbor sites.

get_okeeffe_distance_prediction
(el1, el2)[source]¶ Returns an estimate of the bond valence parameter (bond length) using the derived parameters from ‘Atoms Sizes and Bond Lengths in Molecules and Crystals’ (O’Keeffe & Brese, 1991). The estimate is based on two experimental parameters: r and c. The value for r is based off radius, while c is (usually) the AllredRochow electronegativity. Values used are not generated from pymatgen, and are found in ‘okeeffe_params.json’.
Parameters: el2 (el1,) – two Element objects Returns: a float value of the predicted bond length

get_okeeffe_params
(el_symbol)[source]¶ Returns the elemental parameters related to atom size and electronegativity which are used for estimating bondvalence parameters (bond length) of pairs of atoms on the basis of data provided in ‘Atoms Sizes and Bond Lengths in Molecules and Crystals’ (O’Keeffe & Brese, 1991).
Parameters: el_symbol (str) – element symbol. Returns:  atomsize (‘r’) and electronegativityrelated (‘c’)
 parameter.
Return type: (dict)

gramschmidt
(vin, uin)[source]¶ Returns that part of the first input vector that is orthogonal to the second input vector. The output vector is not normalized.
Parameters:  vin (numpy array) – first input vector
 uin (numpy array) – second input vector

site_is_of_motif_type
(struct, n, approach='min_dist', delta=0.1, cutoff=10.0, thresh=None)[source]¶ Returns the motif type of the site with index n in structure struct; currently featuring “tetrahedral”, “octahedral”, “bcc”, and “cp” (closepacked: fcc and hcp) as well as “square pyramidal” and “trigonal bipyramidal”. If the site is not recognized, “unrecognized” is returned. If a site should be assigned to two different motifs, “multiple assignments” is returned.
Parameters:  struct (Structure) – input structure.
 n (int) – index of site in Structure object for which motif type is to be determined.
 approach (str) – type of neighborfinding approach, where “min_dist” will use the MinimumDistanceNN class, “voronoi” the VoronoiNN class, “min_OKeeffe” the MinimumOKeeffe class, and “min_VIRE” the MinimumVIRENN class.
 delta (float) – tolerance involved in neighbor finding.
 cutoff (float) – (large) radius to find tentative neighbors.
 thresh (dict) – thresholds for motif criteria (currently, required keys and their default values are “qtet”: 0.5, “qoct”: 0.5, “qbcc”: 0.5, “q6”: 0.4).
Returns: motif type (str).