Calculation¶
A Scenario describes what to calculate in everyday units; calculate
returns a Calculation with the diagram, its boundaries and a probe. The engines below
are the lower-level route that calculate uses.
pourbase.calculate ¶
Calculate a scenario with the bundled database unless another is given.
pourbase.Scenario
dataclass
¶
Scenario(symbol: str, mode: Mode = Mode.FIXED_ACTIVITY, concentration: float = -6.0, concentration_unit: str = 'log10_molar', solution_density_kg_L: float = 1.0, davies_ionic_strength_mol_L: float | None = None, log10_gas_fugacity: float = 0.0, ligands: tuple[LigandActivity, ...] = (), pH_min: float = 0.0, pH_max: float = 14.0, U_min_V: float = -1.5, U_max_V: float = 1.5, pH_points: int = 281, U_points: int = 301, allow_incomplete: bool = True, energy_policy: GibbsEnergyPolicy = GibbsEnergyPolicy.EXPERIMENTAL_ONLY, activity_overrides: tuple[tuple[str, float], ...] = (), temperature_K: float = 298.15)
Everything that defines one diagram, in user-facing units.
concentration is read in concentration_unit (log10_molar, molar, ppm or
wt_percent). In fixed-activity mode it sets the activity of every aqueous metal
species; in mass-balance mode it sets the conserved total metal.
davies_ionic_strength_mol_L selects Davies activity coefficients in mass-balance
mode; None means ideal. activity_overrides maps species record IDs, names or
formulas to their own log10 activity in fixed-activity mode. Species without a recommended
Gibbs energy are left out and listed in Calculation.excluded; allow_incomplete=False
raises IncompleteSystemError instead. temperature_K between 273.15 and 373.15 K
extrapolates every Gibbs energy with its entropy of formation (see pourbase.temperature).
conditions ¶
Calculation conditions; log10_activity replaces the converted concentration.
pourbase.Calculation
dataclass
¶
pourbase.Probe
dataclass
¶
Probe(pH: float, U_V: float, species: ThermodynamicSpecies, dissolved_metal_mol_L: float | None = None, precipitated_fraction: float | None = None, speciation: tuple[dict[str, object], ...] = ())
The result at one grid point.
pourbase.Mode ¶
Bases: str, Enum
pourbase.GibbsEnergyPolicy ¶
Bases: str, Enum
Choose which evidence layer may supply a calculation Gibbs energy.
pourbase.LigandActivity
dataclass
¶
LigandActivity(ligand_id: str, log10_free_activity: float | None = None, total_unbound_mol_L: float | None = None, acid_pKa: float | None = None, standard_concentration_mol_L: float = 1.0)
A buffered free-ligand activity or monoprotic acid/base reservoir.
log10_free_activity fixes the activity of the deprotonated ligand directly.
total_unbound_mol_L describes an unbound pool HL + L. Supplying
acid_pKa then calculates the deprotonated fraction at each pH. Omitting the
pKa treats the pool as fully dissociated.
log10_activity ¶
Buffered activity of the deprotonated ligand at each pH.
A fixed free activity is returned as given. A total unbound pool c_L with an acid pKa gives the free (deprotonated) ligand activity
log10 a_L = log10(c_L / c0) - log10(1 + 10^(pKa - pH)) . (11)
pourbase.PourbaixConditions
dataclass
¶
PourbaixConditions(temperature_K: float = 298.15, pressure_bar: float = 1.0, pH_min: float = 0.0, pH_max: float = 14.0, U_min_V: float = -1.5, U_max_V: float = 1.5, pH_points: int = 281, U_points: int = 301, aqueous_activities: AqueousActivityModel = AqueousActivityModel(), gas_fugacities: GasFugacityModel = GasFugacityModel(), ligand_activities: LigandActivityModel | None = None)
Validated grid and activity conditions of one calculation.
pourbase.PourbaixDiagram
dataclass
¶
PourbaixDiagram(system: MetalSystem, conditions: PourbaixConditions, pH: FloatArray, U_V: FloatArray, stable_species_index: IntegerArray, her_V: FloatArray, oer_V: FloatArray, minimum_transformed_gibbs_J_mol_metal: FloatArray | None = None, transformed_gibbs_J_mol_metal: FloatArray | None = None)
Stable species on a pH/U grid.
transformed_gibbs_J_mol_metal holds the energy of every species at every grid
point and minimum_transformed_gibbs_J_mol_metal the lowest one; both are None
for diagrams calculated with store_energies=False.
pourbase.MassBalancedPourbaixDiagram
dataclass
¶
MassBalancedPourbaixDiagram(system: MetalSystem, conditions: PourbaixConditions, total_metal: TotalMetalConcentration, activity_coefficient_model: ActivityCoefficientModel, pH: FloatArray, U_V: FloatArray, dominant_species_index: IntegerArray, precipitating_solid_index: IntegerArray, aqueous_species_indices: IntegerArray, aqueous_activity_coefficient: FloatArray, aqueous_concentration_mol_L: FloatArray, aqueous_activity: FloatArray, dissolved_metal_mol_L: FloatArray, saturation_dissolved_metal_mol_L: FloatArray, precipitated_metal_fraction: FloatArray, equilibrium_metal_chemical_potential_J_mol: FloatArray, her_V: FloatArray, oer_V: FloatArray)
Predominance and inventory grids from a closed metal balance.
stable_species_index
property
¶
The dominant species; the name matches PourbaixDiagram.
stable_species
property
¶
Return every species that dominates at one or more grid points.
aqueous_species
property
¶
Return aqueous entries in concentration-array order.
species_at ¶
Return the dominant species nearest to a requested coordinate.
state_at ¶
Return the complete equilibrium inventory nearest to one coordinate.
pourbase.MassBalancedState
dataclass
¶
MassBalancedState(pH: float, U_V: float, dominant_species: ThermodynamicSpecies, precipitating_solid: ThermodynamicSpecies | None, total_metal_mol_L: float, dissolved_metal_mol_L: float, precipitated_metal_mol_L: float, precipitated_fraction: float, aqueous_concentrations_mol_L: tuple[tuple[ThermodynamicSpecies, float], ...], aqueous_activity_coefficients: tuple[tuple[ThermodynamicSpecies, float], ...], aqueous_activities: tuple[tuple[ThermodynamicSpecies, float], ...])
Equilibrium inventory at one numerical pH/U grid point.
pourbase.PourbaixEngine ¶
Fixed-activity diagrams at the database reference state.
calculate ¶
calculate(symbol: str, conditions: PourbaixConditions, *, allow_incomplete: bool = True, energy_policy: GibbsEnergyPolicy | str = GibbsEnergyPolicy.EXPERIMENTAL_ONLY, store_energies: bool = True) -> PourbaixDiagram
Calculate a diagram; complete data are required unless allow_incomplete.
calculate_system ¶
calculate_system(system: MetalSystem, conditions: PourbaixConditions, *, allow_incomplete: bool = True, store_energies: bool = True) -> PourbaixDiagram
Calculate a previously loaded or transformed system.
pourbase.MassBalanceEngine ¶
MassBalanceEngine(database: ThermodynamicDatabase, activity_coefficient_model: ActivityCoefficientModel | None = None)
Solve aqueous speciation and solid precipitation at fixed total metal.
Protons and electrons remain open reservoirs controlled by pH and U. Water and solids have unit activity. The selected metal is conserved across dissolved species and precipitated solid. A pluggable model supplies aqueous coefficients.
calculate ¶
calculate(symbol: str, conditions: PourbaixConditions, total_metal: TotalMetalConcentration, *, allow_incomplete: bool = True, energy_policy: GibbsEnergyPolicy | str = GibbsEnergyPolicy.EXPERIMENTAL_ONLY) -> MassBalancedPourbaixDiagram
Load one elemental system and calculate its closed metal balance.
calculate_system ¶
calculate_system(system: MetalSystem, conditions: PourbaixConditions, total_metal: TotalMetalConcentration, *, allow_incomplete: bool = True) -> MassBalancedPourbaixDiagram
Calculate an already loaded or transformed metal system.
pourbase.calculate_pourbaix ¶
calculate_pourbaix(symbol: str, conditions: PourbaixConditions | None = None, *, database: ThermodynamicDatabase | str | Path | None = None, allow_incomplete: bool = True, energy_policy: GibbsEnergyPolicy | str = GibbsEnergyPolicy.EXPERIMENTAL_ONLY) -> PourbaixDiagram
Calculate a fixed-activity diagram with the bundled data by default.
pourbase.boundary_equations ¶
boundary_equations(diagram: PourbaixDiagram, database: ThermodynamicDatabase) -> tuple[BoundaryEquation, ...]
Build equations only for phase pairs adjacent on the calculated grid.
pourbase.BoundaryEquation
dataclass
¶
BoundaryEquation(left_record_id: str, right_record_id: str, left_species: str, right_species: str, reaction: str, kind: str, U_intercept_V: float | None, U_slope_V_per_pH: float | None, vertical_pH: float | None, equation: str, source_ids: tuple[str, ...])
One equilibrium between adjacent domains under the diagram conditions.
pourbase.phase_boundary_segments ¶
Line segments between unlike neighbouring cells, shaped (n, 2, 2).
pourbase.AqueousActivityModel
dataclass
¶
Ideal aqueous activities with an optional override for named species.
Override selectors are matched in the order supplied by a calculation backend. The experimental engine uses record ID, display name, and ASCII formula. The MP adapter uses entry ID, entry name, and reduced formula.
pourbase.IdealActivityCoefficientModel
dataclass
¶
Unit activity coefficients for an ideal dilute aqueous mixture.
pourbase.DaviesActivityCoefficientModel
dataclass
¶
Davies coefficients at fixed background ionic strength and 298.15 K.
Ionic strength is supplied on a molarity basis. At this model's dilute range it approximates the molality basis used by the original Davies expression. The selected metal's contribution to ionic strength is not solved because the current chemical system has no explicit supporting-electrolyte counterions.
pourbase.LigandActivityModel
dataclass
¶
Named buffered ligand reservoirs available to a calculation.
pourbase.GasFugacityModel
dataclass
¶
Ideal-gas fugacities relative to the 1 bar standard state.
Values are supplied as log10(f / 1 bar). Selectors use the same record ID, display-name, and formula lookup order as aqueous activity overrides.
pourbase.TotalMetalConcentration
dataclass
¶
Closed-system metal inventory for a mass-balance calculation.
The total is expressed as moles of the selected metal per litre of solution and includes dissolved metal plus metal assigned to precipitated phases.
pourbase.BufferedComponent
dataclass
¶
A stoichiometric amount of one independently buffered reference component.