Skip to content

Commit

Permalink
Compatibility to MSL 4.0.0 (#59)
Browse files Browse the repository at this point in the history
* Convert to MSL 4.0.0 using conversion script

* Fix h_start unit in Volume models (h_default)

* Replaced myMedia by local copy of MSL4 Media; added massFraction functionM; adapted R -> R_s in XRG Media package; still not all adaptions done, not running!

* Update setState_phx function in R143a Media (myMedia); problem occured with getPhase function

* Add density_derp_h to simpleMedium and simpleIdealGasMedium

* Set density derp_h assertion level to warning

* Remove Media Tests from regression testing (experiment_X in annotation)

* Update Modelica Version Number

* Add density_derp_h to common ideal gas media models

* Revert "Set density derp_h assertion level to warning"

This reverts commit ceaa5bcf9f7273a888914343d3df15ccf70ad6c4.

* Add density_derp_h function to remaining media models (adaptions from msl3.2.3 compatible version)

* Update version number of TFS (1.0.0)
  • Loading branch information
nieweber authored Dec 2, 2022
1 parent 8f73ea2 commit cffa928
Show file tree
Hide file tree
Showing 92 changed files with 58,252 additions and 59,349 deletions.
2 changes: 1 addition & 1 deletion ThermofluidStream/Boundaries/DynamicPressureInflow.mo
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ model DynamicPressureInflow
parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "Regularization threshold of mass flow rate"
annotation(Dialog(tab="Advanced", group="Regularization", enable = not extrapolateQuadratic));

Modelica.Blocks.Interfaces.RealInput A_var(unit = "m2") = A if areaFromInput "Area input connector [m2]" annotation (Placement(transformation(
Modelica.Blocks.Interfaces.RealInput A_var(unit = "m2") = A if areaFromInput "Area input connector [m2]" annotation (Placement(transformation(
extent={{-20,-20},{20,20}},
rotation=270,
origin={60,100}), iconTransformation(extent={{-20,-20},{20,20}},
Expand Down
2 changes: 1 addition & 1 deletion ThermofluidStream/Boundaries/DynamicPressureOutflow.mo
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ model DynamicPressureOutflow
parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "Regularization threshold of mass flow rate"
annotation(Dialog(tab="Advanced", group="Regularization", enable = not extrapolateQuadratic));

Modelica.Blocks.Interfaces.RealInput A_var( unit = "m2") = A if areaFromInput "Area input connector [m2]" annotation (Placement(transformation(
Modelica.Blocks.Interfaces.RealInput A_var( unit = "m2") = A if areaFromInput "Area input connector [m2]" annotation (Placement(transformation(
extent={{-20,-20},{20,20}},
rotation=270,
origin={0,100}), iconTransformation(extent={{-20,-20},{20,20}},
Expand Down
2 changes: 1 addition & 1 deletion ThermofluidStream/Boundaries/Internal/PartialVolume.mo
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ partial model PartialVolume "Partial parent class for Volumes with one inlet and
annotation(Dialog(tab= "Initialization", enable=initialize_energy and (not use_hstart)));
parameter Boolean use_hstart = false "True: spedific enthalpy contition instead of Temperature"
annotation(Dialog(tab= "Initialization", enable=initialize_energy));
parameter SI.SpecificEnthalpy h_start = Medium.T_default "Initial specific enthalpy"
parameter SI.SpecificEnthalpy h_start = Medium.h_default "Initial specific enthalpy"
annotation(Dialog(tab= "Initialization", enable=initialize_energy and use_hstart));
parameter Boolean initialize_Xi = true "If true: initialize mass fractions"
annotation(Dialog(tab= "Initialization"));
Expand Down
2 changes: 1 addition & 1 deletion ThermofluidStream/Boundaries/Internal/PartialVolumeM.mo
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ partial model PartialVolumeM "Partial parent class for Volumes with one inlet an
annotation(Dialog(tab= "Initialization", enable=initialize_energy and (not use_hstart)));
parameter Boolean use_hstart = false "True: spedific enthalpy contition instead of Temperature"
annotation(Dialog(tab= "Initialization", enable=initialize_energy));
parameter SI.SpecificEnthalpy h_start = Medium.T_default "Initial specific enthalpy"
parameter SI.SpecificEnthalpy h_start = Medium.h_default "Initial specific enthalpy"
annotation(Dialog(tab= "Initialization", enable=initialize_energy and use_hstart));
parameter Boolean initialize_Xi = true "If true: initialize mass fractions"
annotation(Dialog(tab= "Initialization"));
Expand Down
2 changes: 1 addition & 1 deletion ThermofluidStream/Boundaries/Internal/PartialVolumeN.mo
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ partial model PartialVolumeN "Partial parent class for Volumes with N inlets and
annotation(Dialog(tab= "Initialization", enable=initialize_energy and (not use_hstart)));
parameter Boolean use_hstart = false "True: spedific enthalpy contition instead of Temperature"
annotation(Dialog(tab= "Initialization", enable=initialize_energy));
parameter SI.SpecificEnthalpy h_start = Medium.T_default "Initial specific enthalpy"
parameter SI.SpecificEnthalpy h_start = Medium.h_default "Initial specific enthalpy"
annotation(Dialog(tab= "Initialization", enable=initialize_energy and use_hstart));
parameter Boolean initialize_Xi = true "If true: initialize mass fractions"
annotation(Dialog(tab= "Initialization"));
Expand Down
10 changes: 5 additions & 5 deletions ThermofluidStream/Examples/EspressoMachine.mo
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ model EspressoMachine "Get your simulated coffe!"
annotation (Placement(transformation(extent={{10,10},{-10,-10}},
rotation=180,
origin={-100,-30})));
Modelica.Blocks.Continuous.LimPID
PID3(
Ti=3,controllerType=Modelica.Blocks.Types.SimpleController.PI,
initType=.Modelica.Blocks.Types.InitPID.NoInit,
k=100, limitsAtInit = true,
Modelica.Blocks.Continuous.LimPID PID3(
Ti=3,
controllerType=Modelica.Blocks.Types.SimpleController.PI,
initType=.Modelica.Blocks.Types.Init.NoInit,
k=100,
yMax=5000,
yMin=0,
y_start=0)
Expand Down
12 changes: 7 additions & 5 deletions ThermofluidStream/Examples/HeatPump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,20 @@ model HeatPump
Ti=0.3,
yMax=1,
yMin=0,
initType=Modelica.Blocks.Types.InitPID.InitialOutput,
y_start=1) annotation (Placement(transformation(extent={{-90,-10},{-110,10}})));
initType=Modelica.Blocks.Types.Init.InitialOutput,
y_start=1)
annotation (Placement(transformation(extent={{-90,-10},{-110,10}})));
Modelica.Blocks.Sources.Constant const(k=5) annotation (Placement(transformation(extent={{-50,-10},{-70,10}})));
Modelica.Blocks.Continuous.LimPID PI1(
controllerType=Modelica.Blocks.Types.SimpleController.PI,
k=0.005,
Ti=20,
yMax=1,
yMin=0.0001,
initType=Modelica.Blocks.Types.InitPID.InitialOutput,
initType=Modelica.Blocks.Types.Init.InitialOutput,
xi_start=0,
y_start=0.0001) annotation (Placement(transformation(extent={{124,10},{104,-10}})));
y_start=0.0001)
annotation (Placement(transformation(extent={{124,10},{104,-10}})));
Modelica.Blocks.Sources.Step step(
height=10,
offset=25,
Expand All @@ -251,7 +253,7 @@ model HeatPump
Ti=0.5,
yMax=10,
yMin=-10,
initType=Modelica.Blocks.Types.InitPID.InitialOutput,
initType=Modelica.Blocks.Types.Init.InitialOutput,
xi_start=0,
y_start=0) annotation (Placement(transformation(extent={{82,-10},{62,10}})));
Modelica.Mechanics.Rotational.Sources.Torque torque annotation (Placement(transformation(extent={{44,-10},{24,10}})));
Expand Down
10 changes: 6 additions & 4 deletions ThermofluidStream/Examples/VaporCycle.mo
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ model VaporCycle
Ti=3,
yMax=-0.001,
yMin=-38,
initType=Modelica.Blocks.Types.InitPID.InitialOutput,
y_start=-4) annotation (Placement(transformation(extent={{204,-10},{184,10}})));
initType=Modelica.Blocks.Types.Init.InitialOutput,
y_start=-4)
annotation (Placement(transformation(extent={{204,-10},{184,10}})));
Modelica.Blocks.Math.Gain gain(k=1)
annotation (Placement(transformation(extent={{120,-6},{108,6}})));
Modelica.Blocks.Sources.Step step(
Expand All @@ -284,8 +285,9 @@ model VaporCycle
Ti=0.3,
yMax=10000,
yMin=1,
initType=Modelica.Blocks.Types.InitPID.InitialOutput,
y_start=3000) annotation (Placement(transformation(extent={{148,10},{128,-10}})));
initType=Modelica.Blocks.Types.Init.InitialOutput,
y_start=3000)
annotation (Placement(transformation(extent={{148,10},{128,-10}})));
Modelica.Blocks.Math.Gain gain1(k=-1)
annotation (Placement(transformation(extent={{172,-6},{160,6}})));
inner DropOfCommons dropOfCommons annotation (Placement(transformation(extent={{-180,-128},{-160,-108}})));
Expand Down
3 changes: 1 addition & 2 deletions ThermofluidStream/Examples/WaterHammer.mo
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ model WaterHammer "Pump water by using dynamic pressures"
annotation (Placement(transformation(extent={{-170,-10},{-150,10}})));
Topology.SplitterT2 splitterT2_1(redeclare package Medium =
Medium) annotation (Placement(transformation(extent={{-40,-10},{-20,10}})));
ThermofluidStream.FlowControl.CheckValve checkValve(redeclare package Medium
= Medium, initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state)
ThermofluidStream.FlowControl.CheckValve checkValve(redeclare package Medium = Medium, initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state)
annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
Expand Down
6 changes: 2 additions & 4 deletions ThermofluidStream/FlowControl/FourWaySwitch.mo
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ model FourWaySwitch
extent={{-10,10},{10,-10}},
rotation=180,
origin={60,-60})));
ThermofluidStream.Topology.JunctionT2 junctionT2_1(redeclare package Medium
= Medium)
ThermofluidStream.Topology.JunctionT2 junctionT2_1(redeclare package Medium = Medium)
annotation (Placement(transformation(extent={{-70,-70},{-50,-50}})));
ThermofluidStream.Topology.JunctionT2 junctionT2_2(redeclare package Medium
= Medium)
ThermofluidStream.Topology.JunctionT2 junctionT2_2(redeclare package Medium = Medium)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180,
Expand Down
12 changes: 7 additions & 5 deletions ThermofluidStream/FlowControl/Internal/PartialValve.mo
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ partial model PartialValve "Partial implementation of a physical valve"
origin={0,80})));

Real u(unit="1") "actuation input for flow calculation";
parameter Modelica.SIunits.Pressure dp_ref = 1e5 "Reference pressure difference"
annotation(Dialog(tab="Advanced", group = "Reference values"));
parameter Modelica.SIunits.Density rho_ref = 1000 "Reference density"
annotation(Dialog(tab="Advanced", group = "Reference values"));
parameter Modelica.Units.SI.Pressure dp_ref=1e5
"Reference pressure difference"
annotation (Dialog(tab="Advanced", group="Reference values"));
parameter Modelica.Units.SI.Density rho_ref=1000 "Reference density"
annotation (Dialog(tab="Advanced", group="Reference values"));

protected
final constant Real secondsPerHour(final unit="s/h") = 3600 "Parameter for unit conversion";

//Medium properties
Modelica.SIunits.Density rho = Medium.density(inlet.state) "Medium density at inlet";
Modelica.Units.SI.Density rho=Medium.density(inlet.state)
"Medium density at inlet";

SI.MassFlowRate m_flow_ref "Reference mass flow derived from flow coefficient inputs";
Real k_u(unit="1") "Kv/Kvs, respecting flow characteristics";
Expand Down
8 changes: 5 additions & 3 deletions ThermofluidStream/FlowControl/SpecificValveType.mo
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ model SpecificValveType "Specific technical valve types"

parameter FlowCoeffType flowCoefficient = FlowCoeffType.Kvs "Select type of flow coefficient" annotation(Dialog(group = "Valve parameters"));
//Set valve data as parameter
parameter Modelica.SIunits.Diameter d_valve "Flow diameter" annotation(Evaluate = true, Dialog(group = "Valve parameters",
enable = (flowCoefficient == FlowCoeffType.flowDiameter)));
parameter Modelica.Units.SI.Diameter d_valve "Flow diameter" annotation (
Evaluate=true, Dialog(group="Valve parameters", enable=(flowCoefficient
== FlowCoeffType.flowDiameter)));
//Reference Values
parameter Real Kvs( unit = "m3/h") "Kvs-value (metric) from data sheet (valve fully open)" annotation(Evaluate = true,
Dialog(group = "Valve parameters",enable = (flowCoefficient ==FlowCoeffType.
Expand All @@ -25,7 +26,8 @@ model SpecificValveType "Specific technical valve types"
Dialog(group = "Valve parameters",enable = (flowCoefficient ==FlowCoeffType.m_flow_set)));

protected
Modelica.SIunits.Area A_valve = 0.25*Modelica.Constants.pi*d_valve^2 "Cross-sectional valve area";
Modelica.Units.SI.Area A_valve=0.25*Modelica.Constants.pi*d_valve^2
"Cross-sectional valve area";
constant zetaValueRecord valveData;

SI.VolumeFlowRate V_flow_ref=
Expand Down
3 changes: 1 addition & 2 deletions ThermofluidStream/FlowControl/Switch.mo
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ model Switch
extent={{-10,10},{10,-10}},
rotation=0,
origin={40,0})));
ThermofluidStream.Topology.SplitterT2 splitterT2_1(redeclare package Medium
= Medium, L=0)
ThermofluidStream.Topology.SplitterT2 splitterT2_1(redeclare package Medium = Medium, L=0)
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));

// for dynamic select of graphics only
Expand Down
2 changes: 1 addition & 1 deletion ThermofluidStream/FlowControl/Tests/MCV.mo
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ model MCV "Test for MCV"
redeclare package Medium = Medium,
initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state,
mode=ThermofluidStream.FlowControl.Internal.Types.MassflowControlValveMode.mass_flow,

massFlow_set_par=1,
volumeFlow_set_par=1) annotation (Placement(transformation(extent={{-8,130},
{12,150}})));

equation
connect(mCV.inlet, source.outlet) annotation (Line(
points={{-10,30},{-20,30}},
Expand Down
43 changes: 24 additions & 19 deletions ThermofluidStream/HeatExchangers/CounterFlowNTU.mo
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,22 @@ model CounterFlowNTU "Counter flow heat exchanger using the epsilon-NTU method"
rotation=180,
origin={-110,60})));

parameter Modelica.SIunits.Area A "Conductive Surface";
parameter Modelica.Units.SI.Area A "Conductive Surface";
parameter Utilities.Units.Inertance L = dropOfCommons.L "inertance of the flow"
annotation(Dialog(tab="Advanced"));
parameter Modelica.SIunits.CoefficientOfHeatTransfer k_NTU = 50 "overall heat transfer coefficient";
parameter Modelica.SIunits.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "nominal mass flow for regularisation"
annotation(Dialog(tab = "Advanced", group = "Regularisation parameters"));
parameter Modelica.SIunits.Time TC = 0.01 "time constant for dh"
annotation(Dialog(tab="Advanced"));
parameter Modelica.Units.SI.CoefficientOfHeatTransfer k_NTU=50
"overall heat transfer coefficient";
parameter Modelica.Units.SI.MassFlowRate m_flow_reg=dropOfCommons.m_flow_reg
"nominal mass flow for regularisation"
annotation (Dialog(tab="Advanced", group="Regularisation parameters"));
parameter Modelica.Units.SI.Time TC=0.01 "time constant for dh"
annotation (Dialog(tab="Advanced"));

Modelica.SIunits.TemperatureDifference Delta_T_max "Maximum Temperature Difference";
Modelica.Units.SI.TemperatureDifference Delta_T_max
"Maximum Temperature Difference";

Modelica.SIunits.SpecificEnthalpy dh_A "Enthalpy difference Medium A";
Modelica.SIunits.SpecificEnthalpy dh_B "Enthalpy difference Medium B";
Modelica.Units.SI.SpecificEnthalpy dh_A "Enthalpy difference Medium A";
Modelica.Units.SI.SpecificEnthalpy dh_B "Enthalpy difference Medium B";

SI.HeatFlowRate q_flow "actual heat flow rate";
Real effectiveness(unit="1") "effectiveness derived from NTU correlation";
Expand All @@ -60,17 +63,17 @@ model CounterFlowNTU "Counter flow heat exchanger using the epsilon-NTU method"
protected
outer DropOfCommons dropOfCommons;

Modelica.SIunits.Pressure p_A = MediumA.pressure(inletA.state);
Modelica.SIunits.Pressure p_B = MediumB.pressure(inletB.state);
Modelica.Units.SI.Pressure p_A=MediumA.pressure(inletA.state);
Modelica.Units.SI.Pressure p_B=MediumB.pressure(inletB.state);

MediumA.MassFraction Xi_A[MediumA.nXi] = MediumA.massFraction(inletA.state);
MediumB.MassFraction Xi_B[MediumB.nXi] = MediumB.massFraction(inletB.state);

//In- and outlet enthalpies and enthalpy differences
Modelica.SIunits.SpecificEnthalpy h_in_A "Enthalpy at inlet A";
Modelica.SIunits.SpecificEnthalpy h_in_B "Enthalpy at Inlet B";
Modelica.SIunits.SpecificEnthalpy h_out_A "Enthalpy at inlet A";
Modelica.SIunits.SpecificEnthalpy h_out_B "Enthalpy at Inlet B";
Modelica.Units.SI.SpecificEnthalpy h_in_A "Enthalpy at inlet A";
Modelica.Units.SI.SpecificEnthalpy h_in_B "Enthalpy at Inlet B";
Modelica.Units.SI.SpecificEnthalpy h_out_A "Enthalpy at inlet A";
Modelica.Units.SI.SpecificEnthalpy h_out_B "Enthalpy at Inlet B";

SI.HeatFlowRate q_max "Maximum heat flow rate";
SI.HeatFlowRate q_flowA "Heat flow rate side A";
Expand All @@ -82,11 +85,13 @@ protected
Real C_max(unit="J/(K.s)") "maximum heat capacity rate";
Real C_r(unit="1") "Cmin/Cmax (ratio of heat capacity rates)";

Modelica.SIunits.SpecificHeatCapacityAtConstantPressure cp_A "specific heat capacity of Medium A";
Modelica.SIunits.SpecificHeatCapacityAtConstantPressure cp_B "specific heat capacity of Medium B";
Modelica.Units.SI.SpecificHeatCapacityAtConstantPressure cp_A
"specific heat capacity of Medium A";
Modelica.Units.SI.SpecificHeatCapacityAtConstantPressure cp_B
"specific heat capacity of Medium B";

Modelica.SIunits.MassFlowRate m_flow_A = inletA.m_flow "Mass flow on side A";
Modelica.SIunits.MassFlowRate m_flow_B = inletB.m_flow "Mass flow on side B";
Modelica.Units.SI.MassFlowRate m_flow_A=inletA.m_flow "Mass flow on side A";
Modelica.Units.SI.MassFlowRate m_flow_B=inletB.m_flow "Mass flow on side B";

SI.SpecificHeatCapacity cpA_in = MediumA.specificHeatCapacityCp(inletA.state);
SI.SpecificHeatCapacity cpA_out = MediumA.specificHeatCapacityCp(outletA.state);
Expand Down
Loading

0 comments on commit cffa928

Please sign in to comment.