aquakin.SpatialConditions#

class aquakin.SpatialConditions(fields=<factory>)[source]#

Bases: object

Container for spatially varying condition fields.

Each entry in fields is a JAX array of shape (n_locations,) giving the value of that field at each spatial location. Reactors index into these arrays with loc_idx at runtime.

Variables:

fields (dict[str, jnp.ndarray]) – Mapping from field name (e.g. "pH") to a 1-D JAX array.

Parameters:

fields (dict[str, Array])

__init__(fields=<factory>)#
Parameters:

fields (dict[str, Array])

Return type:

None

Methods

__init__([fields])

uniform([n_locations])

Build a spatially homogeneous SpatialConditions object.

validate_required(required)

Raise ValueError if any required field is missing.

with_(**kwargs)

Return a copy with some fields overridden (or added).

Attributes

n_locations

Number of spatial locations represented.

fields

property n_locations: int#

Number of spatial locations represented.

classmethod uniform(n_locations=1, **kwargs)[source]#

Build a spatially homogeneous SpatialConditions object.

Parameters:
  • n_locations (int, optional) – Number of spatial locations (default 1). Must be at least 1; the default suits a 0-D batch reactor, so a batch user writes SpatialConditions.uniform(pH=7.5, T=293.15). For the 0-D case the OperatingConditions alias reads more naturally still.

  • **kwargs (float) – Field name -> scalar value. The scalar is broadcast to (n_locations,).

Return type:

SpatialConditions

with_(**kwargs)[source]#

Return a copy with some fields overridden (or added).

The common edit-from-defaults pattern: start from model.default_conditions() and change only what differs, e.g.:

conditions = model.default_conditions().with_(T=283.15)   # cold

Scalar overrides are broadcast to this object’s location count (so the result keeps the same n_locations); a length-n_locations array override is used as-is. Fields not named are carried over unchanged. The original is not modified.

Parameters:

**kwargs (float or array-like) – Field name -> new value (scalar, broadcast to n_locations, or a length-n_locations array).

Returns:

A new SpatialConditions (always the base type, so it stays valid for every reactor) with the merged fields.

Return type:

SpatialConditions

validate_required(required)[source]#

Raise ValueError if any required field is missing.

Parameters:

required (iterable of str) – Field names that must be present.

Return type:

None