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
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Internal
Linear
HomotopicVolume
HomotopicPower
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
within Deltares.ChannelFlow.HydraulicStructures.Orifice;

model Orifice "Orifice that only allows flow when HQDown.H < HQUp.H"
extends Deltares.ChannelFlow.Hydraulic.Structures.DischargeControlledStructure(Q(min=0.0));
parameter Modelica.Units.SI.Length dH_max = 10.0;
parameter Modelica.Units.SI.Area area = 1.0;
parameter Real discharge_coefficient = 0.61;
end Orifice;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
within Deltares.ChannelFlow.HydraulicStructures;

package Orifice
end Orifice;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Orifice
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
within Deltares.ChannelFlow.HydraulicStructures.PumpingStation;

partial model Pump "Pump with QHP relationship"
extends Deltares.ChannelFlow.Hydraulic.Structures.Pump;

// Increasing row number is increasing H power (staring at 0th power).
// Increasing column number is increasing Q power (staring at 0th power).
Comment on lines +6 to +7
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'staring' to 'starting'.

Suggested change
// Increasing row number is increasing H power (staring at 0th power).
// Increasing column number is increasing Q power (staring at 0th power).
// Increasing row number is increasing H power (starting at 0th power).
// Increasing column number is increasing Q power (starting at 0th power).

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'staring' to 'starting'.

Suggested change
// Increasing column number is increasing Q power (staring at 0th power).
// Increasing column number is increasing Q power (starting at 0th power).

Copilot uses AI. Check for mistakes.
parameter Real power_coefficients[:, :, :];
parameter Real speed_coefficients[:, :] = {{0.0}};
Comment on lines +8 to +9
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple parameters (power_coefficients, speed_coefficients, working_area, working_area_direction) are declared but never used in the model equations. These parameters appear to define pump characteristics but are not incorporated into any hydraulic or performance calculations.

Copilot uses AI. Check for mistakes.


// Array of working area polynomials, each a function of Q and H. The
// coefficients of each polynomial are like the power coefficients, in that
// increasing row (second index) is increasing power of H, and increasing
// column (third index) is increasing power of Q.
parameter Real working_area[:, :, :];
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple parameters (power_coefficients, speed_coefficients, working_area, working_area_direction) are declared but never used in the model equations. These parameters appear to define pump characteristics but are not incorporated into any hydraulic or performance calculations.

Copilot uses AI. Check for mistakes.

// For each of the polynomials in the working area we have to specify whether
// the expression should evaluate to a positive expression (=1), or a
// negative expression (=-1).
// NOTE: May become unnecessary to specify this in the future, if we can
// figure out a way to determine this automatically based on the working
// area.
parameter Real working_area_direction[:];
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple parameters (power_coefficients, speed_coefficients, working_area, working_area_direction) are declared but never used in the model equations. These parameters appear to define pump characteristics but are not incorporated into any hydraulic or performance calculations.

Copilot uses AI. Check for mistakes.

// Pump's minimum on and off time.
parameter Modelica.Units.SI.Duration minimum_on = 0.0;
parameter Modelica.Units.SI.Duration minimum_off = 0.0;
Comment on lines +27 to +28
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameters minimum_on and minimum_off are declared but never used in any equations or constraints. These timing constraints are not enforced in the model.

Copilot uses AI. Check for mistakes.

// NOTE: Enumerations are not supported in JModelica's CasADi interface. We
// therefore resort to an integer.
// What head to use for the pump head. This can be
// -1: The upstream head
// 0: The differential head (i.e. downstream head minus upstream head)
// 1: The downstream head.
parameter Integer head_option = 0;

parameter Modelica.Units.SI.Energy start_up_energy = 0.0;
parameter Real start_up_cost = 0.0;

parameter Modelica.Units.SI.Energy shut_down_energy = 0.0;
parameter Real shut_down_cost = 0.0;
Comment on lines +38 to +42
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameters for start-up and shut-down energy and costs are declared but never used in any equations. These operational costs are not incorporated into the model.

Copilot uses AI. Check for mistakes.

// NOTE: The equality constraint setting dH to some combination of HQUp and
// HQDown (based on head_option) will be added in the Mixin.
Modelica.Units.SI.Distance dH;

equation
if head_option == -1 then
dH = HQUp.H;
elseif head_option == 1 then
dH = HQDown.H;
else
dH = HQDown.H - HQUp.H;
end if;
end Pump;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
within Deltares.ChannelFlow.HydraulicStructures.PumpingStation;

model PumpingStation
extends Deltares.ChannelFlow.Internal.HQTwoPort;
import SI = Modelica.Units.SI;
parameter Integer n_pumps = 0;

// FIXME: For some reason JModelica/CasADi returns {1, 2} for the expression
// 1:3 if we store it as an Integer, whereas it returns {1, 2, 3} if we
// store it as a Real. The weird thing is that JModelica does not complain
// about any size mismatches. Furthermore, transposes also do not seem to
// work well.
// To work around these issues, we detect the -999 default array, and
// overwrite it in Python with the correct one.
parameter Integer pump_switching_matrix[n_pumps, n_pumps] = fill(-999, n_pumps, n_pumps);
parameter Integer pump_switching_constraints[n_pumps, 2] = fill(-999, n_pumps, 2);

SI.VolumeFlowRate Q;
equation
// Discharge
Q = HQUp.Q;

HQUp.M = -HQDown.M;

// TODO: Annotation / pretty picture. Currently inheriting TwoPort.
end PumpingStation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
within Deltares.ChannelFlow.HydraulicStructures.PumpingStation;

// TODO: Negative flows (from down to up) are not supported. Do we want to support them?
model Resistance "Quadratic resistance of form dH=C*Q^2"
extends Deltares.ChannelFlow.Internal.HQTwoPort;

parameter Real C = 0.0;
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameter C is declared but never used in any equations. Since this model represents 'Quadratic resistance of form dH=C*Q^2', the equation should implement this relationship, but C is not referenced in the equation section.

Copilot uses AI. Check for mistakes.

// Head loss
input Modelica.Units.SI.Distance dH;
equation
// Head
HQDown.H = HQUp.H - dH;

// Discharge
HQUp.Q + HQDown.Q = 0;

// Substances
HQUp.M = -HQDown.M;

// TODO: Annotation / pretty picture. Currently inheriting TwoPort.
end Resistance;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
within Deltares.ChannelFlow.HydraulicStructures;

package PumpingStation
end PumpingStation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Resistance
PumpingStation
Pump
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
within Deltares.ChannelFlow.HydraulicStructures.Weir;

model Weir
import SI = Modelica.Units.SI;
extends Deltares.ChannelFlow.Internal.HQTwoPort;

// Inputs
input SI.VolumeFlowRate Q;

// Parameters
parameter SI.Length width "Width of the weir";
parameter SI.VolumeFlowRate q_min "Minimum flow of the weir; has to be positive";
parameter SI.VolumeFlowRate q_max "Maximum flow of the weir. Should be as low as possible.";
parameter SI.Length hw_min "Minimum height of the weir";
parameter SI.Length hw_max "Maximum height of the weir";
parameter Real weir_coef=0.61 "Weir discharge coefficient";
Comment on lines +11 to +16
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple parameters (width, q_min, q_max, hw_min, hw_max, weir_coef) are declared but never used in the model equations. This indicates incomplete implementation of the weir hydraulic relationships, which should relate flow Q to head difference and weir geometry.

Copilot uses AI. Check for mistakes.
equation
HQUp.Q + HQDown.Q = 0; // Negative comes in, positive out, so in a branch positive goes in
HQUp.Q = Q;
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})));
end Weir;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
within Deltares.ChannelFlow.HydraulicStructures;

package Weir
end Weir;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Weir
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
within Deltares.ChannelFlow;

package HydraulicStructures
end HydraulicStructures;
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Reservoir
Reservoir_turbine_out
Reservoir_turbine_out
Reservoir_multi_io
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Interfaces
Internal
SimpleRouting
Hydraulic
HydraulicStructures