aquakin.Stream#

class aquakin.Stream(Q, C, model, scalars=<factory>)[source]#

Bases: object

A flow stream — bulk volumetric rate plus a concentration vector.

Streams are produced by a unit’s compute_outputs and consumed by downstream units’ rhs / compute_outputs calls. They are intentionally immutable per evaluation: a connection delivers the upstream output directly, with optional StateTranslator interposed for cross-model mappings.

Variables:
  • Q (jnp.ndarray) – Volumetric flow rate (scalar), units must be consistent across the plant (typically m³/d for BSM-family plants).

  • C (jnp.ndarray) – Concentration vector, shape (n_species,) where species ordering is model.species.

  • model (CompiledModel) – The kinetic model whose species ordering applies to C.

  • scalars (Mapping[str, jnp.ndarray]) –

    Per-stream side-channel scalars carried algebraically through the flowsheet alongside Q/C – a single open-ended map rather than a fixed field per quantity, so a new carried scalar needs no new field, no with_* copier and no mixed_* combiner. Multi-inlet units combine them with the one shared mixed_scalars(); pass-through units forward them unchanged (scalars=s_in.scalars). A scalar absent from the map means the stream does not carry it (an agnostic feed / a zero-flow recycle seed); its presence is a static structural property (consistent across RHS calls), so callers stay jit-safe. The two used today are:

    • "T" – stream temperature (K); reactors read their inlet temperature from it for temperature-dependent kinetics and fall back to their static condition when it is absent.

    • "org" – indicator-organism density (e.g. CFU/100 mL) for disinfection; a disinfection unit reduces it by the computed log-inactivation and falls back to its design inlet_density when it is absent.

    Read a scalar with stream.scalars.get(name) (None if not carried); build the map for a leaf stream with make_scalars(), which drops the agnostic (None) entries.

Parameters:
  • Q (jnp.ndarray)

  • C (jnp.ndarray)

  • model (CompiledModel)

  • scalars (Mapping[str, jnp.ndarray])

__init__(Q, C, model, scalars=<factory>)#
Parameters:
  • Q (jnp.ndarray)

  • C (jnp.ndarray)

  • model (CompiledModel)

  • scalars (Mapping[str, jnp.ndarray])

Return type:

None

Methods

__init__(Q, C, model[, scalars])

mass_flow()

Per-species mass flow rate Q * C, shape (n_species,).

with_C(C)

Return a new stream with a new C vector, everything else (including the side-channel scalars) preserved.

with_Q(Q)

Return a new stream with a new flow rate, everything else (including the side-channel scalars) preserved.

Attributes

Q

C

model

scalars

mass_flow()[source]#

Per-species mass flow rate Q * C, shape (n_species,).

Return type:

Array

with_C(C)[source]#

Return a new stream with a new C vector, everything else (including the side-channel scalars) preserved.

Parameters:

C (Array)

Return type:

Stream

with_Q(Q)[source]#

Return a new stream with a new flow rate, everything else (including the side-channel scalars) preserved.

Parameters:

Q (Array)

Return type:

Stream