Skip to content

Commit

Permalink
Add library ThermofluidStreamTest (similar to MSL - ModelicaTest)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobolar committed Feb 9, 2024
1 parent 42b9f34 commit 13c961e
Show file tree
Hide file tree
Showing 18 changed files with 620 additions and 0 deletions.
144 changes: 144 additions & 0 deletions ThermofluidStreamTest/Boundaries/ConditionalConnectors.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
within ThermofluidStreamTest.Boundaries;
model ConditionalConnectors
extends Modelica.Icons.Example;

replaceable package Medium = ThermofluidStream.Media.myMedia.Air.MoistAir
constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium annotation(choicesAllMatching = true);

inner ThermofluidStream.DropOfCommons dropOfCommons annotation (Placement(transformation(extent={{-100,80},{-80,100}})));
ThermofluidStream.Boundaries.Source source(
redeclare package Medium = Medium,
outlet(m_flow(start=0.5, fixed=true)))
annotation (Placement(transformation(extent={{-60,80},{-40,100}})));
ThermofluidStream.Boundaries.Source source1(
redeclare package Medium = Medium,
setEnthalpy=false,
pressureFromInput=true,
temperatureFromInput=true,
enthalpyFromInput=true,
xiFromInput=true,
outlet(m_flow(start=0.5, fixed=true)))
annotation (Placement(transformation(extent={{-50,0},{-30,20}})));
ThermofluidStream.Boundaries.Source source2(
redeclare package Medium = Medium,
setEnthalpy=true,
pressureFromInput=true,
temperatureFromInput=false,
enthalpyFromInput=true,
xiFromInput=true) annotation (Placement(transformation(extent={{-50,-30},{-30,-10}})));
ThermofluidStream.Boundaries.Sink sink(
redeclare package Medium = Medium)
annotation (Placement(transformation(extent={{0,80},{20,100}})));
ThermofluidStream.Boundaries.Sink sink1(
redeclare package Medium = Medium,
pressureFromInput=true)
annotation (Placement(transformation(extent={{-10,0},{10,20}})));
ThermofluidStream.Boundaries.CreateState createState(
redeclare package Medium = Medium)
annotation (Placement(transformation(extent={{-60,50},{-40,70}})));
ThermofluidStream.Boundaries.CreateState createState1(
redeclare package Medium = Medium,
setEnthalpy=false,
PFromInput=true,
TFromInput=true,
XiFromInput=true) annotation (Placement(transformation(extent={{-40,-60},{-20,-40}})));
ThermofluidStream.Boundaries.CreateState createState2(
redeclare package Medium = Medium,
setEnthalpy=true,
PFromInput=true,
TFromInput=false,
hFromInput=true,
XiFromInput=true) annotation (Placement(transformation(extent={{-40,-90},{-20,-70}})));
ThermofluidStream.Boundaries.DynamicPressureInflow dynamicPressureInflow(
redeclare package Medium = Medium,
v_in_par=0.1)
annotation (Placement(transformation(extent={{-10,50},{10,70}})));
ThermofluidStream.Boundaries.DynamicPressureInflow dynamicPressureInflow1(
redeclare package Medium = Medium,
areaFromInput=true,
velocityFromInput=true) annotation (Placement(transformation(extent={{20,-10},{40,-30}})));
ThermofluidStream.Boundaries.DynamicPressureOutflow dynamicPressureOutflow(
redeclare package Medium = Medium,
v_out_par=0.1)
annotation (Placement(transformation(extent={{20,50},{40,70}})));
ThermofluidStream.Boundaries.DynamicPressureOutflow dynamicPressureOutflow1(
redeclare package Medium = Medium,
areaFromInput=true,
velocityFromInput=true) annotation (Placement(transformation(extent={{50,-10},{70,-30}})));
ThermofluidStream.Topology.SplitterT2 splitterT2_1(
redeclare package Medium = Medium)
annotation (Placement(transformation(extent={{-30,100},{-10,80}})));
Modelica.Blocks.Sources.Sine sine_p(
amplitude=0.1,
f=1,
offset=1e5) annotation (Placement(transformation(extent={{-100,10},{-80,30}})));
Modelica.Blocks.Sources.Ramp ramp(
height=0.1,
duration=5,
offset=0.1) annotation (Placement(transformation(extent={{0,-70},{20,-50}})));
Modelica.Blocks.Sources.Sine sine_h(
amplitude=1,
f=1,
offset=4e4) annotation (Placement(transformation(extent={{-100,-90},{-80,-70}})));
Modelica.Blocks.Sources.Ramp ramp1(
height=0.1,
duration=5,
offset=0.1) annotation (Placement(transformation(extent={{100,-60},{80,-40}})));
Modelica.Blocks.Sources.Sine sine_T(
amplitude=1,
f=1,
offset=293) annotation (Placement(transformation(extent={{-100,-30},{-80,-10}})));
Modelica.Blocks.Sources.Sine sine_xi(
amplitude=0.001,
f=0.5,
offset=0.01) annotation (Placement(transformation(extent={{-100,-60},{-80,-40}})));
Modelica.Blocks.Sources.Constant const(k=9e4)
annotation (Placement(transformation(extent={{40,0},{20,20}})));
equation
connect(sine_p.y, source1.p0_var) annotation (Line(points={{-79,20},{-62,20},{-62,16},{-42,16}}, color={0,0,127}));
connect(sine_p.y, source2.p0_var) annotation (Line(points={{-79,20},{-62,20},{-62,-14},{-42,-14}}, color={0,0,127}));
connect(dynamicPressureInflow.outlet,dynamicPressureOutflow. inlet) annotation (Line(
points={{10,60},{20,60}},
color={28,108,200},
thickness=0.5));
connect(source.outlet,splitterT2_1. inlet) annotation (Line(
points={{-40,90},{-30,90}},
color={28,108,200},
thickness=0.5));
connect(splitterT2_1.outletB,sink. inlet) annotation (Line(
points={{-10,90},{0,90}},
color={28,108,200},
thickness=0.5));
connect(splitterT2_1.outletA,dynamicPressureInflow. inlet) annotation (Line(
points={{-20,80},{-20,60},{-10,60}},
color={28,108,200},
thickness=0.5));
connect(source1.outlet, sink1.inlet) annotation (Line(
points={{-30,10},{-10,10}},
color={28,108,200},
thickness=0.5));
connect(sine_p.y, createState1.p_inp) annotation (Line(points={{-79,20},{-62,20},{-62,-40},{-40,-40}}, color={0,0,127}));
connect(sine_p.y, createState2.p_inp) annotation (Line(points={{-79,20},{-62,20},{-62,-70},{-40,-70}}, color={0,0,127}));
connect(dynamicPressureInflow1.outlet, dynamicPressureOutflow1.inlet) annotation (Line(
points={{40,-20},{50,-20}},
color={28,108,200},
thickness=0.5));
connect(source2.outlet, dynamicPressureInflow1.inlet) annotation (Line(
points={{-30,-20},{20,-20}},
color={28,108,200},
thickness=0.5));
connect(ramp.y, dynamicPressureInflow1.v_in_var) annotation (Line(points={{21,-60},{30,-60},{30,-30}}, color={0,0,127}));
connect(ramp.y, dynamicPressureOutflow1.v_out_var) annotation (Line(points={{21,-60},{54,-60},{54,-30}}, color={0,0,127}));
connect(ramp1.y, dynamicPressureInflow1.A_var) annotation (Line(points={{79,-50},{36,-50},{36,-30}}, color={0,0,127}));
connect(ramp1.y, dynamicPressureOutflow1.A_var) annotation (Line(points={{79,-50},{60,-50},{60,-30}}, color={0,0,127}));
connect(sine_T.y, source1.T0_var) annotation (Line(points={{-79,-20},{-68,-20},{-68,10},{-42,10}}, color={0,0,127}));
connect(sine_xi.y, source1.xi_var[1]) annotation (Line(points={{-79,-50},{-74,-50},{-74,4},{-42,4}}, color={0,0,127}));
connect(sine_xi.y, source2.xi_var[1]) annotation (Line(points={{-79,-50},{-74,-50},{-74,-26},{-42,-26}}, color={0,0,127}));
connect(const.y, sink1.p0_var) annotation (Line(points={{19,10},{2,10}}, color={0,0,127}));
connect(sine_T.y, createState1.T_inp) annotation (Line(points={{-79,-20},{-68,-20},{-68,-50},{-40,-50}}, color={0,0,127}));
connect(sine_xi.y, createState1.Xi_inp[1]) annotation (Line(points={{-79,-50},{-74,-50},{-74,-60},{-40,-60}}, color={0,0,127}));
connect(sine_xi.y, createState2.Xi_inp[1]) annotation (Line(points={{-79,-50},{-74,-50},{-74,-90},{-40,-90}}, color={0,0,127}));
connect(sine_h.y, createState2.h0_var) annotation (Line(points={{-79,-80},{-32,-80}}, color={0,0,127}));
connect(sine_h.y, source2.h0_var) annotation (Line(points={{-79,-80},{-56,-80},{-56,-20},{-42,-20}}, color={0,0,127}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false)));
end ConditionalConnectors;
135 changes: 135 additions & 0 deletions ThermofluidStreamTest/Boundaries/ConditionalConnectorsSetEnthalpy.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
within ThermofluidStreamTest.Boundaries;
model ConditionalConnectorsSetEnthalpy
extends Modelica.Icons.Example;

replaceable package Medium = ThermofluidStream.Media.myMedia.Air.MoistAir
constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium annotation(choicesAllMatching = true);

inner ThermofluidStream.DropOfCommons dropOfCommons annotation (Placement(transformation(extent={{-100,80},{-80,100}})));
ThermofluidStream.Boundaries.Source source1(
redeclare package Medium = Medium,
setEnthalpy=false,
pressureFromInput=true,
temperatureFromInput=true,
enthalpyFromInput=true,
xiFromInput=true,
outlet(m_flow(start=0.5, fixed=true)))
annotation (Placement(transformation(extent={{-20,80},{0,100}})));
ThermofluidStream.Boundaries.Source source2(
redeclare package Medium = Medium,
setEnthalpy=true,
pressureFromInput=true,
temperatureFromInput=true,
enthalpyFromInput=true,
xiFromInput=true) annotation (Placement(transformation(extent={{40,60},{60,80}})));
ThermofluidStream.Boundaries.Source source3(
redeclare package Medium = Medium,
setEnthalpy=false,
pressureFromInput=true,
temperatureFromInput=false,
enthalpyFromInput=false,
xiFromInput=true,
outlet(m_flow(start=0.5, fixed=true)))
annotation (Placement(transformation(extent={{-20,40},{0,60}})));
ThermofluidStream.Boundaries.Source source4(
redeclare package Medium = Medium,
setEnthalpy=true,
pressureFromInput=true,
temperatureFromInput=false,
enthalpyFromInput=false,
xiFromInput=true) annotation (Placement(transformation(extent={{40,20},{60,40}})));
ThermofluidStream.Boundaries.CreateState createState1(
redeclare package Medium = Medium,
setEnthalpy=false,
PFromInput=true,
TFromInput=true,
hFromInput=true,
XiFromInput=true) annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
ThermofluidStream.Boundaries.CreateState createState2(
redeclare package Medium = Medium,
setEnthalpy=true,
PFromInput=true,
TFromInput=true,
hFromInput=true,
XiFromInput=true) annotation (Placement(transformation(extent={{42,-40},{62,-20}})));
ThermofluidStream.Boundaries.CreateState createState3(
redeclare package Medium = Medium,
setEnthalpy=false,
PFromInput=true,
TFromInput=true,
hFromInput=true,
XiFromInput=true) annotation (Placement(transformation(extent={{-10,-70},{10,-50}})));
ThermofluidStream.Boundaries.CreateState createState4(
redeclare package Medium = Medium,
setEnthalpy=true,
PFromInput=true,
TFromInput=true,
hFromInput=true,
XiFromInput=true) annotation (Placement(transformation(extent={{42,-100},{62,-80}})));
Modelica.Blocks.Sources.Sine sine_p(
amplitude=0.1,
f=1,
offset=1e5) annotation (Placement(transformation(extent={{-80,30},{-60,50}})));
Modelica.Blocks.Sources.Sine sine_h(
amplitude=1,
f=1,
offset=4e4) annotation (Placement(transformation(extent={{-80,-100},{-60,-80}})));
Modelica.Blocks.Sources.Sine sine_T(
amplitude=1,
f=1,
offset=293) annotation (Placement(transformation(extent={{-80,0},{-60,20}})));
Modelica.Blocks.Sources.Sine sine_xi(
amplitude=0.001,
f=0.5,
offset=0.01) annotation (Placement(transformation(extent={{-80,-40},{-60,-20}})));
equation
connect(sine_p.y, source1.p0_var) annotation (Line(points={{-59,40},{-32,40},{-32,96},{-12,96}},
color={0,0,127}));
connect(sine_p.y, source2.p0_var) annotation (Line(points={{-59,40},{-32,40},{-32,76},{48,76}}, color={0,0,127}));
connect(sine_p.y, createState1.p_inp) annotation (Line(points={{-59,40},{-32,40},{-32,10},{-10,10}}, color={0,0,127}));
connect(sine_p.y, createState2.p_inp) annotation (Line(points={{-59,40},{-32,40},{-32,-20},{42,-20}}, color={0,0,127}));
connect(sine_T.y, source1.T0_var) annotation (Line(points={{-59,10},{-38,10},{-38,90},{-12,90}},
color={0,0,127}));
connect(sine_xi.y, source1.xi_var[1]) annotation (Line(points={{-59,-30},{-44,-30},{-44,84},{-12,84}},
color={0,0,127}));
connect(sine_xi.y, source2.xi_var[1]) annotation (Line(points={{-59,-30},{-44,-30},{-44,64},{48,64}},color={0,0,127}));
connect(sine_T.y, createState1.T_inp) annotation (Line(points={{-59,10},{-38,10},{-38,0},{-10,0}}, color={0,0,127}));
connect(sine_xi.y, createState1.Xi_inp[1]) annotation (Line(points={{-59,-30},{-44,-30},{-44,-10},{-10,-10}}, color={0,0,127}));
connect(sine_xi.y, createState2.Xi_inp[1]) annotation (Line(points={{-59,-30},{-44,-30},{-44,-40},{42,-40}}, color={0,0,127}));
connect(sine_h.y, createState2.h0_var) annotation (Line(points={{-59,-90},{-26,-90},{-26,-30},{50,-30}},
color={0,0,127}));
connect(sine_h.y, source2.h0_var) annotation (Line(points={{-59,-90},{-26,-90},{-26,70},{48,70}},
color={0,0,127}));
connect(sine_p.y,source3. p0_var) annotation (Line(points={{-59,40},{-32,40},{-32,56},{-12,56}},
color={0,0,127}));
connect(sine_p.y,source4. p0_var) annotation (Line(points={{-59,40},{-32,40},{-32,36},{48,36}},color={0,0,127}));
connect(sine_T.y,source3. T0_var) annotation (Line(points={{-59,10},{-38,10},{-38,50},{-12,50}},
color={0,0,127}));
connect(sine_xi.y,source3. xi_var[1]) annotation (Line(points={{-59,-30},{-44,-30},{-44,44},{-12,44}},
color={0,0,127}));
connect(sine_xi.y,source4. xi_var[1]) annotation (Line(points={{-59,-30},{-44,-30},{-44,24},{48,24}},color={0,0,127}));
connect(sine_h.y,source4. h0_var) annotation (Line(points={{-59,-90},{-26,-90},{-26,30},{48,30}},
color={0,0,127}));
connect(sine_p.y,createState3. p_inp) annotation (Line(points={{-59,40},{-32,40},{-32,-50},{-10,-50}},color={0,0,127}));
connect(sine_p.y,createState4. p_inp) annotation (Line(points={{-59,40},{-32,40},{-32,-80},{42,-80}}, color={0,0,127}));
connect(sine_T.y,createState3. T_inp) annotation (Line(points={{-59,10},{-38,10},{-38,-60},{-10,-60}},
color={0,0,127}));
connect(sine_xi.y,createState3. Xi_inp[1]) annotation (Line(points={{-59,-30},{-44,-30},{-44,-70},{-10,-70}},color={0,0,127}));
connect(sine_xi.y,createState4. Xi_inp[1]) annotation (Line(points={{-59,-30},{-44,-30},{-44,-100},{42,-100}},
color={0,0,127}));
connect(sine_h.y,createState4. h0_var) annotation (Line(points={{-59,-90},{50,-90}}, color={0,0,127}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false), graphics={
Text(
extent={{32,22},{78,12}},
textColor={0,140,72},
textString="setEnthalpy=true"),
Line(
points={{30,96},{30,-98}},
color={0,140,72},
pattern=LinePattern.Dash,
thickness=0.5),
Text(
extent={{-18,22},{28,12}},
textColor={238,46,47},
textString="setEnthalpy=false")}));
end ConditionalConnectorsSetEnthalpy;
5 changes: 5 additions & 0 deletions ThermofluidStreamTest/Boundaries/package.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
within ThermofluidStreamTest;
package Boundaries "Test models for ThermofluidStream.Boundaries"
extends Modelica.Icons.ExamplesPackage;

end Boundaries;
2 changes: 2 additions & 0 deletions ThermofluidStreamTest/Boundaries/package.order
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ConditionalConnectors
ConditionalConnectorsSetEnthalpy
5 changes: 5 additions & 0 deletions ThermofluidStreamTest/Resources/Reference/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# exclude following files
*.csv
*.log
*.mat
**/creation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
time
createState.y.state.p
createState.y.state.T
createState1.y.state.p
createState1.y.state.T
createState2.y.state.p
createState2.y.state.T
dynamicPressureInflow.outlet.m_flow
dynamicPressureInflow1.outlet.m_flow
dynamicPressureOutflow.outlet.m_flow
dynamicPressureOutflow1.outlet.m_flow
sink.inlet.m_flow
sink1.r
source.outlet.m_flow
source1.outlet.m_flow
source2.outlet.m_flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
time
createState1.y.state.p
createState1.y.state.T
createState2.y.state.p
createState2.y.state.T
createState3.y.state.p
createState3.y.state.T
createState4.y.state.p
createState4.y.state.T
source1.outlet.m_flow
source2.outlet.m_flow
source3.outlet.m_flow
source4.outlet.m_flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
time
mCV.outlet.m_flow
sourceA.outlet.m_flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
time
boundaryRear1.fore.m_flow
boundaryRear2.fore.m_flow
boundaryRear3.fore.m_flow
boundaryRear4.fore.m_flow
boundaryFore1.rear.m_flow
boundaryFore2.rear.m_flow
boundaryFore3.rear.m_flow
boundaryFore4.rear.m_flow
4 changes: 4 additions & 0 deletions ThermofluidStreamTest/Resources/Reference/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This directory contains the variable names of all example models to be used
as comparison signals for testing purposes. The directory structure is according to
the library tree of the Modelica package. Each file must be named
comparisonSignals.txt and must at least contain the "time" signal as first line.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
within ThermofluidStreamTest.Undirected.Boundaries;
model ConditionalConnectors
extends Modelica.Icons.Example;

replaceable package Medium = ThermofluidStream.Media.myMedia.Incompressible.Examples.Glycol47
constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium annotation(choicesAllMatching = true);

inner ThermofluidStream.DropOfCommons dropOfCommons annotation (Placement(transformation(extent={{-100,80},{-80,100}})));
ThermofluidStream.Boundaries.Source sourceA(
redeclare package Medium = Medium,
T0_par=333.15)
annotation (Placement(transformation(
extent={{10,-10},{-10,10}},
rotation=180,
origin={-30,50})));
ThermofluidStream.FlowControl.MCV mCV annotation (Placement(transformation(extent={{20,40},{40,60}})));
equation
connect(sourceA.outlet, mCV.inlet) annotation (Line(
points={{-20,50},{20,50}},
color={28,108,200},
thickness=0.5));
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false)));
end ConditionalConnectors;
Loading

0 comments on commit 13c961e

Please sign in to comment.