pymatgen.analysis.chempot_diagram module

This module implements the construction and plotting of chemical potential diagrams from a list of entries within a chemical system containing 2 or more elements. The chemical potential diagram is the mathematical dual to the traditional compositional phase diagram.

For more information, please cite/reference the paper below:

Todd, Paul K., McDermott, M.J., et al. “Selectivity in yttrium manganese oxide synthesis via local chemical potentials in hyperdimensional phase space.” ArXiv:2104.05986 [Cond-Mat], Aug. 2021.,

Please also consider referencing the original 1999 paper by H. Yokokawa, who outlined many of its possible uses:

Yokokawa, H. “Generalized chemical potential diagram and its applications to chemical reactions at interfaces between dissimilar materials.” JPE 20, 258 (1999).

class ChemicalPotentialDiagram(entries: List[pymatgen.analysis.phase_diagram.PDEntry], limits: Optional[Dict[pymatgen.core.periodic_table.Element, float]] = None, default_min_limit: Optional[float] = - 20.0)[source]

Bases: monty.json.MSONable

The chemical potential diagram is the mathematical dual to the compositional phase diagram. To create the diagram, convex minimization is performed in energy (E) vs. chemical potential (μ) space by taking the lower convex envelope of hyperplanes. Accordingly, “points” on the compositional phase diagram become N-dimensional convex polytopes (domains) in chemical potential space.

For more information on this specific implementation of the algorithm, please cite/reference the paper below:

Todd, Paul K., McDermott, M.J., et al. “Selectivity in yttrium manganese oxide synthesis via local chemical potentials in hyperdimensional phase space.” ArXiv:2104.05986 [Cond-Mat], Apr. 2021.,

  • entries – List of PDEntry-like objects containing a composition and energy. Must contain elemental references and be suitable for typical phase diagram construction. Entries must be within a chemical system of with 2+ elements

  • limits – Bounds of elemental chemical potentials (min, max), which are used to construct the border hyperplanes used in the HalfSpaceIntersection algorithm; these constrain the space over which the domains are calculated and also determine the size of the plotted diagram. Any elemental limits not specified are covered in the default_min_limit argument

  • default_min_limit (float) – Default minimum chemical potential limit for unspecified elements within the “limits” argument. This results in default limits of (default_min_limit, 0)

property border_hyperplanes: numpy.ndarray[source]

Returns bordering hyperplanes

property chemical_system: str[source]

Returns the chemical system (A-B-C-…) of diagram object

property domains: Dict[str, numpy.ndarray][source]

Mapping of formulas to array of domain boundary points

property el_refs: Dict[pymatgen.core.periodic_table.Element, pymatgen.analysis.phase_diagram.PDEntry][source]

Returns a dictionary of elements and reference entries

property entry_dict: Dict[str, pymatgen.entries.computed_entries.ComputedEntry][source]

Mapping between reduced formula and ComputedEntry

get_plot(elements: Optional[List[Union[pymatgen.core.periodic_table.Element, str]]] = None, label_stable: Optional[bool] = True, formulas_to_draw: Optional[List[str]] = None, draw_formula_meshes: Optional[bool] = True, draw_formula_lines: Optional[bool] = True, formula_colors: List[str] = ['rgb(27,158,119)', 'rgb(217,95,2)', 'rgb(117,112,179)', 'rgb(231,41,138)', 'rgb(102,166,30)', 'rgb(230,171,2)', 'rgb(166,118,29)', 'rgb(102,102,102)']) plotly.graph_objs._figure.Figure[source]

Plot the 2-dimensional or 3-dimensional chemical potential diagram using an interactive Plotly interface.

Elemental axes can be specified; if none provided, will automatically default to first 2-3 elements within the “elements” attribute.

In 3D, this method also allows for plotting of lower-dimensional “slices” of hyperdimensional polytopes (e.g., the LiMnO2 domain within a Y-Mn-O diagram). This allows for visualization of some of the phase boundaries that can only be seen fully in high dimensional space.

  • elements – list of elements to use as axes in the diagram. If None, automatically defaults to the first 2 or elements within the object’s “elements” attribute.

  • label_stable – whether or not to label stable phases by their reduced formulas. Defaults to True.

  • formulas_to_draw – for 3-dimensional diagrams, an optional list of formulas to plot on the diagram; if these are from a different chemical system a 3-d polyhedron “slice” will be plotted.

  • draw_formula_meshes – whether or not to draw a colored mesh for the optionally specified formulas_to_draw. Defaults to True.

  • draw_formula_lines – whether or not to draw bounding lines for the optionally specified formulas_to_draw. Defaults to True.

  • formula_colors – a list of colors to use in the plotting of the optionally specified formulas_to-draw. Defaults to a Plotly color scheme.


A Plotly Figure object

property hyperplane_entries: List[pymatgen.analysis.phase_diagram.PDEntry][source]

Returns list of entries corresponding to hyperplanes

property hyperplanes: numpy.ndarray[source]

Returns array of hyperplane data

property lims: numpy.ndarray[source]

Returns array of limits used in constructing hyperplanes

get_2d_orthonormal_vector(line_pts: numpy.ndarray) numpy.ndarray[source]

Calculates a vector that is orthonormal to a line given by a set of points. Used for determining the location of an annotation on a 2-d chemical potential diagram.


line_pts – a 2x2 array in the form of [[x0, y0], [x1, y1]] giving the coordinates of a line


get_centroid_2d(vertices: numpy.ndarray) numpy.ndarray[source]

A barebones implementation of the formula for calculating the centroid of a 2D polygon. Useful for calculating the location of an annotation on a chemical potential domain within a 3D chemical potential diagram.

NOTE: vertices must be ordered circumfrentially!


vertices – array of 2-d coordinates corresponding to a polygon, ordered circumfrentially


Array giving 2-d centroid coordinates

simple_pca(data: numpy.ndarray, k: int = 2) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]

A barebones implementation of principal component analysis (PCA) used in the ChemicalPotentialDiagram class for plotting.

  • data – array of observations

  • k – Number of principal components returned


Tuple of projected data, eigenvalues, eigenvectors