PID-controlled temperature trajectories for a nonlinear first-order reactor system.
A Python-based simulation framework for analyzing nonlinear reactor dynamics under feedback control.
This project models a nonlinear first-order dynamic system with multiple equilibrium points and applies classical control strategies (P, PI, PID) to stabilize and regulate temperature behavior.
The simulator includes numerical integration, controller comparison, disturbance rejection analysis, phase portraits, and parameter tuning studies.
This project implements:
- Nonlinear first-order reactor dynamics with multiple equilibria
- Euler numerical simulation of system trajectories
- P, PI, and PID feedback controllers
- Setpoint tracking experiments
- Controller tuning studies (Kp, Ki, Kd sweeps)
- Disturbance rejection analysis
- Stability and overshoot comparison
- Phase portrait visualization (open-loop vs closed-loop)
- CSV export of all simulation data
- Automated plot generation for all experiments
The reactor is modeled as:
dT/dt = -k · (T - T₁) · (T - T₂) · (T - T₃)
Where:
- T₁ = 250 K (stable equilibrium)
- T₂ = 300 K (unstable equilibrium)
- T₃ = 350 K (stable equilibrium)
This produces a multi-stable nonlinear system commonly used to study control stability and bifurcations.
u = Kp · (Tset - T)
u = Kp · e + Ki · ∫e dt
u = Kp · e + Ki · ∫e dt + Kd · de/dt
Controllers are used to regulate system temperature toward a defined setpoint (typically 320 K).
The project includes multiple structured experiments:
- Tests system behavior from multiple initial conditions
- Compares controlled vs uncontrolled dynamics
- Evaluates controller performance in tracking a fixed target temperature
- Sweeps across:
- Kp values (P controller)
- Ki values (PI controller)
- Kd values (PID controller)
- Evaluates overshoot, stability, and response speed
- Applies a step disturbance at t = 0.5 s
- Compares rejection performance of P, PI, and PID controllers
- Demonstrates PID instability under high derivative gain
- Compares P vs PI performance tradeoffs
- Visualizes system vector field
- Compares open-loop vs closed-loop dynamics
Trajectories from multiple initial conditions converging toward stable equilibrium states.
PID controller response during setpoint tracking to 320 K.
Comparison of proportional and proportional-integral control performance during setpoint tracking.
Controller responses to a step disturbance introduced during operation.
Phase portrait showing stable and unstable equilibrium points of the nonlinear reactor model.
All simulation results are exported as structured CSV files:
results/data/
|--- basin_dynamics/
|--- setpoint_tracking/
|--- disturbance_response/
Each CSV file contains simulation time data and one or more temperature trajectories generated during the experiments.
The exported data can be analyzed further using Python, Excel, MATLAB, or other scientific computing tools.
This allows external analysis in Python, Excel, or MATLAB.
Process-Dynamics-and-Control-Lab/
|
|--- controllers/
| |--- p.py
| |--- pi.py
| |--- pid.py
|
|--- experiments/
| |--- basin_study.py
| |--- setpoint_tracking.py
| |--- tuning_study.py
| |--- disturbance_response.py
|
|--- models/
| |--- first_order_system.py
|
|--- simulation/
| |--- simulator.py
|
|--- visualization/
| |--- plots.py
|
|--- utils/
| |--- data_export.py
|
|--- parameters.py
|--- main.py
|
|--- results/
| |--- plots/
| |--- data/
|
|--- requirements.txt
|--- LICENSE
|--- .gitignore
|--- README.md
git clone https://github.com/MatthewNguyen865/Process-Dynamics-and-Control-Lab.gitpip install -r requirements.txtpython main.pyThis will:
- run all experiments
- generate plots
- export CSV data into
results/data/
- Feedback control loops
- PID tuning
- Stability and overshoot analysis
- Euler integration
- Discrete-time simulation
- Finite difference derivatives
- Nonlinear reactor dynamics
- Multiple steady states and stability analysis
- Process control and setpoint regulation
- Disturbance rejection in process systems
- Add anti-windup for integral term
- Replace Euler method with RK4 solver
- Add automatic PID tuning (Ziegler–Nichols)
- Add interactive dashboard (Plotly / Streamlit)
- Extend to coupled mass and energy balance models
Matthew Nguyen
Chemical Engineering Student
Texas A&M University


