This package is an overarching package for modules performing various analyses of materials data.
This module implements classes to perform bond valence analyses.
Bases: object
This class implements a maximum a posteriori (MAP) estimation method to determine oxidation states in a structure. The algorithm is as follows: 1) The bond valence sum of all symmetrically distinct sites in a structure is calculated using the element-based parameters in M. O’Keefe, & N. Brese, JACS, 1991, 113(9), 3226-3229. doi:10.1021/ja00009a002. 2) The posterior probabilities of all oxidation states is then calculated using: P(oxi_state/BV) = K * P(BV/oxi_state) * P(oxi_state), where K is a constant factor for each element. P(BV/oxi_state) is calculated as a Gaussian with mean and std deviation determined from an analysis of the ICSD. The posterior P(oxi_state) is determined from a frequency analysis of the ICSD. 3) The oxidation states are then ranked in order of decreasing probability and the oxidation state combination that result in a charge neutral cell is selected.
Get an oxidation state decorated structure. This currently works only for ordered structures only.
Returns a list of valences for the structure. This currently works only for ordered structures only.
Calculates the BV sum of a site.
A module to perform diffusion analyses (e.g. calculating diffusivity from mean square displacements etc.). If you use this module, please consider citing the following papers:
Ong, S. P., Mo, Y., Richards, W. D., Miara, L., Lee, H. S., & Ceder, G.
(2013). Phase stability, electrochemical stability and ionic conductivity
of the Li10+-1MP2X12 (M = Ge, Si, Sn, Al or P, and X = O, S or Se) family
of superionic conductors. Energy & Environmental Science, 6(1), 148.
doi:10.1039/c2ee23355j
Mo, Y., Ong, S. P., & Ceder, G. (2012). First Principles Study of the
Li10GeP2S12 Lithium Super Ionic Conductor Material. Chemistry of Materials,
24(1), 15-17. doi:10.1021/cm203303y
Bases: pymatgen.serializers.json_coders.MSONable
Class for performing diffusion analysis.
This constructor is meant to be used with pre-processed data. Other convenient constructors are provided as class methods (see from_vaspruns and from_files).
Given a matrix of displacements (see arguments below for expected format), the diffusivity is given by:
D = 1 / 2dt * <mean square displacement>
where d is the dimensionality, t is the time. To obtain a reliable diffusion estimate, a least squares regression of the MSD against time to obtain the slope, which is then related to the diffusivity.
Convenient constructor that takes in a list of vasprun.xml paths to perform diffusion analysis.
Convenient constructor that takes in a list of Vasprun objects to perform diffusion analysis.
Plot the smoothed msd vs time graph. Useful for checking convergence.
Returns an Arrhenius plot.
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).
This module provides classes for calculating the ewald sum of a structure.
This class determines the manipulations that will minimize an ewald matrix, given a list of possible manipulations. This class does not perform the manipulations on a structure, but will return the list of manipulations that should be done on one to produce the minimal structure. It returns the manipulations for the n lowest energy orderings. This class should be used to perform fractional species substitution or fractional species removal to produce a new structure. These manipulations create large numbers of candidate structures, and this class can be used to pick out those with the lowest ewald sum.
An alternative (possibly more intuitive) interface to this class is the order disordered structure transformation.
Author - Will Richards
ALGO_TIME_LIMIT: Slowly increases the speed (with the cost of decreasing accuracy) as the minimizer runs. Attempts to limit the run time to approximately 30 minutes.
This adds an m_list to the output_lists and updates the current minimum if the list is full.
Computes a best case given a matrix and manipulation list.
Returns an index that should have the most negative effect on the matrix sum
Bases: object
Calculates the electrostatic energy of a periodic array of charges using the Ewald technique. Ref: http://www.ee.duke.edu/~ayt/ewaldpaper/ewaldpaper.html
This matrix can be used to do fast calculations of ewald sums after species removal.
E = E_recip + E_real + E_point
Atomic units used in the code, then converted to eV.
Initializes and calculates the Ewald sum. Default convergence parameters have been specified, but you can override them if you wish.
Gives total ewald energy for certain sites being removed, i.e. zeroed out.
Gives total ewald energy for an sub structure in the same lattice. The sub_structure must be a subset of the original structure, with possible different charges.
The point space matrix. A diagonal matrix with the point terms for each site in the diagonal elements.
The real space energy matrix. Each matrix element (i, j) corresponds to the interaction energy between site i and site j in real space.
This module provides classes that define a chemical reaction.
Bases: pymatgen.serializers.json_coders.MSONable
An object representing a complete chemical reaction.
Reactants and products to be specified as dict of {Composition: coeff}.
List of all compositions in the reaction.
Calculates the energy of the reaction.
Final coefficients of the calculated reaction
List of elements in the reaction
Generates a balanced reaction from a string. The reaciton must already be balanced.
Returns coefficient for a particular composition
Returns the amount of the element in the reaction.
Normalizes the reaction to one of the compositions. By default, normalizes such that the composition given has a coefficient of 1. Another factor can be specified.
Normalizes the reaction to one of the elements. By default, normalizes such that the amount of the element is 1. Another factor can be specified.
A normalized representation of the reaction. All factors are converted to lowest common factors.
Normalized representation for a reaction For example, 4 Li + 2 O -> 2Li2O becomes 2 Li + O -> Li2O
List of products
List of reactants
Bases: pymatgen.analysis.reaction_calculator.Reaction
Convenience class to generate a reaction from ComputedEntry objects, with some additional attributes, such as a reaction energy based on computed energies.
Bases: pymatgen.analysis.reaction_calculator.BalancedReaction
A more flexible class representing a Reaction. The reaction amounts will be automatically balanced.
Reactants and products to be specified as list of pymatgen.core.structure.Composition. e.g., [comp1, comp2]
This module provides classes to perform topological analyses of structures.
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.
Returns the percentage bond distance changes for each site up to a maximum radius for nearest neighbors.
Returns the percentage lattice parameter changes.
Bases: object
Computes the solid angles swept out by the shared face of the voronoi polyhedron between two sites
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
Bases: object
Uses a Voronoi algorithm to determine the coordination for each site in a structure.
Returns the sites that are in the coordination radius of site with index n.
Returns the coordination number of site with index n.
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, 772-775
Determines if a structure contains peroxide anions.
This module provides classes to perform fitting of structures.
Bases: pymatgen.serializers.json_coders.MSONable
Abstract Comparator class. A Comparator defines how sites are compared in a structure.
Defines how the species of two sites are considered equal. For example, one can consider sites to have the same species only when the species are exactly the same, i.e., Fe2+ matches Fe2+ but not Fe3+. Or one can define that only the element matters, and all oxidation state information are ignored.
Defines a hash for structures. This allows structures to be grouped efficiently for comparison. For example, in exact matching, you should only try to perform matching if structures have the same reduced formula (structures with different formulas can’t possibly match). So the reduced_formula is a good hash. The hash function should be relatively fast to compute relative to the actual matching.
Bases: pymatgen.analysis.structure_matcher.AbstractComparator
A Comparator that matches elements. i.e. oxidation states are ignored.
True if element:amounts are exactly the same, i.e., oxidation state is not considered.
Bases: pymatgen.analysis.structure_matcher.AbstractComparator
A Comparator that matches sites, regardless of species.
Bases: pymatgen.analysis.structure_matcher.AbstractComparator
A Comparator that matches species exactly. The default used in StructureMatcher.
True if species are exactly the same, i.e., Fe2+ == Fe2+ but not Fe3+.
Bases: pymatgen.serializers.json_coders.MSONable
Class to match structures by similarity.
Algorithm:
Given two structures: s1 and s2
Optional: Reduce to primitive cells.
If the number of sites do not match, return False
Reduce to s1 and s2 to Niggli Cells
Optional: Scale s1 and s2 to same volume.
Optional: Remove oxidation states associated with sites
Find all possible lattice vectors for s2 within shell of ltol.
For s1, translate an atom in the smallest set to the origin
For s2: find all valid lattices from permutations of the list of lattice vectors (invalid if: det(Lattice Matrix) < half volume of original s2 lattice)
For each valid lattice:
If the lattice angles of are within tolerance of s1, basis change s2 into new lattice.
For each atom in the smallest set of s2:
i. Translate to origin and compare fractional sites in structure within a fractional tolerance. ii. If true:
ia. Convert both lattices to cartesian and place both structures on an average lattice ib. Compute and return the average and max rms displacement between the two structures normalized by the average free length per atom
- if fit function called:
if normalized max rms displacement is less than stol. Return True
- if get_rms_dist function called:
if normalized average rms displacement is less than the stored rms displacement, store and continue. (This function will search all possible lattices for the smallest average rms displacement between the two structures)
A comparator object implementing an equals method that declares declaring equivalency of sites. Default is SpeciesComparator, which implies rigid species mapping, i.e., Fe2+ only matches Fe2+ and not Fe3+.
Other comparators are provided, e.g., ElementComparator which matches only the elements and not the species.
The reason why a comparator object is used instead of supplying a comparison function is that it is not possible to pickle a function, which makes it otherwise difficult to use StructureMatcher with Python’s multiprocessing.
Given a list of structures, return list of indices where each structure appears in group_list.
Fit two structures.
Performs an anonymous fitting, which allows distinct species in one structure to map to another. E.g., to compare if the Li2O and Na2O structures are similar.
Performs an anonymous fitting, which allows distinct species in one structure to map to another. E.g., to compare if the Li2O and Na2O structures are similar.
Calculate RMS displacement between two structures
A module to perform experimental thermochemical data analysis.
Bases: object
A object container for an experimental Thermochemical Data.