Modeling a water tank system using h(t)

19 views (last 30 days)
Maria
Maria on 26 Nov 2023
Answered: Sam Chak on 27 Nov 2023
I'm trying to model a water tank system with Simulink using the equation (derived from the diff eq for the system)
h(t) = h(0)e^-t/RC
and another w/ q_i
h(t) = q_i*R + (h(0) - qi*R)*e^-t/RC
q_i, R, h(0), and C are all solved constants. I've been trying to figure it out piece by piece on Simulink but keep running into road blocks and am asking for some guidance. Thanks!
  2 Comments
madhan ravi
madhan ravi on 26 Nov 2023
Edited: madhan ravi on 26 Nov 2023
show us what you have tried so far in Simulink
Maria
Maria on 27 Nov 2023
This is for the first equation. I've been trying to figure out how to input -t/RC for u in the exponential

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 27 Nov 2023
Clock signal, Constant -1, Constant R, Constant C: all inputs to a multiply/divide block with * for Clock and -1 and / for R and / for C.
Send output to e^u math block. Send output to multiply block with * type; Constant h(0). Send output to multiply block with * type.
Result is h(0)*exp(-t/(R*C))

Sam Chak
Sam Chak on 27 Nov 2023
The equation you showed, , is actually the analytical solution of a 1st-order linear system that exhibits an exponential decay time response. This analytical solution, , is a function of time that also depends on the initial value and the parameters R and C. However, the analytical solution is commonly used for comparison with the numerical result predicted by a mathematical model. More importantly, most water tanks don't behave as if the water is always drained exponentially like the electrical Capacitor discharge.
If you are referring to the water tank level, modeling the water tank usually requires the ordinary differential equation (ODE) that describes the rate of change of the water level over time. For a single water tank, you can find the ODE in this example, or it is given here:
.
Note that this is a 1st-order nonlinear system due to the nonlinearity that comes from the square root term. Also, the analytical solution of such a nonlinear ODE is a Lambert W-Function, which can be analytically solved using the dsolve() command:
syms h(t)
eqn = diff(h,t) == - 2*sqrt(h) + 3; % watertank dynamics (differential form)
cond = h(0) == 1; % initial condition
hSol(t) = dsolve(eqn, cond) % analytical solution
hSol(t) = 
If you want to model the water tank in Simulink, you can refer to the Water Tank example by entering the syntax "open('watertank')" in the Workspace. However, I prefer constructing models in Simulink as part of the learning process. Note that in Simulink, we model the water tank system in integral form using the Integrator block. In MATLAB, we solve the differential form of the system using ode solvers.
The blocks in Simulink are constructed according to this integral equation (as an input to the Integrator Limited block):
where V is the voltage applied to the water pump, and the value is determined by the PI controller:

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!