A Physics-Based Model With a Moving Time Constant

A gravity-drained tank with an inlet valve above and an outlet valve below

Open the Tank Level Control Studio app

Advanced Control Exercise 1 of 30 in Dynamic Models · All exercises · Time: 15 minutes

The first model in this course is a mass balance you can write in one line. Linearize it and the time constant and gain depend on where the tank sits, so a model fitted at one operating point is wrong at another. This exercise computes how wrong, then runs an MPC built on the old model.

Learning Outcomes

  • Derive the mass balance of a gravity-drained tank and linearize it at an operating point.
  • Compute the time constant and gain at two outlet settings and explain why they move.
  • Predict how an MPC whose model gain is five times too large handles a setpoint step, and compare it with a PID.

Book Chapter

Process Dynamics, Modeling, and Identification (Volume 1), Chapter 2, Gravity-Drained Tank Laboratory for Level Loops With a Moving Time Constant. Read the chapter, open the PDF, or watch the lecture slides.

Theory in Brief

With cross-section `A`, an inlet flow proportional to the valve opening `u` and Bernoulli drainage through an outlet opened to `u_{out}`, the balance is

$$A \frac{dh}{dt} = c_{in}\, u - k \sqrt{h}, \qquad k = c_{out} \frac{u_{out}}{100}$$

This is the general form `\dot x = f(x,u,p)` with one state. Linearize about a steady level `\bar h` with `\delta h = h - \bar h`:

$$\tau \frac{d\,\delta h}{dt} = -\delta h + K\, \delta u, \qquad \tau = \frac{2A\sqrt{\bar h}}{k}, \qquad K = \frac{2 c_{in} \sqrt{\bar h}}{k}$$

The app's tank has `A` = 1 m², `c_{in}` = 0.05 m³/s per percent of inlet and `c_{out}` = 0.35 m³/s/m½ (Show Model lists them). At `\bar h` = 10 m with the outlet at 10 %, `k` = 0.035 and `\tau \approx` 181 s; with the outlet at 50 %, `k` = 0.175 and `\tau \approx` 36 s, and the gain `K` falls by the same factor of five. Every linear model in this course is a snapshot like this one, valid near the point it was taken.

Model: Physics-based. One mass balance with Bernoulli drainage, linearized for the controller at a 10 % outlet.
Decision: The inlet valve opening, from a PID or from an MPC that plans with the linearized model.
Learning: None yet. Exercises 3 and 4 fit models like this one to data instead of deriving them.

Exercise

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

Predict. Compute `\tau` and `K` at both outlet settings. The MPC's model was fitted at the 10 % outlet, so after the outlet opens it believes the tank is five times more sensitive than it is. Will it still remove the offset after a setpoint step? Will it move the inlet more or less than the PID?

Run the Tank Level Control Studio app. Use the fastest speed, 10×, and press Run again to pause at the times in each step.

  1. Press Show Model and confirm the three parameters above. Compute `\tau` and `K` at 10 % and 50 % outlet.
  2. Open 9 · MPC on a tank it was not fitted to. The MPC is in charge in Auto: the outlet opens from 10 % to 50 % at 5 s and the setpoint steps from 10.00 to 11.20 m at 30 s. Press Run and pause at 60 s. Read the IAE and the MV travel in the Control performance tiles.
  3. Set Controller to PID, press Reset, and run the same case to 60 s.

Explain.

  1. The MPC's model gain is five times too large. Why does it still reach the setpoint without offset?
  2. Which model error would hurt the MPC more on this plant, a wrong gain or a wrong order of dynamics, and why?

Generative AI Learning

"Derive the linearized time constant of a gravity-drained tank with A dh/dt = c u − k √h, then evaluate it for A = 1 m², h = 10 m, k = 0.035 and k = 0.175."

Check the answer against your run: Check the derivation against the theory above and the numbers against your own calculation: 181 s and 36 s. A common error is to drop the factor of 2 from the derivative of √h. The assistant is your tutor and reviewer; you answer for every claim you turn in.

What to Turn In

A table with one row per run and the numbers each step asks you to read, your written prediction, and three sentences that answer the two questions.

The time constants are about 181 s at the 10 % outlet and 36 s at 50 %, and the gains fall by the same factor of five. Under the MPC the level IAE over the 60 s run is 6.3 m·s with 92 % of inlet travel; under the PID it is 48.4 m·s with 191 % of travel, and the PID ends 0.91 m short of 11.20 m because it has only proportional action here.

The MPC removes the offset because its estimator turns the mismatch into a load it can see (a disturbance state `\hat d`), and each new plan starts from the measured level. A wrong gain makes each move the wrong size, and the next plan corrects it. A wrong order of dynamics is worse, as exercise 16 shows: the plan expects the water to arrive at the wrong time, and re-planning cannot fix timing it has no model for.

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.

Level Control and Dynamic Modeling write this tank in GEKKO. Simulate the nonlinear balance and the linear model side by side for an inlet step at `\bar h` = 2 m and 10 m, and plot both: the gap between the curves is the linearization error the MPC lives with.

Related

References

  1. Hedengren, J. D. (ed.), Process Dynamics, Modeling, and Identification, Volume 1 of Interactive Control Engineering, Chapter 2, "Gravity-Drained Tank Laboratory for Level Loops With a Moving Time Constant", pp. 23–52, Advanced Process Solutions, 2026. PDF (CC BY 4.0).

Course Information

TCLab

Project

Applications

Advanced Control Exercises

Exams

Modeling

Machine Learning

Estimation

Control

Reinforcement Learning

Related Courses

Admin