atmodeller package

Subpackages

Submodules

atmodeller.classes module

Classes

class atmodeller.classes.EquilibriumModel(species_network: SpeciesNetwork)

Bases: object

An equilibrium model

This is the main class that the user interacts with to build equilibrium models, solve them, and retrieve the results.

Parameters:

species_network – Species network

_solver: Callable | None = None
_output: Output | None = None
_selected_solver: Literal['basic', 'robust'] = 'basic'
property output: Output
calculate_disequilibrium(*, state: ThermodynamicStateProtocol, log_number_moles: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) None

Computes the Gibbs free energy disequilibrium.

This method calculates the Gibbs free energy difference (ΔG) for each considered reaction relative to equilibrium, based on the current state of the system. A value of zero indicates a reaction at equilibrium, while positive or negative values indicate departures from equilibrium in terms of energetic favourability.

Parameters:
  • state – Thermodynamic state

  • log_number_moles – Log number of moles

solve(*, initial_log_number_moles: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray | None = None, initial_log_stability: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray | None = None, state: ThermodynamicStateProtocol | None = None, fugacity_constraints: Mapping[str, FugacityConstraintProtocol] | None = None, mass_constraints: Mapping[str, Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray] | None = None, solver_parameters: SolverParameters | None = None, solver: Literal['basic', 'robust'] = 'robust', solver_recompile: bool = False) None

Runs the nonlinear solver and initialises the output state.

This method executes the compiled equilibrium solver produced by set_solver() and stores the resulting solution for downstream processing. It optionally accepts updated planetary/environmental constraints and initial guesses for the nonlinear system. After successful convergence, an internal Output instance is created to expose number densities, activities, stabilities, and post-processed diagnostic quantities.

If set_solver() has not been called, a suitable solver will be constructed and JIT-compiled automatically. Repeated calls to solve() with compatible shapes will be fast and will reuse cached compilation artifacts.

Parameters:
  • initial_log_number_moles – Initial log number of moles. Defaults to None.

  • initial_log_stability – Initial log stability. Defaults to None.

  • state – Thermodynamic state. Defaults to None.

  • fugacity_constraints – Fugacity constraints. Defaults to None.

  • mass_constraints – Mass constraints. Defaults to None.

  • solver_parameters – Solver parameters. Defaults to None.

  • solver – Build a basic (faster compile time) or a robust (slower compile time) solver. Defaults to robust.

  • solver_recompile – Force recompilation of the solver. Defaults to False.

atmodeller.classes._broadcast_component(component: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray | None, default_value: float, dim: int, batch_size: int, name: str) ndarray[tuple[Any, ...], dtype[float64]]

Broadcasts a scalar, 1D, or 2D input array to shape (batch_size, dim).

This function standardizes inputs that may be:
  • None (in which case default_value is used),

  • a scalar (promoted to a 1D array of length dim),

  • a 1D array of shape (dim,) (broadcast across the batch),

  • or a 2D array of shape (batch_size, dim)`` (used as-is).

Parameters:
  • component – The input data (or None), representing either a scalar, 1D array, or 2D array

  • default_value – The default scalar value to use if component is None

  • dim – The number of features or dimensions per batch item

  • batch_size – The number of batch items

  • name – Name of the component (used for error messages)

Returns:

A numpy array of shape (batch_size, dim), with values broadcast as needed

Raises:

ValueError – If the input array has an unexpected shape or inconsistent dimensions

atmodeller.classes.broadcast_initial_solution(initial_log_number_moles: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray | None, initial_log_stability: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray | None, number_of_species: int, batch_size: int) Float[Array, 'batch_size solution']

Creates and broadcasts the initial solution to shape (batch_size, solution)

D = number_of_species + number_of_stability, i.e. the total number of solution quantities

Parameters:
  • initial_log_number_moles – Initial log number moles or None

  • initial_log_stability – Initial log stability or None

  • number_of_species – Number of species

  • batch_size – Batch size

Returns:

Initial solution with shape (batch_size, solution)

atmodeller.constants module

Physical and numerical constants

This module defines reference thermodynamic conditions and numerical limits.

atmodeller.constants.TEMPERATURE_REFERENCE: float = 298.15

Enthalpy reference temperature in K (\(T_r\) in the JANAF tables) [Chase, 1998, McBride et al., 2002]

atmodeller.constants.STANDARD_PRESSURE: float = 1.0

Standard state pressure in bar

atmodeller.constants.STANDARD_FUGACITY: float = 1.0

Standard fugacity for gases in bar

atmodeller.constants.GAS_STATE: str = 'g'

Suffix to identify gases as per JANAF convention for the state of aggregation

atmodeller.constants.CONDENSED_STATE: str = 'cd'

Suffix to identify condensed phases as per JANAF convention for the state of aggregation

atmodeller.constants.INITIAL_LOG_NUMBER_MOLES: float = 50.0

Initial log number of moles

Empiricially determined. This value is mid-range for Earth-like planets.

atmodeller.constants.INITIAL_LOG_STABILITY: float = -30.0

Initial log stability

Empirically determined

atmodeller.constants.LOG_NUMBER_MOLES_LOWER: float = -200.0

Lower log number of moles for a species

atmodeller.constants.LOG_NUMBER_MOLES_UPPER: float = 80.0

Upper log number of moles for a species

atmodeller.constants.LOG_STABILITY_LOWER: float = -700.0

Lower stability for a species

Derived to ensure that the exponential function exp(x) does not underflow to zero

atmodeller.constants.LOG_STABILITY_UPPER: float = 35.0

Upper stability for a species

Empirically determined.

atmodeller.constants.TAU_MAX: float = 0.001

Maximum tau scaling factor for species stability when using the tau cascade solver

atmodeller.constants.TAU: float = 1e-25

Desired (i.e. final/minimium) tau scaling factor for species stability [Leal et al., 2016].

Tau effectively controls the minimum non-zero number of moles of unstable species. Formally, it defines the number of moles of an unstable pure condensate with an activity of 1/e, which corresponds to a log stability of zero.

atmodeller.constants.TAU_NUM: int = 2

Number of tau values to solve between TAU_MAX and TAU (inclusive) for the tau cascade solver

Empirically determined. Basically, once a solution has been found for TAU_MAX the solver can immediately proceed to TAU. This usually solves within a few steps on the first attempt.

atmodeller.containers module

Containers

class atmodeller.containers.ChemicalSpecies(data: ChemicalSpeciesData, activity: ActivityProtocol, solubility: SolubilityProtocol, solve_for_stability: bool, number_solution: int)

Bases: Module

Chemical species

Parameters:
  • data – Chemical species data

  • activity – Activity

  • solubility – Solubility

  • solve_for_stability – Solve for stability

  • number_solution – Number of solution quantities

data: ChemicalSpeciesData
activity: ActivityProtocol
solubility: SolubilityProtocol
solve_for_stability: bool
number_solution: int
property name: str

Unique name by combining Hill notation and state

classmethod create_condensed(formula: str, *, state: str = 'cd', activity: ActivityProtocol = CondensateActivity(activity=f64[]), solve_for_stability: bool = True) ChemicalSpecies

Creates a condensate

Parameters:
  • formula – Formula

  • state – State of aggregation as defined by JANAF. Defaults to CONDENSED_STATE

  • activity – Activity. Defaults to unity activity.

  • True. (solve_for_stability. Solve for stability. Defaults to)

Returns:

A condensed species

classmethod create_gas(formula: str, *, state: str = 'g', activity: ActivityProtocol = IdealGas(), solubility: SolubilityProtocol = NoSolubility(), solve_for_stability: bool = False) ChemicalSpecies

Creates a gas species

Parameters:
  • formula – Formula

  • state – State of aggregation as defined by JANAF. Defaults to GAS_STATE

  • activity – Activity. Defaults to an ideal gas.

  • solubility – Solubility. Defaults to no solubility.

  • False. (solve_for_stability. Solve for stability. Defaults to)

Returns:

A gas species

_abc_impl = <_abc._abc_data object>
class atmodeller.containers.SpeciesNetwork(data: Iterable[ChemicalSpecies])

Bases: Module

A network of species

Parameters:

species – An iterable of chemical species

data: tuple[ChemicalSpecies, ...]

Chemical species data

number_solution: int

Number of solution quantities that cannot depend on traced quantities

active_stability: ndarray[tuple[Any, ...], dtype[bool]]

Active stability mask

gas_species_mask: ndarray[tuple[Any, ...], dtype[bool]]

Gas species mask

species_names: tuple[str, ...]

Unique names of all species

gas_species_names: tuple[str, ...]

Gas species names

condensed_species_names: tuple[str, ...]

Condensed species names

molar_masses: ndarray[tuple[Any, ...], dtype[float64]]

Molar masses

unique_elements: tuple[str, ...]

Unique elements in species in alphabetical order

element_molar_masses: ndarray[tuple[Any, ...], dtype[float64]]

Molar masses of the ordered elements

diatomic_oxygen_index: ndarray[tuple[Any, ...], dtype[float64]]

Index of diatomic oxygen or np.nan if not present

number_reactions: int

Number of reactions

formula_matrix: ndarray[tuple[Any, ...], dtype[int64]]

Formula matrix

reaction_matrix: ndarray[tuple[Any, ...], dtype[float64]]

Reaction matrix

active_reactions: ndarray[tuple[Any, ...], dtype[bool]]

Active reactions

classmethod create(species_names: Iterable[str]) SpeciesNetwork

Creates an instance

Parameters:

species_names – A list or tuple of species names

Returns

An instance

classmethod available_species() tuple[str, ...]
property gas_only: bool

Checks if a gas-only network

property number_species: int

Number of species

get_diatomic_oxygen_index() ndarray[tuple[Any, ...], dtype[float64]]

Gets the species index corresponding to diatomic oxygen.

Note

This returns a float array for type consistency.

Returns:

Index of diatomic oxygen, or np.nan if diatomic oxygen is not in the species

get_formula_matrix() ndarray[tuple[Any, ...], dtype[int64]]

Gets the formula matrix.

Elements are given in rows and species in columns following the convention in Leal et al. [2017].

Returns:

Formula matrix

get_reaction_dictionary() dict[int, str]

Gets reactions as a dictionary.

Returns:

Reactions as a dictionary

get_reaction_matrix() ndarray[tuple[Any, ...], dtype[float64]]

Gets the reaction matrix.

Returns:

A matrix of linearly independent reactions or an empty array if no reactions

get_temperature_range() tuple[float, float]

Gets the temperature range of the thermodynamic data for the species

Returns:

Minimum and maximum temperature that is valid for the species

_abc_impl = <_abc._abc_data object>
class atmodeller.containers.ThermodynamicState(temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, mass: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray = 1, melt_fraction: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray = 1)

Bases: Module

A generic thermodynamic state

This must adhere to ThermodynamicStateProtocol.

Note

All parameters are stored as JAX arrays (jnp.ndarray) rather than Python floats. This ensures that JAX sees a consistent type during transformations (e.g., jit, grad, vmap), preventing unnecessary recompilation when values change. In JAX, switching between a Python float and an array for the same argument will trigger retracing or recompilation, so keeping everything as arrays avoids this overhead.

Parameters:
  • temperature – Temperature in K

  • pressure – Pressure in bar

  • mass – Mass in kg. Defaults to 1 kg.

  • melt_fraction – Melt fraction by weight in kg/kg. Defaults to 1 kg/kg.

temperature: Array

Temperature in K

pressure: Array

Pressure in bar

mass: Array

Mass in kg

melt_fraction: Array

Mass fraction of melt in kg/kg

property melt_mass: Array

Mass of the melt in kg

property solid_mass: Array

Mass of the solid in kg

get_pressure(gas_mass: Array) Array

Gets the pressure.

Parameters:

gas_mass – Gas mass in kg. Unused but required by the interface.

Returns:

Pressure in bar

asdict() dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Gets a dictionary of the values as NumPy arrays.

Returns:

A dictionary of the values

_abc_impl = <_abc._abc_data object>
class atmodeller.containers.ThinAtmospherePlanet(planet_mass: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray = 5.972e+24, core_mass_fraction: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray = 0.295334691460966, mantle_melt_fraction: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray = 1.0, surface_radius: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray = 6371000, temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray = 2000, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray = nan)

Bases: Module

A planet with a thin atmosphere.

This must adhere to ThermodynamicStateProtocol.

Default values are for a fully molten Earth.

Note

All parameters are stored as JAX arrays (jnp.ndarray) rather than Python floats. This ensures that JAX sees a consistent type during transformations (e.g., jit, grad, vmap), preventing unnecessary recompilation when values change. In JAX, switching between a Python float and an array for the same argument will trigger retracing or recompilation, so keeping everything as arrays avoids this overhead.

Parameters:
  • planet_mass – Mass of the planet in kg. Defaults to 5.972e24 kg (Earth).

  • core_mass_fraction – Mass fraction of the iron core relative to the planetary mass. Defaults to 0.3 kg/kg (Earth).

  • mantle_melt_fraction – Mass fraction of the mantle that is molten. Defaults to 1.0 kg/kg.

  • surface_radius – Radius of the planetary surface in m. Defaults to 6371000 m (Earth).

  • temperature – Temperature in K. Defaults to 2000 K.

  • pressure – Pressure in bar. Defaults to np.nan to solve for the mechanical pressure balance at the surface.

planet_mass: Array

Mass of the planet in kg

core_mass_fraction: Array

Mass fraction of the core relative to the planetary mass in kg/kg

mantle_melt_fraction: Array

Mass fraction of the molten mantle in kg/kg

surface_radius: Array

Radius of the surface in m

temperature: Array

Temperature in K

pressure: Array

Pressure in bar

property mantle_mass: Array

Mantle mass

_abc_impl = <_abc._abc_data object>
property mantle_mass_fraction: Array

Mantle mass fraction

property mantle_melt_mass: Array

Mass of the molten mantle

property mantle_solid_mass: Array

Mass of the solid mantle

property surface_area: Array

Surface area

property surface_gravity: Array

Surface gravity

property mass: Array
property melt_fraction: Array
property melt_mass: Array
property solid_mass: Array
get_pressure(gas_mass: Array) Array

Gets the pressure.

A pressure is used if specified, otherwise the default behaviour is to compute the pressure from the mechanical pressure balance at the planetary surface assuming the thin atmosphere approximation. That is, the surface gravity is computed from the mass of the planet alone and is assumed to act on all the mass of the atmosphere.

Parameters:

gas_mass – Gas mass in kg

Returns:

Pressure in bar

asdict() dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Gets a dictionary of the values as NumPy arrays.

Returns:

A dictionary of the values

atmodeller.containers.Planet

alias of ThinAtmospherePlanet

class atmodeller.containers.FixedFugacityConstraint(fugacity: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray | tuple = nan)

Bases: Module

A fixed fugacity constraint

This must adhere to FugacityConstraintProtocol

Parameters:

fugacity – Fugacity in bar. Defaults to np.nan.

_abc_impl = <_abc._abc_data object>
fugacity: Array = nan

Fugacity

active() Bool[Array, '...']

Active fugacity constraint

Returns:

True if the fugacity constraint is active, otherwise False

log_fugacity(temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Float[Array, '...']
class atmodeller.containers.FugacityConstraintSet(constraints: tuple[FugacityConstraintProtocol, ...], species_network: SpeciesNetwork)

Bases: Module

A set of fugacity constraints

These are applied as constraints on the gas activity.

Parameters:
  • constraints – Fugacity constraints

  • species – Species network

_abc_impl = <_abc._abc_data object>
constraints: tuple[FugacityConstraintProtocol, ...]

Fugacity constraints

species_network: SpeciesNetwork

Species network

classmethod create(species_network: SpeciesNetwork, fugacity_constraints: Mapping[str, FugacityConstraintProtocol] | None = None) FugacityConstraintSet

Creates an instance

Parameters:
  • species_network – Species network

  • fugacity_constraints – Mapping of a species name and a fugacity constraint. Defaults to None.

Returns:

An instance

active() Bool[Array, '...']

Active fugacity constraints

Returns:

Mask indicating whether fugacity constraints are active or not

asdict(temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Gets a dictionary of the evaluated fugacity constraints as NumPy Arrays

Parameters:
  • temperature – Temperature in K

  • pressure – Pressure in bar

Returns:

A dictionary of the evaluated fugacity constraints

log_fugacity(temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Array

Log fugacity

Parameters:
  • temperature – Temperature in K

  • pressure – Pressure in bar

Returns:

Log fugacity in bar

class atmodeller.containers.MassConstraintSet(abundance: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray | tuple, species_network: SpeciesNetwork, units: Literal['mass', 'moles'] = 'mass', oxygen_column_index: int | None = None)

Bases: Module

A set of mass constraints

Note

abundance must be stored as a 2-D array so that the vmapping operation only batches over the leading dimension if it has a size greater than unity. Then, the methods that process abundance consistently return 1-D arrays, shape (elements,), to avoid triggering JAX recompilation.

Parameters:
  • abundance – Abundance

  • species – Species

  • units – Units of the abundance. Defaults to mass.

_abc_impl = <_abc._abc_data object>
abundance: Float[Array, '...']

Abundance

species_network: SpeciesNetwork

Species network

units: Literal['mass', 'moles'] = 'mass'

Units of the abundance

oxygen_column_index: int | None = None

Column index of oxygen in abundance. Defaults to None.

classmethod create(species_network: SpeciesNetwork, mass_constraints: Mapping[str, Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray] | None = None, units: Literal['mass', 'moles'] = 'mass') MassConstraintSet

Creates an instance

Parameters:
  • species_network – Species network

  • mass_constraints – Mapping of element name and mass constraint in units. Defaults to None.

  • units – Units of the abundance. Defaults to mass.

Returns:

An instance

abundance_mol() Float[Array, '...']

Abundance by moles for all elements

Returns:

Abundance by moles for all elements

abundance_mass() Float[Array, '...']

Abundance by mass for all elements

Returns:

Abundance by mass for all elements

log_abundance() Float[Array, '...']

Element abundances in log-space

abundance is stored as a 2-D array with shape (batch, elements) so that vmap only maps over the leading dimension when batching is active. When called inside a vmap, each mapped instance receives a single row of the abundance matrix, i.e. an array of shape (elements,). When called outside vmap, abundance has shape (1, elements) and must be reduced to a consistent 1-D vector.

If the batch dimension is greater than one and the method is called outside a vmapped workflow, the full 2-D log-abundance array is returned unchanged. This preserves the natural behaviour for genuinely batched data while still collapsing the leading singleton dimension in unbatched use.

Returns:

Log abundance by moles for all elements

asdict() dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Gets a dictionary of the values as NumPy arrays

Returns:

A dictionary of the values

active() Bool[Array, '...']

Active mass constraints

Returns:

Mask indicating whether elemental mass constraints are active or not

class atmodeller.containers.SolverParameters(solver: type[AbstractRootFinder | AbstractLeastSquaresSolver | AbstractMinimiser] = <class 'optimistix._solver.newton_chord.Newton'>, atol: float = 1e-06, rtol: float = 1e-06, linear_solver: AbstractLinearSolver = AutoLinearSolver(well_posed=None), norm: Callable = <function max_norm>, throw: bool = False, max_steps: int = 256, jac: Literal['fwd', 'bwd']='fwd', multistart: int = 10, multistart_perturbation: float = 30.0, tau: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray | tuple = 1e-25)

Bases: RootFindParameters

Solver parameters

Parameters:
  • solver – Solver. Defaults to optimistix.Newton.

  • atol – Absolute tolerance. Defaults to 1.0e-6.

  • rtol – Relative tolerance. Defaults to 1.0e-6.

  • linear_solver – Linear solver. Defaults to AutoLinearSolver(well_posed=False).

  • norm – Norm. Defaults to optimistix.max_norm().

  • throw – How to report any failures. Defaults to False.

  • max_steps – The maximum number of steps the solver can take. Defaults to 256.

  • jac – Whether to use forward- or reverse-mode autodifferentiation to compute the Jacobian. Can be either fwd or bwd. Defaults to fwd.

  • multistart – Number of multistarts. Defaults to 10.

  • multistart_perturbation – Perturbation for multistart. Defaults to 30.

  • tau – Tau factor for species stability. Defaults to TAU.

_abc_impl = <_abc._abc_data object>
atol: float = 1e-06

Absolute tolerance

get_solver_instance() AbstractRootFinder | AbstractLeastSquaresSolver | AbstractMinimiser

Instantiates the solver

jac: Literal['fwd', 'bwd'] = 'fwd'

Whether to use forward- or reverse-mode autodifferentiation to compute the Jacobian

linear_solver: AbstractLinearSolver = AutoLinearSolver(well_posed=None)

//docs.kidger.site/lineax/api/solvers/)

Type:

Linear solver (see https

max_steps: int = 256

Maximum number of steps the solver can take

norm() Shaped[Array, '']

Compute the L-infinity norm of a PyTree of arrays.

This is the largest absolute elementwise value. Considering the input x as a flat vector (x_1, …, x_n), then this computes max_i |x_i|.

rtol: float = 1e-06

Relative tolerance

solver

alias of Newton

throw: bool = False

How to report any failures

multistart: int = 10

Number of multistarts

multistart_perturbation: float = 30.0

Perturbation for multistart

tau: Array = 1e-25

Tau factor for species stability

get_options(number_species: int) dict[str, Any]

Gets the solver options.

Parameters:

number_species – Number of species

Returns:

Solver options

_get_lower_bound(number_species: int) Float[Array, 'dim']

Gets the lower bound for truncating the solution during the solve.

Parameters:

number_species – Number of species

Returns:

Lower bound for truncating the solution during the solve

_get_upper_bound(number_species: int) Float[Array, 'dim']

Gets the upper bound for truncating the solution during the solve.

Parameters:

number_species – Number of species

Returns:

Upper bound for truncating the solution during the solve

_get_hypercube_bound(number_species: int, log_number_moles_bound: float, stability_bound: float) Float[Array, 'dim']

Gets the bound on the hypercube.

Parameters:
  • number_species – Number of species

  • log_number_moles_bound – Bound on the log number of moles

  • stability_bound – Bound on the stability

Returns:

Bound on the hypercube that contains the root

class atmodeller.containers.Parameters

Bases: Module

Parameters:
  • species – Species network

  • state – Thermodynamic state

  • fugacity_constraints – Fugacity constraints

  • mass_constraints – Mass constraints

  • solver_parameters – Solver parameters

  • batch_size – Batch size. Defaults to 1.

_abc_impl = <_abc._abc_data object>
species_network: SpeciesNetwork

Species

state: ThermodynamicStateProtocol

Thermodynamic state

fugacity_constraints: FugacityConstraintSet

Fugacity constraints

mass_constraints: MassConstraintSet

Mass constraints

solver_parameters: SolverParameters

Solver parameters

batch_size: int = 1

Batch size

classmethod create(species_network: SpeciesNetwork, state: ThermodynamicStateProtocol | None = None, fugacity_constraints: Mapping[str, FugacityConstraintProtocol] | None = None, mass_constraints: Mapping[str, Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray] | None = None, solver_parameters: SolverParameters | None = None)

Creates an instance

Parameters:
  • species_network – Species network

  • state – Thermodynamic state. Defaults to a new instance of Planet.

  • fugacity_constraints – Mapping of a species name and a fugacity constraint. Defaults to a new instance of FugacityConstraints.

  • mass_constraints – Mapping of element name and mass constraint in kg. Defaults to a new instance of MassConstraints.

  • solver_parameters – Solver parameters. Defaults to a new instance of SolverParameters.

Returns:

An instance

atmodeller.engine module

JAX-based model functions for atmospheric and chemical equilibrium calculations.

This module defines the core set of single-instance model functions (e.g., thermodynamic property calculations, equation-of-state relations, reaction masks) that operate on a single set of inputs, without any implicit batching.

These functions form the building blocks for solving the coupled system of equations governing the model (e.g., mass balance, fugacity constraints, phase stability), and are intended to be:

  1. Pure: No side effects, deterministic outputs for given inputs.

  2. JAX-compatible: Written with jax.numpy and compatible with transformations such as jit, grad, and vmap.

  3. Shape-consistent: Accept and return arrays with predictable shapes, enabling easy vectorisation.

In practice, these functions are rarely called directly in production code. Instead, they are wrapped with equinox.filter_vmap() to enable efficient batched evaluation over multiple scenarios or parameter sets.

atmodeller.engine.get_active_mask(parameters: Parameters) Bool[Array, 'dim']

Gets the mask of active residual quantities.

Parameters:

parameters – Parameters

Returns:

Active mask

atmodeller.engine.get_atmosphere_log_molar_mass(parameters: Parameters, log_number_moles: Float[Array, 'species']) Float[Array, '']

Gets the log molar mass of the atmosphere.

Parameters:
  • parameters – Parameters

  • log_number_moles – Log number of moles

Returns:

Log molar mass of the atmosphere

atmodeller.engine.get_element_moles(parameters: Parameters, log_number_moles: Float[Array, 'species']) Float[Array, 'elements']

Gets the number of moles of elements in the gas or condensed phase.

Input values are sanitised only for output routines, where partitioning between condensed and gas species is required. For the solver itself, this distinction is unnecessary.

Parameters:
  • parameters – Parameters

  • log_number_moles – Log number of moles

Returns:

Number of moles of elements in the gas or condensed phase

atmodeller.engine.get_element_moles_in_melt(parameters: Parameters, log_number_moles: Float[Array, 'species']) Float[Array, 'species']

Gets the number of moles of elements dissolved in melt.

Parameters:
  • parameters – Parameters

  • log_number_moles – Log number of moles

Returns:

Number of moles of elements dissolved in melt

atmodeller.engine.get_gas_species_data(parameters: Parameters, some_array: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Shaped[Array, 'species']

Masks the gas species data from an array.

Parameters:
  • parameters – Parameters

  • some_array – Some array to mask the gas species data from

Returns:

An array with gas species data from some_array and condensate entries zeroed

atmodeller.engine.get_log_mole_fraction_in_gas(parameters: Parameters, log_number_moles: Float[Array, 'species']) Float[Array, 'species']

Gets the log mole fraction of the species in the gas phase

Parameters:
  • parameters – Parameters

  • log_number_moles – Log number of moles

Returns:

Log mole fraction in the gas

atmodeller.engine.get_log_activity(parameters: Parameters, log_number_moles: Float[Array, 'species']) Float[Array, 'species']

Gets the log activity.

Parameters:
  • parameters – Parameters

  • log_number_moles – Log number of moles

Returns:

Log activity

atmodeller.engine.get_log_activity_pure_species(parameters: Parameters, log_number_moles: Float[Array, 'species']) Float[Array, 'species']

Gets the log activity of pure species.

Parameters:
  • parameters – Parameters

  • log_number_moles – Log number of moles

Returns:

Log activity of pure species

atmodeller.engine.get_log_Kp(parameters: Parameters) Float[Array, 'reactions']

Gets log of the equilibrium constant of each reaction in terms of partial pressures.

Parameters:

parameters – Parameters

Returns:

Log of the equilibrium constant of each reaction in terms of partial pressures

atmodeller.engine.get_min_log_elemental_abundance_per_species(parameters: Parameters) Float[Array, 'species']

For each species, find the elemental mass constraint with the lowest abundance.

Parameters:

parameters – Parameters

Returns:

A vector of the minimum log elemental abundance for each species

atmodeller.engine.get_reactions_only_mask(parameters: Parameters) Bool[Array, 'dim']

Returns a mask with True only for active reactions positions, False elsewhere.

Parameters:

parameters – Parameters

Returns:

Reactions only mask for the residual array

atmodeller.engine.get_species_moles_in_melt(parameters: Parameters, log_number_moles: Float[Array, 'species']) Float[Array, 'species']

Gets the number of moles of species dissolved in melt due to species solubility.

Parameters:
  • parameters – Parameters

  • log_number_moles – Log number of moles

Returns:

Number of moles of species dissolved in melt

atmodeller.engine.get_species_ppmw_in_melt(parameters: Parameters, log_number_moles: Float[Array, 'species']) Float[Array, 'species']

Gets the ppmw of species dissolved in melt.

Parameters:
  • parameters – Parameters

  • log_number_moles – Log number of moles

Returns:

ppmw of species dissolved in melt

atmodeller.engine.get_gas_mass(parameters: Parameters, log_number_moles: Float[Array, 'species']) Float[Array, '']

Gets the gas mass.

Parameters:
  • parameters – Parameters

  • log_number_moles – Log number of moles

Returns:

Gas mass

atmodeller.engine.get_total_pressure(parameters: Parameters, log_number_moles: Float[Array, 'species']) Float[Array, '']

Gets the total pressure.

Parameters:
  • parameters – Parameters

  • log_number_moles – Log number of moles

Returns:

Total pressure in bar

atmodeller.engine.objective_function(solution: Float[Array, 'solution'], parameters: Parameters) Float[Array, 'residual']

Objective function

The order of the residual does make a difference to the solution process. More investigations are necessary, but justification for the current ordering is as follows:

  1. Fugacity constraints - fixed target, well conditioned

  2. Reaction constraints - log-linear, physics-based coupling

  3. Mass balance constraints - stiffer, depends on solubility

  4. Stability constraints - stiffer still

Parameters:
  • solution – Solution array for all species i.e. log number of moles and log stability

  • parameters – Parameters

Returns:

Residual

atmodeller.engine_vmap module

Vmapped wrappers for core engine functions.

This module provides a high-level container (VmappedFunctions) that precompiles vectorised versions of key thermodynamic and mass-balance functions. By wrapping each function with equinox.filter_vmap(), the module ensures efficient batched evaluation of model properties.

Currently, these wrappers are used primarily as a convenience for generating and inspecting outputs. They are not responsible for performing the actual equilibrium solution, which is instead handled by the solvers module.

class atmodeller.engine_vmap.VmappedFunctions(parameters: Parameters)

Bases: object

Container for precompiled vmap-ped model functions.

This class wraps a set of model functions (e.g., thermodynamic property calculations, reaction masks, etc.) with equinox.filter_vmap() so they can be evaluated efficiently over batched inputs.

The primary assumption is that log_number_moles inputs are already batched along axis 0. The in_axes specifications for all vmap calls are precomputed at initialisation from the provided parameters object, ensuring consistent vectorisation behavior across all functions.

Each wrapped function is stored as a bound method and internally calls a preconstructed vmap object. This minimizes tracing overhead and avoids recomputing in_axes specs for each call.

Parameters:

parameters – Parameters

parameters: Parameters
_get_atmosphere_log_molar_mass: Callable
_get_element_moles: Callable
_get_element_moles_in_melt: Callable
_get_log_activity: Callable
_get_reactions_only_mask: Callable
_get_species_moles_in_melt: Callable
_get_species_ppmw_in_melt: Callable
_get_total_pressure: Callable
_objective_function_vmap: Callable
get_atmosphere_log_molar_mass(log_number_moles: Array) Array
get_element_moles(log_number_moles: Array) Array
get_element_moles_in_melt(log_number_moles: Array) Array
get_log_activity(log_number_moles: Array) Array
get_reactions_only_mask() Array
get_species_moles_in_melt(log_number_moles: Array) Array
get_species_ppmw_in_melt(log_number_moles: Array) Array
get_total_pressure(log_number_moles: Array) Array
objective_function(solution: Array) Array

atmodeller.interfaces module

Interfaces for thermodynamic models and constraints.

This module defines formal protocol classes (via typing.Protocol) that specify the expected interfaces for different thermodynamic components.

class atmodeller.interfaces.ActivityProtocol(*args, **kwargs)

Bases: Protocol

log_activity(temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray
log_fugacity(temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray
_abc_impl = <_abc._abc_data object>
_is_protocol = True
_is_runtime_protocol = True
class atmodeller.interfaces.FugacityConstraintProtocol(*args, **kwargs)

Bases: Protocol

active() Bool[Array, '...']
log_fugacity(temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray
_abc_impl = <_abc._abc_data object>
_is_protocol = True
_is_runtime_protocol = True
class atmodeller.interfaces.RedoxBufferProtocol(*args, **kwargs)

Bases: FugacityConstraintProtocol, Protocol

evaluation_pressure: float | None
property log10_shift: Array
log10_fugacity_buffer(temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Array
log10_fugacity(temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Array
_abc_impl = <_abc._abc_data object>
_is_protocol = True
_is_runtime_protocol = True
active() Bool[Array, '...']
log_fugacity(temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray
class atmodeller.interfaces.SolubilityProtocol(*args, **kwargs)

Bases: Protocol

Solubility protocol

jax_concentration() is defined in order to allow arguments to be passed by position to lax.switch.

concentration(fugacity: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, *, temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray | None = None, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray | None = None, fO2: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray | None = None) Array
jax_concentration(fugacity: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, temperature: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, pressure: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray, fO2: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray) Array
_abc_impl = <_abc._abc_data object>
_is_protocol = True
_is_runtime_protocol = True
class atmodeller.interfaces.ThermodynamicStateProtocol(*args, **kwargs)

Bases: Protocol

property mass: Array
property melt_fraction: Array
property melt_mass: Array
property solid_mass: Array
property temperature: Array
get_pressure(gas_mass: Array) Array
asdict() dict
_abc_impl = <_abc._abc_data object>
_is_protocol = True
_is_runtime_protocol = True

atmodeller.output module

Output

class atmodeller.output.OutputDisequilibrium(parameters: Parameters, solution: Float[Array, 'batch solution'])

Bases: Output

Output disequilibrium calculations

Parameters:
  • parameters – Parameters

  • solution – Solution

asdict() dict[str, dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]]

All outputs in a dictionary, with caching.

Additionally includes the disequilibrium group, compared to the base class.

Returns:

Dictionary of all output

disequilibrium_asdict() dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Gets the reaction disequilibrium as a dictionary.

Returns:

Reaction disequilibrium as a dictionary

_get_number_moles_output(number_moles: ndarray[tuple[Any, ...], dtype[_ScalarT]], molar_mass_expanded: ndarray[tuple[Any, ...], dtype[_ScalarT]], prefix: str = '') dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Gets the outputs associated with a given number of moles.

Parameters:
  • number_moles – Number of moles. Shape must be 2-D.

  • molar_mass_expanded – Molar mass associated with the number of moles. Shape must be 2-D.

  • prefix – Key prefix for the output. Defaults to an empty string.

Returns

Dictionary of output quantities

activity() ndarray[tuple[Any, ...], dtype[float64]]

Gets the activity of all species.

Returns:

Activity of all species

activity_without_stability() ndarray[tuple[Any, ...], dtype[float64]]

Gets the activity without stability of all species.

Returns:

Activity without stability of all species

condensed_species_asdict(molar_mass: ndarray[tuple[Any, ...], dtype[_ScalarT]], number_moles: ndarray[tuple[Any, ...], dtype[_ScalarT]], activity: ndarray[tuple[Any, ...], dtype[_ScalarT]]) dict[str, dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]]

Gets the condensed species output as a dictionary.

Parameters:
  • molar_mass – Molar mass of all species

  • number_moles – Number of moles of all species

  • activity – Activity of all species

Returns:

Condensed species output as a dictionary

property condensed_species_mask: ndarray[tuple[Any, ...], dtype[bool]]

Mask of condensed species

element_molar_mass_expanded() ndarray[tuple[Any, ...], dtype[float64]]

Gets molar mass of elements.

Returns:

Molar mass of elements

element_moles_condensed() ndarray[tuple[Any, ...], dtype[float64]]

Gets the number of moles of elements in the condensed phase.

Returns:

Number of moles of elements in the condensed phase

element_moles_dissolved() ndarray[tuple[Any, ...], dtype[float64]]

Gets the number of moles of elements dissolved in melt due to species solubility.

Returns:

Number of moles of elements dissolved in melt due to species solubility

element_moles_gas() ndarray[tuple[Any, ...], dtype[float64]]

Gets the number of moles of elements in the gas phase.

Returns:

Number of moles of elements in the gas phase

elements_asdict() dict[str, dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]]

Gets the element properties as a dictionary.

Returns:

Element outputs as a dictionary

gas_asdict() dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Gets the gas properties.

Returns:

Gas properties

gas_log_molar_mass() ndarray[tuple[Any, ...], dtype[float64]]

Gets log molar mass of the gas.

Returns:

Log molar mass of the gas

gas_molar_mass() ndarray[tuple[Any, ...], dtype[_ScalarT]]

Gets the molar mass of the gas.

Returns:

Molar mass of the gas

gas_species_asdict(molar_mass: ndarray[tuple[Any, ...], dtype[_ScalarT]], number_moles: ndarray[tuple[Any, ...], dtype[_ScalarT]], activity: ndarray[tuple[Any, ...], dtype[_ScalarT]]) dict[str, dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]]

Gets the gas species output as a dictionary.

Parameters:
  • molar_mass – Molar mass of all species

  • number_moles – Number of moles of all species

  • activity – Activity of all species

Returns:

Gas species output as a dictionary

property gas_species_mask: ndarray[tuple[Any, ...], dtype[bool]]

Mask of gas species

ideal_gas_volume() ndarray[tuple[Any, ...], dtype[float64]]

Gets the volume of the gas assuming it is ideal.

Returns:

Volume of the gas

log_activity() ndarray[tuple[Any, ...], dtype[float64]]

Gets log activity of all species.

This is usually what the user wants when referring to activity because it includes a consideration of species stability

Returns:

Log activity of all species

log_activity_without_stability() ndarray[tuple[Any, ...], dtype[float64]]

Gets log activity without stability of all species.

Returns:

Log activity without stability

property molar_mass: ndarray[tuple[Any, ...], dtype[float64]]

Molar mass of all species

property number_moles: ndarray[tuple[Any, ...], dtype[float64]]

Number of moles of all species

property number_solutions: int

Number of solutions

pressure() ndarray[tuple[Any, ...], dtype[float64]]

Gets pressure of species in bar.

This will compute pressure of all species, including condensates, for simplicity.

Returns:

Pressure of species in bar

quick_look() dict[str, Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray]

Quick look at the solution

Provides a quick first glance at the output with convenient units and to ease comparison with test or benchmark data.

Returns:

Dictionary of the solution

raw_solution_asdict() dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Gets the raw solution.

Returns:

Dictionary of the raw solution

reaction_mask() ndarray[tuple[Any, ...], dtype[bool]]

Gets the reaction mask of the residual array.

Returns:

Reaction mask of the residual array

residual_asdict() dict[int, ndarray[tuple[Any, ...], dtype[float64]]]

Gets the residual.

Returns:

Dictionary of the residual

property species: SpeciesNetwork

Species

species_molar_mass_expanded() ndarray[tuple[Any, ...], dtype[float64]]

Gets molar mass of all species in an expanded array.

Returns:

Molar mass of all species in an expanded array.

species_number_moles_in_melt() ndarray[tuple[Any, ...], dtype[float64]]

Gets species number of moles in the melt.

Returns:

Species number of moles in the melt

species_ppmw_in_melt() ndarray[tuple[Any, ...], dtype[float64]]

Gets species ppmw in the melt.

Returns:

Species ppmw in the melt

stability() ndarray[tuple[Any, ...], dtype[float64]]

Gets stability of relevant species.

Returns:

Stability of relevant species

property state: ThermodynamicStateProtocol

Thermodynamic state

property temperature: ndarray[tuple[Any, ...], dtype[float64]]

Temperature

to_dataframes() dict[str, DataFrame]

Gets the output in a dictionary of dataframes.

Returns:

Output in a dictionary of dataframes

to_excel(file_prefix: Path | str = 'atmodeller_out') None

Writes the output to an Excel file.

Parameters:

file_prefix – Prefix of the output file. Defaults to atmodeller_out.

to_pickle(file_prefix: Path | str = 'atmodeller_out') None

Writes the output to a pickle file.

Parameters:

file_prefix – Prefix of the output file. Defaults to atmodeller_out.

total_pressure() ndarray[tuple[Any, ...], dtype[float64]]

Gets total pressure.

Returns:

Total pressure

class atmodeller.output.OutputSolution(parameters: Parameters, solution: Float[Array, 'batch solution'], multi_attempt_solution: MultiAttemptSolution)

Bases: Output

Output equilibrium solution(s)

Parameters:
  • parameters – Parameters

  • solution – Solution

  • multi_attempt_solutionMultiAttemptSolution object

asdict() dict[str, dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]]

All outputs in a dictionary, with caching.

Returns:

Dictionary of all output

to_dataframes(drop_unsuccessful: bool = False) dict[str, DataFrame]

Gets the output in a dictionary of dataframes.

Parameters:

drop_unsuccessful – Drop models that did not solve. Defaults to False.

Returns:

Output in a dictionary of dataframes

to_excel(file_prefix: Path | str = 'atmodeller_out', drop_unsuccessful: bool = False) None

Writes the output to an Excel file.

Compared to the base class, this highlights rows where the solver failed to find a a solution if drop_successful = False.

Parameters:
  • file_prefix – Prefix of the output file. Defaults to atmodeller_out.

  • drop_unsuccessful – Drop models that did not solve. Defaults to False.

to_pickle(file_prefix: Path | str = 'atmodeller_out', drop_unsuccessful: bool = False) None

Writes the output to a pickle file.

Parameters:
  • file_prefix – Prefix of the output file. Defaults to atmodeller_out.

  • drop_unsuccessful – Drop models that did not solve. Defaults to False.

_drop_unsuccessful_solves(dataframes: dict[str, DataFrame]) dict[str, DataFrame]

Drops unsuccessful solves.

Parameters:

dataframes – Dataframes from which to drop unsuccessful models

Returns:

Dictionary of dataframes without unsuccessful models

_get_number_moles_output(number_moles: ndarray[tuple[Any, ...], dtype[_ScalarT]], molar_mass_expanded: ndarray[tuple[Any, ...], dtype[_ScalarT]], prefix: str = '') dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Gets the outputs associated with a given number of moles.

Parameters:
  • number_moles – Number of moles. Shape must be 2-D.

  • molar_mass_expanded – Molar mass associated with the number of moles. Shape must be 2-D.

  • prefix – Key prefix for the output. Defaults to an empty string.

Returns

Dictionary of output quantities

activity() ndarray[tuple[Any, ...], dtype[float64]]

Gets the activity of all species.

Returns:

Activity of all species

activity_without_stability() ndarray[tuple[Any, ...], dtype[float64]]

Gets the activity without stability of all species.

Returns:

Activity without stability of all species

condensed_species_asdict(molar_mass: ndarray[tuple[Any, ...], dtype[_ScalarT]], number_moles: ndarray[tuple[Any, ...], dtype[_ScalarT]], activity: ndarray[tuple[Any, ...], dtype[_ScalarT]]) dict[str, dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]]

Gets the condensed species output as a dictionary.

Parameters:
  • molar_mass – Molar mass of all species

  • number_moles – Number of moles of all species

  • activity – Activity of all species

Returns:

Condensed species output as a dictionary

property condensed_species_mask: ndarray[tuple[Any, ...], dtype[bool]]

Mask of condensed species

element_molar_mass_expanded() ndarray[tuple[Any, ...], dtype[float64]]

Gets molar mass of elements.

Returns:

Molar mass of elements

element_moles_condensed() ndarray[tuple[Any, ...], dtype[float64]]

Gets the number of moles of elements in the condensed phase.

Returns:

Number of moles of elements in the condensed phase

element_moles_dissolved() ndarray[tuple[Any, ...], dtype[float64]]

Gets the number of moles of elements dissolved in melt due to species solubility.

Returns:

Number of moles of elements dissolved in melt due to species solubility

element_moles_gas() ndarray[tuple[Any, ...], dtype[float64]]

Gets the number of moles of elements in the gas phase.

Returns:

Number of moles of elements in the gas phase

elements_asdict() dict[str, dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]]

Gets the element properties as a dictionary.

Returns:

Element outputs as a dictionary

gas_asdict() dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Gets the gas properties.

Returns:

Gas properties

gas_log_molar_mass() ndarray[tuple[Any, ...], dtype[float64]]

Gets log molar mass of the gas.

Returns:

Log molar mass of the gas

gas_molar_mass() ndarray[tuple[Any, ...], dtype[_ScalarT]]

Gets the molar mass of the gas.

Returns:

Molar mass of the gas

gas_species_asdict(molar_mass: ndarray[tuple[Any, ...], dtype[_ScalarT]], number_moles: ndarray[tuple[Any, ...], dtype[_ScalarT]], activity: ndarray[tuple[Any, ...], dtype[_ScalarT]]) dict[str, dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]]

Gets the gas species output as a dictionary.

Parameters:
  • molar_mass – Molar mass of all species

  • number_moles – Number of moles of all species

  • activity – Activity of all species

Returns:

Gas species output as a dictionary

property gas_species_mask: ndarray[tuple[Any, ...], dtype[bool]]

Mask of gas species

ideal_gas_volume() ndarray[tuple[Any, ...], dtype[float64]]

Gets the volume of the gas assuming it is ideal.

Returns:

Volume of the gas

log_activity() ndarray[tuple[Any, ...], dtype[float64]]

Gets log activity of all species.

This is usually what the user wants when referring to activity because it includes a consideration of species stability

Returns:

Log activity of all species

log_activity_without_stability() ndarray[tuple[Any, ...], dtype[float64]]

Gets log activity without stability of all species.

Returns:

Log activity without stability

property molar_mass: ndarray[tuple[Any, ...], dtype[float64]]

Molar mass of all species

property number_moles: ndarray[tuple[Any, ...], dtype[float64]]

Number of moles of all species

property number_solutions: int

Number of solutions

pressure() ndarray[tuple[Any, ...], dtype[float64]]

Gets pressure of species in bar.

This will compute pressure of all species, including condensates, for simplicity.

Returns:

Pressure of species in bar

quick_look() dict[str, Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray]

Quick look at the solution

Provides a quick first glance at the output with convenient units and to ease comparison with test or benchmark data.

Returns:

Dictionary of the solution

raw_solution_asdict() dict[str, ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Gets the raw solution.

Returns:

Dictionary of the raw solution

reaction_mask() ndarray[tuple[Any, ...], dtype[bool]]

Gets the reaction mask of the residual array.

Returns:

Reaction mask of the residual array

residual_asdict() dict[int, ndarray[tuple[Any, ...], dtype[float64]]]

Gets the residual.

Returns:

Dictionary of the residual

property species: SpeciesNetwork

Species

species_molar_mass_expanded() ndarray[tuple[Any, ...], dtype[float64]]

Gets molar mass of all species in an expanded array.

Returns:

Molar mass of all species in an expanded array.

species_number_moles_in_melt() ndarray[tuple[Any, ...], dtype[float64]]

Gets species number of moles in the melt.

Returns:

Species number of moles in the melt

species_ppmw_in_melt() ndarray[tuple[Any, ...], dtype[float64]]

Gets species ppmw in the melt.

Returns:

Species ppmw in the melt

stability() ndarray[tuple[Any, ...], dtype[float64]]

Gets stability of relevant species.

Returns:

Stability of relevant species

property state: ThermodynamicStateProtocol

Thermodynamic state

property temperature: ndarray[tuple[Any, ...], dtype[float64]]

Temperature

total_pressure() ndarray[tuple[Any, ...], dtype[float64]]

Gets total pressure.

Returns:

Total pressure

atmodeller.solvers module

Non-linear solvers for chemical equilibrium and parameterised systems

This module provides JAX-compatible solver utilities for efficiently handling both single-system and batched systems of non-linear equations. The solvers are designed to integrate seamlessly with JAX transformations and support Equinox-based pytrees for flexible parameter handling.

atmodeller.solvers.make_objective_function_vmapped(parameters: Parameters) Callable

Gets a vmapped, JIT-compiled objective function.

Parameters:

parameters – Parameters

Returns:

Callable

atmodeller.solvers.solve_single_system(initial_guess: Float[Array, '...'], parameters: Parameters, objective_function: Callable) Solution

Solves a single system.

Parameters:
  • initial_guess – Initial guess for the solution

  • parameters – Parameters

  • objective_function – Callable returning the residual

Returns:

Solution object

atmodeller.solvers.make_independent_solver(parameters: Parameters) Callable

Gets a vmapped, JIT-compiled solver for independent batch systems.

Wraps solve_single_system() with equinox.filter_vmap() and equinox.filter_jit() so that it can solve multiple independent systems in a batch efficiently. Each batch element is solved separately, producing per-element convergence statistics.

Parameters:

parameters – Parameters

Returns:

Callable that returns a MultiAttemptSolution object

atmodeller.solvers.make_batch_solver(parameters: Parameters) Callable

Gets a JIT-compiled solver for batched systems treated as a single problem.

Parameters:

parameters – Parameters

Returns:

Callable that returns a MultiAttemptSolution object

atmodeller.solvers.make_tau_sweep_solver(solver_function: Callable, objective_function: Callable) Callable

Makes a tau sweep solver.

solver_function and objective_function must support batch evaluations.

Parameters:
  • solver_function – Callable for the solver function

  • objective_function – Callable for the objective function

Returns:

Callable

atmodeller.solvers.make_solver(parameters: Parameters) Callable

Solver function with JIT compilation. Handles multistart stability and generic solvers.

Parameters:

parameters – Parameters

Returns:

Solver

atmodeller.type_aliases module

Common type aliases

This module centralizes type definitions for NumPy arrays, scalar values, and Optimistix solvers. Having a single place for these aliases improves readability and consistency across the codebase, whilst also simplifying type checking and documentation.

atmodeller.utilities module

General utilities

This module is designed to have minimal dependencies on the core Atmodeller package, as its functionality is broadly applicable across different parts of the codebase. Keeping this module lightweight also helps avoid circular imports.

class atmodeller.utilities.ExperimentalCalibration(temperature_min: int | float | None = None, temperature_max: int | float | None = None, pressure_min: int | float | None = None, pressure_max: int | float | None = None, log10_fO2_min: int | float | None = None, log10_fO2_max: int | float | None = None)

Bases: Module

Experimental calibration

Parameters:
  • temperature_min – Minimum calibrated temperature. Defaults to None.

  • temperature_max – Maximum calibrated temperature. Defaults to None.

  • pressure_min – Minimum calibrated pressure. Defaults to None.

  • pressure_max – Maximum calibrated pressure. Defaults to None.

  • log10_fO2_min – Minimum calibrated \(\log_{10} f\rm{O}_2\). Defaults to None.

  • log10_fO2_max – Maximum calibrated \(\log_{10} f\rm{O}_2\). Defaults to None.

_abc_impl = <_abc._abc_data object>
temperature_min: float | None = None

Minimum calibrated temperature

temperature_max: float | None = None

Maximum calibrated temperature

pressure_min: float | None = None

Minimum calibrated pressure

pressure_max: float | None = None

Maximum calibrated pressure

log10_fO2_min: float | None = None

Minimum calibrated \(\log_{10} f\rm{O}_2\)

log10_fO2_max: float | None = None

Maximum calibrated \(\log_{10} f\rm{O}_2\)

atmodeller.utilities.bulk_silicate_earth_abundances() dict[str, dict[str, float]]

Bulk silicate Earth element masses in kg

Hydrogen, carbon, and nitrogen from Sakuraba et al. [2021], sulfur from Hirschmann [2016], and chlorine from Kendrick et al. [2017]

Returns:

A dictionary of Earth BSE element masses in kg

atmodeller.utilities.earth_oceans_to_hydrogen_mass(number_of_earth_oceans: Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray = 1) Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray

Converts Earth oceans to hydrogen mass.

Parameters:

number_of_earth_oceans – Number of Earth oceans. Defaults to 1 kg.

Returns:

Hydrogen mass in kg

Module contents

Package level variables and initialises the package logger

atmodeller.complex_formatter() Formatter

Complex formatter

atmodeller.simple_formatter() Formatter

Simple formatter for logging

Returns:

Formatter for logging

atmodeller.debug_logger() Logger

Sets up debug logging to the console.

Returns:

A logger

atmodeller.debug_file_logger() Logger

Sets up info logging to the console and debug logging to a file.

Returns:

A logger