aquakin.Aeration#

class aquakin.Aeration(kla=None, do_setpoint=None, do_sat=8.0, species='SO', controller=None, sensor=None, gain=1.0, Kp=25.0, Ti=0.002, Tt=0.001, kla_offset=120.0, kla_min=0.0, kla_max=360.0, temperature_correction=False, ref_T=293.15, alpha=1.0, beta=1.0, pressure_factor=1.0, kla_theta=1.024, saturation_model='benson_krause')[source]#

Bases: object

Aeration / dissolved-oxygen spec for a CSTRUnit.

The quantity a designer actually thinks in, instead of a raw mass-transfer coefficient on a state variable. Choose exactly one mode.

Open loop – a fixed mass-transfer coefficient (the saturation defaults sensibly, so the common case is one number):

Aeration(kla=120)                 # do_sat defaults to 8.0 gO2/m3
Aeration(kla=120, do_sat=9.0)

Closed loop – a dissolved-oxygen setpoint. The plant auto-wires a PI controller that manipulates this tank’s kLa to hold the setpoint:

Aeration(do_setpoint=2.0)         # this tank holds DO = 2.0 on its own

Several tanks share one controller by giving the same controller id – the BSM2 design, one sensor driving several reactors at per-tank gains:

Aeration(do_setpoint=2.0, controller="do", sensor="tank4", gain=1.0)
Aeration(do_setpoint=2.0, controller="do", sensor="tank4", gain=0.5)
Parameters:
  • kla (float, optional) – Open-loop mass-transfer coefficient (1/time). Mutually exclusive with do_setpoint.

  • do_setpoint (float, optional) – Closed-loop dissolved-oxygen target (same units as species).

  • do_sat (float) – Saturation concentration in the aeration term kLa*(do_sat - C). Default 8.0 (gO2/m3, the usual ASM oxygen saturation).

  • species (str) – The aerated species (default "SO").

  • controller (str, optional) – Closed-loop only. Shared-controller id: tanks giving the same id share one PI controller (and the controller unit takes this name). None (the default) gives this tank its own dedicated controller.

  • sensor (str, optional) – Closed-loop only. Name of the unit whose oxygen the controller measures. Defaults to the controlled tank itself (per-tank control).

  • gain (float) – Closed-loop only. This tank’s share of the controller’s kLa output (default 1.0), so one shared controller can drive tanks at different rates.

  • Kp (float) – Closed-loop PI tuning and output bounds. Defaults are the BSM2 DO loop: Kp=25, Ti=0.002 d, Tt=0.001 d, offset 120, bounds [0, 360] d^-1.

  • Ti (float) – Closed-loop PI tuning and output bounds. Defaults are the BSM2 DO loop: Kp=25, Ti=0.002 d, Tt=0.001 d, offset 120, bounds [0, 360] d^-1.

  • Tt (float) – Closed-loop PI tuning and output bounds. Defaults are the BSM2 DO loop: Kp=25, Ti=0.002 d, Tt=0.001 d, offset 120, bounds [0, 360] d^-1.

  • kla_offset (float) – Closed-loop PI tuning and output bounds. Defaults are the BSM2 DO loop: Kp=25, Ti=0.002 d, Tt=0.001 d, offset 120, bounds [0, 360] d^-1.

  • kla_min (float) – Closed-loop PI tuning and output bounds. Defaults are the BSM2 DO loop: Kp=25, Ti=0.002 d, Tt=0.001 d, offset 120, bounds [0, 360] d^-1.

  • kla_max (float) – Closed-loop PI tuning and output bounds. Defaults are the BSM2 DO loop: Kp=25, Ti=0.002 d, Tt=0.001 d, offset 120, bounds [0, 360] d^-1.

  • temperature_correction (bool) – First of the oxygen-transfer corrections – all off / identity by default, so a default Aeration is bit-faithful to the IWA benchmark constant-saturation, constant-kLa definition. When True, temperature-correct the oxygen driving force using the tank’s operating temperature (the flow-weighted inlet T the kinetics already use, falling back to the static T condition). The saturation is scaled by the clean-water ratio C_s(T)/C_s(ref_T) (oxygen_saturation()) and – for an open-loop fixed kla – the transfer coefficient by kla_theta**(T - ref_T). False (default) leaves both constant. Removes the internal inconsistency whereby a warm run already speeds the (Arrhenius) biology while the oxygen saturation stays pinned. A closed-loop controlled kla is not theta-scaled (the controller already manipulates it to hold the setpoint), but its driving-force saturation still gets the C_s(T) correction.

  • ref_T (float) – Reference temperature (Kelvin) at which do_sat and kla are specified, so the correction is unity there. Default 293.15 (20 degC).

  • alpha (float) – Process kLa-transfer factor (alpha_F): a constant multiplier on kla (clean-water -> process water; typically 0.4-0.7 in activated sludge). Default 1.0. Applied to the open-loop kla only.

  • beta (float) – Salinity saturation factor: a constant multiplier on do_sat (typically 0.95-0.99). Default 1.0.

  • pressure_factor (float) – Elevation / barometric saturation factor: a constant multiplier on do_sat (< 1 at altitude). Default 1.0.

  • kla_theta (float) – Arrhenius base for the open-loop kla(T) = kla*kla_theta**(T-ref_T) correction (only used when temperature_correction is on). Default 1.024, the standard value.

  • saturation_model (str) – Which clean-water saturation correlation supplies the temperature- correction ratio C_s(T)/C_s(ref_T): "benson_krause" (default, the APHA correlation) or "bsm2" (the IWA benchmark van’t Hoff formula, oxygen_saturation_bsm2()). Use "bsm2" to match the benchmark’s oxygen driving force exactly; the two differ by ~0.5 % in shape. Only used when temperature_correction is on.

__init__(kla=None, do_setpoint=None, do_sat=8.0, species='SO', controller=None, sensor=None, gain=1.0, Kp=25.0, Ti=0.002, Tt=0.001, kla_offset=120.0, kla_min=0.0, kla_max=360.0, temperature_correction=False, ref_T=293.15, alpha=1.0, beta=1.0, pressure_factor=1.0, kla_theta=1.024, saturation_model='benson_krause')#
Parameters:
  • kla (float | None)

  • do_setpoint (float | None)

  • do_sat (float)

  • species (str)

  • controller (str | None)

  • sensor (str | None)

  • gain (float)

  • Kp (float)

  • Ti (float)

  • Tt (float)

  • kla_offset (float)

  • kla_min (float)

  • kla_max (float)

  • temperature_correction (bool)

  • ref_T (float)

  • alpha (float)

  • beta (float)

  • pressure_factor (float)

  • kla_theta (float)

  • saturation_model (str)

Return type:

None

Methods

__init__([kla, do_setpoint, do_sat, ...])

controller_id(unit_name)

The id that groups tanks onto one controller: the shared controller if given, else the tank's own name (a dedicated per-tank controller).

signal_name(unit_name)

The control-signal name the controlled tank reads and its controller publishes.

Attributes

Kp

Ti

Tt

alpha

beta

controller

do_sat

do_setpoint

gain

is_closed_loop

kla

kla_max

kla_min

kla_offset

kla_theta

pressure_factor

ref_T

saturation_model

sensor

species

temperature_correction

controller_id(unit_name)[source]#

The id that groups tanks onto one controller: the shared controller if given, else the tank’s own name (a dedicated per-tank controller).

Parameters:

unit_name (str)

Return type:

str

signal_name(unit_name)[source]#

The control-signal name the controlled tank reads and its controller publishes. Derived from the controller id so a shared controller’s tanks all resolve to the same signal.

Parameters:

unit_name (str)

Return type:

str