aquakin.CSTRUnit#

class aquakin.CSTRUnit(name, model, volume, input_port_names, conditions=<factory>, aeration=None, output_port='out')[source]#

Bases: AerationUnit, CouplingAware

A single continuous-flow stirred tank with kinetics + aeration.

Parameters:
  • name (str) – Unit identifier.

  • model (CompiledModel) – Kinetic model whose rate functions provide the chemistry term.

  • volume (float) – Tank liquid volume.

  • input_port_names (list[str]) – Names of the incoming-stream ports. Multiple inflows are summed (treated as a built-in mixer) before the mass balance.

  • conditions (dict[str, float]) – Spatially-uniform condition values (e.g. {"T": 293.15}). One value per condition declared by the model.

  • aeration (Aeration, optional) – How the tank is aerated. None (default) is an anoxic/anaerobic tank (no aeration). Aeration(kla=120) is open-loop aeration at a fixed mass-transfer coefficient; Aeration(do_setpoint=2.0) is closed-loop dissolved-oxygen control, for which the plant auto-wires a PI controller on this tank’s kLa (see Aeration).

  • output_port (str) – Name of the single output port.

__init__(name, model, volume, input_port_names, conditions=<factory>, aeration=None, output_port='out')#
Parameters:
  • name (str)

  • model (CompiledModel)

  • volume (float)

  • input_port_names (list[str])

  • conditions (dict[str, float])

  • aeration (Aeration | None)

  • output_port (str)

Return type:

None

Methods

__init__(name, model, volume, input_port_names)

compute_outputs(t, state, inputs, params[, ...])

coupling_pattern()

Structural Jacobian sparsity.

flow_outputs(input_flows, params[, ctx])

Outflow equals total inflow (constant-volume reactor).

initial_state()

rhs(t, state, inputs, params[, signals])

set_temperature(temperature_K)

Set this reactor's static operating temperature (Kelvin).

Attributes

aeration

input_ports

output_port

output_ports

required_signals

Control-signal names this unit reads from the bus in rhs (the closed-loop aeration signal, if any).

state_size

name

model

volume

input_port_names

conditions

set_temperature(temperature_K)[source]#

Set this reactor’s static operating temperature (Kelvin).

Updates the T condition (and its precomputed rate-evaluation array) in place, so a re-solve runs the kinetics – including any Arrhenius temperature_corrections – at the new temperature. A no-op for a model that declares no T condition. The plant clears its compiled- solve cache after calling this; on a bare unit, rebuild any cached solve.

Parameters:

temperature_K (float)

Return type:

None

coupling_pattern()[source]#

Structural Jacobian sparsity.

self is the reaction kinetics’ coupling from the rate AST (a saturated Monod term is numerically invisible at any single state, so the syntactic dependency is needed, not a probe). inlet is the convective dilution (Q/V)(C_in - C), which couples each species’ derivative to its own inlet concentration only – the identity.

flow_outputs(input_flows, params, ctx=None)[source]#

Outflow equals total inflow (constant-volume reactor).

Parameters:
  • input_flows (dict)

  • params (Array)

Return type:

dict