Examples.QuadTankPlant ​
Quadruple-tank process (Johansson) with two pumps: the lower tanks 1 and 2 are fed by their own pump and by the tank above; the fraction of each pump flow reaching the lower tank is gamma. Levels in cm, pump voltages in V. Translated from the DyadControlSystems quadtank tutorial (non-minimum-phase setting gamma1 = gamma2 = 0.2). The square roots are regularized so the model is smooth near empty tanks.
Usage ​
MPCComponents.Examples.QuadTankPlant(k1=1.6, k2=1.6, g=9.81, A=4.9, a=0.03, gamma1=0.2, gamma2=0.2, h10=2.0, h20=1.0, h30=8.0, h40=3.0)
Parameters: ​
| Name | Description | Units | Default value |
|---|---|---|---|
k1 | – | 1.6 | |
k2 | – | 1.6 | |
g | – | 9.81 | |
A | – | 4.9 | |
a | – | 0.03 | |
gamma1 | – | 0.2 | |
gamma2 | – | 0.2 | |
h10 | Initial levels | – | 2.0 |
h20 | – | 1.0 | |
h30 | – | 8.0 | |
h40 | – | 3.0 |
Connectors ​
u1- This connector represents a real signal as an input to a component (RealInput)u2- This connector represents a real signal as an input to a component (RealInput)y1- This connector represents a real signal as an output from a component (RealOutput)y2- This connector represents a real signal as an output from a component (RealOutput)y3- This connector represents a real signal as an output from a component (RealOutput)y4- This connector represents a real signal as an output from a component (RealOutput)
Variables ​
| Name | Description | Units |
|---|---|---|
h1 | – | |
h2 | – | |
h3 | – | |
h4 | – |
Behavior ​
Behavior of this component cannot be rendered because it includes path variables.
Source ​
"""
Quadruple-tank process (Johansson) with two pumps: the lower tanks 1 and 2 are fed by their own pump
and by the tank above; the fraction of each pump flow reaching the lower tank is `gamma`. Levels in cm,
pump voltages in V. Translated from the DyadControlSystems quadtank tutorial (non-minimum-phase setting
`gamma1 = gamma2 = 0.2`). The square roots are regularized so the model is smooth near empty tanks.
"""
component QuadTankPlant
"Pump 1 voltage"
u1 = RealInput() {
"Dyad": {"placement": {"diagram": {"x1": -100, "x2": 0, "y1": 210, "y2": 310}}}
}
"Pump 2 voltage"
u2 = RealInput() {
"Dyad": {"placement": {"diagram": {"x1": -100, "x2": 0, "y1": 730, "y2": 830}}}
}
"Level of tank 1"
y1 = RealOutput() {
"Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 110, "y2": 210}}}
}
"Level of tank 2"
y2 = RealOutput() {
"Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 320, "y2": 420}}}
}
"Level of tank 3"
y3 = RealOutput() {
"Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 580, "y2": 680}}}
}
"Level of tank 4"
y4 = RealOutput() {
"Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 800, "y2": 900}}}
}
parameter k1::Real = 1.6
parameter k2::Real = 1.6
parameter g::Real = 9.81
parameter A::Real = 4.9
parameter a::Real = 0.03
parameter gamma1::Real = 0.2
parameter gamma2::Real = 0.2
"Initial levels"
parameter h10::Real = 2.0
parameter h20::Real = 1.0
parameter h30::Real = 8.0
parameter h40::Real = 3.0
variable h1::Real(initial = h10)
variable h2::Real(initial = h20)
variable h3::Real(initial = h30)
variable h4::Real(initial = h40)
relations
der(h1) = -a / A * sqrt(max(2 * g * h1, 0) + 0.001) + a / A * sqrt(max(2 * g * h3, 0) + 0.001) + gamma1 * k1 / A * u1
der(h2) = -a / A * sqrt(max(2 * g * h2, 0) + 0.001) + a / A * sqrt(max(2 * g * h4, 0) + 0.001) + gamma2 * k2 / A * u2
der(h3) = -a / A * sqrt(max(2 * g * h3, 0) + 0.001) + (1 - gamma2) * k2 / A * u2
der(h4) = -a / A * sqrt(max(2 * g * h4, 0) + 0.001) + (1 - gamma1) * k1 / A * u1
y1 = h1
y2 = h2
y3 = h3
y4 = h4
metadata {
"Dyad": {
"icons": {"default": "dyad://MPCComponents/QuadTankPlant.svg"},
"doc": {"behavior": false}
}
}
endFlattened Source
"""
Quadruple-tank process (Johansson) with two pumps: the lower tanks 1 and 2 are fed by their own pump
and by the tank above; the fraction of each pump flow reaching the lower tank is `gamma`. Levels in cm,
pump voltages in V. Translated from the DyadControlSystems quadtank tutorial (non-minimum-phase setting
`gamma1 = gamma2 = 0.2`). The square roots are regularized so the model is smooth near empty tanks.
"""
component QuadTankPlant
"Pump 1 voltage"
u1 = RealInput() {
"Dyad": {"placement": {"diagram": {"x1": -100, "x2": 0, "y1": 210, "y2": 310}}}
}
"Pump 2 voltage"
u2 = RealInput() {
"Dyad": {"placement": {"diagram": {"x1": -100, "x2": 0, "y1": 730, "y2": 830}}}
}
"Level of tank 1"
y1 = RealOutput() {
"Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 110, "y2": 210}}}
}
"Level of tank 2"
y2 = RealOutput() {
"Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 320, "y2": 420}}}
}
"Level of tank 3"
y3 = RealOutput() {
"Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 580, "y2": 680}}}
}
"Level of tank 4"
y4 = RealOutput() {
"Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 800, "y2": 900}}}
}
parameter k1::Real = 1.6
parameter k2::Real = 1.6
parameter g::Real = 9.81
parameter A::Real = 4.9
parameter a::Real = 0.03
parameter gamma1::Real = 0.2
parameter gamma2::Real = 0.2
"Initial levels"
parameter h10::Real = 2.0
parameter h20::Real = 1.0
parameter h30::Real = 8.0
parameter h40::Real = 3.0
variable h1::Real(initial = h10)
variable h2::Real(initial = h20)
variable h3::Real(initial = h30)
variable h4::Real(initial = h40)
relations
der(h1) = -a / A * sqrt(max(2 * g * h1, 0) + 0.001) + a / A * sqrt(max(2 * g * h3, 0) + 0.001) + gamma1 * k1 / A * u1
der(h2) = -a / A * sqrt(max(2 * g * h2, 0) + 0.001) + a / A * sqrt(max(2 * g * h4, 0) + 0.001) + gamma2 * k2 / A * u2
der(h3) = -a / A * sqrt(max(2 * g * h3, 0) + 0.001) + (1 - gamma2) * k2 / A * u2
der(h4) = -a / A * sqrt(max(2 * g * h4, 0) + 0.001) + (1 - gamma1) * k1 / A * u1
y1 = h1
y2 = h2
y3 = h3
y4 = h4
metadata {
"Dyad": {
"icons": {"default": "dyad://MPCComponents/QuadTankPlant.svg"},
"doc": {"behavior": false}
}
}
endTest Cases ​
No test cases defined.
Related ​
Examples
Experiments
Analyses