Skip to content

Commit 4e4d7bf

Browse files
authored
Merge pull request #66 from pandeysudan1/fix/remove-interface-calculated-values
Refactor: Remove calculated values from Interfaces (Fix #64)
2 parents 1b758db + 3fe9842 commit 4e4d7bf

File tree

16 files changed

+41
-51
lines changed

16 files changed

+41
-51
lines changed

OpenHPL/ElectroMech/Turbines/Francis.mo

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ model Francis "Model of the Francis turbine"
6060
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";
6161
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";
6262
SI.VolumeFlowRate Vdot "Flow rate";
63+
SI.MassFlowRate mdot "Mass flow rate";
6364
SI.AngularVelocity w=w_in "Angular velocity";
6465
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";
6566
Modelica.Units.NonSI.Angle_deg beta1 "Inlet blade angle";
@@ -202,6 +203,8 @@ equation
202203
coef = Wdot_s / Wdot_t;
203204
// connectors
204205
p_tr2 = o.p;
206+
i.mdot+o.mdot=0;
207+
mdot=i.mdot;
205208
// output mechanical power
206209
P_out = Wdot_s;
207210
annotation (

OpenHPL/ElectroMech/Turbines/Pelton.mo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ model Pelton "Model of the Pelton turbine"
1616
SI.Area A_1, A_0 = pi * D_0 ^ 2 / 4;
1717
SI.EnergyFlowRate Wdot_s "Shaft power";
1818
SI.VolumeFlowRate Vdot "Flow rate";
19+
SI.MassFlowRate mdot "Mass flow rate";
1920
SI.Velocity v_R, v_1;
2021
SI.AngularVelocity w=w_in "Angular velocity";
2122
Real cos_b = Modelica.Math.cos(Modelica.Units.Conversions.from_deg(beta));
@@ -45,6 +46,9 @@ equation
4546
p_tr1 = i.p;
4647
// + dp_n;
4748
p_tr2 = o.p;
49+
// Flow rate connectors
50+
i.mdot+o.mdot=0;
51+
mdot=i.mdot;
4852
// output mechanical power
4953
P_out = Wdot_s;
5054
annotation (

OpenHPL/ElectroMech/Turbines/Turbine.mo

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ model Turbine "Simple turbine model with mechanical connectors"
3131
extends OpenHPL.Interfaces.TurbineContacts;
3232

3333
SI.Pressure dp "Turbine pressure drop";
34+
SI.MassFlowRate mdot "Turbine pressure drop";
3435
SI.EnergyFlowRate Kdot_i_tr "Kinetic energy flow";
3536
SI.VolumeFlowRate Vdot "Flow rate";
3637
Real C_v_ "Guide vane 'valve capacity'";
@@ -46,6 +47,8 @@ equation
4647
"Define guide vane 'valve capacity' base on the Nominal turbine parameters";
4748
dp = Vdot ^ 2 * data.p_a / (C_v_ * max(1e-6, u_t)) ^ 2 "Turbine valve equation for pressure drop";
4849
dp = i.p - o.p "Link the pressure drop to the ports";
50+
i.mdot+o.mdot=0 "Mass balance";
51+
mdot = i.mdot "Flow direction";
4952
Kdot_i_tr = dp * Vdot "Turbine energy balance";
5053
if ConstEfficiency then
5154
Wdot_s = eta_h * Kdot_i_tr;

OpenHPL/Interfaces/ContactNode.mo

Lines changed: 0 additions & 20 deletions
This file was deleted.

OpenHPL/Interfaces/ContactPort.mo

Lines changed: 0 additions & 14 deletions
This file was deleted.

OpenHPL/Interfaces/TurbineContacts.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
within OpenHPL.Interfaces;
22
partial model TurbineContacts "Model of turbine connectors"
3-
extends Interfaces.ContactPort;
3+
extends Interfaces.TwoContacts;
44
parameter Boolean enable_P_out = false "If checked, get a connector for the output power"
55
annotation (choices(checkBox = true), Dialog(group="Outputs",tab="I/O"));
66
input Modelica.Blocks.Interfaces.RealInput u_t "[Guide vane|nozzle] opening of the turbine" annotation (Placement(transformation(
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
within OpenHPL.Interfaces;
2-
partial model TwoContact "Model of two connectors"
2+
partial model TwoContacts "Model of two connectors"
33
Contact_i i "Inlet contact (positive design flow direction is from i to o)"
44
annotation (
55
Placement(transformation(extent={{-110,-10},{-90,10}})));
@@ -12,4 +12,4 @@ partial model TwoContact "Model of two connectors"
1212
Can be used in cases where model is needed inlet and outlet Contacts, but do not need
1313
any specification about mass flow rate and pressures between these Contacts.</p>
1414
</html>"));
15-
end TwoContact;
15+
end TwoContacts;

OpenHPL/Interfaces/package.order

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
Contact
22
Contact_i
33
Contact_o
4-
TwoContact
5-
ContactPort
6-
ContactNode
74
TurbineContacts
5+
TwoContacts

OpenHPL/Waterway/BendPipe.mo

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ model BendPipe "Bend in pipes"
1414
SI.Velocity v(start=Modelica.Constants.eps) "Water velocity";
1515
SI.Area A = pi*D_i^2/4 "Cross section area";
1616
SI.Pressure dp "Pressure drop of fitting";
17-
/* Connector */
18-
extends OpenHPL.Interfaces.ContactPort;
17+
SI.MassFlowRate mdot "Pressure drop of fitting";
18+
extends OpenHPL.Interfaces.TwoContacts;
1919
equation
2020
v = mdot / data.rho / A;
2121
dp = K_L * 0.5 * data.rho * v^2;
22+
// Connections
2223
o.p = i.p - dp "Pressure of the output connector";
24+
i.mdot + o.mdot = 0 "Mass balance";
25+
mdot = i.mdot "Flow direction";
2326
annotation (
2427
Documentation(info="<html>
2528
<p>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.</p>

OpenHPL/Waterway/DraftTube.mo

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ model DraftTube "Model of a draft tube for reaction turbines"
6767
SI.Pressure p_i "Inlet pressure";
6868
SI.Pressure p_o "Outlet pressure";
6969
SI.Pressure dp = p_o-p_i "Pressure drop in and out of draft tube";
70+
SI.MassFlowRate mdot "Mass flow rate";
7071
Real phi_d "Generalized friction factor for draft tube";
7172
Real phi_d_o "Initial generalized friction factor for Moody spreading pipes";
7273

@@ -81,7 +82,7 @@ model DraftTube "Model of a draft tube for reaction turbines"
8182
theta_moody/2)) "Calculating cos_theta_moody_by_2";
8283

8384
// connectors
84-
extends OpenHPL.Interfaces.ContactPort;
85+
extends OpenHPL.Interfaces.TwoContacts;
8586
initial equation
8687
if SteadyState then
8788
der(M) = 0;
@@ -150,6 +151,8 @@ equation
150151
// connector
151152
p_i = i.p;
152153
p_o = o.p;
154+
i.mdot+o.mdot=0;
155+
mdot = i.mdot;
153156
annotation (Documentation(info="<html>
154157
<p>Two of the draft tubes are modeled using <em>Momentum balance</em>.
155158
They are:</p>

0 commit comments

Comments
 (0)