pymatgen.analysis.structure_analyzer module

This module provides classes to perform topological analyses of structures.

class OxideType(structure: 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.

parse_oxide() tuple[str, int][source]

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


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.


max_radius (float) – Maximum radius to search for nearest neighbors. This radius is applied to the initial structure, not the final structure.


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.


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.


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: 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 frequencies is stored.


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

static plot_vor_analysis(voronoi_ensemble)[source]

Plot the Voronoi analysis.





class VoronoiConnectivity(structure: 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) –

property connectivity_array[source]

Provides connectivity array.


An array of shape [atom_i, atom_j, image_j]. atom_i 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 atom_i and image_j of atom_j

Return type:



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)

property max_connectivity[source]

Returns the 2d array [site_i, site_j] 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.

  • structures (list) – list of Structures.

  • freq (int) – sampling frequency of coordination number [every freq steps].


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_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 atom_ic radii

Returns: (dict) - (Element1, Element2) -> float. The two elements are

ordered by Z.

oxide_type(structure: Structure, relative_cutoff: float = 1.1, return_nbonds: bool = False) str | tuple[str, int][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/sulfate


structure (Structure) – Input structure.


(str) sulfide/polysulfide or None if structure is a sulfate.