Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions Modelica/Constants.mo
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ package Constants
final constant SI.Permeability mu_0 = 4*pi*1.00000000055e-7 "Magnetic constant";
final constant Real epsilon_0(final unit="F/m") = 1/(mu_0*c*c)
"Electric constant";
final constant NonSI.Temperature_degC T_zero=-273.15
"Absolute zero temperature";
final constant SI.Temperature T_zero_K = -273.15
"Absolute zero temperature in kelvin";
final constant NonSI.Temperature_degC T_zero = -273.15
"Absolute zero temperature in degree Celsius";

annotation (
Documentation(info="<html>
<p>
Expand Down
4 changes: 2 additions & 2 deletions Modelica/Media/package.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3611,7 +3611,7 @@ no mass or energy is stored in the pipe.
V=0.1) annotation (Placement(transformation(extent={{-40,0},{-20,20}})));
FixedMassFlowRate fixedMassFlowRate(
redeclare package Medium = Medium,
T_ambient=1.2*T_start,
T_ambient=Modelica.Constants.T_zero_K + 1.2*T_start,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change clearly makes things worse; computing a temperature as 1.2 times another is a bit odd (but is ok for a test).

But in the new equation we T_ambient=Modelica.Constants.T_zero_K + 1.2*T_start, which is a form where one would normally expect T_start to be a temperature difference, which it isn't. (We have other equations that use T_a=T_start+0.5*dT so using a literal times a difference is fairly normal).

Copy link
Contributor Author

@henrikt-ma henrikt-ma May 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. This is the reason behind keeping this PR in Draft state. A proper way to write the modification would be:

import Modelica.Constants.T_zero_K;

Suggested change
T_ambient=Modelica.Constants.T_zero_K + 1.2*T_start,
T_ambient=T_zero_K + 1.2*(T_start - T_zero_K),

h_ambient=1.2*h_start,
m_flow=1,
X_ambient=0.5*X_start) annotation (Placement(transformation(extent={{
Expand Down Expand Up @@ -3659,7 +3659,7 @@ no mass or energy is stored in the pipe.
V=0.1) annotation (Placement(transformation(extent={{-60,0},{-40,20}})));
FixedMassFlowRate fixedMassFlowRate(
redeclare package Medium = Medium,
T_ambient=1.2*T_start,
T_ambient=Modelica.Constants.T_zero_K + 1.2*T_start,
h_ambient=1.2*h_start,
m_flow=1,
X_ambient=0.5*X_start) annotation (Placement(transformation(extent={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ protected
annotation(HideResult=true);
SI.SpecificEnthalpy h "Specific enthalpy in the volume";
equation
T_port=flowPort.h/medium.cp;
T=h/medium.cp;
T_port=Modelica.Constants.T_zero_K + flowPort.h/medium.cp;
T=Modelica.Constants.T_zero_K + h/medium.cp;
// mass flow -> ambient: mixing rule
// mass flow <- ambient: energy flow defined by ambient's temperature
if Exchange then
Expand Down
4 changes: 2 additions & 2 deletions Modelica/Thermal/FluidHeatFlow/BaseClasses/SinglePortLeft.mo
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ protected
annotation(HideResult=true);
SI.SpecificEnthalpy h "Specific enthalpy in the volume";
equation
T_port=flowPort.h/medium.cp;
T=h/medium.cp;
T_port=Modelica.Constants.T_zero_K + flowPort.h/medium.cp;
T=Modelica.Constants.T_zero_K + h/medium.cp;
// mass flow -> ambient: mixing rule
// mass flow <- ambient: energy flow defined by ambient's temperature
if Exchange then
Expand Down
4 changes: 2 additions & 2 deletions Modelica/Thermal/FluidHeatFlow/BaseClasses/TwoPort.mo
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public
equation
dp=flowPort_a.p - flowPort_b.p;
V_flow=flowPort_a.m_flow/medium.rho;
T_a=flowPort_a.h/medium.cp;
T_b=flowPort_b.h/medium.cp;
T_a=Modelica.Constants.T_zero_K + flowPort_a.h/medium.cp;
T_b=Modelica.Constants.T_zero_K + flowPort_b.h/medium.cp;
dT=if noEvent(V_flow>=0) then T-T_a else T_b-T;
h = medium.cp*T;
T_q = T - noEvent(sign(V_flow))*(1 - tapT)*dT;
Expand Down
2 changes: 1 addition & 1 deletion Modelica/Thermal/HeatTransfer/Examples/TwoMasses.mo
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ equation
connect(mass2.port, Tsensor2.port) annotation (Line(points={{70,20},{70,
-60},{60,-60}}, color={191,0,0}));
initial equation
T_final_K = (mass1.T*mass1.C + mass2.T*mass2.C)/(mass1.C + mass2.C);
T_final_K = Modelica.Constants.T_zero_K + (mass1.T*mass1.C + mass2.T*mass2.C)/(mass1.C + mass2.C);
annotation (Documentation(info="<html>
<p>
This example demonstrates the thermal response of two masses connected by
Expand Down