Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions OpenHPL/Data.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ record Data "Provides a data set of most common used settings"
extends Modelica.Icons.Record;
parameter Boolean showElevation=true "Display elevation of connectors"
annotation(Dialog(group = "Icon"),
choices(checkBox = true));
choices(checkBox = true));
parameter SI.Acceleration g = Modelica.Constants.g_n "Gravity constant"
annotation (Dialog(enable=false, group = "Constants"));
parameter Real gamma_air = 1.4 "Ratio of heat capacities at constant pressure (C_p) to constant volume (C_v) for air at STP"
Expand All @@ -16,8 +16,24 @@ record Data "Provides a data set of most common used settings"
annotation (Dialog(group = "Waterway properties"));
parameter SI.DynamicViscosity mu = 1.3076e-3 "Dynamic viscosity of water at T_0"
annotation (Dialog(group = "Waterway properties"));
parameter SI.Height p_eps = 0 "Pipe roughness height (default is smooth pipe)"
annotation (Dialog(group = "Waterway properties"));
parameter Types.FrictionMethod FrictionMethod = Types.FrictionMethod.PipeRoughness "Default friction specification method"
annotation (Dialog(group = "Friction"));
parameter SI.Height p_eps_input = 0 "Pipe roughness height (for PipeRoughness method)"
annotation (Dialog(group = "Friction", enable = FrictionMethod == Types.FrictionMethod.PipeRoughness));
parameter Real f_moody(min=0) = 0.02 "Moody friction factor (used when FrictionMethod = MoodyFriction)"
annotation (Dialog(group = "Friction", enable = FrictionMethod == Types.FrictionMethod.MoodyFriction));
parameter Real m_manning(unit="m(1/3)/s", min=0) = 40 "Manning M (Strickler) coefficient (used when FrictionMethod = ManningFriction)"
annotation (Dialog(group = "Friction", enable = FrictionMethod == Types.FrictionMethod.ManningFriction and not use_n));
parameter Boolean use_n = false "If true, use Manning's n instead of M"
annotation (Dialog(group = "Friction", enable = FrictionMethod == Types.FrictionMethod.ManningFriction), choices(checkBox=true));
parameter Real n_manning(unit="s/m(1/3)", min=0) = 0.025 "Manning's n coefficient (used when FrictionMethod = ManningFriction and use_n)"
annotation (Dialog(group = "Friction", enable = FrictionMethod == Types.FrictionMethod.ManningFriction and use_n));
parameter SI.Diameter D_h = 1.0 "Reference hydraulic diameter for friction conversion (used for Moody/Manning)"
annotation (Dialog(group = "Friction", enable = FrictionMethod <> Types.FrictionMethod.PipeRoughness));
final parameter Real n_eff_ = if use_n then n_manning else 1/m_manning "Effective Manning's n coefficient";
final parameter SI.Height p_eps = if FrictionMethod == Types.FrictionMethod.PipeRoughness then p_eps_input
elseif FrictionMethod == Types.FrictionMethod.MoodyFriction then 3.7 * D_h * 10^(-1/(2*sqrt(f_moody)))
else D_h * 3.0971 * exp(-0.118/n_eff_) "Computed equivalent pipe roughness height";
parameter SI.Compressibility beta = 4.5e-10 "Water compressibility"
annotation (Dialog(group = "Waterway properties"));
parameter SI.Compressibility beta_total = 1 / (rho*1000^2) "Total compressibility"
Expand Down
51 changes: 51 additions & 0 deletions OpenHPL/Types/FrictionSpec.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
within OpenHPL.Types;
partial model FrictionSpec "Reusable friction specification with multiple input methods"
outer Data data "Using standard data set";

parameter Types.FrictionMethod FrictionMethod = data.FrictionMethod "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 = FrictionMethod == Types.FrictionMethod.PipeRoughness));
parameter Real f_moody(min=0) = data.f_moody "Moody friction factor (dimensionless, typically 0.01-0.05)" annotation (
Dialog(group = "Friction", enable = FrictionMethod == Types.FrictionMethod.MoodyFriction));
parameter Real m_manning(unit="m(1/3)/s", min=0) = data.m_manning "Manning M (Strickler) coefficient M=1/n (typically 60-110 for steel, 30-60 for rock tunnels)" annotation (
Dialog(group = "Friction", enable = FrictionMethod == Types.FrictionMethod.ManningFriction and not use_n));
parameter Boolean use_n = data.use_n "If true, use Mannings coefficient n (=1/M) instead of Manning's M (Strickler)" annotation (
Dialog(group = "Friction", enable = FrictionMethod == Types.FrictionMethod.ManningFriction), choices(checkBox=true));
parameter Real n_manning(unit="s/m(1/3)", min=0) = data.n_manning "Manning's n coefficient (typically 0.009-0.017 for steel/concrete, 0.017-0.030 for rock tunnels)" annotation (
Dialog(group = "Friction", enable = FrictionMethod == Types.FrictionMethod.ManningFriction and use_n));

parameter SI.Diameter D_h "Hydraulic diameter used for friction conversion" annotation (
Dialog(group = "Friction"));

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 FrictionMethod == Types.FrictionMethod.PipeRoughness then p_eps_input
elseif FrictionMethod == Types.FrictionMethod.MoodyFriction then 3.7 * D_h * 10^(-1/(2*sqrt(f_moody)))
else D_h * 3.0971 * exp(-0.118/n_eff) "Equivalent pipe roughness height";

annotation (preferredView="info",
Documentation(info="<html>
<h4>Friction Specification</h4>
<p>Partial model providing a reusable friction parameter set. Extending models must supply
the hydraulic diameter <code>D_h</code> used for converting Moody and Manning coefficients
to equivalent pipe roughness height <code>p_eps</code>.</p>

<p>Three friction specification methods are supported via the <code>FrictionMethod</code> parameter:</p>
<ul>
<li><strong>Pipe Roughness (p_eps)</strong>: Direct specification of absolute pipe roughness height (m).
Typical values: 0.0001&ndash;0.001 m for steel pipes, 0.001&ndash;0.003 m for concrete.</li>
<li><strong>Moody Friction Factor (f)</strong>: Dimensionless friction factor from Moody diagram.
Typical values: 0.01&ndash;0.05. Converted to equivalent roughness using fully turbulent flow approximation:
p_eps = 3.7&middot;D&middot;10<sup>-1/(2&radic;f)</sup></li>
<li><strong>Manning Coefficient</strong>: Two notations are supported:
<ul>
<li><strong>Manning's M coefficient (Strickler)</strong> [m<sup>1/3</sup>/s]: M = 1/n, typical values 60&ndash;110 for steel,
30&ndash;60 for rock tunnels.</li>
<li><strong>Manning's n coefficient</strong> [s/m<sup>1/3</sup>]: Typical values 0.009&ndash;0.013 for smooth steel,
0.012&ndash;0.017 for concrete, 0.017&ndash;0.030 for rock tunnels. Use checkbox <code>use_n</code> to enable.</li>
</ul>
Converted using: p_eps = D_h&middot;3.097&middot;e<sup>(-0.118/n)</sup> empirically derived from the Karman-Prandtl equation.</li>
</ul>
</html>"));
end FrictionSpec;
1 change: 1 addition & 0 deletions OpenHPL/Types/package.order
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ DraftTube
Efficiency
Fitting
FrictionMethod
FrictionSpec
Lambda
SurgeTank
3 changes: 1 addition & 2 deletions OpenHPL/Waterway/DraftTube.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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));
import Modelica.Constants.pi;
parameter Types.DraftTube DraftTubeType = OpenHPL.Types.DraftTube.ConicalDiffuser "Types of draft tube" annotation (
Dialog(group = "Draft tube types"));
Expand Down Expand Up @@ -29,8 +30,6 @@ model DraftTube "Model of a draft tube for reaction turbines"
choice = 45 "45°",
choice = 60 "60°",
choice = 90 "90°"));
parameter SI.Height p_eps = data.p_eps "Pipe roughness height" annotation (
Dialog(group = "Geometry"));
parameter Boolean SteadyState=data.SteadyState "If true, starts in steady state" annotation (Dialog(group="Initialization"));
parameter SI.VolumeFlowRate Vdot_0=data.Vdot_0 "Initial volume flow rate" annotation (Dialog(group="Initialization"));

Expand Down
3 changes: 1 addition & 2 deletions OpenHPL/Waterway/PenstockKP.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ within OpenHPL.Waterway;
model PenstockKP "Detailed model of the pipe. Could have elastic walls and compressible water. KP scheme"
outer OpenHPL.Data data "Using standard data set";
extends OpenHPL.Icons.Pipe( vertical=true);
extends Types.FrictionSpec( final D_h = (D_i + D_o) / 2);
import Modelica.Constants.pi;
// geometrical parameters of the pipe
parameter SI.Height H = 420 "Height difference from the inlet to the outlet of the pipe" annotation (
Expand All @@ -12,8 +13,6 @@ model PenstockKP "Detailed model of the pipe. Could have elastic walls and compr
Dialog(group = "Geometry"));
parameter SI.Diameter D_o = D_i "Diametr from the outlet side of the pipe" annotation (
Dialog(group = "Geometry"));
parameter SI.Height p_eps = data.p_eps "Pipe roughness height" annotation (
Dialog(group = "Geometry"));
// condition of steady state
parameter Boolean SteadyState=data.SteadyState "If true, starts in steady state" annotation (Dialog(group="Initialization"));
// staedy state values for flow rate in all segments of the pipe
Expand Down
40 changes: 3 additions & 37 deletions OpenHPL/Waterway/Pipe.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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);

// Geometrical parameters of the pipe:
parameter SI.Length H = 0 "Height difference from the inlet to the outlet" annotation (
Expand All @@ -14,21 +15,6 @@ model Pipe "Model of a pipe"
parameter SI.Diameter D_o = D_i "Diameter of the outlet side" 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"));
parameter SI.VolumeFlowRate Vdot_0=data.Vdot_0 "Initial flow rate of the pipe" annotation (Dialog(group="Initialization"));
Expand All @@ -44,10 +30,6 @@ 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 D_*3.0971 *exp(-0.118/n_eff) "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";
Expand Down Expand Up @@ -119,24 +101,8 @@ slopes (positive or negative height difference).</p>
taper geometry: 0.05–0.15 for gentle cones, up to 0.6 for sharp contractions.</p>

<h5>Friction Specification</h5>
<p>The pipe friction can be specified using one of three methods via the <code>friction_method</code> parameter:</p>
<ul>
<li><strong>Pipe Roughness (p_eps)</strong>: Direct specification of absolute pipe roughness height (m).
Typical values: 0.0001-0.001 m for steel pipes, 0.001-0.003 m for concrete.</li>
<li><strong>Moody Friction Factor (f)</strong>: Dimensionless friction factor from Moody diagram.
Typical values: 0.01-0.05. Converted to equivalent roughness using fully turbulent flow approximation:
p_eps = 3.7·D·10<sup>-1/(2√f)</sup></li>
<li><strong>Manning Coefficient</strong>: Two notations are supported:
<ul>
<li><strong>Manning's M coefficient (Strickler)</strong> [m<sup>1/3</sup>/s]: M = 1/n, typical values 60-110 for steel,
30-60 for rock tunnels.</li>
<li><strong>Manning's n coefficient</strong> [s/m<sup>1/3</sup>]: Typical values 0.009-0.013 for smooth steel,
0.012-0.017 for concrete, 0.017-0.030 for rock tunnels. Use checkbox <code>use_n</code> to enable this notation.</li>
</ul>
These are then converted using: p_eps = D_h·3.097·e<sup>(-0.118/n)</sup> empirically derived from the&nbsp;Karman-Prandtl equation.</li>
</ul>
<p>The conversions are simplified for hydropower applications assuming fully turbulent flow,
so they depend only on fixed pipe dimensions and the chosen friction coefficient.</p>
<p>Friction is specified via the inherited <a href=\"modelica://OpenHPL.Waterway.BaseClasses.FrictionSpec\">FrictionSpec</a>
base class, which supports pipe roughness, Moody friction factor, and Manning coefficient methods.</p>

<h5>Initialization</h5>
<p>By default, the pipe provides an initial equation for the flow rate: either <code>der(mdot) = 0</code>
Expand Down
2 changes: 1 addition & 1 deletion OpenHPL/Waterway/Reservoir.mo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPL.Waterway;
within OpenHPL.Waterway;
model Reservoir "Model of the reservoir"
outer Data data "using standard class with constants";
extends OpenHPL.Icons.Reservoir;
Expand Down
11 changes: 5 additions & 6 deletions OpenHPL/Waterway/SurgeTank.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ model SurgeTank "Model of the surge tank/shaft"
outer Data data "Using standard data set";
extends OpenHPL.Icons.Surge(lds=l, Lds=L);
extends OpenHPL.Interfaces.TwoContacts;
extends Types.FrictionSpec( final D_h = D);

parameter Types.SurgeTank SurgeTankType = OpenHPL.Types.SurgeTank.STSimple "Types of surge tank"
annotation (Dialog(group = "Surge tank types"));
Expand All @@ -16,8 +17,6 @@ model SurgeTank "Model of the surge tank/shaft"
annotation (Dialog(group = "Geometry"));


parameter SI.Height p_eps = data.p_eps "Pipe roughness height" annotation (
Dialog(group = "Geometry"));
parameter SI.Diameter D_so = D "If Sharp orifice type: Diameter of sharp orifice" annotation (
Dialog(group = "Geometry",enable=SurgeTankType == OpenHPL.Types.SurgeTank.STSharpOrifice));
parameter SI.Diameter D_t = D "If Throttle value type: Diameter of throat" annotation (
Expand Down Expand Up @@ -113,9 +112,9 @@ equation
F_f = Functions.DarcyFriction.Friction(v, D, l, data.rho, data.mu, p_eps) + A * phiSO * 0.5 * data.rho * abs(v) * v;
F_p = (p_b - p_t) * A;
if v >= 0 then
phiSO = Functions.Fitting.FittingPhi(v, D, D_so, L, 90, data.rho, data.mu, data.p_eps, OpenHPL.Types.Fitting.SharpOrifice);
phiSO = Functions.Fitting.FittingPhi(v, D, D_so, L, 90, data.rho, data.mu, p_eps, OpenHPL.Types.Fitting.SharpOrifice);
else
phiSO = Functions.Fitting.FittingPhi(v, D_so, D, L, 90, data.rho, data.mu, data.p_eps, OpenHPL.Types.Fitting.SharpOrifice);
phiSO = Functions.Fitting.FittingPhi(v, D_so, D, L, 90, data.rho, data.mu, p_eps, OpenHPL.Types.Fitting.SharpOrifice);
end if;
elseif SurgeTankType == OpenHPL.Types.SurgeTank.STThrottleValve then
if l <= L_t then
Expand All @@ -131,10 +130,10 @@ equation
M = m * v;
if v > 0 then
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;
phiSO = Functions.Fitting.FittingPhi(Vdot/A_t, D_t, D, L, 90, data.rho, data.mu, data.p_eps, OpenHPL.Types.Fitting.Square);
phiSO = Functions.Fitting.FittingPhi(Vdot/A_t, D_t, D, L, 90, data.rho, data.mu, p_eps, OpenHPL.Types.Fitting.Square);
elseif v < 0 then
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 * phiSO * 0.5 * data.rho * abs(Vdot/A) * Vdot/A;
phiSO = Functions.Fitting.FittingPhi(Vdot/A, D, D_t, L, 90, data.rho, data.mu, data.p_eps, OpenHPL.Types.Fitting.Square);
phiSO = Functions.Fitting.FittingPhi(Vdot/A, D, D_t, L, 90, data.rho, data.mu, p_eps, OpenHPL.Types.Fitting.Square);
else
F_f = 0;
phiSO = 0;
Expand Down
Loading