Skip to content

Commit 4c377af

Browse files
authored
feat: Adds creek intake to SurgeTank model (#84)
1 parent afdfc09 commit 4c377af

4 files changed

Lines changed: 118 additions & 38 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
within OpenHPL.Examples;
2+
model SimpleValveWithCreek
3+
"Model of a hydropower system with a simple turbine turbine"
4+
extends Modelica.Icons.Example;
5+
Waterway.Reservoir reservoir(h_0 = 10, constantLevel = false) annotation(
6+
Placement(transformation(origin = {-90, 30}, extent = {{-10, -10}, {10, 10}})));
7+
Modelica.Blocks.Sources.Ramp control(duration = 30, height = 0.5, offset = 0, startTime = 500e6) annotation(
8+
Placement(transformation(origin={-10,0}, extent = {{-10, -10}, {10, 10}})));
9+
Waterway.Pipe tunnel1(H = 10, D_i = 5) annotation(
10+
Placement(transformation(extent = {{-70, 20}, {-50, 40}})));
11+
Waterway.Pipe discharge(H = 0.5, L = 600, D_i = 5) annotation(
12+
Placement(transformation(origin={0,-50}, extent = {{50, 20}, {70, 40}})));
13+
Waterway.Reservoir tail(h_0 = 5) annotation(
14+
Placement(transformation(origin = {90, -20}, extent = {{-10, 10}, {10, -10}}, rotation = 180)));
15+
replaceable Waterway.Pipe penstock(D_i = 3, D_o = 3, H = 80, L = 200, vertical = true)
16+
constrainedby Interfaces.TwoContacts annotation(
17+
Placement(transformation(origin={60,30}, extent = {{-10, -10}, {10, 10}})));
18+
Waterway.SurgeTank creekIntake(H = 25, L = 30, h_0 = 20, useCreekIntake = true) annotation(
19+
Placement(transformation(origin = {-30, 30}, extent = {{-10, -10}, {10, 10}})));
20+
inner Data data(Vdot_0 = 0) annotation(
21+
Placement(transformation(origin = {-90, 90}, extent = {{-10, -10}, {10, 10}})));
22+
Waterway.Valve valve(ValveCapacity = false, C_v = 1) annotation(
23+
Placement(transformation(origin={0,-50}, extent = {{20, 20}, {40, 40}})));
24+
OpenHPL.Waterway.Pipe tunnel2(D_i = 5, H = 10) annotation(
25+
Placement(transformation(origin={58,0}, extent = {{-70, 20}, {-50, 40}})));
26+
OpenHPL.Waterway.SurgeTank surgeTank(H = 35, L = 40, h_0 = 30) annotation(
27+
Placement(transformation(origin = {30, 30}, extent = {{-10, -10}, {10, 10}})));
28+
Waterway.VolumeFlowSource volumeFlowSource annotation(
29+
Placement(transformation(origin = {-52, 60}, extent = {{-10, -10}, {10, 10}})));
30+
equation
31+
connect(reservoir.o, tunnel1.i) annotation(
32+
Line(points = {{-80, 30}, {-70, 30}}, color = {28, 108, 200}));
33+
connect(tunnel1.o, creekIntake.i) annotation(
34+
Line(points = {{-50, 30}, {-40, 30}}, color = {28, 108, 200}));
35+
connect(valve.o, discharge.i) annotation(
36+
Line(points={{40,-20},{50,-20}}, color = {0, 128, 255}));
37+
connect(control.y, valve.opening) annotation(
38+
Line(points={{1,0},{30,0},{30,-12}}, color = {0, 0, 127}));
39+
connect(creekIntake.o, tunnel2.i) annotation(
40+
Line(points={{-20,30},{-12,30}}, color = {0, 128, 255}));
41+
connect(tunnel2.o, surgeTank.i) annotation(
42+
Line(points={{8,30},{20,30}}, color = {0, 128, 255}));
43+
connect(surgeTank.o, penstock.i) annotation(
44+
Line(points={{40,30},{50,30}}, color = {0, 128, 255}));
45+
connect(volumeFlowSource.o, creekIntake.creek) annotation(
46+
Line(points = {{-42, 60}, {-30, 60}, {-30, 40}}, color = {0, 128, 255}));
47+
connect(discharge.o, tail.o) annotation(
48+
Line(points={{70,-20},{80,-20}}, color = {0, 128, 255}));
49+
connect(penstock.o, valve.i) annotation (Line(points={{70,30},{80,30},{80,10},
50+
{8,10},{8,-20},{20,-20}}, color={0,128,255}));
51+
annotation(
52+
experiment(StopTime = 1000),
53+
Documentation(info = "<html>
54+
<p>
55+
Simple model of a water way with one creek intake.
56+
This can be used to investigate the effects of a creek intake.
57+
</p>
58+
</html>"));
59+
end SimpleValveWithCreek;

OpenHPL/Examples/package.order

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
BranchingPipes
22
SimpleValve
3+
SimpleValveWithCreek
34
SimpleTurbine
45
SimpleGen
56
SimpleGenFrancis

OpenHPL/Icons/Surge.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ partial class Surge "Surge tank/shaft icon"
88
graphics={
99
Text(
1010
textColor={28,108,200},
11-
extent={{-150,140},{150,100}},
11+
extent={{-150,-60},{150,-100}},
1212
textString="%name",
1313
textStyle={TextStyle.Bold}),
1414
Rectangle(

OpenHPL/Waterway/SurgeTank.mo

Lines changed: 57 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,48 @@ model SurgeTank "Model of the surge tank/shaft"
33
outer Data data "Using standard data set";
44
extends OpenHPL.Icons.Surge(lds=l, Lds=L);
55
extends OpenHPL.Interfaces.TwoContacts;
6-
import Modelica.Constants.pi;
6+
7+
parameter Boolean useCreekIntake=false "If checked, includes a creek intake connector" annotation (
8+
Dialog(group = "Creek intake"),
9+
choices(checkBox = true));
10+
parameter SI.Height H_creek=H "Height of the creek intake above the surge tank base" annotation (
11+
Dialog(group = "Creek intake", enable = useCreekIntake));
712

813
parameter Types.SurgeTank SurgeTankType = OpenHPL.Types.SurgeTank.STSimple "Types of surge tank" annotation (
914
Dialog(group = "Surge tank types"));
10-
// Geometrical parameters of the surge tank
11-
parameter SI.Height H = 120 "Vertical component of the length of the surge shaft" annotation (
15+
parameter SI.Height H = 100 "Vertical component of the length of the surge shaft" annotation (
1216
Dialog(group = "Geometry"));
13-
parameter SI.Length L = 140 "Length of the surge shaft" annotation (
17+
parameter SI.Length L = H "Length of the surge shaft" annotation (
1418
Dialog(group = "Geometry"));
15-
parameter SI.Diameter D = 3.4 "Diameter of the surge shaft" annotation (
19+
parameter SI.Diameter D = 3 "Diameter of the surge shaft" annotation (
1620
Dialog(group = "Geometry"));
1721
parameter SI.Height p_eps = data.p_eps "Pipe roughness height" annotation (
1822
Dialog(group = "Geometry"));
19-
parameter SI.Diameter D_so = 1.7 "If Sharp orifice type: Diameter of sharp orifice" annotation (
23+
parameter SI.Diameter D_so = D "If Sharp orifice type: Diameter of sharp orifice" annotation (
2024
Dialog(group = "Geometry",enable=SurgeTankType == OpenHPL.Types.SurgeTank.STSharpOrifice));
21-
parameter SI.Diameter D_t = 1.7 "If Throttle value type: Diameter of throat" annotation (
25+
parameter SI.Diameter D_t = D "If Throttle value type: Diameter of throat" annotation (
2226
Dialog(group = "Geometry",enable=SurgeTankType == OpenHPL.Types.SurgeTank.STThrottleValve));
23-
parameter SI.Length L_t = 5 "If Throttle value type: Length of throat" annotation (
27+
parameter SI.Length L_t = L "If Throttle value type: Length of throat" annotation (
2428
Dialog(group = "Geometry",enable=SurgeTankType == OpenHPL.Types.SurgeTank.STThrottleValve));
2529

26-
// Condition for steady state
2730
parameter Boolean SteadyState=data.SteadyState "If true, starts in steady state" annotation (Dialog(group="Initialization"));
28-
// steady state values for flow rate and water level in surge tank
2931
parameter SI.VolumeFlowRate Vdot_0 = 0 "Initial volume flow rate in the surge tank" annotation (
3032
Dialog(group = "Initialization"));
31-
parameter SI.Height h_0 = 69.9 "Initial water level in the surge tank" annotation (
33+
parameter SI.Height h_0 = 50 "Initial water level in the surge tank" annotation (
3234
Dialog(group = "Initialization"));
3335
parameter SI.Pressure p_ac = 4*data.p_a "Initial pressure of air-cushion inside the surge tank" annotation (
3436
Dialog(group = "Initialization",enable=SurgeTankType == OpenHPL.Types.SurgeTank.STAirCushion));
35-
parameter SI.Temperature T_ac(displayUnit="degC") = 298.15 "Initial air-cushion temperature"
37+
parameter SI.Temperature T_ac(displayUnit="degC")=298.15 "Initial air-cushion temperature"
3638
annotation (Dialog(group = "Initialization", enable=SurgeTankType == OpenHPL.Types.SurgeTank.STAirCushion));
37-
//possible parameters for temperature variation. Not finished...
38-
//parameter Boolean TempUse = data.TempUse "If checked - the water temperature is not constant" annotation (Dialog(group = "Initialization"));
39-
//parameter SI.Temperature T_i = data.T_i "Initial water temperature in the pipe" annotation (Dialog(group = "Initialization", enable = TempUse));
40-
// variables
39+
4140
SI.Mass m "Water mass";
4241
SI.MassFlowRate mdot "Mass flow rate";
4342
SI.Mass m_a = p_ac*A*(L-h_0/cos_theta)*data.M_a/(Modelica.Constants.R*T_ac) "Air mass inside surge tank";
4443
SI.Momentum M "Water momentum";
4544
SI.Force Mdot "Difference in influent and effulent momentum";
4645
SI.Force F "Total force acting in the surge tank";
47-
SI.Area A = (pi*D ^ 2) / 4 "Cross sectional area of the surge tank";
48-
SI.Area A_t = (pi*D_t ^ 2) / 4 "Cross sectional area of the throttle valve surge tank";
46+
SI.Area A = (C.pi*D ^ 2) / 4 "Cross sectional area of the surge tank";
47+
SI.Area A_t = (C.pi*D_t ^ 2) / 4 "Cross sectional area of the throttle valve surge tank";
4948
SI.Length l = h / cos_theta "Length of water in the surge tank";
5049
Real cos_theta = H / L "Slope ratio";
5150
SI.Velocity v "Water velocity";
@@ -55,12 +54,16 @@ model SurgeTank "Model of the surge tank/shaft"
5554
SI.Pressure p_t "Pressure at top of the surge tank";
5655
SI.Pressure p_b "Pressure at bottom of the surge tank";
5756
Real phiSO "Dimensionless factor based on the type of fitting ";
58-
// initial values for differential variables
5957
SI.Height h(start = h_0) "Water height in the surge tank";
6058
SI.VolumeFlowRate Vdot(start = Vdot_0, fixed=true) "Volume flow rate";
61-
// variables for temperature. Not in use for now...
62-
// Real W_f, W_e;
63-
// connector (acquisition of algebraic variable, mass flow rate mdot, and node pressure (manifold pressure) p_n)
59+
60+
Interfaces.Contact_i creek(
61+
p = p_t + data.rho * data.g * (h - H_creek),
62+
mdot = mdot_creek) if useCreekIntake "Creek intake connector (connects to VolumeFlowSource)"
63+
annotation (Placement(transformation(extent = {{-10, 90}, {10, 110}})));
64+
65+
protected
66+
SI.MassFlowRate mdot_creek "Creek mass flow rate (zero when creek connector is absent)";
6467

6568
initial equation
6669
if SteadyState then
@@ -69,12 +72,27 @@ initial equation
6972
else
7073
h = h_0;
7174
end if;
75+
7276
equation
73-
assert( h >= 0, "Water level h in surge tank must be greater than 0!",
77+
assert( h >= 0, "Water level h in surge tank must be greater than 0!",
7478
AssertionLevel.error);
7579

76-
der(m) = mdot "Mass balance";
80+
p_b = i.p "Linking bottom node pressure to connector";
81+
i.p = o.p "Inlet and outlet pressure equality";
82+
83+
F_g = m * data.g * cos_theta "Gravitational force";
84+
F = F_p - F_f - F_g "Acting forces";
85+
86+
Mdot = mdot * v;
7787
der(M) = Mdot+F "Momentum balance";
88+
mdot = data.rho * Vdot;
89+
mdot = i.mdot + o.mdot "Mass balance";
90+
91+
if not useCreekIntake then
92+
mdot_creek = 0;
93+
end if "Conditional creek intake equation balance";
94+
95+
der(m) = mdot + mdot_creek "Mass balance";
7896

7997
if SurgeTankType == OpenHPL.Types.SurgeTank.STSimple then
8098
v = Vdot / A;
@@ -111,11 +129,11 @@ equation
111129
M = m * v;
112130
F_f = Functions.DarcyFriction.Friction(v, D_t, l, data.rho, data.mu, p_eps) + A_t * phiSO * 0.5 * data.rho * abs(v) * v;
113131
phiSO = 0;
114-
F_p = (p_b - p_t) * A;
132+
F_p = (p_b - p_t) * A_t;
115133
else
116-
v = Vdot * (1 / A_t + 1 / A) / 2;
134+
v = Vdot * l / (A_t * L_t + A * (l - L_t));
117135
m = data.rho * (A_t * L_t + A * (l - L_t));
118-
M = data.rho * (A_t * L_t*Vdot/A_t + A * (l - L_t)*Vdot/A);
136+
M = m * v;
119137
if v > 0 then
120138
F_f = Functions.DarcyFriction.Friction(Vdot/A_t, D_t, L_t, data.rho, data.mu, p_eps) + Functions.DarcyFriction.Friction(Vdot/A, D, l - L_t, data.rho, data.mu, p_eps) + A_t * phiSO * 0.5 * data.rho * abs(Vdot/A_t) * Vdot/A_t;
121139
phiSO = Functions.Fitting.FittingPhi(Vdot/A_t, D_t, D, L, 90, data.rho, data.mu, data.p_eps, OpenHPL.Types.Fitting.Square);
@@ -130,13 +148,7 @@ equation
130148
end if;
131149
p_t = data.p_a;
132150
end if;
133-
mdot = data.rho * Vdot;
134-
Mdot = mdot * v;
135-
F = F_p - F_f - F_g;
136-
p_b = i.p "Linking bottom node pressure to connector";
137-
i.p = o.p "Inlet and outlet pressure equality";
138-
mdot = i.mdot+o.mdot "Mass balance";
139-
F_g = m * data.g * cos_theta;
151+
140152
annotation (preferredView="info",
141153
Documentation(info="<html>
142154
<h4>Surge Tank Model</h4>
@@ -186,15 +198,23 @@ calculated using the Darcy friction factor f<sub>D,s</sub>.</p>
186198
<p>The manifold preserves mass in steady-state: $$ \\dot{V}_\\mathrm{i} = \\dot{V}_\\mathrm{p} + \\dot{V} $$
187199
The manifold pressure is equal for all three connections. This is implemented via <code>ContactNode</code> connectors.</p>
188200
201+
<h5>Creek Intake</h5>
189202
203+
<p>When <code>useCreekIntake = true</code>, an additional inlet connector <code>creek</code> becomes active.
204+
This connector can be attached to a <code>VolumeFlowSource</code> to model lateral inflow
205+
(e.g., a creek or groundwater seepage) entering the surge tank. The parameter <code>H_creek</code>
206+
specifies the height of the intake above the surge tank base (default H = at the top of the surge tank,
207+
not relavant if a volume flow source is connected).
208+
The connector pressure is set hydrostatically from the water surface down to the intake elevation,
209+
so it correctly follows the actual water level <code>h</code> in the tank:</p>
210+
<p>$$ p_\\mathrm{creek} = p_\\mathrm{t} + \\rho g (h - H_\\mathrm{creek}) $$</p>
211+
<p>The creek inflow is included in the mass balance:</p>
212+
<p>$$ \\frac{\\mathrm{d}m}{\\mathrm{d}t} = \\rho \\dot{V} + \\dot{m}_\\mathrm{creek} $$</p>
190213
191214
<h5>Parameters and Initialization</h5>
192215
193216
<p>Required geometry parameters: length L, height H, diameter D,
194217
roughness p<sub>ε</sub>, and atmospheric pressure p<sup>atm</sup>. Initialize with flow rate V̇<sub>0</sub>
195218
and water height h<sub>0</sub>. Option for steady-state initialization is available.</p>
196-
197-
<h5>More Information</h5>
198-
<p>More details in <a href=\"modelica://OpenHPL.UsersGuide.References\">[Splavska2017]</a>.</p>
199219
</html>"));
200220
end SurgeTank;

0 commit comments

Comments
 (0)