A Batch Trajectory With a Safety Limit

A jacketed semi-batch reactor with a dosing pump feeding a reagent

Open the Semi-Batch Exothermic Reactor app

Advanced Control Exercise 22 of 30 in Nonlinear and Economic MPC · All exercises · Time: 15 minutes

A semi-batch reactor is safe only if the reagent fed but not yet reacted could not, should the cooling fail, heat the batch past a limit. The fastest batch feeds as hard as that limit allows. This exercise compares a one-step optimizer that feeds to its limit now with an MPC that predicts the temperature its feed will cause, and then compares the MPC linearized once with the same MPC relinearized along its own plan.

Learning Outcomes

  • Formulate a batch problem with a time objective, a path constraint and a safety constraint on accumulation.
  • Compare a one-step optimizer and an MPC by batch time, temperature cuts and margin to the limit.
  • Explain relinearizing along the plan as a sequential quadratic programming step toward nonlinear MPC.

Book Chapter

Batch, Run-to-Run, and Hybrid Control (Volume 8), Chapter 2, Semi-Batch Exothermic Reactor Simulator With Dosing as the Safety Layer. Read the chapter, open the PDF, or watch the lecture slides.

Theory in Brief

The safety measure is the maximum temperature of the synthesis reaction (MTSR): the temperature the batch would reach if the cooling failed and the unreacted reagent `n_{acc}` reacted adiabatically,

$$\mathrm{MTSR} = T + \frac{(-\Delta H)\, n_{acc}}{m\, c_p}$$

The feed `F` should finish the batch fast while the temperature stays under the cut and the MTSR under its own limit:

$$\begin{gathered} \min_{F(t)} t_f \\ \mathrm{s.t.}\quad \dot x = f(x, F), \\ T(t) \le T_{cut} - b, \mathrm{MTSR}(t) \le \mathrm{MTSR}_{max}, 0 \le F \le F_{max} \end{gathered}$$

with a back-off `b` for model error. A one-step optimizer picks the largest feed that satisfies the limits now; it cannot see the temperature rise its feed will cause later. An MPC predicts it over a horizon. Its model is nonlinear in `T` through the Arrhenius rate, so the plan linearizes it. Linearized once at the current state, the prediction is right only near now. Relinearized along the plan just computed,

$$x_{k+1} \approx f(\bar x_k, \bar F_k) + A_k \left(x_k - \bar x_k\right) + B_k \left(F_k - \bar F_k\right)$$

each pass is one step of sequential quadratic programming, and repeating it converges toward the nonlinear MPC's plan.

Model: Physics-based. Mass and energy balances of the batch, with the unreacted reagent estimated by a reaction calorimeter.
Decision: The reagent feed rate, planned over a horizon against the temperature cut and the MTSR limit.
Learning: The calorimeter estimates the accumulation online from the heat balance; the plan trusts its estimate.

Exercise

Read 2 min · Predict 1 min · Run 7 min · Explain 3 min · Check your AI 2 min.

Predict. The one-step optimizer feeds as hard as the limits allow right now. Will it finish the batch sooner than the MPC, and at what cost? Will relinearizing the MPC's model along its plan make the batch faster, safer, or both?

Run the Semi-Batch Exothermic Reactor app. Use the fastest speed, 300 min/s, and press Run again to pause at the times in each step.

  1. Open 9 · MPC: the temperature cut, planned ahead. Press Run and let the batch finish. Read Dose finished, Batch, Highest T and Worst |T − SP|.
  2. Press Reset, set Dosing strategy to One-step optimizer before pressing Run, and run to the end. Read the same tiles and count the temperature cuts.
  3. Open 10 · MPC: linearized once or along its own plan, a different batch (case 2's recipe, dosed from 10 min), so compare it only with its own second run. Run to the end. Then press Reset, set MPC linearization to Single (Advanced), and run again.

Explain.

  1. Why does the one-step optimizer finish sooner but get cut, while the MPC is never cut?
  2. What does relinearizing along the plan correct, and what does it still not know about the plant?

Generative AI Learning

"For a semi-batch exothermic reactor, explain MTSR and accumulation, and formulate the dosing problem as an optimal control problem with a safety constraint. How would an MPC solve it in real time?"

Check the answer against your run: A good answer defines MTSR with the accumulated reagent, writes a time or productivity objective with temperature and MTSR constraints, and describes linearizing or iterating the model inside the MPC. Compare its constraints with the theory. The assistant is your tutor and reviewer; you answer for every claim you turn in.

What to Turn In

A four-row table (MPC, one-step optimizer, MPC iterated, MPC single) with dose end, batch end, highest T and worst deviation, your written prediction, and three sentences that answer the two questions.

The MPC's dose finishes at 3:38 and the batch at complete 3:52, with a highest temperature of 71.9 °C and Worst |T − SP| 1.87 K. The one-step optimizer finishes its dose at 3:28 and the batch at complete 3:46, but its highest temperature is 73.2 °C and its worst deviation 3.00 K: it feeds to its limit now, the temperature passes the 72 °C cut a few minutes later, and the cut stops the feed, again and again. The MPC predicts the temperature its feed will cause and plans it just under the cut less its back-off, so it is never cut and holds the batch closer to its setpoint, at the price of a little more time.

Relinearized along its own plan, the MPC's dose ends at 2:55 and the batch at complete 3:18; linearized once, at 2:58 and complete 3:23, both at 71.9 °C. Linearized once, the plan overestimates the temperature its later feed will cause, so it holds the batch further below the ceiling than it needs to. Iterating makes the plan right about the controller's model. It still uses the calorimeter's estimates, so it is no better than they are about the real plant.

Measured with the app build of December 3, 2026 by a scripted replay of the steps above. Numbers that no tile shows come from the replay's record; your readings from the trends will be close. A later app release may move the last digit.

Nonlinear Control and Formulation pose batch problems in GEKKO. Write the semi-batch balances with a free final time and the MTSR constraint, solve for the feed profile with `IMODE=6`, and compare its shape with the MPC's feed trend.

Related

References

  1. Hedengren, J. D. (ed.), Batch, Run-to-Run, and Hybrid Control, Volume 8 of Interactive Control Engineering, Chapter 2, "Semi-Batch Exothermic Reactor Simulator With Dosing as the Safety Layer", pp. 23–54, Advanced Process Solutions, 2026. PDF (CC BY 4.0).
  2. Stoessel, F., Thermal Safety of Chemical Processes: Risk Assessment and Process Design, 2nd ed., Wiley-VCH, 2020, Chapter 7.

Course Information

TCLab

Project

Applications

Advanced Control Exercises

Exams

Modeling

Machine Learning

Estimation

Control

Reinforcement Learning

Related Courses

Admin