Skip to content

Commit 21761ec

Browse files
Add modelica blocks of hydraulic structures.
1 parent af3434b commit 21761ec

File tree

13 files changed

+155
-0
lines changed

13 files changed

+155
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
within Deltares.ChannelFlow.HydraulicStructures.Orifice;
2+
3+
model Orifice "Orifice that only allows flow when HQDown.H < HQUp.H"
4+
extends Deltares.ChannelFlow.Hydraulic.Structures.DischargeControlledStructure(Q(min=0.0));
5+
parameter Modelica.Units.SI.Length dH_max = 10.0;
6+
parameter Modelica.Units.SI.Area area = 1.0;
7+
parameter Real discharge_coefficient = 0.61;
8+
end Orifice;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
within Deltares.ChannelFlow.HydraulicStructures;
2+
3+
package Orifice
4+
end Orifice;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Orifice
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
within Deltares.ChannelFlow.HydraulicStructures.PumpingStation;
2+
3+
partial model Pump "Pump with QHP relationship"
4+
extends Deltares.ChannelFlow.Hydraulic.Structures.Pump;
5+
6+
// Increasing row number is increasing H power (staring at 0th power).
7+
// Increasing column number is increasing Q power (staring at 0th power).
8+
parameter Real power_coefficients[:, :, :];
9+
parameter Real speed_coefficients[:, :] = {{0.0}};
10+
11+
12+
// Array of working area polynomials, each a function of Q and H. The
13+
// coefficients of each polynomial are like the power coefficients, in that
14+
// increasing row (second index) is increasing power of H, and increasing
15+
// column (third index) is increasing power of Q.
16+
parameter Real working_area[:, :, :];
17+
18+
// For each of the polynomials in the working area we have to specify whether
19+
// the expression should evaluate to a positive expression (=1), or a
20+
// negative expression (=-1).
21+
// NOTE: May become unnecessary to specify this in the future, if we can
22+
// figure out a way to determine this automatically based on the working
23+
// area.
24+
parameter Real working_area_direction[:];
25+
26+
// Pump's minimum on and off time.
27+
parameter Modelica.Units.SI.Duration minimum_on = 0.0;
28+
parameter Modelica.Units.SI.Duration minimum_off = 0.0;
29+
30+
// NOTE: Enumerations are not supported in JModelica's CasADi interface. We
31+
// therefore resort to an integer.
32+
// What head to use for the pump head. This can be
33+
// -1: The upstream head
34+
// 0: The differential head (i.e. downstream head minus upstream head)
35+
// 1: The downstream head.
36+
parameter Integer head_option = 0;
37+
38+
parameter Modelica.Units.SI.Energy start_up_energy = 0.0;
39+
parameter Real start_up_cost = 0.0;
40+
41+
parameter Modelica.Units.SI.Energy shut_down_energy = 0.0;
42+
parameter Real shut_down_cost = 0.0;
43+
44+
// NOTE: The equality constraint setting dH to some combination of HQUp and
45+
// HQDown (based on head_option) will be added in the Mixin.
46+
Modelica.Units.SI.Distance dH;
47+
48+
equation
49+
if head_option == -1 then
50+
dH = HQUp.H;
51+
elseif head_option == 1 then
52+
dH = HQDown.H;
53+
else
54+
dH = HQDown.H - HQUp.H;
55+
end if;
56+
end Pump;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
within Deltares.ChannelFlow.HydraulicStructures.PumpingStation;
2+
3+
model PumpingStation
4+
extends Deltares.ChannelFlow.Internal.HQTwoPort;
5+
import SI = Modelica.Units.SI;
6+
parameter Integer n_pumps = 0;
7+
8+
// FIXME: For some reason JModelica/CasADi returns {1, 2} for the expression
9+
// 1:3 if we store it as an Integer, whereas it returns {1, 2, 3} if we
10+
// store it as a Real. The weird thing is that JModelica does not complain
11+
// about any size mismatches. Furthermore, transposes also do not seem to
12+
// work well.
13+
// To work around these issues, we detect the -999 default array, and
14+
// overwrite it in Python with the correct one.
15+
parameter Integer pump_switching_matrix[n_pumps, n_pumps] = fill(-999, n_pumps, n_pumps);
16+
parameter Integer pump_switching_constraints[n_pumps, 2] = fill(-999, n_pumps, 2);
17+
18+
SI.VolumeFlowRate Q;
19+
equation
20+
// Discharge
21+
Q = HQUp.Q;
22+
23+
HQUp.M = -HQDown.M;
24+
25+
// TODO: Annotation / pretty picture. Currently inheriting TwoPort.
26+
end PumpingStation;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
within Deltares.ChannelFlow.HydraulicStructures.PumpingStation;
2+
3+
// TODO: Negative flows (from down to up) are not supported. Do we want to support them?
4+
model Resistance "Quadratic resistance of form dH=C*Q^2"
5+
extends Deltares.ChannelFlow.Internal.HQTwoPort;
6+
7+
parameter Real C = 0.0;
8+
9+
// Head loss
10+
input Modelica.Units.SI.Distance dH;
11+
equation
12+
// Head
13+
HQDown.H = HQUp.H - dH;
14+
15+
// Discharge
16+
HQUp.Q + HQDown.Q = 0;
17+
18+
// Substances
19+
HQUp.M = -HQDown.M;
20+
21+
// TODO: Annotation / pretty picture. Currently inheriting TwoPort.
22+
end Resistance;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
within Deltares.ChannelFlow.HydraulicStructures;
2+
3+
package PumpingStation
4+
end PumpingStation;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Resistance
2+
PumpingStation
3+
Pump
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
within Deltares.ChannelFlow.HydraulicStructures.Weir;
2+
3+
model Weir
4+
import SI = Modelica.Units.SI;
5+
extends Deltares.ChannelFlow.Internal.HQTwoPort;
6+
7+
// Inputs
8+
input SI.VolumeFlowRate Q;
9+
10+
// Parameters
11+
parameter SI.Length width "Width of the weir";
12+
parameter SI.VolumeFlowRate q_min "Minimum flow of the weir; has to be positive";
13+
parameter SI.VolumeFlowRate q_max "Maximum flow of the weir. Should be as low as possible.";
14+
parameter SI.Length hw_min "Minimum height of the weir";
15+
parameter SI.Length hw_max "Maximum height of the weir";
16+
parameter Real weir_coef=0.61 "Weir discharge coefficient";
17+
equation
18+
HQUp.Q + HQDown.Q = 0; // Negative comes in, positive out, so in a branch positive goes in
19+
HQUp.Q = Q;
20+
annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {10, 10}), graphics = {Polygon(visible = true, origin = {0, -16.667}, fillColor = {255, 128, 0}, fillPattern = FillPattern.Solid, lineThickness = 2, points = {{0, 66.667}, {-50, -33.333}, {50, -33.333}})}), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {10, 10})));
21+
end Weir;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
within Deltares.ChannelFlow.HydraulicStructures;
2+
3+
package Weir
4+
end Weir;

0 commit comments

Comments
 (0)