Models
src.pcgym.model_classes
cstr
dataclass
Bases: BaseModel
first_order_system
dataclass
First-order system model.
Attributes:
Name | Type | Description |
---|---|---|
K |
float
|
Gain |
tau |
float
|
Time constant |
int_method |
str
|
Integration method ('jax' or other) |
__call__(x, u)
Calculate the state derivative for the first-order system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
Current state [x] |
required |
u
|
ndarray
|
Input [u] |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: State derivative [dx/dt] |
info()
Get model information.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Dictionary containing model parameters, states, inputs, and disturbances. |
multistage_extraction
dataclass
Multistage extraction model.
Attributes:
Name | Type | Description |
---|---|---|
Vl |
float
|
Liquid volume in each stage |
Vg |
float
|
Gas volume in each stage |
m |
float
|
Equilibrium constant |
Kla |
float
|
Mass transfer capacity constant (1/hr) |
eq_exponent |
float
|
Nonlinearity of the equilibrium relationship |
X0 |
float
|
Feed concentration of liquid |
Y6 |
float
|
Feed concentration of gas |
int_method |
str
|
Integration method ('jax' or other) |
__call__(x, u)
Calculate the state derivatives for the multistage extraction model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
Current state [X1, Y1, X2, Y2, X3, Y3, X4, Y4, X5, Y5] |
required |
u
|
ndarray
|
Input [L, G] or [L, G, X0, Y6] |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: State derivatives |
info()
Get model information.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Dictionary containing model parameters, states, inputs, and disturbances. |
nonsmooth_control
dataclass
Nonsmooth control model (Bang-Bang Control).
Attributes:
Name | Type | Description |
---|---|---|
int_method |
str
|
Integration method ('jax' or other) |
a_11, |
a_12, a_21, a_22 (float
|
System matrix coefficients |
b_1, |
b_2 (float
|
Input vector coefficients |
__call__(x, u)
Calculate the state derivatives for the nonsmooth control model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
Current state [x1, x2] |
required |
u
|
ndarray
|
Input [u] |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: State derivatives [dx1/dt, dx2/dt] |
info()
Get model information.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Dictionary containing model parameters, states, inputs, and disturbances. |
distillation_column
dataclass
Distillation column model.
Attributes:
Name | Type | Description |
---|---|---|
D |
float
|
Distillate flow rate (kmol/hr) |
q |
float
|
Feed quality (q=1 is saturated liquid) |
alpha |
float
|
Relative volatility of more volatile component |
X_feed |
float
|
Feed composition |
M0, |
Mb, M (float
|
Holdup in different sections of the column |
__call__(x, u)
Calculate the state derivatives for the distillation column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
Current state [X0, X1, X2, X3, Xf, X4, X5, X6, Xb] |
required |
u
|
ndarray
|
Input [R, F] |
required |
Returns:
Type | Description |
---|---|
np.ndarray: State derivatives |
info()
Get model information.
Returns:
Name | Type | Description |
---|---|---|
dict |
Dictionary containing model parameters, states, inputs, and disturbances. |
cstr_series_recycle
dataclass
CSTR series with recycle model.
Attributes:
Name | Type | Description |
---|---|---|
C_O |
float
|
Initial concentration (mol/m3) |
T_O |
float
|
Initial temperature (K) |
V1, |
V2 (float
|
Reactor volumes (m3) |
U1A1, |
U2A2 (float
|
Heat transfer coefficients times areas (kJ/s*K) |
rho |
float
|
Density (kg/m3) |
cp |
float
|
Heat capacity (kJ/kg*K) |
k |
float
|
Reaction rate constant (s-1) |
E |
float
|
Activation energy (kJ/mol) |
deltaH |
float
|
Heat of reaction (kJ/mol) |
R |
float
|
Gas constant (kJ/mol K) |
__call__(x, u)
Calculate the state derivatives for the CSTR series with recycle.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
Current state [C1, T1, C2, T2] |
required |
u
|
ndarray
|
Input [F, L, Tc1, Tc2] |
required |
Returns:
Type | Description |
---|---|
np.ndarray: State derivatives |
info()
Get model information.
Returns:
Name | Type | Description |
---|---|---|
dict |
Dictionary containing model parameters, states, inputs, and disturbances. |
multistage_extraction_reactive
dataclass
Multistage extraction with reactive components model.
Attributes:
Name | Type | Description |
---|---|---|
Vl |
float
|
Liquid volume in each stage |
Vg |
float
|
Gas volume in each stage |
m |
float
|
Equilibrium constant |
Kla |
float
|
Mass transfer capacity constant (1/hr) |
k |
float
|
Reaction equilibrium constant |
eq_exponent |
float
|
Nonlinearity of the equilibrium relationship |
XA0 |
float
|
Feed concentration of component A in liquid phase |
YA6, |
YB6, YC6 (float
|
Feed concentrations in gas phase |
__call__(x, u)
Calculate the state derivatives for the multistage extraction with reactive components.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
Current state [XA1, YA1, YB1, YC1, XA2, YA2, YB2, YC2, XA3, YA3, YB3, YC3, XA4, YA4, YB4, YC4, XA5, YA5, YB5, YC5] |
required |
u
|
ndarray
|
Input [L, G] |
required |
Returns:
Type | Description |
---|---|
np.ndarray: State derivatives |
info()
Get model information.
Returns:
Name | Type | Description |
---|---|---|
dict |
Dictionary containing model parameters, states, inputs, and disturbances. |
four_tank
dataclass
Four-tank system model.
Attributes:
Name | Type | Description |
---|---|---|
g |
float
|
Acceleration due to gravity (m/s2) |
gamma_1, |
gamma_2 (float
|
Fraction bypassed by valves |
k1, |
k2 (float
|
Pump gains (m3/Volts S) |
a1, |
a2, a3, a4 (float
|
Cross-sectional areas of outlets (m2) |
A1, |
A2, A3, A4 (float
|
Cross-sectional areas of tanks (m2) |
int_method |
str
|
Integration method ('jax' or other) |
__call__(x, u)
Calculate the state derivatives for the four-tank system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
Current state [h1, h2, h3, h4] |
required |
u
|
ndarray
|
Input [v1, v2] |
required |
Returns:
Type | Description |
---|---|
np.ndarray: State derivatives |
info()
Get model information.
Returns:
Name | Type | Description |
---|---|---|
dict |
Dictionary containing model parameters, states, inputs, and disturbances. |
heat_exchanger
dataclass
Heat exchanger model.
Attributes:
Name | Type | Description |
---|---|---|
Utm |
float
|
Tube-metal overall heat transfer coefficient (kW/m2 K) |
Usm |
float
|
Shell-metal overall heat transfer coefficient (kW/m2 K) |
L |
float
|
Length segment of each stage |
Dt |
float
|
Internal diameter of tube wall (m) |
Dm |
float
|
Outside diameter of metal wall (m) |
Ds |
float
|
Shell wall diameter (m) |
cpt, |
cpm, cps (float
|
Heat capacities (kJ/kg K) |
rhot, |
rhom, rhos (float
|
Densities (kg/m3) |
__call__(x, u)
Calculate the state derivatives for the heat exchanger.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
Current state [Tt1, Tm1, Ts1, ..., Tt8, Tm8, Ts8] |
required |
u
|
ndarray
|
Input [Ft, Fs, Tt0, Ts9] |
required |
Returns:
Type | Description |
---|---|
np.ndarray: State derivatives |
info()
Get model information.
Returns:
Name | Type | Description |
---|---|---|
dict |
Dictionary containing model parameters, states, inputs, and disturbances. |
biofilm_reactor
dataclass
Biofilm reactor model.
Attributes:
Name | Type | Description |
---|---|---|
V |
float
|
Volume of one reactor stage (L) |
Va |
float
|
Volume of absorber tank (L) |
Kla |
float
|
Transfer coefficient (hr) |
m |
float
|
Equilibrium constant |
eq_exponent |
float
|
Nonlinearity of equilibrium relationship |
O_air |
float
|
Concentration of oxygen in air (mg/L) |
vm_1, |
vm_2 (float
|
Maximum velocities through fluidized bed (mg/L hr) |
K1, |
K2 (float
|
Equilibrium constants for reactions |
KO_1, |
KO_2 (float
|
Equilibrium constants for oxygen |
int_method |
str
|
Integration method ('jax' or other) |
__call__(x, u)
Calculate the state derivatives for the biofilm reactor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
Current state [S1_1, S2_1, S3_1, O_1, ..., S1_A, S2_A, S3_A, O_A] |
required |
u
|
ndarray
|
Input [F, Fr, S1_F, S2_F, S3_F] |
required |
Returns:
Type | Description |
---|---|
np.ndarray: State derivatives |
info()
Get model information.
Returns:
Name | Type | Description |
---|---|---|
dict |
Dictionary containing model parameters, states, inputs, and disturbances. |
polymerisation_reactor
dataclass
Polymerisation reactor model.
Attributes:
Name | Type | Description |
---|---|---|
Ap, |
Ad, At (float
|
Pre-exponential factors (1/sec) |
Ep_over_R, |
Ed_over_R, Et_over_R (float
|
Activation energies over R (K) |
f |
float
|
Reactivity fraction for free radicals |
V |
float
|
Reactor volume (m3) |
deltaHp |
float
|
Heat of reaction per monomer unit (kJ/kmol) |
rho |
float
|
Density of input fluid mixture (kg/m3) |
cp |
float
|
Heat capacity of fluid mixture (kj/kg K) |
__call__(x, u)
Calculate the state derivatives for the polymerisation reactor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
Current state [T, M, I] |
required |
u
|
ndarray
|
Input [F, Tf, Mf, If] |
required |
Returns:
Type | Description |
---|---|
np.ndarray: State derivatives |
info()
Get model information.
Returns:
Name | Type | Description |
---|---|---|
dict |
Dictionary containing model parameters, states, inputs, and disturbances. |
crystallization
dataclass
Crystallization of K2SO4 Control (PBE Model).
This model represents a highly nonlinear crystallization process based on population balance equations (PBE). It simulates the evolution of crystal size distribution and concentration during the crystallization process.
Attributes:
Name | Type | Description |
---|---|---|
ka |
float
|
Nucleation rate constant |
kb |
float
|
Nucleation activation energy parameter |
kc |
float
|
Nucleation supersaturation exponent |
kd |
float
|
Nucleation crystal density exponent |
kg |
float
|
Growth rate constant |
k1 |
float
|
Growth activation energy parameter |
k2 |
float
|
Growth supersaturation exponent |
a |
float
|
Moment model parameter for nucleation |
b |
float
|
Moment model parameter for growth |
alfa |
float
|
Shape factor for volume calculation |
ro |
float
|
Crystal density (g/cm^3) |
int_method |
str
|
Integration method ('jax' or other) |
Reference
https://pubs.acs.org/doi/10.1021/acs.iecr.3c00739
__call__(x, u)
Calculate the state derivatives for the crystallization model.
This method computes the rates of change for the moments of the crystal size distribution and the solute concentration based on the current state and input temperature.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
Current state vector containing: - mu0 (float): 0th moment of crystal size distribution - mu1 (float): 1st moment of crystal size distribution - mu2 (float): 2nd moment of crystal size distribution - mu3 (float): 3rd moment of crystal size distribution - conc (float): Solute concentration |
required |
u
|
ndarray
|
Input vector containing: - T (float): Temperature (°C) |
required |
Returns:
Type | Description |
---|---|
np.ndarray: State derivatives vector containing: - dmu0/dt: Rate of change of 0th moment - dmu1/dt: Rate of change of 1st moment - dmu2/dt: Rate of change of 2nd moment - dmu3/dt: Rate of change of 3rd moment - dconc/dt: Rate of change of solute concentration |
info()
Get model information.
This method returns a dictionary containing information about the model's parameters, states, inputs, and disturbances.
Returns:
Name | Type | Description |
---|---|---|
dict |
Dictionary containing: - parameters: Model parameters - states: Names of state variables - inputs: Names of input variables - disturbances: Names of disturbance variables (if any) |