@@ -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
6568initial equation
6669 if SteadyState then
@@ -69,12 +72,27 @@ initial equation
6972 else
7073 h = h_0;
7174 end if ;
75+
7276equation
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} $$
187199The 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,
194217roughness p<sub>ε</sub>, and atmospheric pressure p<sup>atm</sup>. Initialize with flow rate V̇<sub>0</sub>
195218and 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>" ));
200220end SurgeTank;
0 commit comments