Modeling a water tank system using h(t)
13 views (last 30 days)
Show older comments
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
on 26 Nov 2023
Edited: madhan ravi
on 26 Nov 2023
show us what you have tried so far in Simulink
Answers (2)
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))
0 Comments
Sam Chak
on 27 Nov 2023
Hi @Maria
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1553037/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1553042/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1553047/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1553052/image.png)
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
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):
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1553062/image.png)
where V is the voltage applied to the water pump, and the value is determined by the PI controller:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1553067/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1553072/image.png)
0 Comments
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!