pymatgen.analysis.pourbaix_diagram module

This module is intended to be used to compute Pourbaix diagrams of arbitrary compositions and formation energies. If you use this module in your work, please consider citing the following:

General formalism for solid-aqueous equilibria from DFT:

Persson et al., DOI: 10.1103/PhysRevB.85.235438

Decomposition maps, or Pourbaix hull diagrams

Singh et al., DOI: 10.1021/acs.chemmater.7b03980

Fast computation of many-element Pourbaix diagrams:

Patel et al., (submitted)

class IonEntry(ion, energy, name=None, attribute=None)[source]

Bases: PDEntry

Object similar to PDEntry, but contains an Ion object instead of a Composition object.


A name for the entry. This is the string shown in the phase diagrams. By default, this is the reduced formula for the composition, but can be set to some other string for display purposes.

  • ion – Ion object

  • energy – Energy for composition.

  • name – Optional parameter to name the entry. Defaults to the chemical formula.


Creates a dict of composition, energy, and ion name

classmethod from_dict(d)[source]

Returns an IonEntry object from a dict.

class MultiEntry(entry_list, weights=None)[source]

Bases: PourbaixEntry

PourbaixEntry-like object for constructing multi-elemental Pourbaix diagrams.

Initializes a MultiEntry.

  • entry_list ([PourbaixEntry]) – List of component PourbaixEntries

  • weights ([float]) – Weights associated with each entry. Default is None


Returns: MSONable dict

classmethod from_dict(d)[source]

() (d) – Dict representation



property name[source]

MultiEntry name, i. e. the name of each entry joined by ‘ + ‘

class PourbaixDiagram(entries: list[PourbaixEntry] | list[MultiEntry], comp_dict: dict[str, float] | None = None, conc_dict: dict[str, float] | None = None, filter_solids: bool = True, nproc: int | None = None)[source]

Bases: MSONable

Class to create a Pourbaix diagram from entries

  • entries ([PourbaixEntry] or [MultiEntry]) – Entries list containing Solids and Ions or a list of MultiEntries

  • comp_dict (dict[str, float]) – Dictionary of compositions, defaults to equal parts of each elements

  • conc_dict (dict[str, float]) – Dictionary of ion concentrations, defaults to 1e-6 for each element

  • filter_solids (bool) – applying this filter to a Pourbaix diagram ensures all included solid phases are filtered by stability on the compositional phase diagram. Defaults to True. The practical consequence of this is that highly oxidized or reduced phases that might show up in experiments due to kinetic limitations on oxygen/hydrogen evolution won’t appear in the diagram, but they are not actually “stable” (and are frequently overstabilized from DFT errors). Hence, including only the stable solid phases generally leads to the most accurate Pourbaix diagrams.

  • nproc (int) – number of processes to generate multientries with in parallel. Defaults to None (serial processing)

property all_entries[source]

Return all entries used to generate the Pourbaix diagram


() (include_unprocessed_entries) – DEPRECATED. Whether to include unprocessed entries (equivalent to filter_solids=False). Serialization now includes all unprocessed entries by default. Set filter_solids=False before serializing to include unstable solids from the generated Pourbaix Diagram.


MSONable dict.

find_stable_entry(pH, V)[source]

Finds stable entry at a pH,V condition :param pH: pH to find stable entry :type pH: float :param V: V to find stable entry :type V: float


classmethod from_dict(d)[source]

() (d) – Dict representation.



get_decomposition_energy(entry, pH, V)[source]

Finds decomposition to most stable entries in eV/atom, supports vectorized inputs for pH and V

  • entry (PourbaixEntry) – PourbaixEntry corresponding to compound to find the decomposition for

  • pH (float, [float]) – pH at which to find the decomposition

  • V (float, [float]) – voltage at which to find the decomposition


Decomposition energy for the entry, i. e. the energy above

the “Pourbaix hull” in eV/atom at the given conditions

get_hull_energy(pH, V)[source]

Gets the minimum energy of the Pourbaix “basin” that is formed from the stable Pourbaix planes. Vectorized.

  • pH (float or [float]) – pH at which to find the hull energy

  • V (float or [float]) – V at which to find the hull energy


(float or [float]) minimum Pourbaix energy at conditions

static get_pourbaix_domains(pourbaix_entries, limits=None)[source]

Returns a set of Pourbaix stable domains (i. e. polygons) in pH-V space from a list of pourbaix_entries

This function works by using scipy’s HalfspaceIntersection function to construct all of the 2-D polygons that form the boundaries of the planes corresponding to individual entry gibbs free energies as a function of pH and V. Hyperplanes of the form a*pH + b*V + 1 - g(0, 0) are constructed and supplied to HalfspaceIntersection, which then finds the boundaries of each Pourbaix region using the intersection points.

  • pourbaix_entries ([PourbaixEntry]) – Pourbaix entries with which to construct stable Pourbaix domains

  • limits ([[float]]) – limits in which to do the pourbaix analysis


[boundary_points]}. The list of boundary points are the sides of the N-1 dim polytope bounding the allowable ph-V range of each entry.

Return type:

Returns a dict of the form {entry

get_stable_entry(pH, V)[source]

Gets the stable entry at a given pH, V condition

  • pH (float) – pH at a given condition

  • V (float) – V at a given condition


Pourbaix or multi-entry

corresponding ot the minimum energy entry at a given pH, V condition

Return type:

(PourbaixEntry or MultiEntry)

static process_multientry(entry_list, prod_comp, coeff_threshold=0.0001)[source]

Static method for finding a multientry based on a list of entries and a product composition. Essentially checks to see if a valid aqueous reaction exists between the entries and the product composition and returns a MultiEntry with weights according to the coefficients if so.

  • entry_list ([Entry]) – list of entries from which to create a MultiEntry

  • prod_comp (Composition) – composition constraint for setting weights of MultiEntry

  • coeff_threshold (float) – threshold of stoichiometric coefficients to filter, if weights are lower than this value, the entry is not returned

property stable_entries[source]

Returns the stable entries in the Pourbaix diagram.

property unprocessed_entries[source]

Return unprocessed entries

property unstable_entries[source]

Returns all unstable entries in the Pourbaix diagram

class PourbaixEntry(entry, entry_id=None, concentration=1e-06)[source]

Bases: MSONable, Stringify

An object encompassing all data relevant to a solid or ion in a Pourbaix diagram. Each bulk solid/ion has an energy g of the form: e = e0 + 0.0591 log10(conc) - nO mu_H2O + (nH - 2nO) pH + phi (-nH + 2nO + q)

Note that the energies corresponding to the input entries should be formation energies with respect to hydrogen and oxygen gas in order for the Pourbaix diagram formalism to work. This may be changed to be more flexible in the future.

  • entry (ComputedEntry/ComputedStructureEntry/PDEntry/IonEntry) – An entry object

  • () (concentration) –

  • ()


Returns dict which contains Pourbaix Entry data. Note that the pH, voltage, H2O factors are always calculated when constructing a PourbaixEntry object.

property composition[source]

Returns composition

property conc_term[source]

Returns the concentration contribution to the free energy, and should only be present when there are ions in the entry

property energy[source]

returns energy

Returns (float): total energy of the Pourbaix

entry (at pH, V = 0 vs. SHE)

energy_at_conditions(pH, V)[source]

Get free energy for a given pH and V

  • pH (float) – pH at which to evaluate free energy

  • V (float) – voltage at which to evaluate free energy


free energy at conditions

property energy_per_atom[source]

energy per atom of the Pourbaix entry

Returns (float): energy per atom

classmethod from_dict(d)[source]

Invokes a PourbaixEntry from a dictionary


Gets the elemental fraction of a given non-OH element


element (Element or str) – string or element corresponding to element to get from composition


fraction of element / sum(all non-OH elements)

property nH2O[source]

Number of H2O.



property nPhi[source]

Number of H2O.



property name[source]

Name for entry



property normalization_factor[source]

Sum of number of atoms minus the number of H and O in composition

property normalized_energy[source]

Returns: energy normalized by number of non H or O atoms, e. g. for Zn2O6, energy / 2 or for AgTe3(OH)3, energy / 4

normalized_energy_at_conditions(pH, V)[source]

Energy at an electrochemical condition, compatible with numpy arrays for pH/V input

  • pH (float) – pH at condition

  • V (float) – applied potential at condition


energy normalized by number of non-O/H atoms at condition

property npH[source]


property num_atoms[source]

Return number of atoms in current formula. Useful for normalization

to_pretty_string() str[source]

A pretty string representation.

class PourbaixPlotter(pourbaix_diagram)[source]

Bases: object

A plotter class for phase diagrams.


pourbaix_diagram (PourbaixDiagram) – A PourbaixDiagram object.


Returns the vertices of the Pourbaix domain.


entry – Entry for which domain vertices are desired


list of vertices

get_pourbaix_plot(limits=None, title='', label_domains=True, label_fontsize=20, show_water_lines=True, show_neutral_axes=True, plt=None)[source]

Plot Pourbaix diagram.

  • limits – 2D list containing limits of the Pourbaix diagram of the form [[xlo, xhi], [ylo, yhi]]

  • title (str) – Title to display on plot

  • label_domains (bool) – whether to label Pourbaix domains

  • label_fontsize – font size for domain labels

  • show_water_lines – whether to show dashed lines indicating the region of water stability.

  • lines (show_neutral_axes; whether to show dashed horizontal and vertical) – at 0 V and pH 7, respectively.

  • plt (pyplot) – Pyplot instance for plotting


plt (pyplot) - matplotlib plot object with Pourbaix diagram

plot_entry_stability(entry, pH_range=None, pH_resolution=100, V_range=None, V_resolution=100, e_hull_max=1, cmap='RdYlBu_r', **kwargs)[source]
  • () (**kwargs) –

  • ()

  • ()

  • ()

  • ()

  • ()

  • ()

  • ()


show(*args, **kwargs)[source]

Shows the Pourbaix plot

  • *args – args to get_pourbaix_plot

  • **kwargs – kwargs to get_pourbaix_plot




Generates a label for the Pourbaix plotter


entry (PourbaixEntry or MultiEntry) – entry to get a label for


Returns either an ion object or composition object given a formula.


formula – String formula. Eg. of ion: NaOH(aq), Na[+]; Eg. of solid: Fe2O3(s), Fe(s), Na2O


Composition/Ion object