Deep Neural Network Nonlinear Model Predictive Control for CSTR#
Introduction#
The Continuous Stirred Tank Reactor (CSTR) is a fundamental model in chemical engineering, representing a reactor where the contents are well-mixed, ensuring uniform composition and temperature throughout. This report delves into the mathematical modeling of a CSTR, its simulation, and control using a Nonlinear Model Predictive Control (NMPC) strategy integrated with a neural network for predictive behavior.
CSTR Model#
The CSTR dynamics are governed by the mass and energy balance equations:
The reaction rate is:
Parameter |
Value Description |
---|---|
Initial Flow Rate |
Initial volumetric flow rate |
Initial Temperature |
Initial temperature |
Initial Concentration |
Initial concentration |
Reactor Radius |
Reactor radius |
Reaction Rate Constant |
Reaction rate constant |
Activation Energy/Gas Const |
Activation energy/gas constant |
Heat Transfer Coefficient |
Overall heat transfer coefficient |
Density |
Density |
Specific Heat Capacity |
Specific heat capacity |
Heat of Reaction |
Heat of reaction |
Small Value |
Small value |
Mass Fractions |
Mass fractions |
Input Parameters |
Input parameters |
Parameter Equations#
$$ F_0 = 0.1~\mathrm{m}^3/\mathrm{min} $$
$$ T_0 = 350.0~\mathrm{K} $$
$$ c_0 = 1.0~\mathrm{kmol}/\mathrm{m}^3 $$
$$ r = 0.219~\mathrm{m} $$
$$ k_0 = 7.2 \times 10^{10}~\mathrm{min}^{-1} $$
$$ \frac{E_b}{R} = 8750~\mathrm{K} $$
$$ U = 54.94~\mathrm{kJ}/(\mathrm{min}\cdot\mathrm{m}^2\cdot\mathrm{K}) $$
$$ \rho = 1000~\mathrm{kg}/\mathrm{m}^3 $$
$$ C_p = 0.239~\mathrm{kJ}/(\mathrm{kg}\cdot\mathrm{K}) $$
$$ \Delta H = -5 \times 10^4~\mathrm{kJ}/\mathrm{kmol} $$
$$ \varepsilon = 1 \times 10^{-5}~\mathrm{m} $$
$$ x_s = [0.878,,324.5,,0.659] $$
$$ u_s = [300,,0.1] $$
Nonlinear Model Predictive Control (NMPC)#
NMPC optimizes control inputs over a prediction horizon to minimize deviations from desired setpoints while respecting constraints.
Parameters#
Cost Function#
Where:
Weights:
Constraints#
ACADOS Configuration#
Solver: SQP / SQP-RTI
Integrator: IRK
QP Solver: PARTIAL_CONDENSING_HPIPM
Condensing: Full ($N$ intervals)
Regularization:
Neural Network Integration#
Data Preparation#
Gather time-series data: concentration, temperature, inflow, heat input
Scale input/output:
Neural Network Architecture#
Input: $ \mathbf{a}_0 = \mathbf{x} $
Hidden layers:
Output:
Training#
Loss: Mean Squared Error
Optimizer: Adam or SGD
Validation: Prevent overfitting using a held-out validation set.
Results#

Training loss over epochs#

DNN-NMPC simulation results for CSTR#
Conclusion#
The CSTR model, integrated with a neural network and controlled via NMPC, represents a sophisticated and powerful approach for managing complex chemical systems. This architecture allows for efficient real-time control and adaptation to dynamic operating conditions.