Process Models

A list of the available Process Models.

There are two different kinds of defining processes in this library, the equation-defined models and the matrix-defined models. The list below is thus split into the two parts.

Index

Equation-defined Models

BioChemicalTreatment.ProcessSimulator.ASM1Function
ASM1(; name, Y_H=0.67, Y_A=0.24, i_XB=0.086, i_XP=0.01, f_P=0.08, mu_H=6.0, K_S=20.0, K_OH=0.2, K_NO=0.5, b_H=0.62,
     eta_g=0.8, mu_A=0.8, K_NH=1.0, K_OA=0.4, b_A=0.1, kappa_h=3.0, eta_h=0.4, K_X=0.03, kappa_a=0.08)

A component that defines the process rates in the activated sludge model number 1 (ASM1). Taken from (Henze et al., 1987)

Initial State

When using this model, one needs to set the initial state/initial condition in the corresponding reactor. This is because the default values are all 0, and some of the process equations have a division by 0 if all states are 0!

Parameters:

  • stoichiometric parameter (all at 20 deg. C, neutral pH):
    • Y_H heterotrophic yield (default 0.67 gCOD/gCOD)
    • Y_A autotrophic yield (default 0.24 gCOD/gCOD)
    • i_XB nitrogen fraction in biomass (default 0.086 gN/gCOD)
    • i_XP nitrogen fraction in endogenous mass (default 0.01 gN/gCOD)
    • f_P fraction of biomass leading to particulate material (default 0.08)
  • kinetic parameter heterotrophs:
    • mu_H maximum specific growth rate (default 6.0 1/day)
    • K_S substrate saturation constant (default 20.0 gCOD/m3)
    • K_OH oxygen saturation constant (default 0.2 gO2/m3)
    • K_NO nitrate saturation constant (default 0.5 gNO3-N/m3)
    • b_H specific decay rate (default 0.62 1/day)
    • eta_g anoxic growth correction factor (default 0.8)
  • kinetic parameter autotrophs:
    • mu_A maximum specific growth rate (default 0.8 1/day)
    • K_NH ammonium saturation constant (default 1.0 gO2/m3)
    • K_OA oxygen saturation constant (default 0.4 gO2/m3)
    • b_A specific decay rate (default 0.1 1/day)
  • hydrolysis parameter
    • kappa_h maximum specific hydrolysis rate (default 3.0 1/day)
    • eta_h anoxic hydrolysis correction factor (default 0.4 -)
    • K_X half-saturation coefficient for hydrolysis of XS (default 0.03 -)
  • ammonification
    • kappa_a ammonification rate constant (default 0.08 m3/(gCOD*day))

States:

  • S_I soluble inert organic matter
  • S_S readily biodegradable substrate
  • S_O oxygen
  • S_NO nitrate and nitrite nitrogen
  • S_NH ammonium and ammonia nitrogen
  • S_ND soluble biodegradable organic nitrogen
  • S_ALK alkalinity
  • X_I particulate inert organic matter
  • X_S slowly biodegradable substrate
  • X_BH active heterotrophic biomass
  • X_BA active autotrophic biomass
  • X_P particulate products from biomass decay
  • X_ND particulate biodegradable organic
source
BioChemicalTreatment.ProcessSimulator.OzoneDisinfectionFunction
OzoneDisinfection(; name, kO3=10, kd=1500)

A component that defines two processes in a ozone disinfection i.e. decay of ozone and disinfection. This can be used as an example for testing the package.

Parameters:

  • kO3 the ozone decay constant
  • kD the disinfection constant

States:

  • S_O3 the dissolved ozone concentration
  • X_B the bacteria concentration (particulate)
source
BioChemicalTreatment.ProcessSimulator.AerationFunction
Aeration(; name, k_La=240, S_O_max=8)

A component that defines a simple aeration process using the oxygen transfer coefficient k_L*a and the oxygen saturation concentration.

Parameters:

  • k_La initial oxygen transfer coefficient (default 240 1/d)
  • S_O_max the saturation concentration for oxygen (default 8 g/m3)

States:

  • S_O oxygen

Connectors

  • state The reactor states to connect (only dissolved oxygen)
  • rate The calculated rate (dissolved oxygen only)
  • k_La The oxygen transfer coefficent. Is a ModelingToolkitStandardLibrary.Blocks.RealInput, for usage with the systems from the ModelingToolkitStandardLibrary which provides e.g. controllers.
source

Matrix-defined Models

Matrix-defined models are loaded using the default Process constructor, which supports loading models directly from files as well as using the included models:

BioChemicalTreatment.ProcessSimulator.ProcessMethod
Process(args...; name, error_invalid_composition=true, kwargs...)

Loads a process from files over the BioChemicalReactionSystem. Generates the process and checks if the composition requirement is fulfilled.

Arguments

Keyword Arguments

  • name: The name of the created system
  • error_invalid_composition: If an error should be thrown on invalid compositions. Defaults to true to force the user to actively activate that the invalid composition works. A warning is thrown instead of an error if this argument is set to false
  • kwargs...: Keyword arguments specifying the parameters of the model. An error is thrown if no matching parameter is found to set. Can be values or expressions of the other parameters (but be careful for circular expressions, they are not supported).
source

Currently, the following matrix-defined process models are part of this library:

They are called by passing the first string in the list above (before the colon) as argument to the Process:

@named asm = Process("ASM1")

To set model parameters, use keyword arguments:

@named asm = Process("ASM1"; Y_H = 12)

Process Combinations

There exist helper systems for combining different processes, e.g. for combining multiple processes in a single reactor.

The handy thing about all of these is, that they are again processes themselves! This means that they share the same interface as all the other processes.

BioChemicalTreatment.ProcessSimulator.CombinedProcessFunction
CombinedProcess(processes;
    name,
    state_mapping = default_state_mapping(),
    use_default_processes = true)

A process combining multiple sub-processes in parallel.

This is for combining multiple processes in a single reactor. E.g. for an aerated reactor with asm1, one would combine the aeration and the asm1 process. By default, processes with the same name are considered equal and combined. If differently named processes are designating the same variable (e.g. S_O and S_O2), this can be specified using the state_mapping argument.

Parameters

  • processes: The processes to combine. Either a vector of Processes, or a single Process. In the latter case it can be used for renaming the states according to the mapping.
  • name: The name of the combined process.
  • state_mapping: Mapping to rename and set states equal. Defaults to default_state_mapping().
  • use_default_processes: Boolean, if the default processes (from default_processes()) are added to the given processes or not.

Examples

julia> @named comb = CombinedProcess([ASM1(; name=:asm), Aeration(; name=:aer)])
Process Combination (ASM1 and Aeration) 'comb':
States (13): see states(comb)
  S_ALK(t) [guess is 0.0]: S_ALK
  S_I(t) [guess is 0.0]: S_I
  S_ND(t) [guess is 0.0]: S_ND
  S_NH(t) [guess is 0.0]: S_NH
  S_NO(t) [guess is 0.0]: S_NO
  S_O(t) [guess is 0.0]: S_O
  ⋮
Exogenous Inputs (1): see exogenous_inputs(comb)
  :aer₊k_La
Parameters (20): see parameters(comb)
  asm₊Y_H [defaults to 0.67]
  asm₊Y_A [defaults to 0.24]
  asm₊i_XB [defaults to 0.086]
  asm₊i_XP [defaults to 0.01]
  asm₊f_P [defaults to 0.08]
  asm₊mu_H [defaults to 6.0]
  ⋮
julia> @named comb = CombinedProcess([ASM1(; name=:asm), Aeration(; name=:aer)]; state_mapping=Dict(:DO => (;names=Set([:S_O]), particulate=false, colloidal=false, soluble=true)))
Process Combination (ASM1 and Aeration) 'comb':
States (13): see states(comb)
  DO(t) [guess is 0]: DO
  S_ALK(t) [guess is 0.0]: S_ALK
  S_I(t) [guess is 0.0]: S_I
  S_ND(t) [guess is 0.0]: S_ND
  S_NH(t) [guess is 0.0]: S_NH
  S_NO(t) [guess is 0.0]: S_NO
  ⋮
Exogenous Inputs (1): see exogenous_inputs(comb)
  :aer₊k_La
Parameters (20): see parameters(comb)
  asm₊Y_H [defaults to 0.67]
  asm₊Y_A [defaults to 0.24]
  asm₊i_XB [defaults to 0.086]
  asm₊i_XP [defaults to 0.01]
  asm₊f_P [defaults to 0.08]
  asm₊mu_H [defaults to 6.0]
  ⋮
julia> @named rename_state = CombinedProcess(Aeration(; name=:aer); state_mapping=Dict(:DO => (;names=Set([:S_O]), particulate=false, colloidal=false, soluble=true)))
Process Combination (Aeration) 'rename_state':
States (1): see states(rename_state)
  DO(t) [guess is 0]: DO
Exogenous Inputs (1): see exogenous_inputs(rename_state)
  :aer₊k_La
Parameters (1): see parameters(rename_state)
  aer₊S_O_max [defaults to 8]
source
BioChemicalTreatment.ProcessSimulator.@process_combinationMacro
@process_combination

Convenience macro for constructing combined processes.

Takes a block with the processes to combine:

@process_combination comb = begin
    aer = Aeration()
    asm = ASM1()
end

# output

Process Combination (Aeration and ASM1) 'comb':
States (13): see states(comb)
  S_ALK(t) [guess is 0.0]: S_ALK
  S_I(t) [guess is 0.0]: S_I
  S_ND(t) [guess is 0.0]: S_ND
  S_NH(t) [guess is 0.0]: S_NH
  S_NO(t) [guess is 0.0]: S_NO
  S_O(t) [guess is 0.0]: S_O
  ⋮
Exogenous Inputs (1): see exogenous_inputs(comb)
  :aer₊k_La
Parameters (20): see parameters(comb)
  aer₊S_O_max [defaults to 8]
  asm₊Y_H [defaults to 0.67]
  asm₊Y_A [defaults to 0.24]
  asm₊i_XB [defaults to 0.086]
  asm₊i_XP [defaults to 0.01]
  asm₊f_P [defaults to 0.08]
  ⋮

Like this, arbitrarily many processes can be combined.

Warning

This way of combining processes, the default processes and state mapping are always added.

source
BioChemicalTreatment.ProcessSimulator.CascadedProcessFunction
CascadedProcess(sys::AbstractVector{Reactor}; name)

Construct a process cascade.

A process encapsulating a series of cascaded processes.

Note

This cascaded process is provided for usage with the CascadedReactor in the Low-Level interface. However, this has some caveats and it is recommended to use the CascadedReactor directly with the high-level interface (encapsulating all processes directly)

Lowlevel interface

The CascadedProcess is of the type Process and shares the same interface as everyone of them. If used as such, the states and rates subsystem contain all of the states, resp. rates, of the cascaded processes.

This system is indended for the use of lowlevel interface with the CascadedReactor, which has the states and rates defined similarly to this system. However, for both the naming is depending on the contained systems and their structure and thus it might not be matching.

This leads to the connect function not be usable for connecting them. However as an alternative, use:

# Connect states
Equation.(getproperty.(Ref(cascaded_reactor.stateunif.stateoutput), Symbol.(getproperty.(unknowns(states(cascaded_reactor)), :f))), getproperty.(Ref(cascaded_process.statesplit.stateinput), Symbol.(getproperty.(unknowns(states(cascaded_process)), :f))))
# Connect rates
Equation.(getproperty.(Ref(cascaded_process.rateunif.reactionoutput), Symbol.(getproperty.(unknowns(rates(cascaded_process)), :f))), getproperty.(Ref(cascaded_reactor.ratesplit.reactioninput), Symbol.(getproperty.(unknowns(rates(cascaded_reactor)), :f))))
source
BioChemicalTreatment.ProcessSimulator.@process_cascadeMacro
@process_cascade

Convenience macro for constructing cascaded processes. Has two different forms, one for a cascade of equal processes, the other one for a cascade of potentially different ones:

The first one takes the construction of the process (adds the name as the @named macro) and then in square brackets the number of processes to chain. E.g.:

julia> @process_cascade casc = OzoneDisinfection() [2]
Process Cascade (OzoneDisinfection and OzoneDisinfection) 'casc':
States (4): see states(casc)
  s1_casc_1_S_O3(t) [guess is 0]: s1_casc_1_S_O3
  s1_casc_1_X_B(t) [guess is 0]: s1_casc_1_X_B
  s2_casc_2_S_O3(t) [guess is 0]: s2_casc_2_S_O3
  s2_casc_2_X_B(t) [guess is 0]: s2_casc_2_X_B
Parameters (4): see parameters(casc)
  casc_1₊kO3 [defaults to 10]
  casc_1₊kd [defaults to 1500]
  casc_2₊kO3 [defaults to 10]
  casc_2₊kd [defaults to 1500]

The second one takes a block with the processes to cascade:

@process_cascade cascade = begin
    disin1 = OzoneDisinfection(; kO3 = 1)
    disin2 = OzoneDisinfection(; kO3 = 2)
end

# output

Process Cascade (OzoneDisinfection and OzoneDisinfection) 'cascade':
States (4): see states(cascade)
  s1_disin1_S_O3(t) [guess is 0]: s1_disin1_S_O3
  s1_disin1_X_B(t) [guess is 0]: s1_disin1_X_B
  s2_disin2_S_O3(t) [guess is 0]: s2_disin2_S_O3
  s2_disin2_X_B(t) [guess is 0]: s2_disin2_X_B
Parameters (4): see parameters(cascade)
  disin1₊kO3 [defaults to 1]
  disin1₊kd [defaults to 1500]
  disin2₊kO3 [defaults to 2]
  disin2₊kd [defaults to 1500]

In this version, it is also possible to repeat a certain number of equal processes using braces:

@process_cascade cascade = begin
    disin1 = OzoneDisinfection(; kO3 = 1)
    {disins = OzoneDisinfection(; kO3 = 2) [2]}
end

# output

Process Cascade (OzoneDisinfection, OzoneDisinfection and OzoneDisinfection) 'cascade':
States (6): see states(cascade)
  s1_disin1_S_O3(t) [guess is 0]: s1_disin1_S_O3
  s1_disin1_X_B(t) [guess is 0]: s1_disin1_X_B
  s2_disins_1_S_O3(t) [guess is 0]: s2_disins_1_S_O3
  s2_disins_1_X_B(t) [guess is 0]: s2_disins_1_X_B
  s3_disins_2_S_O3(t) [guess is 0]: s3_disins_2_S_O3
  s3_disins_2_X_B(t) [guess is 0]: s3_disins_2_X_B
Parameters (6): see parameters(cascade)
  disin1₊kO3 [defaults to 1]
  disin1₊kd [defaults to 1500]
  disins_1₊kO3 [defaults to 2]
  disins_1₊kd [defaults to 1500]
  disins_2₊kO3 [defaults to 2]
  disins_2₊kd [defaults to 1500]

Like this, arbitrarily many processes can be chained.

source