Skip to content
Open
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
13 changes: 10 additions & 3 deletions OpenHPL/Waterway/BendPipe.mo
Original file line number Diff line number Diff line change
Expand Up @@ -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 = A_i "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
Expand Down
39 changes: 24 additions & 15 deletions OpenHPL/Waterway/DraftTube.mo
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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));
Expand All @@ -35,12 +41,12 @@ model DraftTube "Model of a draft tube for reaction turbines"
// parameter Boolean TempUse = data.TempUse "If checked - the water temperature is not constant" annotation (Dialog(group = "Initialization"));
// 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";

protected
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";

/* variables */
SI.Mass m "Mass of water inside conical diffuser";
SI.Mass m_m "Mass of water inside Main section Moody spreading pipes";
SI.Mass m_b "Mass of water inside Branch section Moody spreading pipes";
Expand Down Expand Up @@ -79,6 +85,9 @@ 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;
initial equation
if SteadyState then
der(M) = 0;
Expand All @@ -88,7 +97,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
Expand All @@ -98,7 +107,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
Expand All @@ -111,7 +120,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;

Expand All @@ -131,8 +140,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;

Expand All @@ -159,8 +168,8 @@ equation
<p>Two draft tube variants are modeled using <em>momentum balance</em>.</p>
<p><strong>Parameterization:</strong></p>
<ul>
<li><strong>Conical diffuser:</strong> use <code>H</code>, <code>L</code>, <code>D_i</code>, and <code>D_o</code>. The inclination is derived internally from the slope ratio <code>H/L</code>.</li>
<li><strong>Moody spreading pipe:</strong> use <code>L_m</code>, <code>L_b</code>, <code>D_i</code>, <code>D_o</code>, and <code>theta_moody</code>.</li>
<li><strong>Conical diffuser:</strong> use <code>H</code>, <code>L</code>, and inlet/outlet diameters <code>D_i</code>/<code>D_o</code> or areas <code>A_i</code>/<code>A_o</code>. The inclination is derived internally from the slope ratio <code>H/L</code>.</li>
<li><strong>Moody spreading pipe:</strong> use <code>L_m</code>, <code>L_b</code>, inlet/outlet diameters <code>D_i</code>/<code>D_o</code> or areas <code>A_i</code>/<code>A_o</code>, and <code>theta_moody</code>.</li>
</ul>
<p>They are:</p>
<ul>
Expand Down
30 changes: 20 additions & 10 deletions OpenHPL/Waterway/Fitting.mo
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ model Fitting "Different pipes fitting"
parameter Types.Fitting fit_type=OpenHPL.Types.Fitting.Square "Type of pipe fitting";
/* geometrical parameters for fitting */
parameter SI.Diameter D_i = 5.8 "Pipe diameter of the inlet (LHS)" annotation (
Dialog(group = "Geometry"));
Dialog(group = "Geometry", enable=not use_A));
parameter SI.Diameter D_o = 3.3 "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 = 26.42 "Area of the inlet side" annotation (
Dialog(group = "Geometry", enable=use_A));
parameter SI.Area A_o = 8.55 "Area of the outlet side" annotation (
Dialog(group = "Geometry", enable=use_A));
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
parameter Modelica.Units.NonSI.Angle_deg theta=45 "If Tapered fitting: angle of the tapered reduction/expansion" annotation (Dialog(group="Geometry", enable=fit_type == OpenHPL.Types.Fitting.Tapered));
parameter SI.Length L(max = 5 * D_o) = 1 "If Thick Orifice: length of the thick orifice, condition L/D_2<=5. If this condition is not satisfied (L is longer) then use Square Reduction followed by Square Expansion" annotation (
parameter SI.Length L(max = 5 * D_o_) = 1 "If Thick Orifice: length of the thick orifice, condition L/D_2<=5. If this condition is not satisfied (L is longer) then use Square Reduction followed by Square Expansion" annotation (
Dialog(group = "Geometry", enable=fit_type == OpenHPL.Types.Fitting.ThickOrifice));
/* variables */
SI.Velocity v(start=Modelica.Constants.eps) "Water velocity";
Expand All @@ -26,28 +36,28 @@ equation
if v>=0 then
phi =Functions.Fitting.FittingPhi(
v,
D_i,
D_o,
D_i_,
D_o_,
L,
theta,
data.rho,
data.mu,
data.p_eps,
fit_type);
A = pi * D_i^2 / 4;
A = if use_A then A_i else pi * D_i^2 / 4;
dp = phi * 0.5 * data.rho * v^2;
else
phi =Functions.Fitting.FittingPhi(
v,
D_o,
D_i,
D_o_,
D_i_,
L,
theta,
data.rho,
data.mu,
data.p_eps,
fit_type);
A = pi * D_o^2 / 4;
A = if use_A then A_o else pi * D_o^2 / 4;
dp = - phi * 0.5 * data.rho * v^2;
end if;
o.p = i.p - dp "Pressure of the output connector";
Expand All @@ -56,7 +66,7 @@ equation
o.elevation.z = i.elevation.z "Elevation propagation: no height change across fitting";
annotation (preferredView="info",
Documentation(info="<html>
<p>Various possibilities of the fittings for the pipes with different diameters
<p>Various possibilities of the fittings for the pipes with different diameters or cross-sectional areas
and also the orifices in the pipe.
Here, the pressure drop due to these constrictions is defined.</p>
<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" width=\"50%\"><tr>
Expand Down
14 changes: 11 additions & 3 deletions OpenHPL/Waterway/Penstock.mo
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ model Penstock "Model of the penstock with elastic walls and compressible water.
parameter SI.Length L = 600 "length of the pipe, m" annotation (
Dialog(group = "Geometry"));
parameter SI.Diameter D_i = 3.3 "Diametr from the input side of the pipe" annotation (
Dialog(group = "Geometry"));
Dialog(group = "Geometry", enable=not use_A));
parameter SI.Diameter D_o = D_i "Diametr from the output side of the pipe" 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 = 8.55 "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));
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;
parameter SI.VolumeFlowRate Vdot_0 = 20 "Initial volume flow rate" annotation (
Dialog(group = "Initialization"));
parameter Integer N = 20 "Number of segments" annotation (
Dialog(group = "Discretization"));
SI.Diameter dD = 0.5 * (D_i + D_o), D[N] = linspace(D_i + dD / 2, D_o - dD / 2, N), D_[N + 1] = linspace(D_i, D_o, N + 1);
SI.Diameter dD = 0.5 * (D_i_ + D_o_), D[N] = linspace(D_i_ + dD / 2, D_o_ - dD / 2, N), D_[N + 1] = linspace(D_i_, D_o_, N + 1);
SI.Area A[N] = D .^ 2 * pi / 4, A_[N + 1] = D_ .^ 2 * pi / 4, A_m[N - 2], A_m_end, A_m_first;
SI.Pressure p_i, p_o, p_[N - 1], dp = data.rho * data.g * H / N, p_m[N - 2];
SI.Length dx = L / N, Per_m[N - 2];
Expand Down
18 changes: 13 additions & 5 deletions OpenHPL/Waterway/PenstockKP.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@ 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( slanted=true);
extends Types.FrictionSpec( final D_h = (D_i + D_o) / 2);
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 (
Dialog(group = "Geometry"));
parameter SI.Length L = 600 "length of the pipe" annotation (
Dialog(group = "Geometry"));
parameter SI.Diameter D_i = 3.3 "Diametr from the inlet side of the pipe" annotation (
Dialog(group = "Geometry"));
Dialog(group = "Geometry", enable=not use_A));
parameter SI.Diameter D_o = D_i "Diametr from the outlet side of the pipe" 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 = 8.55 "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));
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;
// 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 All @@ -30,7 +38,7 @@ model PenstockKP "Detailed model of the pipe. Could have elastic walls and compr
choices(checkBox = true),
Dialog(group = "Properties"));
// variables
SI.Diameter dD = (D_i - D_o) / N "step in diameter change", D[N] = linspace(D_i + dD / 2, D_o - dD / 2, N) "centered diameter vector in atm. p.", D_[N + 1] = linspace(D_i, D_o, N + 1) "boundary diameter vector in atm. p.";
SI.Diameter dD = (D_i_ - D_o_) / N "step in diameter change", D[N] = linspace(D_i_ + dD / 2, D_o_ - dD / 2, N) "centered diameter vector in atm. p.", D_[N + 1] = linspace(D_i_, D_o_, N + 1) "boundary diameter vector in atm. p.";
SI.Area A_atm[N] = D .* D * pi / 4 "centered cross are vector in atm. p.", A_atm_[N + 1] = D_ .* D_ * pi / 4 "boundary cross are vector in atm. p.", A[N] "centered cross are vector", A_[N, 4] "boundary cross are vector", _A_atm[N, 4] "boundary cross are matrix in atm. p.";
SI.Pressure p_p[N] "centered pressure", dp = data.rho * data.g * H / N "initial p. step", p_i "Inlet pressure (LHS)", p_o "Outlet Pressure (RHS)", p_[N, 4] "boundary p. matrix";
SI.Length dx = L / N "length step", dh = H / N "height step";
Expand Down Expand Up @@ -167,7 +175,7 @@ c = √(A<sub>p</sub>/(A<sub>p</sub><sup>atm</sup> ρ<sup>atm</sup> β<sup>tot</
<h5>Parameters</h5>
<p>User specifies:</p>
<ul>
<li>Geometry: length <code>L</code>, height difference <code>H</code>, inlet/outlet diameters <code>D_i</code>/<code>D_o</code>,
<li>Geometry: length <code>L</code>, height difference <code>H</code>, inlet/outlet diameters <code>D_i</code>/<code>D_o</code> or areas <code>A_i</code>/<code>A_o</code>,
roughness <code>p_eps</code></li>
<li>Discretization: number of cells <code>N</code></li>
<li>Model fidelity: <code>PipeElasticity</code> checkbox to enable/disable elastic walls</li>
Expand Down
25 changes: 17 additions & 8 deletions OpenHPL/Waterway/Pipe.mo
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 0.785 "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"));
Expand All @@ -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
Expand Down
Loading
Loading