aquakin.SpatialConditions#
- class aquakin.SpatialConditions(fields=<factory>)[source]#
Bases:
objectContainer for spatially varying condition fields.
Each entry in
fieldsis a JAX array of shape(n_locations,)giving the value of that field at each spatial location. Reactors index into these arrays withloc_idxat 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
SpatialConditionsobject.validate_required(required)Raise
ValueErrorif any required field is missing.with_(**kwargs)Return a copy with some fields overridden (or added).
Attributes
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
SpatialConditionsobject.- 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 theOperatingConditionsalias reads more naturally still.**kwargs (float) – Field name -> scalar value. The scalar is broadcast to
(n_locations,).
- Return type:
- 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_locationsarray 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_locationsarray).- Returns:
A new
SpatialConditions(always the base type, so it stays valid for every reactor) with the merged fields.- Return type: