Skip to content

Commit

Permalink
Added small pressure losses to DynamicPipeEnergyConservationCheck2 to…
Browse files Browse the repository at this point in the history
… avoid index reduction with the fixed pressure boundary.

Changed to explicit steady state initialization to avoid unspecified initial conditions
Fixes modelica#4424
  • Loading branch information
casella committed Feb 25, 2025
1 parent 9e8b7fb commit 1d419eb
Showing 1 changed file with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ model DynamicPipeEnergyConservationCheck2
modelStructure=Modelica.Fluid.Types.ModelStructure.av_b,
useInnerPortProperties=true)
annotation (Placement(transformation(extent={{-10,40},{10,60}})));
inner Modelica.Fluid.System system
inner Modelica.Fluid.System system(energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyStateInitial)
annotation (Placement(transformation(extent={{-100,80},{-80,100}})));
Modelica.Fluid.Sources.MassFlowSource_h boundary(
nPorts=1,
Expand Down Expand Up @@ -59,9 +59,9 @@ model DynamicPipeEnergyConservationCheck2
redeclare package Medium = Modelica.Media.Air.DryAirNasa,
m_flow=1) annotation (Placement(transformation(extent={{-40,0},{-20,20}})));
Modelica.Fluid.Sources.FixedBoundary boundary7(
nPorts=1,
redeclare package Medium = Modelica.Media.Air.DryAirNasa,
p=100000) annotation (Placement(transformation(extent={{40,0},{20,20}})));
p=100000,
nPorts=1) annotation (Placement(transformation(extent={{70,0},{50,20}})));
Modelica.Fluid.Pipes.DynamicPipe pipeAV_VB(
length=100,
redeclare package Medium = Modelica.Media.Air.DryAirNasa,
Expand All @@ -86,9 +86,9 @@ model DynamicPipeEnergyConservationCheck2
redeclare package Medium = Modelica.Media.Air.DryAirNasa,
m_flow=1) annotation (Placement(transformation(extent={{-40,-40},{-20,-20}})));
Modelica.Fluid.Sources.FixedBoundary boundary13(
nPorts=1,
redeclare package Medium = Modelica.Media.Air.DryAirNasa,
p=100000) annotation (Placement(transformation(extent={{40,-40},{20,-20}})));
p=100000,
nPorts=1) annotation (Placement(transformation(extent={{70,-40},{50,-20}})));
Modelica.Fluid.Pipes.DynamicPipe pipeA_V_B(
length=100,
redeclare package Medium = Modelica.Media.Air.DryAirNasa,
Expand Down Expand Up @@ -116,6 +116,14 @@ model DynamicPipeEnergyConservationCheck2
nPorts=1,
redeclare package Medium = Modelica.Media.Air.DryAirNasa,
p=100000) annotation (Placement(transformation(extent={{40,-80},{20,-60}})));
Modelica.Fluid.Fittings.GenericResistances.VolumeFlowRate loss1(
redeclare package Medium = Modelica.Media.Air.DryAirNasa,
a=0,
b=2.3e3) annotation (Placement(transformation(extent={{22,0},{42,20}})));
Modelica.Fluid.Fittings.GenericResistances.VolumeFlowRate loss2(
redeclare package Medium = Modelica.Media.Air.DryAirNasa,
a=0,
b=2.3e3) annotation (Placement(transformation(extent={{20,-40},{40,-20}})));
equation
total_AV_B_a = pipeAV_B.H_flows[1] + pipeAV_B.m_flows[1]*pipeAV_B.flowModel.vs[1]^2/2;
total_AV_B_b = pipeAV_B.H_flows[end] + pipeAV_B.m_flows[end]*pipeAV_B.flowModel.vs[end]^2/2;
Expand All @@ -135,16 +143,20 @@ equation
annotation (Line(points={{10,50},{20,50}}, color={0,127,255}));
connect(boundary6.ports[1], pipeA_VB.port_a)
annotation (Line(points={{-20,10},{-10,10}}, color={0,127,255}));
connect(pipeA_VB.port_b, boundary7.ports[1])
annotation (Line(points={{10,10},{20,10}}, color={0,127,255}));
connect(boundary12.ports[1], pipeAV_VB.port_a)
annotation (Line(points={{-20,-30},{-10,-30}}, color={0,127,255}));
connect(pipeAV_VB.port_b, boundary13.ports[1])
annotation (Line(points={{10,-30},{20,-30}}, color={0,127,255}));
connect(boundary18.ports[1], pipeA_V_B.port_a)
annotation (Line(points={{-20,-70},{-10,-70}}, color={0,127,255}));
connect(pipeA_V_B.port_b, boundary19.ports[1])
annotation (Line(points={{10,-70},{20,-70}}, color={0,127,255}));
connect(pipeA_VB.port_b, loss1.port_a)
annotation (Line(points={{10,10},{22,10}}, color={0,127,255}));
connect(boundary7.ports[1], loss1.port_b)
annotation (Line(points={{50,10},{42,10}}, color={0,127,255}));
connect(pipeAV_VB.port_b, loss2.port_a)
annotation (Line(points={{10,-30},{20,-30}}, color={0,127,255}));
connect(boundary13.ports[1], loss2.port_b)
annotation (Line(points={{50,-30},{40,-30}}, color={0,127,255}));
annotation (experiment(StopTime=500),
Documentation(info="<html>
Test of energy conservation in dynamic pipes.
Expand Down

0 comments on commit 1d419eb

Please sign in to comment.