aquakin.ChlorineContactUnit#

class aquakin.ChlorineContactUnit(name, model, volume, dose, ct_per_log, decay_rate=0.0, baffling_factor=0.5, max_log=None, inlet_density=0.0, initial_residual=0.0, dechlorinate=False, input_port='in', output_port='out')[source]#

Bases: object

A chlorine contact tank: CT-driven log-removal with residual decay.

The applied chlorine residual is a dynamic state (a completely-mixed tank with first-order decay, dCl/dt = (Q/V)(dose Cl) k_decay·Cl); the CT credit residual × T10 drives the log-removal. Passes the process stream through and reduces the indicator-organism density (Stream.org, else inlet_density). dechlorinate reports the discharged residual as zero (the credit is already earned in the tank) – e.g. a downstream bisulfite dose.

Parameters:
  • name (str)

  • model (CompiledModel)

  • volume (float) – Contact-tank volume (m³).

  • dose (float) – Applied chlorine dose at the inlet (g Cl/m³ ≡ mg/L).

  • ct_per_log (float) – CT (residual × T10) that earns one log of inactivation, in the same units as residual × time (from the regulatory CT tables for the organism / pH / temperature). Time-unit trap: T10 = baffling·V/Q is in the plant’s time unit (days for the BSM models, whose rate constants are 1/d), while the regulatory CT tables are in mg·min/L. Supply ct_per_log in the plant time unit – e.g. for a days-based plant multiply a mg·min/L table value by 1/1440 (min→day) – or both the CT and the credit are off by 1440×. V/Q and decay_rate are in that same plant time unit.

  • decay_rate (float) – First-order chlorine-decay rate (1/time, plant time unit). Default 0.

  • baffling_factor (float) – T10/HRT factor for the contact time (T10 = baffling·V/Q). Default 0.5.

  • max_log (float, optional) – Cap on the log-removal. None = uncapped.

  • inlet_density (float) – Indicator density used when the inlet carries none. Default 0.

  • initial_residual (float) – Initial chlorine residual state (g/m³). Default 0.

  • dechlorinate (bool) – If true, the reported discharged residual is 0. Default False.

  • input_port (str)

  • output_port (str)

__init__(name, model, volume, dose, ct_per_log, decay_rate=0.0, baffling_factor=0.5, max_log=None, inlet_density=0.0, initial_residual=0.0, dechlorinate=False, input_port='in', output_port='out')#
Parameters:
  • name (str)

  • model (CompiledModel)

  • volume (float)

  • dose (float)

  • ct_per_log (float)

  • decay_rate (float)

  • baffling_factor (float)

  • max_log (float | None)

  • inlet_density (float)

  • initial_residual (float)

  • dechlorinate (bool)

  • input_port (str)

  • output_port (str)

Return type:

None

Methods

__init__(name, model, volume, dose, ct_per_log)

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

ct(residual, flow)

CT = residual × T10, with T10 = baffling·V/Q (plant time unit).

discharged_residual(state)

The chlorine residual leaving the tank (0 if dechlorinated).

flow_outputs(input_flows, params[, ctx])

initial_state()

log_removal(residual, flow)

The chlorine CT log-removal at the given residual and throughflow.

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

Attributes

baffling_factor

decay_rate

dechlorinate

initial_residual

inlet_density

input_port

input_ports

max_log

output_port

output_ports

state_size

name

model

volume

dose

ct_per_log

ct(residual, flow)[source]#

CT = residual × T10, with T10 = baffling·V/Q (plant time unit).

Return type:

Array

log_removal(residual, flow)[source]#

The chlorine CT log-removal at the given residual and throughflow.

Return type:

Array

discharged_residual(state)[source]#

The chlorine residual leaving the tank (0 if dechlorinated).

Return type:

float