Skip to content

Commit

Permalink
added unit test for verifying steady state mass dynamics behavior whe…
Browse files Browse the repository at this point in the history
…n simulating a compressible medium

added reference result and plot command
  • Loading branch information
Mathadon committed Mar 9, 2015
1 parent 895fbcb commit ce690c0
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 0 deletions.
@@ -0,0 +1,84 @@
within Annex60.Fluid.MixingVolumes.Examples;
model MixingVolumeSteadyStateMass "Test model for steady state mass dynamics"
extends Modelica.Icons.Example;
package Medium = Annex60.Experimental.Media.AirPTDecoupled;
Sources.MassFlowSource_T sou(
redeclare package Medium = Medium,
use_m_flow_in=true,
nPorts=1) "Flow source and sink"
annotation (Placement(transformation(extent={{-20,-20},{0,0}})));
Sources.Boundary_pT bou(
redeclare package Medium = Medium,
nPorts=1) "Boundary condition"
annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={92,-10})));
Annex60.Fluid.MixingVolumes.MixingVolume vol(
V=1,
redeclare package Medium = Medium,
m_flow_nominal=0.01,
massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
allowFlowReversal=true,
prescribedHeatFlowRate=false,
nPorts=2,
mSenFac=2,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial)
"Mixing volume with steady state mass dynamics"
annotation (Placement(transformation(extent={{30,20},{50,40}})));
Modelica.Blocks.Sources.Ramp ramp(
duration=1,
offset=1,
height=-2) "Ramp input"
annotation (Placement(transformation(extent={{-90,-20},{-70,0}})));

Modelica.Blocks.Math.Gain gain(k=0.01) "Gain for nominal mass flow rate"
annotation (Placement(transformation(extent={{-60,-20},{-40,0}})));
FixedResistances.FixedResistanceDpM res(
redeclare package Medium = Medium,
m_flow_nominal=0.01,
dp_nominal=1000) "Pressure drop"
annotation (Placement(transformation(extent={{50,-20},{70,0}})));
equation
connect(ramp.y, gain.u) annotation (Line(
points={{-69,-10},{-62,-10}},
color={0,0,127},
smooth=Smooth.None));
connect(gain.y, sou.m_flow_in) annotation (Line(
points={{-39,-10},{-31.5,-10},{-31.5,-2},{-20,-2}},
color={0,0,127},
smooth=Smooth.None));
connect(sou.ports[1], vol.ports[1]) annotation (Line(
points={{0,-10},{38,-10},{38,20}},
color={0,127,255},
smooth=Smooth.None));
connect(vol.ports[2], res.port_a) annotation (Line(
points={{42,20},{42,-10},{50,-10}},
color={0,127,255},
smooth=Smooth.None));
connect(res.port_b, bou.ports[1]) annotation (Line(
points={{70,-10},{82,-10}},
color={0,127,255},
smooth=Smooth.None));
annotation (Documentation(
info="<html>
<p>
This model shows that steady state mass dynamics are correctly simulated.
A change in pressure does not lead to an exchange and/or creation of mass.
The mixing volume temperature is also unaffected by a pressure change.
</p>
</html>", revisions="<html>
<ul>
<li>
March 9, 2015 by Filip Jorissen:<br/>
First implementation.
</li>
</ul>
</html>"),
experiment(StopTime=1.0),
__Dymola_Commands(file=
"modelica://Annex60/Resources/Scripts/Dymola/Fluid/MixingVolumes/Examples/MixingVolumeSteadyStateMass.mos"
"Simulate and plot"),
Diagram(graphics));
end MixingVolumeSteadyStateMass;
1 change: 1 addition & 0 deletions Annex60/Fluid/MixingVolumes/Examples/package.order
Expand Up @@ -5,3 +5,4 @@ MixingVolumeHeatConduction
MixingVolumePrescribedHeatFlowRate
MixingVolumeMassFlow
MixingVolumeMFactor
MixingVolumeSteadyStateMass
@@ -0,0 +1,6 @@
last-generated=2015-03-09
vol.dynBal.m=[1.20000004768371582031, 1.20000004768371582031]
time=[0.00000000000000000000, 1.00000000000000000000]
vol.T=[293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000, 293.14999389648437500000]
vol.ports[2].m_flow=[-0.00999999977648258209, -0.00980000011175867491, -0.00960000044703476947, -0.00939999985098829982, -0.00920000018626438223, -0.00899999962747108188, -0.00879999992549399500, -0.00860000029802314089, -0.00839999966472450635, -0.00820000011175910787, -0.00800000040978140516, -0.00779999977648265438, -0.00760000007450550592, -0.00739999990686832001, -0.00719999988824135753, -0.00700000033527540567, -0.00680000001862605171, -0.00659999999999978312, -0.00639999998137434807, -0.00620000013038489364, -0.00600000011175834749, -0.00579999979510982793, -0.00559999977648272668, -0.00540000022351691273, -0.00519999990686839230, -0.00499999988824129105, -0.00480000003725183661, -0.00460000031664837584, -0.00439999999999985542, -0.00419999968335133499, -0.00400000042840694108, -0.00380000011175842022, -0.00359999979510989936, -0.00340000030733486180, -0.00319999999068675727, -0.00299999990686777070, -0.00280000018626444871, -0.00260000010244546128, -0.00240000001862647342, -0.00219999970197684233, -0.00200000021420347011, -0.00179999989755474216, -0.00159999969732098780, -0.00140000009313222436, -0.00120000000931323671, -0.00099999980907892745, -0.00080000014668302340, -0.00060000000465665370, -0.00039999977531894756, -0.00020000018568204714, 0.00000000000000000000, 0.00020000018567920501, 0.00040000037135854880, 0.00060000060069273628, 0.00079999955064460210, 0.00099999980908248125, 0.00120000000931252742, 0.00140000009313009151, 0.00160000029336155886, 0.00180000049359302599, 0.00199999961816496033, 0.00219999970198110585, 0.00240000001862789459, 0.00260000010244404011, 0.00280000018626018520, 0.00300000050290697437, 0.00319999939465131795, 0.00339999971129505401, 0.00359999979511203220, 0.00380000011175912972, 0.00400000042840338750, 0.00420000027939277515, 0.00439999940396554150, 0.00459999972060677956, 0.00480000003725467896, 0.00499999988824129105, 0.00520000020488697000, 0.00540000052153264895, 0.00560000037252370107, 0.00579999949709480295, 0.00599999981374048190, 0.00620000013038418413, 0.00639999998137221523, 0.00660000029801622885, 0.00680000061466190780, 0.00699999973923411990, 0.00719999959022406179, 0.00739999990686974075, 0.00760000022351541970, 0.00780000007450314201, 0.00800000085680122562, 0.00819999951571714729, 0.00839999936671152921, 0.00860000014901294435, 0.00880000000000097544, 0.00899999985098616680, 0.00920000063328536150, 0.00939999929220017121, 0.00960000007450935791, 0.00979999992549597000, 0.00999999977648258209]
sou.ports[1].m_flow=[-0.00999999977648258209, -0.00980000011175867491, -0.00960000044703476947, -0.00939999985098829982, -0.00920000018626438223, -0.00899999962747108188, -0.00879999992549399500, -0.00860000029802314089, -0.00839999966472450635, -0.00820000011175910787, -0.00800000040978140516, -0.00779999977648265438, -0.00760000007450550592, -0.00739999990686832001, -0.00719999988824135753, -0.00700000033527540567, -0.00680000001862605171, -0.00659999999999978312, -0.00639999998137434807, -0.00620000013038489364, -0.00600000011175834749, -0.00579999979510982793, -0.00559999977648272668, -0.00540000022351691273, -0.00519999990686839230, -0.00499999988824129105, -0.00480000003725183661, -0.00460000031664837584, -0.00439999999999985542, -0.00419999968335133499, -0.00400000042840694108, -0.00380000011175842022, -0.00359999979510989936, -0.00340000030733486180, -0.00319999999068675727, -0.00299999990686777070, -0.00280000018626444871, -0.00260000010244546128, -0.00240000001862647342, -0.00219999970197684233, -0.00200000021420347011, -0.00179999989755474216, -0.00159999969732098780, -0.00140000009313222436, -0.00120000000931323671, -0.00099999980907892745, -0.00080000014668302340, -0.00060000000465665370, -0.00039999977531894756, -0.00020000018568204714, 0.00000000000000000000, 0.00020000018567920501, 0.00040000037135854880, 0.00060000060069273628, 0.00079999955064460210, 0.00099999980908248125, 0.00120000000931252742, 0.00140000009313009151, 0.00160000029336155886, 0.00180000049359302599, 0.00199999961816496033, 0.00219999970198110585, 0.00240000001862789459, 0.00260000010244404011, 0.00280000018626018520, 0.00300000050290697437, 0.00319999939465131795, 0.00339999971129505401, 0.00359999979511203220, 0.00380000011175912972, 0.00400000042840338750, 0.00420000027939277515, 0.00439999940396554150, 0.00459999972060677956, 0.00480000003725467896, 0.00499999988824129105, 0.00520000020488697000, 0.00540000052153264895, 0.00560000037252370107, 0.00579999949709480295, 0.00599999981374048190, 0.00620000013038418413, 0.00639999998137221523, 0.00660000029801622885, 0.00680000061466190780, 0.00699999973923411990, 0.00719999959022406179, 0.00739999990686974075, 0.00760000022351541970, 0.00780000007450314201, 0.00800000085680122562, 0.00819999951571714729, 0.00839999936671152921, 0.00860000014901294435, 0.00880000000000097544, 0.00899999985098616680, 0.00920000063328536150, 0.00939999929220017121, 0.00960000007450935791, 0.00979999992549597000, 0.00999999977648258209]
@@ -0,0 +1,31 @@
oldStoreProtVar=Advanced.StoreProtectedVariables;
Advanced.StoreProtectedVariables:=true;
simulateModel("Annex60.Fluid.MixingVolumes.Examples.MixingVolumeSteadyStateMass", method="dassl", resultFile="MixingVolumeSteadyStateMass");
createPlot(id=1,
position={0, 0, 804, 518},
y={"vol.dynBal.m"},
range={0.0, 1.0, 1.0, 1.4},
grid=true,
subPlot=1,
leftTitleType=1,
bottomTitleType=1,
colors={{0,0,255}});
createPlot(id=1,
position={0, 0, 804, 256},
y={"vol.T"},
range={0.0, 1.0, 260.0, 340.0},
grid=true,
subPlot=2,
leftTitleType=1,
bottomTitleType=1,
colors={{0,0,255}});
createPlot(id=1,
position={35, 30, 730, 142},
y={"sou.ports[1].m_flow", "vol.ports[2].m_flow"},
range={0.0, 1.0, -0.02, 0.02},
grid=true,
subPlot=3,
leftTitleType=1,
bottomTitleType=1,
colors={{0,0,255}, {255,0,0}});
Advanced.StoreProtectedVariables=oldStoreProtVar;

0 comments on commit ce690c0

Please sign in to comment.