Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MoistAir entropy and isentropicExponent issue #172

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
within ThermofluidStream.Media.Tests.MoistAirDiscussion;
model MoistAirEntropy "Find PsiXmax concerning entropy, found that entropy is continous and therefor not as critical as kappa"
extends Modelica.Icons.Example;
package Medium = ThermofluidStream.Media.myMedia.Air.MoistAir
"Medium model";

Medium.ThermodynamicState state;
//SI.SpecificEntropy s2 = Medium.specificEntropy_pTX(state.p,state.T,state.X);
SI.SpecificEntropy s1 = Medium.specificEntropy(state);
Real XSaturation "Saturation of state3";
parameter SI.Pressure p0 = 1e5;
parameter SI.Temperature T0 = 273.15+20;
parameter SI.TemperatureDifference dT = 20;
parameter Real x0 = Medium.xsaturation_pT(p0,T0);
parameter SI.MassFraction X0 = x0/(1+x0);
parameter SI.MassFraction dX0 = X0;
parameter SI.AngularFrequency omega0 = 10;
Real phi;
protected
constant SI.Time unitTime=1;
equation
state.p = p0;
state.T = T0;
state.X = {X0, 1-X0} - {dX0, 1-dX0}*(2*time-1);
XSaturation = Medium.Xsaturation(state);
phi = Medium.relativeHumidity(state);
annotation (experiment(StopTime=1.0, Tolerance=1e-005), Documentation(info="<html>
<p>Check specific entropy <code>s</code> and relative humidity <code>phi</code> versus <code>time</code>.</p>
<p>Since there is no kink in specific entropy <code>s</code> at satuarion (<code>X_sat = X</code>), i assume, that MoistAir uses the specific entropy of vapor also for condensed water.
Of course this is wrong, but the error is proportional to the amount of condensed water, and therefor the calculation of specific entropy is not as critial as the calculation of isentropic coefficient kappa, which jumps at saturation.</p>
</html>"));
end MoistAirEntropy;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
within ThermofluidStream.Media.Tests.MoistAirDiscussion;
model MoistAirEntropyAndIsentropicExponent "Warning check for moist air concerning entropy and kappa, compare XSaturation with state.X to check if oversaturated"
extends Modelica.Icons.Example;
package Medium = ThermofluidStream.Media.myMedia.Air.MoistAir
"Medium model";

Medium.ThermodynamicState state;
//SI.SpecificEntropy s2 = Medium.specificEntropy_pTX(state.p,state.T,state.X);
SI.SpecificEntropy s = Medium.specificEntropy(state);
Real kappa = Medium.isentropicExponent(state);
Real XSaturation "Saturation of state3";
parameter SI.Temperature T0 = 273.15+20;
parameter SI.TemperatureDifference dT = 20;
parameter SI.MassFraction X0 = 10e-3;
parameter SI.AngularFrequency omega0 = 10;
protected
constant SI.Time unitTime=1;
equation
state.p = 1.e5;
state.T = T0 + dT*cos(omega0*time);
state.X = {X0, 1-X0};
XSaturation = Medium.Xsaturation(state);
annotation (experiment(StopTime=1.0, Tolerance=1e-005), Documentation(info="<html>
<p>Check isentropic exponent <code>kappa</code>, mass fraction of water <code>X0</code> and mass fraction of water at saturation <code>XSaturation</code> versus <code>time</code>.</p>
<p>Pressure and water mass fraction are constant, whereas temperature is changed peridically, and therefor saturation is changed periodically</p>
<p> For (over)saturated state both Medium.specificEntropy(state), Medium.specificEntropy_pTX(p,T,X) and Medium.isentropicCoefficient will give a warning</p></html>"));
end MoistAirEntropyAndIsentropicExponent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
within ThermofluidStream.Media.Tests.MoistAirDiscussion;
model MoistAirIsentropicExponent "Find PsiXmax concerning kappa (found to be 0.998)"
extends Modelica.Icons.Example;
package Medium = ThermofluidStream.Media.myMedia.Air.MoistAir
"Medium model";

Medium.ThermodynamicState state;
//SI.SpecificEntropy s2 = Medium.specificEntropy_pTX(state.p,state.T,state.X);
//SI.SpecificEntropy s1 = Medium.specificEntropy(state);
Real kappa = Medium.isentropicExponent(state);
Real XSaturation "Saturation of state3";
parameter SI.Pressure p0 = 1e5;
parameter SI.Temperature T0 = 273.15+20;
parameter SI.TemperatureDifference dT = 20;
parameter Real x0 = Medium.xsaturation_pT(p0,T0);
parameter SI.MassFraction X0 = x0/(1+x0);
parameter SI.MassFraction dX0 = 1e-2*X0;
parameter SI.AngularFrequency omega0 = 10;
Real phi;
parameter Real kappa0 = 1.39811;
Real e_kappa_real = (kappa-kappa0)/kappa0;
SI.SpecificEntropy s1 = Medium.specificEntropy(state);
protected
constant SI.Time unitTime=1;
equation
state.p = p0;
state.T = T0;
state.X = {X0, 1-X0} - {dX0, 1-dX0}*time;
XSaturation = Medium.Xsaturation(state);
phi = Medium.relativeHumidity(state);
annotation (experiment(StopTime=1.0, Tolerance=1e-005), Documentation(info="<html>
<p>Check isentropic exponent <code>kappa</code> and relative humidity <code>phi</code> versus <code>time</code>.</p>
<p> Isentropic exponent <code>kappa</code> 'jumps' at approximatly <code>phi=1</code>. Therefor the calculation of isentropic exponent <code>kappa</code> should be limited.
I suggest a limit of <code>phimax=0.998</code>, we could of course also choose one that is more on the 'safe side', but <code>phimax</code> may not be 1!</p></html>"));
end MoistAirIsentropicExponent;
6 changes: 6 additions & 0 deletions ThermofluidStream/Media/Tests/MoistAirDiscussion/package.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
within ThermofluidStream.Media.Tests;
package MoistAirDiscussion
extends Modelica.Icons.ExamplesPackage;


end MoistAirDiscussion;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MoistAirEntropyAndIsentropicExponent
MoistAirIsentropicExponent
MoistAirEntropy
1 change: 1 addition & 0 deletions ThermofluidStream/Media/Tests/package.order
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
TestXRGMedia
MoistAirDiscussion
10 changes: 9 additions & 1 deletion ThermofluidStream/Media/myMedia/Air/MoistAir.mo
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,11 @@ Derivative function for <a href=\"modelica://Modelica.Media.Air.MoistAir.h_pTX\"

redeclare function extends isentropicExponent
"Return isentropic exponent (only for gas fraction!)"
protected
MassFraction Xsat = Xsaturation(state) "Absolute Humidity at saturation";
Real PsiX = state.X[Water]/Xsat "Relative humidity (based on X)";
algorithm
assert(PsiX <= 0.998, "MoistAir.isentropicExponent is not valid for (over)saturated air", level = AssertionLevel.warning);
gamma := specificHeatCapacityCp(state)/specificHeatCapacityCv(state);
end isentropicExponent;

Expand Down Expand Up @@ -1057,8 +1061,12 @@ Derivative function for <a href=\"modelica://Modelica.Media.Air.MoistAir.specifi

redeclare function extends specificEntropy
"Return specific entropy from thermodynamic state record, only valid for phi<1"

protected
MassFraction Xsat = Xsaturation(state) "Absolute Humidity at saturation";
Real PsiX = state.X[Water]/Xsat "Relative humidity (based on X)";
algorithm
assert(PsiX <= 1, "MoistAir.specificEntropy is not valid for oversaturated air", level = AssertionLevel.warning);

s := s_pTX(
state.p,
state.T,
Expand Down
Loading