From 9252e55633ca6a571f3958f0c846368031b73fa9 Mon Sep 17 00:00:00 2001 From: Dietmar Winkler Date: Mon, 9 Feb 2026 14:36:00 +0100 Subject: [PATCH 1/5] Adds pipe friction method selection Adds functionality to specify pipe friction using different methods: pipe roughness, Moody friction factor, or Manning coefficient. This enhancement simplifies friction specification and offers flexibility for various application scenarios. --- OpenHPL/Types/FrictionMethod.mo | 5 ++++ OpenHPL/Types/package.order | 1 + OpenHPL/Waterway/Pipe.mo | 46 ++++++++++++++++++++++++++++++--- 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 OpenHPL/Types/FrictionMethod.mo diff --git a/OpenHPL/Types/FrictionMethod.mo b/OpenHPL/Types/FrictionMethod.mo new file mode 100644 index 00000000..21e29803 --- /dev/null +++ b/OpenHPL/Types/FrictionMethod.mo @@ -0,0 +1,5 @@ +within OpenHPL.Types; +type FrictionMethod = enumeration( + PipeRoughness "Direct pipe roughness height (p_eps)", + MoodyFriction "Moody friction factor (f)", + ManningFriction "Manning roughness coefficient (M or n)") "Enumeration defining method for specifying pipe friction"; diff --git a/OpenHPL/Types/package.order b/OpenHPL/Types/package.order index 5ec69b5b..1f93386e 100644 --- a/OpenHPL/Types/package.order +++ b/OpenHPL/Types/package.order @@ -1,4 +1,5 @@ DraftTube Fitting +FrictionMethod Lambda SurgeTank diff --git a/OpenHPL/Waterway/Pipe.mo b/OpenHPL/Waterway/Pipe.mo index 8790ab90..b7e679b6 100644 --- a/OpenHPL/Waterway/Pipe.mo +++ b/OpenHPL/Waterway/Pipe.mo @@ -13,8 +13,21 @@ model Pipe "Model of a pipe" Dialog(group = "Geometry")); parameter SI.Diameter D_o = D_i "Diameter of the outlet side" annotation ( Dialog(group = "Geometry")); - parameter SI.Height p_eps = data.p_eps "Pipe roughness height" annotation ( - Dialog(group = "Geometry")); + + // Friction specification: + parameter Types.FrictionMethod friction_method = Types.FrictionMethod.PipeRoughness "Method for specifying pipe friction" annotation ( + Dialog(group = "Friction")); + parameter SI.Height p_eps_input = data.p_eps "Pipe roughness height (absolute)" annotation ( + Dialog(group = "Friction", enable = friction_method == Types.FrictionMethod.PipeRoughness)); + parameter Real f_moody(min=0) = 0.02 "Moody friction factor (dimensionless, typically 0.01-0.05)" annotation ( + Dialog(group = "Friction", enable = friction_method == Types.FrictionMethod.MoodyFriction)); + parameter Real m_manning(unit="m(1/3)/s", min=0) = 40 "Manning M (Strickler) coefficient M=1/n (typically 60-110 for steel, 30-60 for rock tunnels)" annotation ( + Dialog(group = "Friction", enable = friction_method == Types.FrictionMethod.ManningFriction and not use_n)); + parameter Boolean use_n = false "If true, use Mannings coefficient n (=1/M) instead of Manning's M (Strickler)" annotation ( + Dialog(group = "Friction", enable = friction_method == Types.FrictionMethod.ManningFriction), choices(checkBox=true)); + parameter Real n_manning(unit="s/m(1/3)", min=0) = 0.025 "Manning's n coefficient (typically 0.009-0.017 for steel/concrete, 0.017-0.030 for rock tunnels)" annotation ( + Dialog(group = "Friction", enable = friction_method == Types.FrictionMethod.ManningFriction and use_n)); + // Steady state: parameter Boolean SteadyState=data.SteadyState "If true, starts in steady state" annotation (Dialog(group="Initialization")); @@ -29,6 +42,10 @@ model Pipe "Model of a pipe" SI.VolumeFlowRate Vdot "Volume flow rate"; protected + parameter Real n_eff = if use_n then n_manning else 1/m_manning "Effective Manning's n coefficient"; + parameter SI.Height p_eps = if friction_method == Types.FrictionMethod.PipeRoughness then p_eps_input + elseif friction_method == Types.FrictionMethod.MoodyFriction then 3.7 * D_ * 10^(-1/(2*sqrt(f_moody))) + else 7.66 * n_eff^1.5 "Equivalent pipe roughness height"; parameter SI.Diameter D_ = ( D_i + D_o) / 2 "Average diameter"; parameter SI.Area A_i = D_i ^ 2 * C.pi / 4 "Inlet cross-sectional area"; parameter SI.Area A_o = D_o ^ 2 * C.pi / 4 "Outlet cross-sectional area"; @@ -72,8 +89,29 @@ equation

If the pipe is slightly tapered then this can be taken into account by adjusting K_c based on your taper geometry: 0.05–0.15 for gentle cones, up to 0.6 for sharp contractions.

+
Friction Specification
+

The pipe friction can be specified using one of three methods via the friction_method parameter:

+ +

The conversions are simplified for hydropower applications assuming fully turbulent flow, + so they depend only on fixed pipe dimensions and the chosen friction coefficient.

+ +
More info

More info about the pipe model can be found in [Vytvytskyi2017] - and [Splavska2017a].

Updated formulation for non-equal inlet- and outlet diameter.



+ and [Splavska2017a].

")); -end Pipe; +end Pipe; \ No newline at end of file From 3c6bf166c297b690b4e6c1b590cf9c8b249859f7 Mon Sep 17 00:00:00 2001 From: Dietmar Winkler Date: Mon, 9 Feb 2026 14:38:36 +0100 Subject: [PATCH 2/5] Fix HTML tags --- OpenHPL/Waterway/Pipe.mo | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenHPL/Waterway/Pipe.mo b/OpenHPL/Waterway/Pipe.mo index b7e679b6..a01cd472 100644 --- a/OpenHPL/Waterway/Pipe.mo +++ b/OpenHPL/Waterway/Pipe.mo @@ -92,16 +92,16 @@ equation
Friction Specification

The pipe friction can be specified using one of three methods via the friction_method parameter:

- These are then converted using: p_eps = 7.66·n1.5 + These are then converted using: p_eps = D_h*3.097 exp(-0.118/n) empirically derived from the Karman-Prandtl equation.

The conversions are simplified for hydropower applications assuming fully turbulent flow, so they depend only on fixed pipe dimensions and the chosen friction coefficient.

@@ -113,5 +112,5 @@ equation

More info about the pipe model can be found in [Vytvytskyi2017] and [Splavska2017a].

- ")); -end Pipe; \ No newline at end of file + ")); +end Pipe; From a7b20c4db898e817b25eb5c5118089bb5f1117a8 Mon Sep 17 00:00:00 2001 From: Dietmar Winkler Date: Tue, 10 Feb 2026 13:08:39 +0100 Subject: [PATCH 4/5] Cosmetic improvements --- OpenHPL/Waterway/Pipe.mo | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenHPL/Waterway/Pipe.mo b/OpenHPL/Waterway/Pipe.mo index 8ad971bc..858f25a0 100644 --- a/OpenHPL/Waterway/Pipe.mo +++ b/OpenHPL/Waterway/Pipe.mo @@ -1,4 +1,4 @@ -within OpenHPL.Waterway; +within OpenHPL.Waterway; model Pipe "Model of a pipe" outer Data data "Using standard data set"; extends OpenHPL.Icons.Pipe; @@ -27,7 +27,7 @@ model Pipe "Model of a pipe" Dialog(group = "Friction", enable = friction_method == Types.FrictionMethod.ManningFriction), choices(checkBox=true)); parameter Real n_manning(unit="s/m(1/3)", min=0) = 0.025 "Manning's n coefficient (typically 0.009-0.017 for steel/concrete, 0.017-0.030 for rock tunnels)" annotation ( Dialog(group = "Friction", enable = friction_method == Types.FrictionMethod.ManningFriction and use_n)); - + // Steady state: parameter Boolean SteadyState=data.SteadyState "If true, starts in steady state" annotation (Dialog(group="Initialization")); @@ -73,7 +73,7 @@ equation mdot = i.mdot "Inlet direction for mdot"; annotation ( - Documentation(info= "

The simple model of the pipe gives possibilities + Documentation(info="

The simple model of the pipe gives possibilities for easy modelling of different conduit: intake race, penstock, tail race, etc.

This model is described by the momentum differential equation, which depends on pressure drop through the pipe together with friction and gravity forces. @@ -103,7 +103,7 @@ equation

  • Manning's n coefficient [s/m1/3]: Typical values 0.009-0.013 for smooth steel, 0.012-0.017 for concrete, 0.017-0.030 for rock tunnels. Use checkbox use_n to enable this notation.
  • - These are then converted using: p_eps = D_h*3.097 exp(-0.118/n) empirically derived from the Karman-Prandtl equation. + These are then converted using: p_eps = D_h·3.097·e(-0.118/n) empirically derived from the Karman-Prandtl equation.

    The conversions are simplified for hydropower applications assuming fully turbulent flow, so they depend only on fixed pipe dimensions and the chosen friction coefficient.

    @@ -112,5 +112,5 @@ equation

    More info about the pipe model can be found in [Vytvytskyi2017] and [Splavska2017a].

    - ")); + ")); end Pipe; From e983a8bdc854d8456d69ed2dc7c23acf4f72bb9e Mon Sep 17 00:00:00 2001 From: Dietmar Winkler Date: Tue, 10 Feb 2026 13:11:13 +0100 Subject: [PATCH 5/5] BOM fix --- OpenHPL/Waterway/Pipe.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenHPL/Waterway/Pipe.mo b/OpenHPL/Waterway/Pipe.mo index 858f25a0..6e962bf5 100644 --- a/OpenHPL/Waterway/Pipe.mo +++ b/OpenHPL/Waterway/Pipe.mo @@ -1,4 +1,4 @@ -within OpenHPL.Waterway; +within OpenHPL.Waterway; model Pipe "Model of a pipe" outer Data data "Using standard data set"; extends OpenHPL.Icons.Pipe; @@ -107,7 +107,7 @@ equation

    The conversions are simplified for hydropower applications assuming fully turbulent flow, so they depend only on fixed pipe dimensions and the chosen friction coefficient.

    - +
    More info

    More info about the pipe model can be found in [Vytvytskyi2017]