6.1 Draining of a Tank
213
Fig. 6.6 Creating a LimitValue Function (output limit)
This function, which has three input variables and one output variable, is as
follows:
function LimitValue
input Real pMin;
input Real pMax;
input Real p;
output Real pLim;
algorithm
pLim:=if p > pMax then pMax else if p < pMin then pMin
else p;
end LimitValue;
Now, we will create the main model using the obtained equations and parameter
values given to us in the task:
model FlatTank ”Flat model of a tank”
parameter Real q0(unit = ”m3/s”) = 0.15 ”Scaling of input
flow”;
parameter Real A(unit = ”m2”) = 1.0 ”Tank bottom area”;
parameter Real K(unit = ”m2/s”) = 0.1 ”PI controller gain”;
parameter Real T(unit = ”s”) = 10 ”PI controller integrator
time constant”;
parameter Real minFlow(unit = ”m3/s”) = 0.0 ”Minimum flow
through output valve”;
parameter Real maxFlow(unit = ”m3/s”) = 0.5 ”Maximum flow
through output valve”;
parameter Real ref(unit = ”m”) = 0.25 ”Reference level
for control”;
Real h(start = 0, unit = ”m”) ”Tank level”;
Real qIn(unit = ”m3/s”) ”Flow through input valve”;
Real qOut(unit = ”m3/s”) ”Flow through output valve”;
Real qOutMax(unit = ”m3/s”) ”Maximum output flow
considering that the tank level cannot be negative”;
Précédent

- 224/274

Suivant