Skip to content

Analyses

See Analyses for worked examples.

pourbase.stability_margin

stability_margin(diagram: PourbaixDiagram, pH: float, U_V: float, assumed_uncertainty_J_mol: float = DEFAULT_ASSUMED_UNCERTAINTY_J_MOL) -> StabilityMargin

The runner-up species and the nearest boundaries at the grid point nearest to a coordinate.

pourbase.StabilityMargin dataclass

StabilityMargin(pH: float, U_V: float, species: ThermodynamicSpecies, runner_up: ThermodynamicSpecies | None, margin_J_mol_metal: float | None, margin_uncertainty_J_mol_metal: float | None, runner_up_uses_assumed_uncertainty: bool, higher_potential: NeighbourBoundary | None, lower_potential: NeighbourBoundary | None, higher_pH: NeighbourBoundary | None, lower_pH: NeighbourBoundary | None)

Why one species is stable at a point, and how firmly.

margin_J_mol_metal is the energy above the stable species of the runner-up, the species with the next lowest energy; margin_uncertainty_J_mol_metal is their combined uncertainty. Potential distances are exact at the grid point; pH distances follow the grid.

pourbase.stability_uncertainty

stability_uncertainty(diagram: PourbaixDiagram, confidence_sigma: float = 1.0, assumed_uncertainty_J_mol: float = DEFAULT_ASSUMED_UNCERTAINTY_J_MOL) -> StabilityUncertainty

Mark the points where the stable species could change within the stated uncertainties.

A point is uncertain when some other species lies above the stable one by less than confidence_sigma times the combined uncertainty of the two, per mole of metal.

pourbase.StabilityUncertainty dataclass

StabilityUncertainty(confidence_sigma: float, assumed_uncertainty_J_mol: float, uncertain: NDArray[bool_], assumed_record_ids: tuple[str, ...])

Grid points where another species lies within confidence_sigma combined uncertainties.

pourbase.stability_region

stability_region(calculation, target: str, min_margin_J_mol: float = 0.0, k_sigma: float | None = None, assumed_uncertainty_J_mol: float = 2000.0) -> StabilityRegion

Where target is stable with at least min_margin_J_mol (or k_sigma uncertainties) to spare.

pourbase.StabilityRegion dataclass

StabilityRegion(target: str, pH: ndarray, U_V: ndarray, margin_J_mol_metal: ndarray, satisfied: ndarray, min_margin_J_mol: float, k_sigma: float | None)

pourbase.KINDS module-attribute

KINDS = {'immunity': 'Metal stable (immunity)', 'passivation': 'Solid compound stable (passivation)', 'corrosion': 'Dissolved (corrosion)', 'solid': 'Any solid or liquid stable'}

pourbase.screen_window

screen_window(database, kind: str, pH: tuple[float, float], U_V: tuple[float, float], min_margin_J_mol: float = 0.0, points: int = 21, **scenario) -> dict[str, WindowResult]

For every element, the share of a pH–potential window where kind holds.

scenario takes Scenario fields such as concentration, ligands or temperature_K; the diagrams are fixed-activity.

pourbase.WindowResult dataclass

WindowResult(symbol: str, fraction: float | None, minimum_margin_J_mol_metal: float | None, note: str = '')

pourbase.screen_periodic_table

screen_periodic_table(database: ThermodynamicDatabase | None = None, *, pH: float = 7.0, potential_V: float = 0.0, reference: str = 'SHE', concentration: float = -6.0, concentration_unit: str = 'log10_molar', solution_density_kg_L: float = 1.0, log10_gas_fugacity: float = 0.0, allow_incomplete: bool = True, energy_policy: GibbsEnergyPolicy | str = GibbsEnergyPolicy.EXPERIMENTAL_ONLY, ligands: tuple[LigandActivity, ...] = (), temperature_K: float = 298.15) -> PeriodicScreen

The lowest-energy species of every element at one pH and potential.

ligands are buffered ligand reservoirs; their complexes take part for every element that forms them. Species without a recommended Gibbs energy are left out unless allow_incomplete is False, which marks such elements as incomplete instead. temperature_K extrapolates the Gibbs energies as in pourbase.temperature.

pourbase.PeriodicScreen dataclass

PeriodicScreen(pH: float, input_potential_V: float, reference: str, potential_V_vs_SHE: float, concentration: float, concentration_unit: str, elements: tuple[ElementResult, ...])

pourbase.ElementResult dataclass

ElementResult(atomic_number: int, symbol: str, system: str | None, status: ElementStatus, category: Category, reason: str | None = None, stable: ThermodynamicSpecies | None = None, energy_margin_J_mol_metal: float | None = None, missing_record_ids: tuple[str, ...] = (), gibbs_source: SourceReference | None = None, structure_label: str | None = None, warnings: tuple[RecordWarning, ...] = ())

pourbase.ElementStatus

Bases: str, Enum

is_provisional property

is_provisional: bool

Calculated with species left out or with Materials Project estimates.

has_system property

has_system: bool

The element has species in the database, calculated here or not.

pourbase.Category

Bases: str, Enum

pourbase.phase_path

phase_path(calculation, *vertices: tuple[float, float], smooth: bool = False, points: int = 401) -> PhasePath

Stable species along the path through vertices, each (pH, U in V vs SHE).

pourbase.PhasePath dataclass

PhasePath(fraction: ndarray, pH: ndarray, U_V: ndarray, species: tuple[ThermodynamicSpecies, ...], stable_species_index: ndarray, crossings: tuple[Crossing, ...])

pourbase.Crossing dataclass

Crossing(fraction: float, pH: float, U_V: float, before: ThermodynamicSpecies, after: ThermodynamicSpecies, boundary: BoundaryEquation | None)

pourbase.path_curve

path_curve(vertices, smooth: bool = False, points: int = 401) -> tuple[np.ndarray, np.ndarray, np.ndarray]

(position, pH, U) sampled along a path through vertices; position runs from 0 to 1.

Each segment receives samples in proportion to its length, with pH and potential scaled by 14 pH units and 3 V. smooth joins the points with a Catmull-Rom curve.

pourbase.assess_points

assess_points(calculation, points, assumed_uncertainty_J_mol: float = DEFAULT_ASSUMED_UNCERTAINTY_J_MOL) -> tuple[PointAssessment, ...]

The predicted species at each measured point; fixed-activity diagrams add the margin to the runner-up.

pourbase.MeasuredPoint dataclass

MeasuredPoint(label: str, pH: float, U_V: float)

pourbase.PointAssessment dataclass

PointAssessment(point: MeasuredPoint, inside: bool, species: ThermodynamicSpecies | None, runner_up: ThermodynamicSpecies | None = None, margin_J_mol_metal: float | None = None, margin_uncertainty_J_mol_metal: float | None = None)

within_uncertainty property

within_uncertainty: bool

True when the runner-up lies within one combined standard uncertainty (Eq. 12, k = 1).

pourbase.selection_sensitivity

selection_sensitivity(diagram, selections: Mapping, samples: int = 200, seed: int = 1, classes: set[str] | None = None, progress: Callable[[float], bool] | None = None) -> SelectionSensitivity

Sensitivity of a fixed-activity diagram to the choice between eligible Gibbs energies.

selections maps (record_id, property) to the Selection of a policy, for example database.selections. classes limits the alternatives to some evidence classes, such as {"A", "B", "C"}. progress(fraction) may return False to stop.

pourbase.SelectionSensitivity dataclass

SelectionSensitivity(pH: ndarray, U_V: ndarray, changed_fraction: ndarray, samples: int, species: tuple[SpeciesSensitivity, ...])

unfixed_fraction property

unfixed_fraction: float

Share of the diagram whose stable species depends on the selection.

pourbase.speciation_profile

speciation_profile(diagram: MassBalancedPourbaixDiagram, U_V: float) -> SpeciationProfile

Metal fractions along pH at the grid U nearest to U_V.

pourbase.SpeciationProfile dataclass

SpeciationProfile(U_V: float, pH: FloatArray, species: tuple[ThermodynamicSpecies, ...], metal_fraction: FloatArray)

Metal fractions along pH at one U, derived from curated Gibbs records.

pourbase.speciation_at

speciation_at(diagram: MassBalancedPourbaixDiagram, pH: float, U_V: float) -> tuple[dict[str, object], ...]

Sourced metal fractions at one point, largest first, including a precipitated solid.

pourbase.metal_fraction_grid

metal_fraction_grid(diagram: MassBalancedPourbaixDiagram) -> FloatArray

Fraction of the total metal held by each species at every grid point.

pourbase.solubility

solubility(calculation, U_V: float, pH: ndarray | None = None) -> Solubility

Dissolved metal in equilibrium with the most stable condensed phase at potential U_V (V vs SHE).

pourbase.Solubility dataclass

Solubility(pH: ndarray, U_V: float, species: tuple[ThermodynamicSpecies, ...], log10_metal_mol_L: ndarray, log10_total_mol_L: ndarray, solids: tuple[ThermodynamicSpecies, ...], solid_index: ndarray)

pourbase.ligand_predominance

ligand_predominance(calculation, ligand_id: str, U_V: float, log10_activity: ndarray | None = None) -> LigandPredominance

Stable species over pH and the free activity of ligand_id at potential U_V (V vs SHE).

The metal activity and any other ligands are those of the calculation's scenario, read as a fixed-activity diagram.

pourbase.LigandPredominance dataclass

LigandPredominance(pH: ndarray, log10_activity: ndarray, U_V: float, ligand_id: str, species: tuple[ThermodynamicSpecies, ...], stable_species_index: ndarray)

pourbase.plating_potentials

plating_potentials(diagram: PourbaixDiagram, database: ThermodynamicDatabase) -> tuple[PlatingPotential, ...]

Return direct simple-cation/elemental-metal equilibria at configured activity.

pourbase.PlatingPotential dataclass

PlatingPotential(metal_record_id: str, ion_record_id: str, ion_species: str, potential_V_vs_SHE: float, reaction: str, source_ids: tuple[str, ...])

Activity-conditioned aqueous-ion/metal equilibrium at pH 0.

pourbase.ConcentrationSweepEngine

ConcentrationSweepEngine(database: ThermodynamicDatabase)

Fixed-activity diagrams over a range of the default aqueous metal activity.

calculate

calculate(symbol: str, conditions: PourbaixConditions, log10_activity_min: float, log10_activity_max: float, points: int = 7, *, allow_incomplete: bool = True, energy_policy: GibbsEnergyPolicy | str = GibbsEnergyPolicy.EXPERIMENTAL_ONLY, store_energies: bool = False, progress: Callable[[float], bool | None] | None = None) -> ConcentrationSweep

Calculate points evenly spaced activity levels.

Diagrams are stored without their energy stacks unless store_energies. progress receives the completed fraction; returning False raises CalculationCancelled.

pourbase.ConcentrationSweep dataclass

ConcentrationSweep(log10_activities: FloatArray, diagrams: tuple[PourbaixDiagram, ...])

A common pH/U grid evaluated at several default aqueous activities.