Skip to content

Commit 1424c67

Browse files
committed
Implement with use of overconstrained connector
The previous variant did not allow for parallel connections.
1 parent a3bd784 commit 1424c67

20 files changed

Lines changed: 63 additions & 36 deletions

OpenHPL/ElectroMech/BaseClasses/BaseValve.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ equation
3434
Vdot = mdot/data.rho;
3535
dp*(C_v_*max(epsilon, u^alpha))^2 = Vdot*abs(Vdot) "Valve equation for pressure drop";
3636
dp = i.p - o.p "Link the pressure drop to the ports";
37-
o.z = i.z "Elevation propagation: no height change across valve";
37+
o.elevation.z = i.elevation.z "Elevation propagation: no height change across valve";
3838
annotation (preferredView="info", Documentation(info="<html>
3939
<p>
4040
This is a partial, simple model of hydraulic valve. &nbsp;</p><p>This model is based on the energy balance of a valve.

OpenHPL/ElectroMech/Turbines/Francis.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ equation
210210
p_tr2 = o.p;
211211
i.mdot+o.mdot=0;
212212
mdot=i.mdot;
213-
o.z = i.z "Elevation propagation: no height change across turbine";
213+
o.elevation.z = i.elevation.z "Elevation propagation: no height change across turbine";
214214

215215
connect(p_out, P_out) annotation (Line(points={{40,90},{40,110}}, color={0,0,127}));
216216
annotation (preferredView="info",

OpenHPL/ElectroMech/Turbines/Pelton.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ equation
5454
// Flow rate connectors
5555
i.mdot+o.mdot=0;
5656
mdot=i.mdot;
57-
o.z = i.z "Elevation propagation: no height change across turbine";
57+
o.elevation.z = i.elevation.z "Elevation propagation: no height change across turbine";
5858

5959
connect(p_out, P_out) annotation (Line(points={{40,90},{40,110}}, color={0,0,127}));
6060
annotation (preferredView="info",

OpenHPL/Interfaces/Contact.mo

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ connector Contact "Water flow connector"
44
SI.Pressure p "Contact pressure";
55
//SI.Temperature T "Contact temperature";
66
flow SI.MassFlowRate mdot "Mass flow rate through the contact";
7-
SI.Height z "Elevation at connection point";
8-
flow Real gz(unit="m2/s") "Auxiliary elevation flow variable (always zero, for connector balance)";
9-
7+
Elevation elevation "Overconstrained elevation at connection point";
8+
109
annotation (
1110
Documentation(info = "<html>
1211
<p>Contact is a basic water flow connector, which consists of water pressure, mass flow rate,
@@ -16,15 +15,17 @@ and elevation at the connector (positive if water is flowing into connector and
1615
<ul>
1716
<li><code>p</code> &ndash; Pressure (potential variable, equated across connections)</li>
1817
<li><code>mdot</code> &ndash; Mass flow rate (flow variable, summed to zero across connections)</li>
19-
<li><code>z</code> &ndash; Elevation (potential variable, equated across connections).
18+
<li><code>elevation.z</code> &ndash; Elevation (overconstrained variable, propagated via spanning tree).
2019
Each component provides an equation relating its connector elevations,
2120
enabling automatic propagation of absolute elevation through the system.
22-
Source components (e.g., Reservoir) set the absolute reference elevation.</li>
21+
Source components (e.g., Reservoir) set the absolute reference elevation.
22+
Uses the overconstrained connector mechanism (Modelica Spec 9.4) to support
23+
arbitrary topologies including parallel pipes and loops.</li>
2324
</ul>
2425
</html>"),
2526
Icon(graphics = {
26-
Text(origin = {0, -175},
27-
textColor = {0, 85, 255},
28-
extent = {{-100, 100}, {100, -100}},
29-
textString = DynamicSelect("", if showElevation then String(z) else ""))}));
27+
Text(origin = {0, -175},
28+
textColor = {0, 85, 255},
29+
extent = {{-100, 100}, {100, -100}},
30+
textString = DynamicSelect("", if showElevation then String(elevation.z) else ""))}));
3031
end Contact;

OpenHPL/Interfaces/Elevation.mo

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
within OpenHPL.Interfaces;
2+
record Elevation "Overconstrained elevation record for connector balance"
3+
SI.Position z "Elevation at connection point";
4+
function equalityConstraint
5+
input Elevation e1;
6+
input Elevation e2;
7+
output Real residue[0] "No residual equations — elevation is propagated via spanning tree";
8+
algorithm
9+
end equalityConstraint;
10+
end Elevation;

OpenHPL/Interfaces/TwoContacts.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ partial model TwoContacts "Model of two connectors"
88
annotation (
99
Placement(transformation(extent={{90,-10},{110,10}})));
1010
equation
11-
o.gz = i.gz "Elevation auxiliary variable: propagate gz from inlet to outlet";
11+
Connections.branch(i.elevation, o.elevation) "Elevation graph: inlet and outlet are in the same connected set";
1212
annotation (
1313
Documentation(info = "<html>
1414
<p>TwoContact is a partial model, which consists of two Contacts <em>i</em>and <em>o</em>.

OpenHPL/Interfaces/package.order

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Contact
22
Contact_i
33
Contact_o
4+
Elevation
45
TurbineContacts
56
TwoContacts

OpenHPL/Waterway/BendPipe.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ equation
2323
o.p = i.p - dp "Pressure of the output connector";
2424
i.mdot + o.mdot = 0 "Mass balance";
2525
mdot = i.mdot "Flow direction";
26-
o.z = i.z "Elevation propagation: no height change across bend";
26+
o.elevation.z = i.elevation.z "Elevation propagation: no height change across bend";
2727
annotation (preferredView="info",
2828
Documentation(info="<html>
2929
<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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ equation
153153
p_o = o.p;
154154
i.mdot+o.mdot=0;
155155
mdot = i.mdot;
156-
o.z = i.z - H "Elevation propagation: outlet is H below inlet";
156+
o.elevation.z = i.elevation.z - H "Elevation propagation: outlet is H below inlet";
157157
annotation (preferredView="info", Documentation(info="<html>
158158
<p>Two of the draft tubes are modeled using <em>Momentum balance</em>.
159159
They are:</p>

OpenHPL/Waterway/Fitting.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ equation
5353
o.p = i.p - dp "Pressure of the output connector";
5454
i.mdot+o.mdot = 0 "Mass balance";
5555
mdot = i.mdot "Flow direction";
56-
o.z = i.z "Elevation propagation: no height change across fitting";
56+
o.elevation.z = i.elevation.z "Elevation propagation: no height change across fitting";
5757
annotation (preferredView="info",
5858
Documentation(info="<html>
5959
<p>Various possibilities of the fittings for the pipes with different diameters

0 commit comments

Comments
 (0)