-
Notifications
You must be signed in to change notification settings - Fork 49
/
tankYPipe.mos
61 lines (55 loc) · 3 KB
/
tankYPipe.mos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
loadModel(Modelica); getErrorString();
setCommandLineOptions("-d=newInst,fmuExperimental"); getErrorString();
loadString("
model tank1
parameter Real tankSurface = 2 \"tank area (m^2)\";
parameter Real holeSurface = 0.1 \"area of hole at bottom of tank (m^2)\";
parameter Real initialLevel = 3 \"initial water level (m)\";
constant Real g = 9.81 \"gravitation constant (m/s)\";
Modelica.Blocks.Interfaces.RealOutput level(start = initialLevel) \"water level in tank (m)\";
Modelica.Blocks.Interfaces.RealOutput outputRate(start = holeSurface * sqrt(2 * g * initialLevel)) \"output flow rate (m^3/s)\";
Modelica.Blocks.Interfaces.RealInput inputRate(start = 0.5) \"input flow rate (m^3/s)\";
equation
der(level) = (inputRate - holeSurface * sqrt(2 * g * level)) / tankSurface;
outputRate = holeSurface * sqrt(2 * g * level);
annotation (experiment(StopTime=100));
end tank1;
model tank2
parameter Real tankSurface = 2 \"tank area (m^2)\";
parameter Real holeSurface = 0.1 \"area of hole at bottom of tank (m^2)\";
parameter Real initialLevel = 3 \"initial water level (m)\";
constant Real g = 9.81 \"gravitation constant (m/s)\";
Modelica.Blocks.Interfaces.RealOutput level(start = initialLevel) \"water level in tank (m)\";
Modelica.Blocks.Interfaces.RealOutput outputRate(start = holeSurface * sqrt(2 * g * initialLevel)) \"output flow rate (m^3/s)\";
Modelica.Blocks.Interfaces.RealInput inputRate(start = 0.1) \"input flow rate (m^3/s)\";
equation
der(level) = (inputRate - holeSurface * sqrt(2 * g * level)) / tankSurface;
outputRate = holeSurface * sqrt(2 * g * level);
annotation (experiment(StopTime=100));
end tank2;
model tank3
parameter Real tankSurface = 2 \"tank area (m^2)\";
parameter Real holeSurface = 0.1 \"area of hole at bottom of tank (m^2)\";
parameter Real initialLevel = 3 \"initial water level (m)\";
constant Real g = 9.81 \"gravitation constant (m/s)\";
Modelica.Blocks.Interfaces.RealOutput level(start = initialLevel) \"water level in tank (m)\";
Modelica.Blocks.Interfaces.RealOutput outputRate(start = holeSurface * sqrt(2 * g * initialLevel)) \"output flow rate (m^3/s)\";
Modelica.Blocks.Interfaces.RealInput inputRate(start = 0) \"input flow rate (m^3/s)\";
equation
der(level) = (inputRate - holeSurface * sqrt(2 * g * level)) / tankSurface;
outputRate = holeSurface * sqrt(2 * g * level);
annotation (experiment(StopTime=100));
end tank3;
model ypipe
Modelica.Blocks.Interfaces.RealOutput outputRate(start = 0) \"output flow rate (m^3/s)\";
Modelica.Blocks.Interfaces.RealInput inputRate1(start = 0) \"input flow rate #1 (m^3/s)\";
Modelica.Blocks.Interfaces.RealInput inputRate2(start = 0) \"input flow rate #2 (m^3/s)\";
equation
outputRate = inputRate1 + inputRate2;
annotation (experiment(StopTime=100));
end ypipe;
"); getErrorString();
buildModelFMU(tank1, fmuType="cs"); getErrorString();
buildModelFMU(tank2, fmuType="cs"); getErrorString();
buildModelFMU(tank3, fmuType="cs"); getErrorString();
buildModelFMU(ypipe, fmuType="cs"); getErrorString();