Skip to content

Plotting and export

See Plotting and export for examples.

pourbase.plot_diagram

plot_diagram(diagram: PourbaixDiagram | MassBalancedPourbaixDiagram, *, ax: Any | None = None, title: str | None = None, colors: Mapping[str, Any] | None = None, label_domains: bool = True, show_legend: bool = True, show_boundaries: bool = True, show_water: bool = True) -> Any

Plot one phase map and return its Matplotlib axes.

pourbase.plot_uncertainty

plot_uncertainty(diagram: PourbaixDiagram, *, ax: Any, confidence_sigma: float = 1.0, assumed_uncertainty_kJ_mol: float = 2.0, color: Any = 'black') -> Any

Hatch the points where another species lies within confidence_sigma combined uncertainties (Eq. 12).

Species without a reported uncertainty take assumed_uncertainty_kJ_mol. Draws on ax, the axes of a diagram plotted with plot_diagram, and returns it.

pourbase.plot_boltzmann_diagram

plot_boltzmann_diagram(smoothed: BoltzmannSmoothedDiagram, *, ax: Any | None = None, title: str | None = None, colors: Mapping[str, Any] | None = None, label_domains: bool = True, show_legend: bool = True, show_boundaries: bool = True, show_water: bool = True, minimum_peak_weight: float = 0.01) -> Any

Plot a blend of every species' soft-minimum weight (Eq. 8).

The colors show energetic competition. They are not equilibrium phase fractions; use the mass-balance engine when conserved amounts are needed.

pourbase.boltzmann_smooth

boltzmann_smooth(diagram: PourbaixDiagram, width_J_mol: float | None = None, *, blend_all_phases: bool = False, thermal_scale: float | None = None) -> BoltzmannSmoothedDiagram

Soft-minimum weights exp(-(G - Gmin) / width) of a fixed-activity diagram.

width_J_mol defaults to RT. With blend_all_phases the sums run over every species, so solids blend with the solution as well. thermal_scale gives the width in units of RT and is kept for compatibility. Subtracting the grid minimum gives the same normalized weights as the direct expression and prevents numerical overflow.

pourbase.BoltzmannSmoothedDiagram dataclass

BoltzmannSmoothedDiagram(diagram: PourbaixDiagram, width_J_mol: float, weights: FloatArray, soft_minimum_gibbs_J_mol_metal: FloatArray, dominant_weight: FloatArray, mixing_entropy_J_mol_K: FloatArray)

Soft-minimum weights of one fixed-activity diagram for a blend width in J/mol.

mixing_entropy_J_mol_K is R times the Shannon entropy of the weights, a measure of how many species share a point; it is a thermodynamic mixing entropy only where the weights are physical fractions (see the module documentation).

thermal_scale property

thermal_scale: float

The width in units of RT (deprecated; use width_J_mol).

effective_thermal_energy_J_mol property

effective_thermal_energy_J_mol: float

The blend width (deprecated name; use width_J_mol).

weights_at

weights_at(pH: float, U_V: float) -> tuple[tuple[ThermodynamicSpecies, float], ...]

Return species and descending weight at one grid point.

pourbase.dissolved_blend_weights

dissolved_blend_weights(diagram: MassBalancedPourbaixDiagram) -> FloatArray

Weights for coloring a closed-balance diagram by its dissolved fractions.

Where no solid precipitates, the weights are the fractions of the dissolved species (they sum to one). Where a solid precipitates, it is a separate phase and takes the whole weight, so every edge between solid and solution stays sharp.

pourbase.plot_mass_balance_summary

plot_mass_balance_summary(diagram: MassBalancedPourbaixDiagram, *, title: str | None = None, label_domains: bool = True, show_legend: bool = True, show_boundaries: bool = True, show_water: bool = True) -> tuple[Any, Any]

Plot phase domains, precipitated fraction, and dissolved metal.

pourbase.plot_speciation_profile

plot_speciation_profile(profile: SpeciationProfile, *, ax: object | None = None, title: str | None = None) -> object

Plot sourced species fractions along pH at a fixed U.

pourbase.plot_concentration_sweep

plot_concentration_sweep(sweep: ConcentrationSweep, *, probe_pH: float = 7.0, probe_U_V: float = 0.0, show_water: bool = True) -> tuple[Any, Any]

Plot stacked 3D boundaries and two orthogonal concentration projections.

pourbase.diagram_figure

diagram_figure(diagram: Any, *, labels: bool = True, legend: bool = True, boundaries: bool = True, water: bool = True, plating_potential_V: float | None = None, blend_width_kJ_mol: float | None = None, boltzmann_scale: float | None = None) -> Any

A Matplotlib figure of a fixed-activity or mass-balance diagram.

blend_width_kJ_mol draws soft-minimum weights (Eq. 8) of that width; boltzmann_scale gives the width in units of RT and is kept for compatibility.

pourbase.species_colors

species_colors(record_ids) -> dict[str, Any]

Colors for species keyed by record ID: tab20 over the sorted IDs.

pourbase.save_figure

save_figure(figure: Any, path: str | Path, dpi: int = 300) -> Path

pourbase.grid_csv

grid_csv(diagram: Any) -> str

Every grid point with its stable species, and the metal inventory for a mass balance.