From 141f6c5a858a65eca955880c97b9024316710356 Mon Sep 17 00:00:00 2001 From: Dietmar Winkler Date: Fri, 23 Oct 2026 23:52:12 +0200 Subject: [PATCH 1/3] Added Area option to pipe model --- OpenHPL/Waterway/Pipe.mo | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/OpenHPL/Waterway/Pipe.mo b/OpenHPL/Waterway/Pipe.mo index 2600893..6a7f9a0 100644 --- a/OpenHPL/Waterway/Pipe.mo +++ b/OpenHPL/Waterway/Pipe.mo @@ -3,17 +3,24 @@ model Pipe "Model of a pipe" outer Data data "Using standard data set"; extends OpenHPL.Icons.Pipe; extends OpenHPL.Interfaces.TwoContacts; - extends Types.FrictionSpec( final D_h = (D_i + D_o) / 2); + extends Types.FrictionSpec(final D_h = D_); // Geometrical parameters of the pipe: parameter SI.Length H = 0 "Height difference from the inlet to the outlet" annotation ( Dialog(group = "Geometry")); parameter SI.Length L = 1000 "Length of the pipe" annotation ( Dialog(group = "Geometry")); - parameter SI.Diameter D_i = 1.0 "Diameter of the inlet side" annotation ( - Dialog(group = "Geometry")); + parameter SI.Diameter D_i = 1 "Diameter of the inlet side" annotation ( + Dialog(group = "Geometry", enable=not use_A)); parameter SI.Diameter D_o = D_i "Diameter of the outlet side" annotation ( - Dialog(group = "Geometry")); + Dialog(group = "Geometry", enable=not use_A)); + parameter Boolean use_A = false "Use areas instead of diameters" annotation ( + Dialog(group = "Geometry"), choices(checkBox=true)); + parameter SI.Area A_i = 1 "Area of the inlet side" annotation ( + Dialog(group = "Geometry", enable=use_A)); + parameter SI.Area A_o = A_i "Area of the outlet side" annotation ( + Dialog(group = "Geometry", enable=use_A)); + // Steady state: parameter Boolean SteadyState=data.SteadyState "If true, starts in steady state" annotation (Dialog(group="Initialization")); @@ -30,13 +37,15 @@ model Pipe "Model of a pipe" SI.VolumeFlowRate Vdot "Volume flow rate"; protected - parameter SI.Diameter D_ = ( D_i + D_o) / 2 "Average diameter"; + parameter SI.Diameter D_i_ = if use_A then sqrt(4 * A_i / C.pi) else D_i "Equivalent inlet diameter"; + parameter SI.Diameter D_o_ = if use_A then sqrt(4 * A_o / C.pi) else D_o "Equivalent outlet diameter"; + parameter SI.Diameter D_ = if use_A then sqrt(4 * A_ / C.pi) else (D_i_ + D_o_) / 2 "Average diameter"; - parameter SI.Area A_ = D_ ^ 2 * C.pi / 4 "Average cross-sectional area"; - parameter Real delta=2*(D_i-D_o)/(D_i+D_o) "Contraction factor"; + parameter SI.Area A_ = if use_A then (A_i + A_o) / 2 else D_^2 * C.pi / 4 "Average cross-sectional area"; + parameter Real delta=2*(D_i_-D_o_)/(D_i_+D_o_) "Contraction factor"; parameter Real cf=1+2*delta^2 "Conical pipe function"; parameter Real cos_theta = H / L "Slope ratio"; - parameter Modelica.Units.NonSI.Angle_deg phi = Modelica.Units.Conversions.to_deg(Modelica.Math.atan((abs(D_i-D_o)/(2*L)))) "Cone half angle"; + parameter Modelica.Units.NonSI.Angle_deg phi = Modelica.Units.Conversions.to_deg(Modelica.Math.atan(abs(D_i_-D_o_)/(2*L))) "Cone half angle"; initial equation if useInitialFlow then From 6a06b9514b753d7890f60a286e437c888f6da6bb Mon Sep 17 00:00:00 2001 From: Dietmar Winkler Date: Sat, 24 Oct 2026 00:21:04 +0200 Subject: [PATCH 2/3] Apply Area option to the rest of the waterway models. --- OpenHPL/Waterway/BendPipe.mo | 13 +++++++--- OpenHPL/Waterway/DraftTube.mo | 36 +++++++++++++++++----------- OpenHPL/Waterway/Fitting.mo | 30 +++++++++++++++-------- OpenHPL/Waterway/Penstock.mo | 14 ++++++++--- OpenHPL/Waterway/PenstockKP.mo | 18 ++++++++++---- OpenHPL/Waterway/Pipe.mo | 4 ++-- OpenHPL/Waterway/SurgeTank.mo | 44 +++++++++++++++++++++------------- 7 files changed, 105 insertions(+), 54 deletions(-) diff --git a/OpenHPL/Waterway/BendPipe.mo b/OpenHPL/Waterway/BendPipe.mo index ea3ce82..37099c1 100644 --- a/OpenHPL/Waterway/BendPipe.mo +++ b/OpenHPL/Waterway/BendPipe.mo @@ -8,15 +8,22 @@ model BendPipe "Bend in pipes" Dialog(group = "Manufacturer's design")); /* geometrical parameters for fitting */ parameter SI.Diameter D_i = 3 "Pipe diameter of the inlet (LHS)" annotation ( - Dialog(group = "Geometry")); + Dialog(group = "Geometry", enable=not use_A)); parameter SI.Diameter D_o = D_i "Pipe diameter of the outlet (RHS)" annotation ( - Dialog(group = "Geometry")); + Dialog(group = "Geometry", enable=not use_A)); + parameter Boolean use_A = false "Use areas instead of diameters" annotation ( + Dialog(group = "Geometry"), choices(checkBox=true)); + parameter SI.Area A_i = 7.07 "Area of the inlet side" annotation ( + Dialog(group = "Geometry", enable=use_A)); + parameter SI.Area A_o = 7.07 "Area of the outlet side" annotation ( + Dialog(group = "Geometry", enable=use_A)); SI.Velocity v(start=Modelica.Constants.eps) "Water velocity"; - SI.Area A = pi*D_i^2/4 "Cross section area"; + SI.Area A "Cross section area"; SI.Pressure dp "Pressure drop of fitting"; SI.MassFlowRate mdot "Mass flow rate"; extends OpenHPL.Interfaces.TwoContacts; equation + A = if use_A then (if mdot >= 0 then A_i else A_o) else pi * D_i ^ 2 / 4; v = mdot / data.rho / A; dp = K_L * 0.5 * data.rho * v^2; // Connections diff --git a/OpenHPL/Waterway/DraftTube.mo b/OpenHPL/Waterway/DraftTube.mo index 97f0d44..b54ed0e 100644 --- a/OpenHPL/Waterway/DraftTube.mo +++ b/OpenHPL/Waterway/DraftTube.mo @@ -2,7 +2,7 @@ within OpenHPL.Waterway; model DraftTube "Model of a draft tube for reaction turbines" outer Data data "Using standard data set"; extends OpenHPL.Icons.DraftTube; - extends Types.FrictionSpec( final D_h = 0.5 * (D_i + D_o)); + extends Types.FrictionSpec(final D_h = D_); import Modelica.Constants.pi; parameter Types.DraftTube DraftTubeType = OpenHPL.Types.DraftTube.ConicalDiffuser "Types of draft tube" annotation ( Dialog(group = "Draft tube types")); @@ -13,9 +13,15 @@ model DraftTube "Model of a draft tube for reaction turbines" parameter SI.Length L = 7.017 "Centerline/slant length (conical diffuser). Inclination is derived from H and L." annotation ( Dialog(group = "Geometry",enable=DraftTubeType == OpenHPL.Types.DraftTube.ConicalDiffuser)); parameter SI.Diameter D_i = 4 "Diameter of the inlet side" annotation ( - Dialog(group = "Geometry")); + Dialog(group = "Geometry", enable=not use_A)); parameter SI.Diameter D_o = 4.978 "Diameter of the outlet side" annotation ( - Dialog(group = "Geometry")); + Dialog(group = "Geometry", enable=not use_A)); + parameter Boolean use_A = false "Use areas instead of diameters" annotation ( + Dialog(group = "Geometry"), choices(checkBox=true)); + parameter SI.Area A_i = 12.57 "Area of the inlet side" annotation ( + Dialog(group = "Geometry", enable=use_A)); + parameter SI.Area A_o = 19.46 "Area of the outlet side" annotation ( + Dialog(group = "Geometry", enable=use_A)); parameter SI.Length L_m = 4 "Length of main section (Moody spreading pipe)" annotation ( Dialog(group = "Geometry",enable=DraftTubeType == OpenHPL.Types.DraftTube.MoodySpreadingPipe)); @@ -36,10 +42,8 @@ model DraftTube "Model of a draft tube for reaction turbines" // parameter SI.Temperature T_0 = data.T_0 "Initial water temperature in the pipe" annotation (Dialog(group = "Initialization", enable = TempUse)); /* variables */ - SI.Diameter D_ = 0.5 * (D_i + D_o) "Average diameter"; - SI.Area A_i = D_i ^ 2 * pi / 4 "Inlet cross-section area of draft tube"; - SI.Area A_o = D_o ^ 2 * pi / 4 "Outlet cross-section area of draft tube"; - SI.Area A_ = D_ ^ 2 * pi / 4 "Average cross-section area of conical diffuser"; + parameter SI.Diameter D_ = if use_A then sqrt(4 * A_ / pi) else 0.5 * (D_i_ + D_o_) "Average diameter"; + parameter SI.Area A_ = if use_A then (A_i + A_o) / 2 else D_ ^ 2 * pi / 4 "Average cross-section area of conical diffuser"; SI.Mass m "Mass of water inside conical diffuser"; SI.Mass m_m "Mass of water inside Main section Moody spreading pipes"; @@ -79,6 +83,10 @@ model DraftTube "Model of a draft tube for reaction turbines" // connectors extends OpenHPL.Interfaces.TwoContacts; +protected + parameter SI.Diameter D_i_ = if use_A then sqrt(4 * A_i / pi) else D_i; + parameter SI.Diameter D_o_ = if use_A then sqrt(4 * A_o / pi) else D_o; +public initial equation if SteadyState then der(M) = 0; @@ -88,7 +96,7 @@ initial equation //n.T = p.T; end if; equation - assert(D_i > 0 and D_o > 0, "DraftTube diameters D_i and D_o must be > 0.", AssertionLevel.error); + assert(D_i_ > 0 and D_o_ > 0, "DraftTube areas or diameters must be > 0.", AssertionLevel.error); der(M) = Mdot + F "Momentum balance"; if DraftTubeType == OpenHPL.Types.DraftTube.ConicalDiffuser then @@ -98,7 +106,7 @@ equation M = m*v; m = data.rho*V "Mass of water inside the draft tube"; m_m=0;m_b=0; // Unimportant for conical diffuser - V = pi*H/12*(D_i^2+D_o^2+D_i*D_o) "Volume of water inside the draft tube"; + V = pi*H/12*(D_i_^2+D_o_^2+D_i_*D_o_) "Volume of water inside the draft tube"; v = Vdot/A_; Vdot_b = 0; // Unimportant for conical diffuser v_m=0;v_b=0; // Unimportant for conical diffuser @@ -111,7 +119,7 @@ equation F_p = p_i * A_i - p_o * A_o; F_f = Functions.DarcyFriction.Friction(v, D_, L, data.rho, data.mu, p_eps)+1/2*data.rho*v*abs(v)*A_i*phi_d; F_fm=0;F_fb=0; - phi_d = 0.23*(1-D_i/D_o)^2; + phi_d = 0.23*(1-D_i_/D_o_)^2; phi_d_o=0; // Unimportant for conical diffuser F_g = m*data.g*cos_theta; @@ -131,8 +139,8 @@ equation F_p = p_i*A_i-2*p_o*A_o*cos_theta_moody_by_2; F_g = m_m*data.g+2*m_b*data.g*cos_theta_moody_by_2; F_f = F_fm+2*F_fb*cos_theta_moody_by_2+data.rho*v_m*abs(v_m)*A_i*phi_d; - F_fm = Functions.DarcyFriction.Friction(v_m, D_i, L_m, data.rho, data.mu, p_eps); - F_fb = Functions.DarcyFriction.Friction(v_b, D_o, L_b, data.rho, data.mu, p_eps); + F_fm = Functions.DarcyFriction.Friction(v_m, D_i_, L_m, data.rho, data.mu, p_eps); + F_fb = Functions.DarcyFriction.Friction(v_b, D_o_, L_b, data.rho, data.mu, p_eps); phi_d = 1+(v_b/v_m)^2-2*v_b/v_m*cos_theta_moody-phi_d_o*(v_b/v_m)^2; @@ -159,8 +167,8 @@ equation

Two draft tube variants are modeled using momentum balance.

Parameterization:

They are: