Simulation Control

t_end — Simulation Time (s)

Type the simulation time and press Enter to apply.

Temperature PID → Coolant Tc

Kp 3.00
Ki 1.00
Kd 0.30
Setpoint T (K) 350.0
Coolant Bias Tc0 (K) 300
β — P Setpoint Weight 1.00
γ — D Setpoint Weight 0.00
PV Noise σ (K) 0.000
α — D Filter (0 = off) 0.00

Concentration PID → Feed q

Kp 30.0
Ki 8.0
Kd 1.50
Setpoint CA (mol/L) 0.50
Feed Bias q0 100
β — P Setpoint Weight 1.00
γ — D Setpoint Weight 0.00
PV Noise σ (mol/L) 0.000
α — D Filter (0 = off) 0.00

Disturbances (live)

Feed Conc. CAin 1.00
Feed Temp Ti (K) 350

Drag these while running to watch both loops reject the disturbance.

Reactor Parameters

V — Volume (m³) 100
UA — Heat Transfer (W/K) 50.0k
k₀ — Pre-exponential (1/s) 7.2e10
E/R — Activation (K) 8750
ΔHr -5.0e4
ρ — Density (kg/m³) 1000
Cp — Heat Capacity 0.239

Initial Conditions

CA0 (mol/L) 0.87725
T0 (K) 324.475

Changing an initial condition restarts the simulation.

Two-Loop Control T-loop: Tc = PIDT(Tsp − T)
CA-loop: q = PIDCA(CA,sp − CA)
Decentralized PID. The loops interact — coolant temperature and feed flow both affect T and CA. Try changing one setpoint and watch the other loop compensate.

CSTR Control Schematic

LIVE
T CA TEMPERATURE PID Tc out CONCENTRATION PID q out M q q = 100 Tc Tc = 300 K Coolant out Product out T = 324.5 K CA = 0.877 measurement control
t0.0 s
T324.5 K
CA0.877
Tc300.0 K
q100.0
eT+0.00 K
eCA+0.0000
PV Reactor Temperature T — controlled variable
MV Coolant Temperature Tc — manipulated by the T-loop
Temperature
324.5 K
Concentration
0.877
Coolant Tc
300.0 K
Feed q
100.0
Error T
0.00 K
Error CA
0.0000

Parameters & Equations

The reactor model and both control loops, written out for study.

Reactor Model

Mole balance dCA/dt = (q/V)(CAin − CA) − k·CA
Energy balance dT/dt = (q/V)(Ti − T) − ΔHr·k·CA/(ρCp) + UA(Tc − T)/(ρCpV)
Arrhenius rate k = k0·exp(−(E/R)/T) The exponential makes the system stiff: small T changes cause large rate changes.

Two Control Loops — 2-DOF PID 2-DOF

Temperature loop → coolant temperature Tc = clamp[ Tc0 + Kp,T(βT·Tsp − T) + Ki,T∫(Tsp−T)dt + Kd,T(γT·dTsp/dt − dT/dt), 250, 400 ]
Concentration loop → feed flow q = clamp[ q0 + Kp,CA(βCA·CA,sp − CA) + Ki,CA∫(CA,sp−CA)dt + Kd,CA(γCA·dCA,sp/dt − dCA/dt), 10, 300 ] The two loops interact: both Tc and q affect T and CA.
Term contributions (each loop) u = ubias + P + I + Df
P = Kp(β·SP − PV)
I = Ki∫(SP − PV)dt
Df[k] = a·Df[k−1] + (1−a)·Kd(γ·dSP/dt − dPV/dt),   a = exp(−Δt/τ) Only the sum u is limited by the actuator. When it saturates, anti-reset windup removes the over-drive from I so the integral cannot wind up.

β (beta) — proportional setpoint weight · γ (gamma) — derivative setpoint weight. β = 1, γ = 0 is a standard PID with derivative-on-measurement.

Reactor Parameters

SymbolMeaningDefault
CAinFeed concentration1.00 mol/L
VReactor volume100 m³
TiFeed temperature350 K
UAHeat-transfer coefficient5.0×10⁴ W/K
k0Pre-exponential factor7.2×10¹⁰ 1/s
E/RActivation temperature8750 K
ΔHrHeat of reaction−5.0×10⁴
ρDensity1000 kg/m³
CpHeat capacity0.239
Tc0, q0Controller bias (operating point)300 K, 100

Controller Parameters & Options

SymbolMeaningDefault (T / CA)
KpProportional gain3 / 30
KiIntegral gain1 / 8
KdDerivative gain0.3 / 1.5
Tsp, CA,spSetpoints350 K / 0.5 mol/L
β 2-DOFProportional setpoint weight1.00 / 1.00
γ 2-DOFDerivative setpoint weight0.00 / 0.00
α filterDerivative filter (0 = off)0.00 / 0.00
σ noisePV sensor noise std-dev0 K / 0 mol/L
AW windupAnti-reset windup (back-calculation)on / on

PV noise: each measurement is corrupted by zero-mean Gaussian noise: Tmeas = T + σT·N(0,1) and CA,meas = CA + σCA·N(0,1). The reactor state itself remains noise-free.

Anti-reset windup: when the actuator saturates, back-calculation bleeds the integral by the over-drive I ← I + (Δt/Tt)(usat − u), so I settles at the value that holds the actuator on its limit instead of accumulating error. It is robust to noisy PVs (unlike an error-sign freeze test), and the integral is always kept within its own limits. Disable it to observe windup.

Derivative filter (α): Df[k] = a·Df[k−1] + (1−a)·Draw[k] with a = exp(−Δt/τ) and τ set from α. α = 0 disables filtering; larger α smooths the derivative (useful with noisy sensors). Because the filter is defined by a physical time constant τ (not a fixed per-sample weight), the same α gives the same smoothing at every integration step.