Skip to content

Commit

Permalink
Add non-physical topology constraints and add MCV bidi (#46)
Browse files Browse the repository at this point in the history
* add splitters/junction with mass-flow splits

* add comments to nonphysical and increase version number

* whitespace changes from dymola 80 char line length

* add vapor quality to phase separator; add visual warning to mcv and add clip cases to tests; implement working bidi version of mcv with test; add Q_flow to HEX-summary; increase version number
  • Loading branch information
mimeissner authored Feb 21, 2022
1 parent 0d33852 commit bc8c48c
Show file tree
Hide file tree
Showing 97 changed files with 2,223 additions and 510 deletions.
2 changes: 2 additions & 0 deletions ThermofluidStream/Boundaries/PhaseSeparator.mo
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ model PhaseSeparator "Parent to Reciever and Accumulator models"
Real liquid_level(unit="1") "level of liquid line";
Real liquid_level_pipe(unit="1") "level of liquid line in pipe";

Real vapor_quality = max(0,min(1,x));

protected
Medium.MassFraction x = (medium.h-h_bubble)/(h_dew - h_bubble) "Calculated vapor quality of medium that can go below zero and above one";
SI.SpecificEnthalpy h_pipe;
Expand Down
6 changes: 4 additions & 2 deletions ThermofluidStream/Boundaries/Tests/Reservoir.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ within ThermofluidStream.Boundaries.Tests;
model Reservoir "Test for Reservoir"
extends Modelica.Icons.Example;

replaceable package Medium = Media.myMedia.CompressibleLiquids.LinearColdWater
replaceable package Medium =
Media.myMedia.CompressibleLiquids.LinearColdWater
constrainedby Media.myMedia.Interfaces.PartialMedium
"Medium Model"
annotation(choicesAllMatching=true, Documentation(info="<html>
Expand All @@ -25,7 +26,8 @@ model Reservoir "Test for Reservoir"
Processes.Pump pump(redeclare package Medium=Medium,
initM_flow= ThermofluidStream.Utilities.Types.InitializationMethods.state,
omega_from_input=true,
redeclare function dp_tau_pump = Processes.Internal.TurboComponent.dp_tau_nominal_flow (
redeclare function dp_tau_pump =
Processes.Internal.TurboComponent.dp_tau_nominal_flow (
V_r_input(displayUnit="m3") = 0.1,
k_p_input=500,
k_fric_input=0))
Expand Down
3 changes: 2 additions & 1 deletion ThermofluidStream/Boundaries/Tests/SourceSink.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ model SourceSink "Test for source and sink model"
extends Modelica.Icons.Example;

replaceable package Medium = Media.myMedia.Air.SimpleAir
constrainedby Media.myMedia.Interfaces.PartialMedium
constrainedby
Media.myMedia.Interfaces.PartialMedium
"Medium package"
annotation (Documentation(info="<html>
<p><span style=\"font-family: Courier New;\">Medium package used in the Test.</span></p>
Expand Down
3 changes: 2 additions & 1 deletion ThermofluidStream/Boundaries/Tests/TerminalSourceSink.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ model TerminalSourceSink "Test for Terminal source and sink model"
extends Modelica.Icons.Example;

replaceable package Medium = Media.myMedia.Air.SimpleAir
constrainedby Media.myMedia.Interfaces.PartialMedium
constrainedby
Media.myMedia.Interfaces.PartialMedium
"Medium package"
annotation (Documentation(info="<html>
<p><span style=\"font-family: Courier New;\">Medium package used in the Test.</span></p>
Expand Down
3 changes: 2 additions & 1 deletion ThermofluidStream/Boundaries/Tests/Volumes.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ model Volumes "Test Volumes"
extends Modelica.Icons.Example;

replaceable package Medium = Media.myMedia.Air.SimpleAir
constrainedby Media.myMedia.Interfaces.PartialMedium
constrainedby
Media.myMedia.Interfaces.PartialMedium
"Medium package"
annotation (Documentation(info="<html>
<p><span style=\"font-family: Courier New;\">Medium package used in the Test.</span></p>
Expand Down
6 changes: 4 additions & 2 deletions ThermofluidStream/Examples/EspressoMachine.mo
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ model EspressoMachine "Get your simulated coffe!"
initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state,
omega_from_input=true,
omegaStateSelect=StateSelect.never,
redeclare function dp_tau_pump = Processes.Internal.TurboComponent.dp_tau_nominal_flow (k_fric_input=0))
redeclare function dp_tau_pump =
Processes.Internal.TurboComponent.dp_tau_nominal_flow ( k_fric_input=0))
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180,
Expand Down Expand Up @@ -199,7 +200,8 @@ model EspressoMachine "Get your simulated coffe!"
annotation (Placement(transformation(extent={{126,-106},{146,-86}})));
Processes.Pump pump1(
J_p=1e-3,redeclare package Medium = Water,
redeclare function dp_tau_pump = Processes.Internal.TurboComponent.dp_tau_nominal_flow (
redeclare function dp_tau_pump =
Processes.Internal.TurboComponent.dp_tau_nominal_flow (
parametrizeByDesignPoint=false,
V_r_input(displayUnit="m3") = 0.1,
k_p_input=1e6,
Expand Down
18 changes: 12 additions & 6 deletions ThermofluidStream/Examples/HeatPump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ within ThermofluidStream.Examples;
model HeatPump
extends Modelica.Icons.Example;

replaceable package Medium = Media.XRGMedia.R1234yf_ph constrainedby Media.myMedia.Interfaces.PartialMedium "Refrigerant Medium"
replaceable package Medium = Media.XRGMedia.R1234yf_ph constrainedby
Media.myMedia.Interfaces.PartialMedium "Refrigerant Medium"
annotation(choicesAllMatching=true);
replaceable package Air = Media.myMedia.Air.DryAirNasa constrainedby Media.myMedia.Interfaces.PartialMedium "Air Medium"
replaceable package Air = Media.myMedia.Air.DryAirNasa constrainedby
Media.myMedia.Interfaces.PartialMedium "Air Medium"
annotation(choicesAllMatching=true);

HeatExchangers.DiscretizedCounterFlowHEX
condenser(
redeclare package MediumA = Air,
redeclare package MediumB = Medium,
redeclare model ConductionElementA = HeatExchangers.Internal.ConductionElementHEX,
redeclare model ConductionElementB = HeatExchangers.Internal.ConductionElementHEX_twoPhase,
redeclare model ConductionElementA =
HeatExchangers.Internal.ConductionElementHEX,
redeclare model ConductionElementB =
HeatExchangers.Internal.ConductionElementHEX_twoPhase,
initializeMassFlow=false,
nCells=10,
A=10,
Expand All @@ -23,8 +27,10 @@ model HeatPump
HeatExchangers.DiscretizedCounterFlowHEX evaporator(
redeclare package MediumA = Air,
redeclare package MediumB = Medium,
redeclare model ConductionElementA = HeatExchangers.Internal.ConductionElementHEX,
redeclare model ConductionElementB = HeatExchangers.Internal.ConductionElementHEX_twoPhase,
redeclare model ConductionElementA =
HeatExchangers.Internal.ConductionElementHEX,
redeclare model ConductionElementB =
HeatExchangers.Internal.ConductionElementHEX_twoPhase,
initializeMassFlow=false,
nCells=10,
A=10,
Expand Down
31 changes: 18 additions & 13 deletions ThermofluidStream/Examples/ReverseHeatPump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ model ReverseHeatPump
redeclare package Medium = RefrigerantMedium,
initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.none,
omega_from_input=true,
redeclare function dp_tau_compressor = Processes.Internal.TurboComponent.dp_tau_const_isentrop (
redeclare function dp_tau_compressor =
Processes.Internal.TurboComponent.dp_tau_const_isentrop (
kappaFromMedia=false,
kappa_fixed=1.13,
eta=0.8))
Expand All @@ -29,8 +30,10 @@ model ReverseHeatPump
discretizedHEX(
redeclare package MediumA = SecondaryMedium,
redeclare package MediumB = RefrigerantMedium,
redeclare model ConductionElementA = Undirected.HeatExchangers.Internal.ConductionElementHEX,
redeclare model ConductionElementB = Undirected.HeatExchangers.Internal.ConductionElementHEX_twoPhase,
redeclare model ConductionElementA =
Undirected.HeatExchangers.Internal.ConductionElementHEX,
redeclare model ConductionElementB =
Undirected.HeatExchangers.Internal.ConductionElementHEX_twoPhase,
init_B=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.fore,
nCells=5,
initializeMassFlow=false,
Expand All @@ -43,8 +46,10 @@ model ReverseHeatPump
discretizedHEX1(
redeclare package MediumA = SecondaryMedium,
redeclare package MediumB = RefrigerantMedium,
redeclare model ConductionElementA = Undirected.HeatExchangers.Internal.ConductionElementHEX,
redeclare model ConductionElementB = Undirected.HeatExchangers.Internal.ConductionElementHEX_twoPhase,
redeclare model ConductionElementA =
Undirected.HeatExchangers.Internal.ConductionElementHEX,
redeclare model ConductionElementB =
Undirected.HeatExchangers.Internal.ConductionElementHEX_twoPhase,
init_B=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.rear,
nCells=5,
initializeMassFlow=false,
Expand Down Expand Up @@ -147,8 +152,8 @@ model ReverseHeatPump
annotation (Placement(transformation(extent={{10,10},{-10,-10}},
rotation=90,
origin={0,-38})));
Undirected.Topology.ConnectRearOutlet connectRearOutlet(redeclare package Medium =
RefrigerantMedium, useDefaultStateAsRear=true) annotation (
Undirected.Topology.ConnectRearOutlet connectRearOutlet(redeclare package
Medium = RefrigerantMedium, useDefaultStateAsRear=true) annotation (
Placement(transformation(
extent={{10,-10},{-10,10}},
rotation=90,
Expand Down Expand Up @@ -209,19 +214,19 @@ model ReverseHeatPump
rotation=90,
origin={0,-10})));
inner DropOfCommons dropOfCommons(m_flow_reg=0.001) annotation (Placement(transformation(extent={{96,10},{116,30}})));
Undirected.Topology.ConnectInletFore connectInletFore(redeclare package Medium =
RefrigerantMedium) annotation (Placement(transformation(
Undirected.Topology.ConnectInletFore connectInletFore(redeclare package
Medium = RefrigerantMedium) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={-44,40})));
Undirected.Topology.ConnectInletFore connectInletFore1(redeclare package Medium =
RefrigerantMedium) annotation (Placement(transformation(
Undirected.Topology.ConnectInletFore connectInletFore1(redeclare package
Medium = RefrigerantMedium) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=0,
origin={46,40})));
ThermofluidStream.Utilities.Icons.DLRLogo dLRLogo annotation (Placement(transformation(extent={{104,-64},{160,-8}})));
Undirected.Topology.ConnectRearOutlet connectRearOutlet1(redeclare package Medium =
RefrigerantMedium, useDefaultStateAsRear=true) annotation (
Undirected.Topology.ConnectRearOutlet connectRearOutlet1(redeclare package
Medium = RefrigerantMedium, useDefaultStateAsRear=true) annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
Expand Down
29 changes: 19 additions & 10 deletions ThermofluidStream/Examples/SimpleAirCycle.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ model SimpleAirCycle "Basic bootstrap cooling cycle"
extends Modelica.Icons.Example;

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


Expand Down Expand Up @@ -53,7 +55,8 @@ model SimpleAirCycle "Basic bootstrap cooling cycle"
initOmega=ThermofluidStream.Utilities.Types.InitializationMethods.state,
initPhi=true,
redeclare function dp_tau_compressor =
ThermofluidStream.Processes.Internal.TurboComponent.dp_tau_const_isentrop (
ThermofluidStream.Processes.Internal.TurboComponent.dp_tau_const_isentrop
(
omega_ref=2000,
skew=1,
m_flow_ref=1,
Expand All @@ -70,7 +73,8 @@ model SimpleAirCycle "Basic bootstrap cooling cycle"
L=5e2,
omega_from_input=false,
redeclare function dp_tau_turbine =
ThermofluidStream.Processes.Internal.TurboComponent.dp_tau_const_isentrop (
ThermofluidStream.Processes.Internal.TurboComponent.dp_tau_const_isentrop
(
omega_ref=Modelica.Constants.inf,
m_flow_ref=0.36,
skew=-0.2,
Expand All @@ -92,7 +96,8 @@ model SimpleAirCycle "Basic bootstrap cooling cycle"
initOmega=ThermofluidStream.Utilities.Types.InitializationMethods.state,
initPhi=true,
redeclare function dp_tau_turbine =
ThermofluidStream.Processes.Internal.TurboComponent.dp_tau_const_isentrop (
ThermofluidStream.Processes.Internal.TurboComponent.dp_tau_const_isentrop
(
omega_ref=Modelica.Constants.inf,
m_flow_ref=0.39,
skew=-0.2,
Expand All @@ -115,17 +120,21 @@ model SimpleAirCycle "Basic bootstrap cooling cycle"
extent={{-10,-10},{10,10}},
rotation=270,
origin={0,96})));
Processes.Fan fan(redeclare package Medium = Medium_ram, redeclare function dp_tau_fan =
ThermofluidStream.Processes.Internal.TurboComponent.dp_tau_const_isentrop (
Processes.Fan fan(redeclare package Medium = Medium_ram, redeclare function
dp_tau_fan =
ThermofluidStream.Processes.Internal.TurboComponent.dp_tau_const_isentrop
(
omega_ref=500,
skew=1,
m_flow_ref=0.21,
eta=0.7)) annotation (Placement(transformation(
extent={{-10,10},{10,-10}},
rotation=270,
origin={-80,-66})));
Processes.Fan fan1(redeclare package Medium = Medium_ram, redeclare function dp_tau_fan =
ThermofluidStream.Processes.Internal.TurboComponent.dp_tau_const_isentrop (
Processes.Fan fan1(redeclare package Medium = Medium_ram, redeclare function
dp_tau_fan =
ThermofluidStream.Processes.Internal.TurboComponent.dp_tau_const_isentrop
(
omega_ref=1000,
skew=1,
eta=0.7)) annotation (Placement(transformation(
Expand Down
38 changes: 20 additions & 18 deletions ThermofluidStream/Examples/SimpleCoolingCycle.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ within ThermofluidStream.Examples;
model SimpleCoolingCycle "Basic cooling cycle with a load"
extends Modelica.Icons.Example;

replaceable package Medium_liquid = Media.myMedia.Water.ConstantPropertyLiquidWater
replaceable package Medium_liquid =
Media.myMedia.Water.ConstantPropertyLiquidWater
constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium annotation(choicesAllMatching = true);

replaceable package Medium_air =
Expand Down Expand Up @@ -41,23 +42,23 @@ extends Modelica.Icons.Example;
r=0.05,
l=1,
redeclare function pLoss =
ThermofluidStream.Processes.Internal.FlowResistance.linearQuadraticPressureLoss (
k=1e5))
ThermofluidStream.Processes.Internal.FlowResistance.linearQuadraticPressureLoss
(k=1e5))
annotation (Placement(transformation(extent={{60,50},{80,70}})));
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm1(redeclare package Medium =
Medium_liquid, temperatureUnit="degC")
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm1(redeclare package
Medium = Medium_liquid, temperatureUnit="degC")
annotation (Placement(transformation(extent={{50,-14},{30,6}})));
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm2(redeclare package Medium =
Medium_liquid, temperatureUnit="degC")
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm2(redeclare package
Medium = Medium_liquid, temperatureUnit="degC")
annotation (Placement(transformation(extent={{-6,-14},{-26,6}})));
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3(redeclare package Medium =
Medium_liquid,
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3(redeclare package
Medium = Medium_liquid,
digits=2,
outputMassFlowRate=true,
temperatureUnit="degC")
annotation (Placement(transformation(extent={{-60,-14},{-80,-34}})));
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm4(redeclare package Medium =
Medium_liquid, temperatureUnit="degC")
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm4(redeclare package
Medium = Medium_liquid, temperatureUnit="degC")
annotation (Placement(transformation(extent={{10,10},{-10,-10}},
rotation=180,
origin={-30,70})));
Expand All @@ -69,8 +70,8 @@ extends Modelica.Icons.Example;
extent={{10,-10},{-10,10}},
rotation=180,
origin={8,-46})));
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm5(redeclare package Medium =
Medium_air, temperatureUnit="degC")
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm5(redeclare package
Medium = Medium_air, temperatureUnit="degC")
annotation (Placement(
transformation(
extent={{10,-10},{-10,10}},
Expand All @@ -88,7 +89,8 @@ extends Modelica.Icons.Example;
annotation (Placement(transformation(extent={{98,-70},{118,-50}})));

ThermofluidStream.Processes.Fan fan(redeclare package Medium = Medium_air,
initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state,redeclare function dp_tau_fan =
initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state,redeclare
function dp_tau_fan =
Processes.Internal.TurboComponent.dp_tau_const_isentrop (omega_ref=100))
annotation (Placement(transformation(extent={{140,-36},{160,-16}})));
Modelica.Blocks.Sources.RealExpression pump_speed(y=80 + 273.15)
Expand All @@ -103,13 +105,13 @@ extends Modelica.Icons.Example;
annotation (Placement(transformation(extent={{-190,70},{-170,90}})));
inner ThermofluidStream.DropOfCommons dropOfCommons
annotation (Placement(transformation(extent={{150,76},{170,96}})));
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm6(redeclare package Medium =
Medium_liquid, temperatureUnit="degC")
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm6(redeclare package
Medium = Medium_liquid, temperatureUnit="degC")
annotation (Placement(transformation(extent={{-10,10},{10,-10}},
rotation=180,
origin={124,-4})));
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm7(redeclare package Medium =
Medium_air, temperatureUnit="degC")
ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm7(redeclare package
Medium = Medium_air, temperatureUnit="degC")
annotation (Placement(
transformation(
extent={{10,-10},{-10,10}},
Expand Down
12 changes: 6 additions & 6 deletions ThermofluidStream/Examples/SimpleEngine.mo
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ model SimpleEngine "Simple steam engine"
rotation=90,
origin={190,90})));

Processes.ConductionElement conductionElement( redeclare package Medium =
Water,
Processes.ConductionElement conductionElement( redeclare package
Medium = Water,
A=20,
init=ThermofluidStream.Processes.Internal.InitializationMethodsCondElement.T,
T_0=573.15)
Expand Down Expand Up @@ -49,13 +49,13 @@ model SimpleEngine "Simple steam engine"
m0_left=0.1,
m0_right=0.1,
x0=0.5) annotation (Placement(transformation(extent={{88,-92},{28,-32}})));
Undirected.Topology.ConnectorInletOutletFore switchConnector(redeclare package Medium =
Water) annotation (Placement(transformation(
Undirected.Topology.ConnectorInletOutletFore switchConnector(redeclare
package Medium = Water) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=0,
origin={70,34})));
Undirected.Topology.ConnectorInletOutletFore switchConnector1(redeclare package Medium =
Water) annotation (Placement(transformation(
Undirected.Topology.ConnectorInletOutletFore switchConnector1(redeclare
package Medium = Water) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=0,
origin={50,54})));
Expand Down
Loading

0 comments on commit bc8c48c

Please sign in to comment.