Water Storage Tank Modelling

16 views (last 30 days)
Abdelmoniem Abomosalam
Abdelmoniem Abomosalam on 15 Nov 2023
Commented: Sam Chak on 28 Nov 2023
I am assigned to work on a project where I am required to perform multiple types of data analyses on process data using Python/Matlab. The analyses chosen must relate to at least one process objective (e.g., fault detection). I am required to choose one basic linear technique and one more advanced technique. For example, you could choose to solve a regression problem using multiple linear regression and deep learning neural networks. Similarly, you could do feature extraction using PCA and convolution neural networks/autoencoders.
I was thinking to consider model a simple system like a water storage tank with two pumps and two valves aimed at maintaining a certain set point. I am uncertain about where to begin. should I start by modeling water tank system using differential equations that describe the rate of change of water level in the tank to generate data representing normal operating conditions. Then I would introduce faults in the form of sensors biases to generate faulty data. I am not aware on how one can model bias to accurately represent the behavior of a sensor. Also, how can I apply regression techniques to predict the water level if I lack actual measurements?

Answers (2)

SOUMNATH PAUL
SOUMNATH PAUL on 28 Nov 2023
Hi,
To my understanding you are trying to:
  1. Conduct diverse data analyses using Python/MATLAB for a process objective.
  2. Seeking help for a basic linear method and an advanced method.
  3. You are considering modelling a water storage tank with 2 pumps and 2 valves aimed at maintaining set point.
  4. You want to begin by modelling the water tank system using differential equations to generate data representing normal operating conditions.
  5. You want to simulate faults by introducing biases in sensor data, reflecting sensor behaviour under faulty conditions.
  6. Address the challenge of accurately modelling sensor biases to realistically represent their behavior in a faulty scenario.
  7. Explore how regression techniques can be applied to predict water levels in the absence of direct measurements.
Here are some suggestions that you can follow:
  1. Begin the project by focusing on modelling a water storage tank system using Simulink. Here’s how you can do this https://in.mathworks.com/help/slcontrol/gs/watertank-simulink-model.html
  2. Kindly utilize differential equations to precisely describe the dynamics of the system, particularly the rate of change of water level in the tank.
  3. To simulate faults, you can introduce biases to sensors in your Simulink model. For instance, you can add biases to the level sensors to mimic faulty data.
  4. Adjust sensor readings to represent different fault scenarios, such as sensor bias or inaccuracies. Model sensor bias by adding an offset to the sensor readings. For example, if the actual water level is 100 units, introduce a bias that might make the sensor report 90 units.
  5. Simulate the system with introduced biases to generate faulty data. This data can be used to train and test your fault detection algorithm.
  6. If you lack actual measurements for the water level, you can use regression techniques to predict it based on other available data. Collect various parameters from your system (e.g., pump speeds, valve positions) as input features and the water level as the output variable for the regression model.
  7. Implement your data analysis and regression techniques in MATLAB. Use MATLAB's regression functions to train your model on the normal operating data and test its predictive capabilities on the faulty data. Here is an example of how to do it https://in.mathworks.com/help/stats/train-linear-regression-model.html
  8. For a basic linear technique, kindly consider using simple linear regression in MATLAB to predict the water level based on selected parameters.
  9. For a more advanced technique, kindly use MATLAB’s built-in functions for creating and training neural networks. Here is how you can do this https://in.mathworks.com/help/deeplearning/ref/trainnetwork.html
You can consider going through the below mentioned link for more information on fault detection using data-based models.
Hope it helps!
Regards,
Soumnath

Sam Chak
Sam Chak on 28 Nov 2023
Your question is quite broad, so I recommend starting with the modeling of water tank level control. If successful, you can then incorporate additional components into the system based on your research objectives. Below, I'll provide a demonstration MATLAB code. The water tank parameters are extracted from a Simulink model, which you can access by typing the following syntax in the Workspace: "open('watertank')".
The Simulink model for the watertank employs a PI controller. However, I have personally adjusted the PI control gains since the existing controller in the Simulink model did not yield satisfactory water level control performance from certain initial heights. Ideally, if the initial water level is at the desired height, the level controller should not take any action. Due to this, I believe a different controller should be considered.
%% Call ODE solver
tspan = [0 30]; % Simulation time
L0 = 1; % Initial water level <-- change this value [0 – 10]
h0 = [L0; 0]; % Initial values
[t, h] = ode45(@(t, h) watertank(t, h, L0), tspan, h0);
%% Plot result
wLvl = h(:,1); % Water level
plot(t, wLvl), grid on
xlabel('t'), ylabel('h(t)')
title('Time response of Water Level in the Tank')
%% Water Tank Level Control System
function dhdt = watertank(t, h, L0)
dhdt = zeros(2, 1);
href = 10; % Desired water level (Reference height)
herr = h(1) - href; % Difference btw measured water level & href (Error height)
hint = h(2); % Integral of error height (for control purposes)
% Parameters
a = 2; % Rate of outflow
b = 5; % Rate of inflow
A = 20; % Cross-sectional area of tank
Kp = 1.6; % Proportional control gain
% Initial Level-dependent Ki Gain Schedule
L0_dat = [0.0 1.5 3.0 4.5 6.0 7.5 9.0];
Ki_dat = [0.04903711987232 0.05671571146904 0.06731531487845 0.08273450262417 0.106860786145 0.1474455450287 0.2005176417837];
[P, S] = polyfit(L0_dat, Ki_dat, 6);
Ki = polyval(P, L0); % Integral control gain
% PI Controller
u = - Kp*herr - Ki*hint;
% Differential equations
dhdt(1) = - (a/A)*sqrt(h(1)) + (b/A)*u; % Water tank dynamics
dhdt(2) = herr; % auxiliary variable
end
  1 Comment
Sam Chak
Sam Chak on 28 Nov 2023
This plots the time responses of the water level for different initial values. As you can observe, the proposed P + Gain-scheduled I controller is capable of ensuring fixed-time convergence (around ) for any initial values of the water level.
L0 = 0:9; % A vector of initial values of water level
for j = 1:length(L0)
%% Call ODE solver
tspan = [0 30]; % Simulation time
h0 = [L0(j); 0]; % Initial values
[t, h] = ode45(@(t, h) watertank(t, h, L0(j)), tspan, h0);
%% Plot result
wLvl = h(:,1); % Water level
plot(t, wLvl), hold on
end
grid on
xlabel('t'), ylabel('h(t)')
title('Time responses of Water Level in the Tank')
hold off

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!