| 1 | package NewFEbug
|
|---|
| 2 | import SI = Modelica.SIunits;
|
|---|
| 3 |
|
|---|
| 4 | connector ODF_AB "Base port for oleodynamic components"
|
|---|
| 5 | SI.Pressure p "pressure";
|
|---|
| 6 | flow SI.MassFlowRate w "mass flowrate";
|
|---|
| 7 | annotation(
|
|---|
| 8 | Icon(coordinateSystem(grid = {1, 1}, initialScale = 0.1), graphics = {Ellipse(extent = {{-100, 100}, {100, -100}}, lineColor = {255, 128, 0}, fillColor = {255, 255, 0}, fillPattern = FillPattern.Solid)}),
|
|---|
| 9 | Documentation(info = "<html><head></head><body>base port to exchange olodynamic fluid between components.<div><br></div><div>(c) Dynamica - all right reserved</div></body></html>"));
|
|---|
| 10 | end ODF_AB;
|
|---|
| 11 |
|
|---|
| 12 | connector ODF_P "port to exchange olodynamic fluid - side P"
|
|---|
| 13 | extends ODF_AB;
|
|---|
| 14 | annotation(
|
|---|
| 15 | Icon(graphics = {Ellipse(extent = {{-100, 100}, {100, -100}}, lineColor = {255, 128, 0}, fillColor = {255, 128, 0}, fillPattern = FillPattern.Solid)}),
|
|---|
| 16 | Documentation(info = "<html><head></head><body><br><div><br></div><div><span style=\"font-size: 12px;\">(c) Dynamica - all right reserved</span></div></body></html>"));
|
|---|
| 17 | end ODF_P;
|
|---|
| 18 |
|
|---|
| 19 | connector ODF_T
|
|---|
| 20 | extends ODF_AB;
|
|---|
| 21 | annotation(
|
|---|
| 22 | Icon(graphics = {Ellipse(lineColor = {255, 128, 0}, fillColor = {255, 128, 0}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}, endAngle = 360), Ellipse(lineColor = {255, 255, 255}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-40, 40}, {40, -40}}, endAngle = 360)}, coordinateSystem(initialScale = 0.1)));
|
|---|
| 23 | end ODF_T;
|
|---|
| 24 |
|
|---|
| 25 | model ImposedPressure "Node with imposed Pressure, independently from the oil flow"
|
|---|
| 26 | final constant Real NotUsed = Modelica.Constants.inf;
|
|---|
| 27 | parameter SI.Pressure p0 = NotUsed "imposed pressure if not use_in_p0";
|
|---|
| 28 | parameter Boolean use_in_p0 = false "use connector input for the pressure" annotation(
|
|---|
| 29 | Dialog(group = "External inputs"),
|
|---|
| 30 | choices(checkBox = true));
|
|---|
| 31 | // variables
|
|---|
| 32 | SI.Pressure p "Actual pressure";
|
|---|
| 33 | // interface
|
|---|
| 34 | ODF_P fl_P annotation(
|
|---|
| 35 | Placement(visible = true, transformation(origin = {88, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
|
|---|
| 36 | // conditional interface
|
|---|
| 37 | Modelica.Blocks.Interfaces.RealInput in_p0 if use_in_p0 annotation(
|
|---|
| 38 | Placement(transformation(origin = {-40, 92}, extent = {{-20, -20}, {20, 20}}, rotation = 270)));
|
|---|
| 39 | protected
|
|---|
| 40 | Modelica.Blocks.Interfaces.RealInput in_p0_internal;
|
|---|
| 41 | equation
|
|---|
| 42 | fl_P.p = p;
|
|---|
| 43 | p = in_p0_internal;
|
|---|
| 44 | // Conditional connectors
|
|---|
| 45 | if not use_in_p0 then
|
|---|
| 46 | in_p0_internal = p0 "Pressure set by parameter";
|
|---|
| 47 | end if;
|
|---|
| 48 | connect(in_p0, in_p0_internal);
|
|---|
| 49 | annotation(
|
|---|
| 50 | Diagram(graphics),
|
|---|
| 51 | Icon(graphics = {Ellipse(fillColor = {255, 128, 0}, fillPattern = FillPattern.Solid, extent = {{-80, 80}, {80, -80}}, endAngle = 360), Text(lineColor = {255, 255, 255}, extent = {{-20, 34}, {28, -26}}, textString = "P", fontName = "DejaVu Sans Mono"), Text(lineColor = {0, 0, 255}, extent = {{-100, -78}, {100, -106}}, textString = "%name", fontName = "DejaVu Sans Mono"), Text(extent = {{-106, 90}, {-52, 50}}, textString = "p0")}));
|
|---|
| 52 | end ImposedPressure;
|
|---|
| 53 |
|
|---|
| 54 | partial model FlexiblePipeRC
|
|---|
| 55 | import g = Modelica.Constants.g_n;
|
|---|
| 56 | constant Real pi = 3.1415;
|
|---|
| 57 | parameter Boolean oilCompressibility = true "= true, if oil compressibility is used";
|
|---|
| 58 | parameter Boolean FlangePatBottom = false "= true, if flange P is at bottom of not-horizontal pipe";
|
|---|
| 59 | parameter Integer N(min=1) = 1 "number of pipe segments";
|
|---|
| 60 | parameter SI.Temperature Toil = 273.15 + 20 "Oil temperature";
|
|---|
| 61 | parameter SI.Length d "pipe diameter";
|
|---|
| 62 | parameter SI.Length L "pipe length";
|
|---|
| 63 | parameter SI.Length h(min = 0) "pipe vertical total elevation (always positive or null), relevant to bottom flange";
|
|---|
| 64 | parameter SI.Length tk "pipe thickness";
|
|---|
| 65 | parameter SI.BulkModulus E "Young's modulus of pipe";
|
|---|
| 66 | parameter SI.Pressure pP_start "Start value of pressure at flange P" annotation(
|
|---|
| 67 | Dialog(tab = "Initialization"));
|
|---|
| 68 | parameter SI.Pressure pT_start = pP_start + rhoOil_start*g*z_tot "Start value of pressure at flange T" annotation(
|
|---|
| 69 | Dialog(tab = "Initialization"));
|
|---|
| 70 | final parameter SI.Length z_tot = if FlangePatBottom then -h else h "pipe vertical elevation from P to T flange, with signum";
|
|---|
| 71 | final parameter SI.Density rhoOil_start = 1000 "start oil density";
|
|---|
| 72 | final parameter SI.Area A = 0.25*pi*d^2 "pipe cross-section";
|
|---|
| 73 | final parameter SI.Length dl = L/N "length of each pipe segment";
|
|---|
| 74 | final parameter SI.BulkModulus Kpipe = E*tk/d "pipe bulk modulus";
|
|---|
| 75 | final parameter SI.BulkModulus Koil = 2e9 "oil bulk modulus";
|
|---|
| 76 | final parameter SI.KinematicViscosity kinVisc = 8.17e-6 "oil kinematic viscosity";
|
|---|
| 77 | final parameter SI.Length z[N+1](each fixed=false) "elevation profile, one value for each pipe node";
|
|---|
| 78 | final parameter Real I(final unit="1/m") = dl/A "segment equivalent inertance";
|
|---|
| 79 |
|
|---|
| 80 | //variables, pipe left/bottom side is for index=0
|
|---|
| 81 | SI.Density rho[N](each start = rhoOil_start, each fixed = true) "oil density profile, one value for each segment";
|
|---|
| 82 | SI.Volume V[N](each start = A*L/N, each fixed = true) "pipe volume profile, one value for each segment";
|
|---|
| 83 | SI.MassFlowRate w[N+1] "mass flowrate profile, one value for each node";
|
|---|
| 84 | SI.Pressure p[N](start = linspace(pP_start, pT_start, N), each fixed = true) "pressure profile, one value for each segment";
|
|---|
| 85 | SI.Mass M[N] "oil mass profile, one value for each segment";
|
|---|
| 86 | SI.PerUnit Re[N+1] "Reynolds Number profile, one value for node";
|
|---|
| 87 | SI.Pressure Dpstat[N] "static pressure drop, one value for each segment";
|
|---|
| 88 | SI.Pressure Dpfric[N+1] "friction pressure drop, one value for each node";
|
|---|
| 89 | SI.Pressure dpTot = fl_P.p - fl_T.p "total delta pressure across pipe, for monitoring only";
|
|---|
| 90 | ODF_P fl_P annotation(
|
|---|
| 91 | Placement(visible = true, transformation(origin = {-102, 0}, extent = {{-20, -10}, {20, 10}}, rotation = 0), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
|---|
| 92 | ODF_T fl_T annotation(
|
|---|
| 93 | Placement(visible = true, transformation(origin = {100, 0}, extent = {{-20, -10}, {20, 10}}, rotation = 0), iconTransformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
|---|
| 94 |
|
|---|
| 95 | //interfaces
|
|---|
| 96 |
|
|---|
| 97 | initial algorithm
|
|---|
| 98 | for i in 1:N+1 loop
|
|---|
| 99 | z[i] := if FlangePatBottom then (i-1)*h/N else h - (i-1)*h/N;
|
|---|
| 100 | end for;
|
|---|
| 101 | assert(h>=0, "elevation cannot be negative");
|
|---|
| 102 |
|
|---|
| 103 | equation
|
|---|
| 104 | //Reynolds Number profile calculation
|
|---|
| 105 | for k in 1:N loop
|
|---|
| 106 | Re[k] = abs(w[k])*d/(rho[k]*A*kinVisc);
|
|---|
| 107 | end for;
|
|---|
| 108 | Re[N+1] = abs(w[N+1])*d/(rho[N]*A*kinVisc);
|
|---|
| 109 |
|
|---|
| 110 | //Static head profile calculation
|
|---|
| 111 | for i in 1:N loop
|
|---|
| 112 | Dpstat[i] = rho[i]*g*(z[i+1] - z[i]);
|
|---|
| 113 | end for;
|
|---|
| 114 |
|
|---|
| 115 | //Mass Balance @ SEGMENTS
|
|---|
| 116 | for i in 1:N loop
|
|---|
| 117 | M[i] = V[i]*rho[i];
|
|---|
| 118 | der(M[i]) = w[i] - w[i+1];
|
|---|
| 119 | der(V[i]) = A*dl*der(p[i])/Kpipe;
|
|---|
| 120 | if oilCompressibility then
|
|---|
| 121 | der(rho[i]) = rho[i]*der(p[i])/Koil;
|
|---|
| 122 | else
|
|---|
| 123 | rho[i] = rhoOil_start;
|
|---|
| 124 | end if;
|
|---|
| 125 | end for;
|
|---|
| 126 |
|
|---|
| 127 | //Momentum balance @ NODES
|
|---|
| 128 | (p[1] - fl_P.p) + Dpstat[1]/2 + Dpfric[1] = 0;
|
|---|
| 129 | for j in 2:N loop
|
|---|
| 130 | (p[j] - p[j-1]) + Dpstat[j-1]/2 + Dpstat[j]/2 + Dpfric[j] = 0;
|
|---|
| 131 | end for;
|
|---|
| 132 | (fl_T.p - p[N]) + Dpstat[N]/2 + Dpfric[N+1] = 0;
|
|---|
| 133 |
|
|---|
| 134 | //boundary conditions
|
|---|
| 135 | w[1] = fl_P.w;
|
|---|
| 136 | w[N+1] = -fl_T.w;
|
|---|
| 137 |
|
|---|
| 138 | annotation(
|
|---|
| 139 | Icon(coordinateSystem(initialScale = 0.1), graphics = {Line(origin = {-22, -46}, points = {{-60, 20}, {76, 20}}, color = {255, 128, 0}), Polygon(origin = {63.72, -26}, lineColor = {255, 128, 0}, fillColor = {255, 128, 0}, fillPattern = FillPattern.Solid, points = {{-9.72361, 10}, {10.2764, 0}, {-9.72361, -10}, {-9.72361, 10}, {-9.72361, 10}}), Text(origin = {-45, -14}, extent = {{-5, 20}, {95, 4}}, textString = "FLEXIBLE RC"), Rectangle(extent = {{-100, 20}, {100, -20}})}), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})));
|
|---|
| 140 |
|
|---|
| 141 | end FlexiblePipeRC;
|
|---|
| 142 |
|
|---|
| 143 | model FlexiblePipeRCLaminar
|
|---|
| 144 | extends FlexiblePipeRC;
|
|---|
| 145 |
|
|---|
| 146 | equation
|
|---|
| 147 | // laminar friction losses calculation
|
|---|
| 148 | Dpfric[1] = 32*kinVisc*(dl/2)*w[1]/(A*d^2);
|
|---|
| 149 | for j in 2:N loop
|
|---|
| 150 | Dpfric[j] = 32*kinVisc*dl*w[j]/(A*d^2);
|
|---|
| 151 | end for;
|
|---|
| 152 | Dpfric[N+1] = 32*kinVisc*(dl/2)*w[N+1]/(A*d^2);
|
|---|
| 153 |
|
|---|
| 154 | annotation(
|
|---|
| 155 | Icon(coordinateSystem(initialScale = 0.1), graphics = {Text(origin = {-3, 24}, extent = {{-41, 12}, {49, -8}}, textString = "Laminar")}));
|
|---|
| 156 |
|
|---|
| 157 | end FlexiblePipeRCLaminar;
|
|---|
| 158 |
|
|---|
| 159 | model TestFlexiblePipeRCFilling
|
|---|
| 160 | extends Modelica.Icons.Example;
|
|---|
| 161 | FlexiblePipeRCLaminar flexiblePipeLaminar1(E(displayUnit = "Pa") = 2.06e+08, L = 500, N = 10, d = 0.00277, h = 500, pP_start = 100000, tk = 0.0018) annotation(
|
|---|
| 162 | Placement(visible = true, transformation(origin = {-38, -2.66454e-15}, extent = {{-22, -22}, {22, 22}}, rotation = 0)));
|
|---|
| 163 | ImposedPressure imposedPressure1Lam(use_in_p0 = true) annotation(
|
|---|
| 164 | Placement(visible = true, transformation(origin = {-90, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
|---|
| 165 | Modelica.Blocks.Sources.Trapezoid Pset(amplitude = 600e5, falling = 5, nperiod = 1, offset = 1e5, period = 410, rising = 5, startTime = 2, width = 200) annotation(
|
|---|
| 166 | Placement(visible = true, transformation(origin = {-130, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
|---|
| 167 | equation
|
|---|
| 168 | connect(Pset.y, imposedPressure1Lam.in_p0) annotation(
|
|---|
| 169 | Line(points = {{-118, 30}, {-94, 30}, {-94, 10}, {-94, 10}}, color = {0, 0, 127}));
|
|---|
| 170 | connect(imposedPressure1Lam.fl_P, flexiblePipeLaminar1.fl_P) annotation(
|
|---|
| 171 | Line(points = {{-80, 0}, {-60, 0}, {-60, 0}, {-60, 0}}, color = {255, 128, 0}));
|
|---|
| 172 | annotation(
|
|---|
| 173 | Icon(coordinateSystem(grid = {0.1, 0.1})),
|
|---|
| 174 | Diagram(coordinateSystem(extent = {{-200, -100}, {200, 100}})),
|
|---|
| 175 | experiment(StartTime = 0, StopTime = 400, Tolerance = 1e-06, Interval = 0.2));
|
|---|
| 176 | end TestFlexiblePipeRCFilling;
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 | annotation(
|
|---|
| 182 | Icon(coordinateSystem(grid = {0.1, 0.1})),
|
|---|
| 183 | Diagram(coordinateSystem(extent = {{-200, -100}, {200, 100}})));
|
|---|
| 184 | end NewFEbug;
|
|---|