Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The DLR ThermoFluid Stream Library uses a [innovative computational scheme](http

Watch the <a href="https://youtu.be/u0Y7z0MyKd4" target="_blank">introductory video</a> from the 2021 Modelica Conference and read the <a href="https://www.mdpi.com/2079-9292/11/22/3790" target="_blank">corresponding paper in MDPI electronics</a> (<a href="https://ecp.ep.liu.se/index.php/modelica/article/view/199/159" target="_blank">short version</a>):

<a href="https://youtu.be/u0Y7z0MyKd4" target="_blank"><img src="/doc/VideoThermoFluidCover.png"
<a href="https://youtu.be/u0Y7z0MyKd4" target="_blank"><img src="/doc/VideoThermoFluidCover.PNG"
alt="IMAGE ALT TEXT HERE" height="200" border="1" /></a>

## License, Terms of Use, Literature
Expand Down
18 changes: 3 additions & 15 deletions ThermofluidStream/DropOfCommons.mo
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ model DropOfCommons "Model for global parameters"

parameter AssertionLevel assertionLevel = AssertionLevel.error "Global assertion level";

parameter Boolean displayInstanceNames = true "= true, if ThermofluidStream instance names are displayed" annotation(Dialog(group="Layout"),Evaluate=true, HideResult=true, choices(checkBox=true));
parameter Boolean displayParameters = true "= true, if displaying parameters is enabled" annotation(Dialog(group="Layout"),Evaluate=true, HideResult=true, choices(checkBox=true));
final parameter Integer instanceNameColor[3] = {28,108,200}; // Default Color: {28,108,200}
parameter Boolean displayInstanceNames = false "= true, if ThermofluidStream instance names are displayed" annotation(Dialog(group="Layout"),Evaluate=true, HideResult=true, choices(checkBox=true));
parameter Boolean displayParameters = false "= true, if displaying parameters is enabled" annotation(Dialog(group="Layout"),Evaluate=true, HideResult=true, choices(checkBox=true));
final parameter Integer instanceNameColor[3] = {28,108,200}; // {28,108,200}

annotation (defaultComponentName="dropOfCommons",
defaultComponentPrefixes="inner",
Expand Down Expand Up @@ -57,17 +57,5 @@ to specify system properties.",Icon(coordinateSystem(preserveAspectRatio=false),
coordinateSystem(preserveAspectRatio=false)),
Documentation(revisions="<html>
<p><img src=\"modelica:/ThermofluidStream/Resources/dlr_logo.png\"/>(c) 2020-2021, DLR, Institute of System Dynamics and Control</p>
</html>", info="<html>
<p>The <strong>DropOfCommons</strong> defines global parameters and settings for simulation models. This model serves several purposes: </p>
<ul>
<li>It provides <strong>default physical constants</strong> (e.g., gravity acceleration) and flow properties (e.g., inertance) that are used by all components in the model.</li>
<li>It defines <strong>regularization parameters</strong> (e.g., minimal density, minimal pressure, mass flow threshold, angular velocity, and volume damping factor) that ensure numerical stability of transient simulations. These parameters must be adjusted to match the characteristics of the simulated system, for example, if the system&rsquo;s design involves mass flows on the order of magnitude of the regularization threshold (m_flow_reg), or angular velocities near omega_reg, their values should be updated to prevent artificial inaccuracies. Detailed information on the volume damping factor is available in the <a href=\"modelica://ThermofluidStream.Boundaries.Internal.PartialVolume\">PartialVolume</a> documentation.</li>
<li>It defines <strong>global assertion and error handling</strong> behavior via the <span style=\"font-family: Courier New;\">assertionLevel</span> parameter.</li>
<li>It provides <strong>layout and visualization settings</strong> for model diagrams, such as displaying instance names and parameter values.</li>
</ul>
<p>Since the global parameters defined in DropOfCommons are used by multiple ThermofluidStream components, exactly one instance of this model needs to be present at the top level of a simulation model. The basic declaration is: </p>
<p style=\"margin-left: 40px;\"><strong><span style=\"font-family: Courier New;\">inner</span></strong> ThermofluidStream.DropOfCommons dropOfCommons </p>
<p>Note, it must be an <strong>inner</strong> declaration with instance name <strong>dropOfCommons</strong> so that all components of a ThermofluidStream model can reference it. When dragging the &quot;DropOfCommons&quot; object from the package browser into the diagram layer, this declaration is automatically generated (defined via annotations in the model). </p>
<p>All flow, density, pressure, and visualization parameters in a simulation model are resolved relative to the settings in this dropOfCommons instance. Adjusting these parameters allows controlling global simulation behavior, visualization preferences, and regularization methods consistently across all components. </p>
</html>"));
end DropOfCommons;
13 changes: 6 additions & 7 deletions ThermofluidStream/Examples/HeatPump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ model HeatPump
Boundaries.Source source(redeclare package Medium = Air,
T0_par=293.15,
p0_par=100000)
annotation (Placement(transformation(extent={{-160,86},{-140,106}})));
annotation (Placement(transformation(extent={{-160,78},{-140,98}})));
Processes.FlowResistance flowResistance1(
redeclare package Medium = Air,
r=1,
Expand All @@ -93,7 +93,7 @@ model HeatPump
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=0,
origin={-110,96})));
origin={-110,88})));
Processes.FlowResistance flowResistance2(
redeclare package Medium = Air,
r=1,
Expand Down Expand Up @@ -218,8 +218,7 @@ model HeatPump
Sensors.SingleSensorSelect singleSensorSelect3(
redeclare package Medium = Air,
digits=1,
quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.T_C) annotation (Placement(transformation(extent={{-120,
108},{-100,128}})));
quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.T_C) annotation (Placement(transformation(extent={{-120,100},{-100,120}})));
Sensors.SingleSensorSelect singleSensorSelect4(
redeclare package Medium = Air,
digits=1,
Expand Down Expand Up @@ -304,11 +303,11 @@ equation
color={28,108,200},
thickness=0.5));
connect(source.outlet, flowResistance1.inlet) annotation (Line(
points={{-140,96},{-120,96}},
points={{-140,88},{-120,88}},
color={28,108,200},
thickness=0.5));
connect(flowResistance1.outlet, condenser.inletA) annotation (Line(
points={{-100,96},{-94,96},{-94,88},{-90,88}},
points={{-100,88},{-90,88}},
color={28,108,200},
thickness=0.5));
connect(condenser.outletA, fan.inlet) annotation (Line(
Expand Down Expand Up @@ -389,7 +388,7 @@ equation
thickness=0.5));
connect(singleSensorSelect3.inlet, flowResistance1.inlet)
annotation (Line(
points={{-120,118},{-126,118},{-126,96},{-120,96}},
points={{-120,110},{-126,110},{-126,88},{-120,88}},
color={28,108,200},
thickness=0.5));
connect(singleSensorSelect4.inlet, flowResistance2.inlet)
Expand Down
2 changes: 1 addition & 1 deletion ThermofluidStream/Examples/ReverseHeatPump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ equation
thickness=0.5));
connect(multiSensor_Tpm6.rear, TEVcooling.fore)
annotation (Line(
points={{70,130},{60,130},{60,180},{50,180}},
points={{70,130},{70,180},{50,180}},
color={28,108,200},
thickness=0.5));
connect(junctionT1_1.inletB, multiSensor_Tpm.outlet)
Expand Down
5 changes: 2 additions & 3 deletions ThermofluidStream/Examples/SimpleGasTurbine.mo
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ model SimpleGasTurbine "Simple version of a Gas Turbine"
Sensors.MultiSensor_Tp multiSensor_Tp2(
redeclare package Medium = Medium,
digits=3,
pressureUnit="bar") annotation (Placement(transformation(extent={{-104,0},{
-84,20}})));
pressureUnit="bar") annotation (Placement(transformation(extent={{-104,-4},{-84,16}})));
Modelica.Blocks.Continuous.LimPID PI(
controllerType=Modelica.Blocks.Types.SimpleController.PI,
k=2000,
Expand Down Expand Up @@ -110,7 +109,7 @@ equation
annotation (Line(points={{-110,-60},{-80,-60},{-80,-20}},
color={0,0,0}));
connect(multiSensor_Tp2.inlet, source.outlet) annotation (Line(
points={{-104,10},{-110,10},{-110,-10},{-120,-10}},
points={{-104,6},{-110,6},{-110,-10},{-120,-10}},
color={28,108,200},
thickness=0.5));
connect(speedSensor.flange, turbine.flange)
Expand Down
14 changes: 5 additions & 9 deletions ThermofluidStream/Examples/Utilities/Tests/Piston.mo
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ model Piston "Test for Piston model"
extent={{-10,-10},{10,10}},
rotation=0,
origin={10,10})));
FlowControl.Switch switch(redeclare package Medium = Medium,
initializeOneMassflowSplit=false)
FlowControl.Switch switch(redeclare package Medium = Medium, initializeOneMassflowSplit=true)
annotation (Placement(transformation(extent={{-10,10},{10,-10}},
rotation=0,
origin={-66,10})));
Expand All @@ -84,7 +83,6 @@ model Piston "Test for Piston model"
Processes.FlowResistance flowResistance2(
redeclare package Medium = Medium,
m_flowStateSelect=StateSelect.prefer,
initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state,
computeL=false,
L_value=1e-3,
r=0.1,
Expand Down Expand Up @@ -127,19 +125,17 @@ initial equation

equation

connect(linearSpeedDependentForce.flange, piston2_1.flange) annotation (Line(points={{40,-50},
{40,-50},{14,-50}}, color={0,127,0}));
connect(linearSpeedDependentForce.flange, piston2_1.flange) annotation (Line(points={{40,-50},{40,-50.2},{14,-50.2}}, color={0,127,0}));

connect(piston2_1.x_out, showRealValue.numberPort) annotation (Line(points={{10,
-54.8},{10,-72},{30,-72}}, color={0,0,127}));
connect(piston2_1.x_out, showRealValue.numberPort) annotation (Line(points={{10,-55},{10,-72},{30.5,-72}}, color={0,0,127}));
connect(switchConnector.fore, piston2_1.port_left)
annotation (Line(
points={{-10,-30},{-10,-45.8},{-6,-45.8}},
points={{-10,-30},{-10,-46},{-6,-46}},
color={28,108,200},
thickness=0.5));
connect(switchConnector1.fore, piston2_1.port_right)
annotation (Line(
points={{10,0},{10,-10},{20,-10},{20,-45.8},{14,-45.8}},
points={{10,0},{10,-10},{20,-10},{20,-46},{14,-46}},
color={28,108,200},
thickness=0.5));
connect(pulse.y, firstOrder.u) annotation (Line(points={{-43,56},{-32,56}}, color={0,0,127}));
Expand Down
3 changes: 1 addition & 2 deletions ThermofluidStream/Examples/VenturiPump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ model VenturiPump "Pumping of liquid water using the venturi effect"
extent={{-10,-10},{10,10}},
rotation=270,
origin={0,50})));
inner DropOfCommons dropOfCommons(p_min(displayUnit="Pa") = 612,
displayInstanceNames=true)
inner DropOfCommons dropOfCommons(p_min(displayUnit="Pa") = 612, displayInstanceNames=false)
annotation (Placement(transformation(extent={{-90,12},{-70,32}})));
ThermofluidStream.Utilities.Icons.DLRLogo dLRLogo annotation (Placement(transformation(extent={{82,62},{118,98}})));
equation
Expand Down
3 changes: 1 addition & 2 deletions ThermofluidStream/Examples/WaterHammer.mo
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ model WaterHammer "Pump water by using dynamic pressures"
"Medium model"
annotation(choicesAllMatching=true);

inner ThermofluidStream.DropOfCommons dropOfCommons(assertionLevel = AssertionLevel.warning,
displayInstanceNames=true)
inner ThermofluidStream.DropOfCommons dropOfCommons(assertionLevel = AssertionLevel.warning, displayInstanceNames=false)
annotation (Placement(transformation(extent={{-100,60},{-80,80}})));
ThermofluidStream.Boundaries.Source source(
redeclare package Medium = Medium,
Expand Down
2 changes: 1 addition & 1 deletion ThermofluidStream/FlowControl/MCV.mo
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,6 @@ equation
<p>This component can be used to emulate a mass- or volume-flow regulated valve, depending on its mode. </p>
<p>The mass- or volume-flow-setpoint can be set or given by a real input signal, and the valve tries to enforce a PT1- dynamic on this setpoint, within its pressure limits. The valve will not create pressure, or let the outlet pressure drop below p_min. To avoid this, the internally integrated pressure-drop is clipped. If it is clipped and hence the setpoint cannot be reached, an optional output leaves its &quot;zero&quot; value and a visual wanring is shown (circle becomes red). </p>
<p>Documentation of the used equations:</p>
<p><img src=\"modelica://ThermoFluidStream/Resources/Doku/ThermofluidStream.FlowControl.MCV.png\"/></p>
<p><img src=\"modelica://ThermoFluidStream/Resources/Doku/ThermofluidStream.FlowControl.MCV.PNG\"/></p>
</html>"));
end MCV;
22 changes: 13 additions & 9 deletions ThermofluidStream/HeatExchangers/Internal/PartialNTU.mo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ partial model PartialNTU "Partial heat exchanger model using the epsilon-NTU met
annotation (choicesAllMatching=true);

parameter Modelica.Units.SI.Area A "Heat transfer area";
parameter Modelica.Units.SI.CoefficientOfHeatTransfer k_NTU=50 "Overall heat transfer coefficient";
parameter Modelica.Units.SI.CoefficientOfHeatTransfer k_NTU=50 "Thermal transmittance";
parameter Utilities.Units.Inertance L=dropOfCommons.L "Inertance"
annotation (Dialog(tab="Advanced"));
parameter Modelica.Units.SI.MassFlowRate m_flow_reg=dropOfCommons.m_flow_reg "Nominal mass flow rate for regularization"
Expand All @@ -19,7 +19,7 @@ partial model PartialNTU "Partial heat exchanger model using the epsilon-NTU met
// ------ Parameter Display Configuration ------------------------
parameter Boolean displayArea = true "= true, if the heat transfer area A is displayed"
annotation(Dialog(tab="Layout",group="Display parameters",enable=displayParameters),Evaluate=true, HideResult=true, choices(checkBox=true));
parameter Boolean displaykNTU = true "= true, if the overall heat transfer coefficient k_NTU is displayed"
parameter Boolean displaykNTU = true "= true, if the thermal transmittance k_NTU is displayed"
annotation(Dialog(tab="Layout",group="Display parameters",enable=displayParameters),Evaluate=true, HideResult=true, choices(checkBox=true));
final parameter Boolean d1A = displayParameters and displayArea "displayArea at position 1"
annotation(Evaluate=true, HideResult=true); //d1A -> Display at position 1 A=Area
Expand Down Expand Up @@ -53,7 +53,7 @@ partial model PartialNTU "Partial heat exchanger model using the epsilon-NTU met
Modelica.Units.SI.SpecificEnthalpy dh_A "Specific enthalpy difference medium A";
Modelica.Units.SI.SpecificEnthalpy dh_B "Specific enthalpy difference medium B";

SI.HeatFlowRate q_flow "Heat flow rate A to B (Q_flow)";
SI.HeatFlowRate q_flow "Heat flow rate (Q_flow)";
Real effectiveness(unit="1") "Heat exchanger efficiency";
Real NTU(unit="1") "Number of transfer units";

Expand All @@ -78,9 +78,9 @@ protected
Modelica.Units.SI.SpecificEnthalpy h_out_A "Specific enthalpy at outlet A";
Modelica.Units.SI.SpecificEnthalpy h_out_B "Specific enthalpy at outlet B";

SI.HeatFlowRate q_max "Maximum heat flow rate A to B (Q_flow_max)";
SI.HeatFlowRate q_flowA "Heat flow rate A to B (Q_flowA)";
SI.HeatFlowRate q_flowB "Heat flow rate B to A (Q_flowB)";
SI.HeatFlowRate q_max "Maximum heat flow rate (Q_max)";
SI.HeatFlowRate q_flowA "Heat flow rate side A (Q_flowA)";
SI.HeatFlowRate q_flowB "Heat flow rate side B (Q_flowB)";

Real C_A(unit="J/(K.s)") "Heat capacity flow rate of Medium A";
Real C_B(unit="J/(K.s)") "Heat capacity flow rate of Medium B";
Expand Down Expand Up @@ -166,6 +166,9 @@ equation
//Based on regularization for mass flow
dh_B = (m_flow_B*q_flowB)/(m_flow_B^2 + (m_flow_reg/10)^2);

der(h_out_A)*TC = h_in_A - dh_A - h_out_A;
der(h_out_B)*TC = h_in_B - dh_B - h_out_B;

else

//No heat is transferred, if both mass flow rates are smaller than regularization mass flow rate
Expand All @@ -180,10 +183,11 @@ equation

//Based on regularization for mass flow
dh_A = (m_flow_A*q_flowA)/(m_flow_A^2 + (m_flow_reg/10)^2);
end if;

der(h_out_A)*TC = h_in_A - dh_A - h_out_A;
der(h_out_B)*TC = h_in_B - dh_B - h_out_B;
der(h_out_A)*TC = h_in_A - dh_A - h_out_A;
der(h_out_B)*TC = h_in_B - dh_B - h_out_B;

end if;

outletA.state = MediumA.setState_phX(
p_A,
Expand Down
2 changes: 1 addition & 1 deletion ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU.mo
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ model CounterFlowNTU
Medium = MediumB, outputMassFlowRate=false,
temperatureUnit="degC")
annotation (Placement(transformation(extent={{60,20},{40,40}})));
inner DropOfCommons dropOfCommons
inner DropOfCommons dropOfCommons(displayInstanceNames=false, displayParameters=false)
annotation (Placement(transformation(extent={{-158,-98},{-138,-78}})));
ThermofluidStream.HeatExchangers.CounterFlowNTU counterFlowNTU(
redeclare package MediumA = MediumA,
Expand Down
2 changes: 1 addition & 1 deletion ThermofluidStream/HeatExchangers/Tests/CrossFlowNTU.mo
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ model CrossFlowNTU
annotation (Placement(transformation(extent={{10,-10},{-10,10}},
rotation=90,
origin={-10,32})));
inner DropOfCommons dropOfCommons
inner DropOfCommons dropOfCommons(displayInstanceNames=false)
annotation (Placement(transformation(extent={{-156,-98},{-136,-78}})));
ThermofluidStream.HeatExchangers.CrossFlowNTU crossFlowNTU(
redeclare package MediumA = MediumA,
Expand Down
20 changes: 10 additions & 10 deletions ThermofluidStream/Processes/CentrifugalPump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ model CentrifugalPump "Model of a centrifugal pump"

parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "Mass flow rate for regularization"
annotation(Dialog(tab="Advanced"));
parameter SI.Power P_reg = 1 "Power for regularization (eta = 0 for P < P_reg)"
parameter SI.Power P_reg = dropOfCommons.m_flow_reg/1000*1e5 "Power for regularization (eta = 0 for P < eps_P)"
annotation(Dialog(tab="Advanced"));

// ------ Parameter Display Configuration ------------------------
Expand Down Expand Up @@ -174,14 +174,14 @@ equation
if pumpMode == PumpMode.flowControlled or pumpMode == PumpMode.pressureControlled then
w_n = 1/(2*c_head[1])*(-c_head[2]*V_n + sqrt(c_head[2]^2*V_n^2 - 4*c_head[1]*(c_head[3]*V_n^2 - h_n))); // To avoid systems of nonlinear equations the quadratic equation head_n = f(w_n) is solved for w_n explicitly
elseif pumpMode == PumpMode.speedControlled or pumpMode == PumpMode.flange then
h_n = c_head[1]*w_n^2 + c_head[2]*abs(w_n)*V_n + c_head[3]*V_n*abs(V_n); // Simple extension for negative flow
h_n = c_head[1]*w_n^2 + c_head[2]*w_n*V_n + c_head[3]*V_n*abs(V_n); // Simple extension for negative flow
end if;
tau_n = smooth(0, if noEvent(V_n > 0) then rho_n*(c_power[1]*w_n^2 + c_power[2]*abs(w_n)*V_n + c_power[3]*V_n^2) else rho_n*c_power[1]*w_n^2); // Simple extension for negative flow
tau_n = smooth(0, if noEvent(V_n > 0) then rho_n*(c_power[1]*w_n^2 + c_power[2]*w_n*V_n + c_power[3]*V_n^2) else rho_n*c_power[1]*w_n^2); // Simple extension for negative flow
dp = head*rho*Modelica.Constants.g_n;
P = tau*w;
h_out = h_in + w_t;
Xi_out = Xi_in;
eta_is = if noEvent(P >= P_reg) then dp*V_flow/P else 0;
eta_is = dp*V_flow/max(P,P_reg);
w_t = P/max(m_flow,m_flow_reg);
annotation (Icon(graphics={
Text(visible=displayInstanceName,
Expand Down Expand Up @@ -318,11 +318,11 @@ further modifications are necessary.
</p>

</html>", revisions="<html>
<ul>
<li>
May 2025, by Raphael Gebhart (raphael.gebhart@dlr.de):<br>
Initial version.
</li>
</ul>
<ul>
<li>
May 2025, by Raphael Gebhart (raphael.gebhart@dlr.de):<br>
Initial version.
</li>
</ul>
</html>"));
end CentrifugalPump;
Loading