diff --git a/OpenHPL/ElectroMech/Turbines/Francis.mo b/OpenHPL/ElectroMech/Turbines/Francis.mo index fe22681..f86471e 100644 --- a/OpenHPL/ElectroMech/Turbines/Francis.mo +++ b/OpenHPL/ElectroMech/Turbines/Francis.mo @@ -60,6 +60,7 @@ model Francis "Model of the Francis turbine" SI.Area A_1 "Runner inlet cross section", A_0 "Turbine inlet cross section", A_v "Guide vane cross section", A_2 "Runner outlet cross section"; SI.EnergyFlowRate Wdot_s "Shaft power", Wdot_ft "Total runner losses", W_t1 "Euler first term", W_t2 "Euler second term", Wdot_ft_s "Shock losses", Wdot_ft_w "Whirl losses", Wdot_ft_l "Friction losses", Wdot_t "Total power"; SI.VolumeFlowRate Vdot "Flow rate"; + SI.MassFlowRate mdot "Mass flow rate"; SI.AngularVelocity w=w_in "Angular velocity"; SI.Velocity u_2 "Outlet reference velocity", c_m2 "Outlet meridional velocity", c_m1 "Inlet meridional velocity", u_1 "Inlet reference velocity", c_u1 "Inlet tangential velocity"; Modelica.Units.NonSI.Angle_deg beta1 "Inlet blade angle"; @@ -202,6 +203,8 @@ equation coef = Wdot_s / Wdot_t; // connectors p_tr2 = o.p; + i.mdot+o.mdot=0; + mdot=i.mdot; // output mechanical power P_out = Wdot_s; annotation ( diff --git a/OpenHPL/ElectroMech/Turbines/Pelton.mo b/OpenHPL/ElectroMech/Turbines/Pelton.mo index 2f0a1b3..4ce1f79 100644 --- a/OpenHPL/ElectroMech/Turbines/Pelton.mo +++ b/OpenHPL/ElectroMech/Turbines/Pelton.mo @@ -16,6 +16,7 @@ model Pelton "Model of the Pelton turbine" SI.Area A_1, A_0 = pi * D_0 ^ 2 / 4; SI.EnergyFlowRate Wdot_s "Shaft power"; SI.VolumeFlowRate Vdot "Flow rate"; + SI.MassFlowRate mdot "Mass flow rate"; SI.Velocity v_R, v_1; SI.AngularVelocity w=w_in "Angular velocity"; Real cos_b = Modelica.Math.cos(Modelica.Units.Conversions.from_deg(beta)); @@ -45,6 +46,9 @@ equation p_tr1 = i.p; // + dp_n; p_tr2 = o.p; + // Flow rate connectors + i.mdot+o.mdot=0; + mdot=i.mdot; // output mechanical power P_out = Wdot_s; annotation ( diff --git a/OpenHPL/ElectroMech/Turbines/Turbine.mo b/OpenHPL/ElectroMech/Turbines/Turbine.mo index 07e7cc5..935fd19 100644 --- a/OpenHPL/ElectroMech/Turbines/Turbine.mo +++ b/OpenHPL/ElectroMech/Turbines/Turbine.mo @@ -31,6 +31,7 @@ model Turbine "Simple turbine model with mechanical connectors" extends OpenHPL.Interfaces.TurbineContacts; SI.Pressure dp "Turbine pressure drop"; + SI.MassFlowRate mdot "Turbine pressure drop"; SI.EnergyFlowRate Kdot_i_tr "Kinetic energy flow"; SI.VolumeFlowRate Vdot "Flow rate"; Real C_v_ "Guide vane 'valve capacity'"; @@ -46,6 +47,8 @@ equation "Define guide vane 'valve capacity' base on the Nominal turbine parameters"; dp = Vdot ^ 2 * data.p_a / (C_v_ * max(1e-6, u_t)) ^ 2 "Turbine valve equation for pressure drop"; dp = i.p - o.p "Link the pressure drop to the ports"; + i.mdot+o.mdot=0 "Mass balance"; + mdot = i.mdot "Flow direction"; Kdot_i_tr = dp * Vdot "Turbine energy balance"; if ConstEfficiency then Wdot_s = eta_h * Kdot_i_tr; diff --git a/OpenHPL/Interfaces/ContactNode.mo b/OpenHPL/Interfaces/ContactNode.mo deleted file mode 100644 index d647800..0000000 --- a/OpenHPL/Interfaces/ContactNode.mo +++ /dev/null @@ -1,20 +0,0 @@ -within OpenHPL.Interfaces; -partial model ContactNode "Model of two connectors and node pressure" - SI.Pressure p_n "Node pressure"; - //SI.Temperature T_n "Node temperature"; - SI.MassFlowRate mdot "Mass flow rate"; - extends TwoContact; -equation - p_n = i.p; - i.p = o.p; - //T_n = i.T; - //i.T = o.T; - mdot = i.mdot + o.mdot; - annotation ( - Documentation(info = " -

ContactNode is a superclass, which has two Contacts i, o and assumes - that inlet pressure of i is equal to outlet at o. - This node pressure is determined by p_n. - Also the mass flow rate in this node is mdot.

-")); -end ContactNode; diff --git a/OpenHPL/Interfaces/ContactPort.mo b/OpenHPL/Interfaces/ContactPort.mo deleted file mode 100644 index 1fe29e1..0000000 --- a/OpenHPL/Interfaces/ContactPort.mo +++ /dev/null @@ -1,14 +0,0 @@ -within OpenHPL.Interfaces; -partial model ContactPort "Model of two connectors with mass flow rate" - SI.MassFlowRate mdot "Mass flow rate"; - extends TwoContact; -equation - 0 = i.mdot + o.mdot; - mdot = i.mdot; - annotation ( - Documentation(info = " -

ContactPort is a superclass, which has two Contacts i, o and - assumes that the inlet mass flow rate of i is identical to the outlet - mass flow rate of o. This mass flow rate is determined as mdot.

-")); -end ContactPort; diff --git a/OpenHPL/Interfaces/TurbineContacts.mo b/OpenHPL/Interfaces/TurbineContacts.mo index a4cd0e5..f4dcfe5 100644 --- a/OpenHPL/Interfaces/TurbineContacts.mo +++ b/OpenHPL/Interfaces/TurbineContacts.mo @@ -1,6 +1,6 @@ within OpenHPL.Interfaces; partial model TurbineContacts "Model of turbine connectors" - extends Interfaces.ContactPort; + extends Interfaces.TwoContacts; parameter Boolean enable_P_out = false "If checked, get a connector for the output power" annotation (choices(checkBox = true), Dialog(group="Outputs",tab="I/O")); input Modelica.Blocks.Interfaces.RealInput u_t "[Guide vane|nozzle] opening of the turbine" annotation (Placement(transformation( diff --git a/OpenHPL/Interfaces/TwoContact.mo b/OpenHPL/Interfaces/TwoContacts.mo similarity index 91% rename from OpenHPL/Interfaces/TwoContact.mo rename to OpenHPL/Interfaces/TwoContacts.mo index ac13bec..a1d422b 100644 --- a/OpenHPL/Interfaces/TwoContact.mo +++ b/OpenHPL/Interfaces/TwoContacts.mo @@ -1,5 +1,5 @@ within OpenHPL.Interfaces; -partial model TwoContact "Model of two connectors" +partial model TwoContacts "Model of two connectors" Contact_i i "Inlet contact (positive design flow direction is from i to o)" annotation ( Placement(transformation(extent={{-110,-10},{-90,10}}))); @@ -12,4 +12,4 @@ partial model TwoContact "Model of two connectors" Can be used in cases where model is needed inlet and outlet Contacts, but do not need any specification about mass flow rate and pressures between these Contacts.

")); -end TwoContact; +end TwoContacts; diff --git a/OpenHPL/Interfaces/package.order b/OpenHPL/Interfaces/package.order index 51a499e..b30ebfb 100644 --- a/OpenHPL/Interfaces/package.order +++ b/OpenHPL/Interfaces/package.order @@ -1,7 +1,5 @@ Contact Contact_i Contact_o -TwoContact -ContactPort -ContactNode TurbineContacts +TwoContacts diff --git a/OpenHPL/Waterway/BendPipe.mo b/OpenHPL/Waterway/BendPipe.mo index 542d80e..3c8b699 100644 --- a/OpenHPL/Waterway/BendPipe.mo +++ b/OpenHPL/Waterway/BendPipe.mo @@ -14,12 +14,15 @@ model BendPipe "Bend in pipes" SI.Velocity v(start=Modelica.Constants.eps) "Water velocity"; SI.Area A = pi*D_i^2/4 "Cross section area"; SI.Pressure dp "Pressure drop of fitting"; - /* Connector */ - extends OpenHPL.Interfaces.ContactPort; + SI.MassFlowRate mdot "Pressure drop of fitting"; + extends OpenHPL.Interfaces.TwoContacts; equation v = mdot / data.rho / A; dp = K_L * 0.5 * data.rho * v^2; + // Connections o.p = i.p - dp "Pressure of the output connector"; + i.mdot + o.mdot = 0 "Mass balance"; + mdot = i.mdot "Flow direction"; annotation ( Documentation(info="

Usually minor head losses in pipes are considered to be due to fittings, diffusers, nozzles, bend in pipes, etc. We are more interested in head loss due to bend pipes for this model.

diff --git a/OpenHPL/Waterway/DraftTube.mo b/OpenHPL/Waterway/DraftTube.mo index f5daabd..3407c0f 100644 --- a/OpenHPL/Waterway/DraftTube.mo +++ b/OpenHPL/Waterway/DraftTube.mo @@ -67,6 +67,7 @@ model DraftTube "Model of a draft tube for reaction turbines" SI.Pressure p_i "Inlet pressure"; SI.Pressure p_o "Outlet pressure"; SI.Pressure dp = p_o-p_i "Pressure drop in and out of draft tube"; + SI.MassFlowRate mdot "Mass flow rate"; Real phi_d "Generalized friction factor for draft tube"; Real phi_d_o "Initial generalized friction factor for Moody spreading pipes"; @@ -81,7 +82,7 @@ model DraftTube "Model of a draft tube for reaction turbines" theta_moody/2)) "Calculating cos_theta_moody_by_2"; // connectors - extends OpenHPL.Interfaces.ContactPort; + extends OpenHPL.Interfaces.TwoContacts; initial equation if SteadyState then der(M) = 0; @@ -150,6 +151,8 @@ equation // connector p_i = i.p; p_o = o.p; + i.mdot+o.mdot=0; + mdot = i.mdot; annotation (Documentation(info="

Two of the draft tubes are modeled using Momentum balance. They are:

diff --git a/OpenHPL/Waterway/Fitting.mo b/OpenHPL/Waterway/Fitting.mo index a151bd3..087c916 100644 --- a/OpenHPL/Waterway/Fitting.mo +++ b/OpenHPL/Waterway/Fitting.mo @@ -17,9 +17,10 @@ model Fitting "Different pipes fitting" SI.Velocity v(start=Modelica.Constants.eps) "Water velocity"; SI.Area A "Cross section area"; SI.Pressure dp "Pressure drop of fitting"; + SI.MassFlowRate mdot "Mass flow rate"; Real phi "Dimensionless factor based on the type of fitting "; /* Connector */ - extends OpenHPL.Interfaces.ContactPort; + extends OpenHPL.Interfaces.TwoContacts; equation v = mdot / data.rho / A; if v>=0 then @@ -50,6 +51,8 @@ equation dp = - phi * 0.5 * data.rho * v^2; end if; o.p = i.p - dp "Pressure of the output connector"; + i.mdot+o.mdot = 0 "Mass balance"; + mdot = i.mdot "Flow direction"; annotation ( Documentation(info="

Various possibilities of the fittings for the pipes with different diameters diff --git a/OpenHPL/Waterway/OpenChannel.mo b/OpenHPL/Waterway/OpenChannel.mo index 3a26b4d..c255131 100644 --- a/OpenHPL/Waterway/OpenChannel.mo +++ b/OpenHPL/Waterway/OpenChannel.mo @@ -18,7 +18,7 @@ model OpenChannel "Open channel model (use KP scheme)" SI.VolumeFlowRate Vdot_i "Inlet flow rate"; SI.Height h[N] "Water level in each unit of the channel"; // connector - extends OpenHPL.Interfaces.TwoContact; + extends OpenHPL.Interfaces.TwoContacts; // using open channel example from KP method class Internal.KPOpenChannel openChannel( N=N, diff --git a/OpenHPL/Waterway/Penstock.mo b/OpenHPL/Waterway/Penstock.mo index 82f7b62..f6bdf19 100644 --- a/OpenHPL/Waterway/Penstock.mo +++ b/OpenHPL/Waterway/Penstock.mo @@ -27,7 +27,7 @@ model Penstock "Model of the penstock with elastic walls and compressible water. SI.Density rho_m[N - 2], rho_m_end, rho_m_first; SI.Velocity v_exp[N]; SI.VolumeFlowRate V_p_out[N - 2], V_p_out_end; - extends OpenHPL.Interfaces.TwoContact; + extends OpenHPL.Interfaces.TwoContacts; initial equation mdot_R = data.rho * Vdot_0; mdot_V = data.rho * Vdot_0; diff --git a/OpenHPL/Waterway/PenstockKP.mo b/OpenHPL/Waterway/PenstockKP.mo index 783732d..aa88a0d 100644 --- a/OpenHPL/Waterway/PenstockKP.mo +++ b/OpenHPL/Waterway/PenstockKP.mo @@ -42,7 +42,7 @@ model PenstockKP "Detailed model of the pipe. Could have elastic walls and compr SI.VolumeFlowRate Vdot[N] "centered volumetric flow"; SI.Force F_f[N] "centered friction force vector"; Real theta = 1.3 "parameter for slope limiter"; - extends OpenHPL.Interfaces.TwoContact; + extends OpenHPL.Interfaces.TwoContacts; public Functions.KP07.KPmethod KP(N = N, U = U, dx = dx, theta = theta, B = zeros(N + 4), S_ = S_, F_ = F_, lam1 = lam1, lam2 = lam2, boundary = [p_i, 0; p_o, 0], boundaryCon = [true, false; true, false]); // specify all variables which is needed for using KP method for solve PDE diff --git a/OpenHPL/Waterway/Pipe.mo b/OpenHPL/Waterway/Pipe.mo index a7cc23f..5d94f89 100644 --- a/OpenHPL/Waterway/Pipe.mo +++ b/OpenHPL/Waterway/Pipe.mo @@ -2,7 +2,7 @@ within OpenHPL.Waterway; model Pipe "Model of a pipe" outer Data data "Using standard data set"; extends OpenHPL.Icons.Pipe; - extends OpenHPL.Interfaces.ContactPort; + extends OpenHPL.Interfaces.TwoContacts; // Geometrical parameters of the pipe: parameter SI.Length H = 25 "Height difference from the inlet to the outlet" annotation ( @@ -35,6 +35,7 @@ model Pipe "Model of a pipe" SI.Pressure p_i "Inlet pressure"; SI.Pressure p_o "Outlet pressure"; SI.Pressure dp=p_o-p_i "Pressure difference across the pipe"; + SI.MassFlowRate mdot "Mass flow rate"; SI.VolumeFlowRate Vdot(start = Vdot_0) "Volume flow rate"; /* TBD: @@ -71,8 +72,11 @@ equation - F_f - F_taper + m * data.g * cos_theta "Momentum balance including tapering loss"; - p_i = i.p "Inlet pressure"; + // Connnections + p_i = i.p "Inlet pressure"; p_o = o.p "Outlet pressure"; + i.mdot+o.mdot = 0 "Mass balance"; + mdot = i.mdot "Inlet direction for mdot"; /* TBD: // possible temperature variation implementation. Not finished... diff --git a/OpenHPL/Waterway/SurgeTank.mo b/OpenHPL/Waterway/SurgeTank.mo index 4281362..4ea50ee 100644 --- a/OpenHPL/Waterway/SurgeTank.mo +++ b/OpenHPL/Waterway/SurgeTank.mo @@ -2,7 +2,7 @@ within OpenHPL.Waterway; 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.ContactNode; + extends OpenHPL.Interfaces.TwoContacts; import Modelica.Constants.pi; parameter Types.SurgeTank SurgeTankType = OpenHPL.Types.SurgeTank.STSimple "Types of surge tank" annotation ( @@ -39,6 +39,7 @@ model SurgeTank "Model of the surge tank/shaft" //parameter SI.Temperature T_i = data.T_i "Initial water temperature in the pipe" annotation (Dialog(group = "Initialization", enable = TempUse)); // variables SI.Mass m "Water mass"; + SI.MassFlowRate mdot "Mass flow rate"; 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"; SI.Momentum M "Water momentum"; SI.Force Mdot "Difference in influent and effulent momentum"; @@ -129,7 +130,9 @@ equation mdot = data.rho * Vdot; Mdot = mdot * v; F = F_p - F_f - F_g; - p_b = p_n "Linking bottom node pressure to connector"; + p_b = i.p "Linking bottom node pressure to connector"; + i.p = o.p "Inlet and outlet pressure equality"; + mdot = i.mdot+o.mdot "Mass balance"; F_g = m * data.g * cos_theta; annotation ( Documentation(info="