pymatgen.analysis.structure_analyzer module

class OxideType(structure, relative_cutoff=1.1)[source]

Bases: object

Separate class for determining oxide type.

  • structure – Input structure.
  • relative_cutoff – Relative_cutoff * act. cutoff stipulates the max. distance two O atoms must be from each other. Default value is 1.1. At most 1.1 is recommended, nothing larger, otherwise the script cannot distinguish between superoxides and peroxides.

Determines if an oxide is a peroxide/superoxide/ozonide/normal oxide.

Returns:Type of oxide ozonide/peroxide/superoxide/hydroxide/None. nbonds (int): Number of peroxide/superoxide/hydroxide bonds in structure.
Return type:oxide_type (str)
class RelaxationAnalyzer(initial_structure, final_structure)[source]

Bases: object

This class analyzes the relaxation in a calculation.

Please note that the input and final structures should have the same ordering of sites. This is typically the case for most computational codes.

  • initial_structure (Structure) – Initial input structure to calculation.
  • final_structure (Structure) – Final output structure from calculation.

Returns the percentage bond distance changes for each site up to a maximum radius for nearest neighbors.

Parameters:max_radius (float) – Maximum radius to search for nearest neighbors. This radius is applied to the initial structure, not the final structure.
Returns:Bond distance changes as a dict of dicts. E.g., {index1: {index2: 0.011, …}}. For economy of representation, the index1 is always less than index2, i.e., since bonding between site1 and siten is the same as bonding between siten and site1, there is no reason to duplicate the information or computation.

Returns the percentage lattice parameter changes.

Returns:A dict of the percentage change in lattice parameter, e.g., {‘a’: 0.012, ‘b’: 0.021, ‘c’: -0.031} implies a change of 1.2%, 2.1% and -3.1% in the a, b and c lattice parameters respectively.

Returns the percentage volume change.

Returns:Volume change in percentage, e.g., 0.055 implies a 5.5% increase.
class VoronoiAnalyzer(cutoff=5.0, qhull_options='Qbb Qc Qz')[source]

Bases: object

Performs a statistical analysis of Voronoi polyhedra around each site. Each Voronoi polyhedron is described using Schaefli notation. That is a set of indices {c_i} where c_i is the number of faces with i number of vertices. E.g. for a bcc crystal, there is only one polyhedron notation of which is [0,6,0,8,0,0,…]. In perfect crystals, these also corresponds to the Wigner-Seitz cells. For distorted-crystals, liquids or amorphous structures, rather than one-type, there is a statistical distribution of polyhedra. See ref: Microstructure and its relaxation in Fe-B amorphous system simulated by molecular dynamics,

Stepanyuk et al., J. Non-cryst. Solids (1993), 159, 80-87.
  • cutoff (float) – cutoff distance to search for neighbors of a given atom (default = 5.0)
  • qhull_options (str) – options to pass to qhull (optional)
analyze(structure, n=0)[source]

Performs Voronoi analysis and returns the polyhedra around atom n in Schlaefli notation.

  • structure (Structure) – structure to analyze
  • n (int) – index of the center atom in structure


where c_i denotes number of facets with i vertices.

Return type:

voronoi index of n

analyze_structures(structures, step_freq=10, most_frequent_polyhedra=15)[source]

Perform Voronoi analysis on a list of Structures. Note that this might take a significant amount of time depending on the size and number of structures.

  • structures (list) – list of Structures
  • (float (cutoff) – cutoff distance around an atom to search for neighbors
  • step_freq (int) – perform analysis every step_freq steps
  • qhull_options (str) – options to pass to qhull
  • most_frequent_polyhedra (int) – this many unique polyhedra with highest frequences is stored.

A list of tuples in the form (voronoi_index,frequency)

static plot_vor_analysis()[source]
class VoronoiConnectivity(structure, cutoff=10)[source]

Bases: object

Computes the solid angles swept out by the shared face of the voronoi polyhedron between two sites.

  • structure (Structure) – Input structure
  • cutoff (float) –

Provides connectivity array.

Returns:An array of shape [atomi, atomj, imagej]. atomi is the index of the atom in the input structure. Since the second atom can be outside of the unit cell, it must be described by both an atom index and an image index. Array data is the solid angle of polygon between atomi and imagej of atomj
Return type:connectivity

Returns a list of site pairs that are Voronoi Neighbors, along with their real-space distances.

get_sitej(site_index, image_index)[source]

Assuming there is some value in the connectivity array at indices (1, 3, 12). sitei can be obtained directly from the input structure (structure[1]). sitej can be obtained by passing 3, 12 to this function

  • site_index (int) – index of the site (3 in the example)
  • image_index (int) – index of the image (12 in the example)

returns the 2d array [sitei, sitej] that represents the maximum connectivity of site i to any periodic image of site j

average_coordination_number(structures, freq=10)[source]

Calculates the ensemble averaged Voronoi coordination numbers of a list of Structures using VoronoiNN. Typically used for analyzing the output of a Molecular Dynamics run. :param structures: list of Structures. :type structures: list :param freq: sampling frequency of coordination number [every freq steps]. :type freq: int

Returns:Dictionary of elements as keys and average coordination numbers as values.
contains_peroxide(structure, relative_cutoff=1.1)[source]

Determines if a structure contains peroxide anions.

  • structure (Structure) – Input structure.
  • relative_cutoff – The peroxide bond distance is 1.49 Angstrom. Relative_cutoff * 1.49 stipulates the maximum distance two O atoms must be to each other to be considered a peroxide.

Boolean indicating if structure contains a peroxide anion.

get_dimensionality(structure, max_hkl=2, el_radius_updates=None, min_slab_size=5, min_vacuum_size=5, standardize=True, bonds=None)[source]

This method returns whether a structure is 3D, 2D (layered), or 1D (linear chains or molecules) according to the algorithm published in Gorai, P., Toberer, E. & Stevanovic, V. Computational Identification of Promising Thermoelectric Materials Among Known Quasi-2D Binary Compounds. J. Mater. Chem. A 2, 4136 (2016).

Note that a 1D structure detection might indicate problems in the bonding algorithm, particularly for ionic crystals (e.g., NaCl)

Users can change the behavior of bonds detection by passing either el_radius_updates to update atomic radii for auto-detection of max bond distances, or bonds to explicitly specify max bond distances for atom pairs. Note that if you pass both, el_radius_updates are ignored.

  • structure – (Structure) structure to analyze dimensionality for
  • max_hkl – (int) max index of planes to look for layers
  • el_radius_updates – (dict) symbol->float to update atomic radii
  • min_slab_size – (float) internal surface construction parameter
  • min_vacuum_size – (float) internal surface construction parameter
  • standardize (bool) – whether to standardize the structure before analysis. Set to False only if you already have the structure in a convention where layers / chains will be along low <hkl> indexes.
  • bonds ({(specie1, specie2) – max_bond_dist}: bonds are specified as a dict of tuples: float of specie1, specie2 and the max bonding distance. For example, PO4 groups may be defined as {(“P”, “O”): 3}.
Returns: (int) the dimensionality of the structure - 1 (molecules/chains),
2 (layered), or 3 (3D)
get_max_bond_lengths(structure, el_radius_updates=None)[source]

Provides max bond length estimates for a structure based on the JMol table and algorithms.

  • structure – (structure)
  • el_radius_updates – (dict) symbol->float to update atomic radii
Returns: (dict) - (Element1, Element2) -> float. The two elements are
ordered by Z.
oxide_type(structure, relative_cutoff=1.1, return_nbonds=False)[source]

Determines if an oxide is a peroxide/superoxide/ozonide/normal oxide

  • structure (Structure) – Input structure.
  • relative_cutoff (float) – Relative_cutoff * act. cutoff stipulates the max distance two O atoms must be from each other.
  • return_nbonds (bool) – Should number of bonds be requested?
solid_angle(center, coords)[source]

Helper method to calculate the solid angle of a set of coords from the center.

  • center (3x1 array) – Center to measure solid angle from.
  • coords (Nx3 array) – List of coords to determine solid angle.

The solid angle.


Determines if a structure is a sulfide/polysulfide

Parameters:structure (Structure) – Input structure.
Returns:(str) sulfide/polysulfide/sulfate