Skip to content

Commit

Permalink
Back-port of #3291 for the pump model into MSL 3.2.3 maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
casella authored and beutlich committed Aug 7, 2020
1 parent 3f9398b commit 1a4a823
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions Modelica/Fluid/Examples/PumpingSystem.mo
Expand Up @@ -28,6 +28,7 @@ model PumpingSystem "Model of a pumping system for drinking water"

Machines.PrescribedPump pumps(
checkValve=true,
checkValveHomotopy = Modelica.Fluid.Types.CheckValveHomotopyType.Closed,
N_nominal=1200,
redeclare function flowCharacteristic =
Modelica.Fluid.Machines.BaseClasses.PumpCharacteristics.quadraticFlow (
Expand Down
20 changes: 16 additions & 4 deletions Modelica/Fluid/Machines.mo
Expand Up @@ -311,6 +311,8 @@ Then the model can be replaced with a Pump with rotational shaft or with a Presc
parameter Medium.MassFlowRate m_flow_start = system.m_flow_start
"Guess value of m_flow = port_a.m_flow"
annotation(Dialog(tab = "Initialization"));
parameter Types.CheckValveHomotopyType checkValveHomotopy = Types.CheckValveHomotopyType.NoHomotopy "= whether the valve is Closed, Open, or unknown at initialization"
annotation(Dialog(tab = "Initialization"));
final parameter SI.VolumeFlowRate V_flow_single_init = m_flow_start/rho_nominal/nParallel
"Used for simplified initialization model";
final parameter SI.Position delta_head_init = flowCharacteristic(V_flow_single_init*1.1)-flowCharacteristic(V_flow_single_init)
Expand Down Expand Up @@ -434,11 +436,21 @@ Then the model can be replaced with a Pump with rotational shaft or with a Presc
else
// Flow characteristics when check valve is open
// The simplified model uses an approximation of the tangent to the head curve in the initialization point
head = homotopy(if s > 0 then (N/N_nominal)^2*flowCharacteristic(V_flow_single*N_nominal/N)
// or the zero-flow vertical axis in case the system is initialized with the check valve closed
if checkValveHomotopy == Types.CheckValveHomotopyType.NoHomotopy then
head = if s > 0 then (N/N_nominal)^2*flowCharacteristic(V_flow_single*N_nominal/N)
else (N/N_nominal)^2*flowCharacteristic(0) - s*unitHead;
V_flow_single = if s > 0 then s*unitMassFlowRate/rho else 0;
else
head = homotopy(if s > 0 then (N/N_nominal)^2*flowCharacteristic(V_flow_single*N_nominal/N)
else (N/N_nominal)^2*flowCharacteristic(0) - s*unitHead,
N/N_nominal*(flowCharacteristic(V_flow_single_init)+(V_flow_single-V_flow_single_init)*noEvent(if abs(V_flow_single_init)>0 then delta_head_init/(0.1*V_flow_single_init) else 0)));
V_flow_single = homotopy(if s > 0 then s*unitMassFlowRate/rho else 0,
s*unitMassFlowRate/rho_nominal);
if checkValveHomotopy == Types.CheckValveHomotopyType.Open then
N/N_nominal*(flowCharacteristic(V_flow_single_init)+(V_flow_single-V_flow_single_init)*noEvent(if abs(V_flow_single_init)>0 then delta_head_init/(0.1*V_flow_single_init) else 0))
else
N/N_nominal*flowCharacteristic(0) - s*unitHead);
V_flow_single = homotopy(if s > 0 then s*unitMassFlowRate/rho else 0,
if checkValveHomotopy == Types.CheckValveHomotopyType.Open then s*unitMassFlowRate/rho_nominal else 0);
end if;
end if;
// Power consumption
if use_powerCharacteristic then
Expand Down
7 changes: 7 additions & 0 deletions Modelica/Fluid/Types.mo
Expand Up @@ -318,6 +318,13 @@ ModelStructure.a_vb).

</html>"));

type CheckValveHomotopyType = enumeration(Open, Closed, NoHomotopy)
"Enumeration with choices for check valve homotopy"
annotation (Documentation(info="<html>
<p>If it is know whether the check valve will start open or closed this can simplify the initialization.</p>
<p>The choice <strong>NoHomotopy</strong> is useful if nothing is known for the check valve.</p>
</html>"));

annotation (preferredView="info",
Documentation(info="<html>

Expand Down

0 comments on commit 1a4a823

Please sign in to comment.