From 74131007efbea2c4ab3e6dcf494ce5dcb7a5ac49 Mon Sep 17 00:00:00 2001 From: Raphael Gebhart Date: Mon, 11 Mar 2024 10:47:34 +0100 Subject: [PATCH 1/3] Added assert(relativeHumidty<=1) to MoistAir.isentropicExponent and MoistAir.specificEntropy and added 3 Test Models for further discussion --- .../MoistAirDiscussion/MoistAirEntropy.mo | 32 +++++++++++++++++ .../MoistAirEntropyAndIsentropicExponent.mo | 27 ++++++++++++++ .../MoistAirIsentropicExponent.mo | 35 +++++++++++++++++++ .../Media/Tests/MoistAirDiscussion/package.mo | 6 ++++ .../Tests/MoistAirDiscussion/package.order | 3 ++ ThermofluidStream/Media/Tests/TestXRGMedia.mo | 2 +- ThermofluidStream/Media/Tests/package.order | 1 + .../Media/myMedia/Air/MoistAir.mo | 10 +++++- 8 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 ThermofluidStream/Media/Tests/MoistAirDiscussion/MoistAirEntropy.mo create mode 100644 ThermofluidStream/Media/Tests/MoistAirDiscussion/MoistAirEntropyAndIsentropicExponent.mo create mode 100644 ThermofluidStream/Media/Tests/MoistAirDiscussion/MoistAirIsentropicExponent.mo create mode 100644 ThermofluidStream/Media/Tests/MoistAirDiscussion/package.mo create mode 100644 ThermofluidStream/Media/Tests/MoistAirDiscussion/package.order diff --git a/ThermofluidStream/Media/Tests/MoistAirDiscussion/MoistAirEntropy.mo b/ThermofluidStream/Media/Tests/MoistAirDiscussion/MoistAirEntropy.mo new file mode 100644 index 00000000..2afb2572 --- /dev/null +++ b/ThermofluidStream/Media/Tests/MoistAirDiscussion/MoistAirEntropy.mo @@ -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=" +

Check specific entropy s and relative humidity phi versus time.

+

Since there is no kink in specific entropy s at satuarion (X_sat = X), 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.

+")); +end MoistAirEntropy; diff --git a/ThermofluidStream/Media/Tests/MoistAirDiscussion/MoistAirEntropyAndIsentropicExponent.mo b/ThermofluidStream/Media/Tests/MoistAirDiscussion/MoistAirEntropyAndIsentropicExponent.mo new file mode 100644 index 00000000..e7ca43b4 --- /dev/null +++ b/ThermofluidStream/Media/Tests/MoistAirDiscussion/MoistAirEntropyAndIsentropicExponent.mo @@ -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=" +

Check isentropic exponent kappa, mass fraction of water X0 and mass fraction of water at saturation XSaturation versus time.

+

Pressure and water mass fraction are constant, whereas temperature is changed peridically, and therefor saturation is changed periodically

+

For (over)saturated state both Medium.specificEntropy(state), Medium.specificEntropy_pTX(p,T,X) and Medium.isentropicCoefficient will give a warning

")); +end MoistAirEntropyAndIsentropicExponent; diff --git a/ThermofluidStream/Media/Tests/MoistAirDiscussion/MoistAirIsentropicExponent.mo b/ThermofluidStream/Media/Tests/MoistAirDiscussion/MoistAirIsentropicExponent.mo new file mode 100644 index 00000000..d451a389 --- /dev/null +++ b/ThermofluidStream/Media/Tests/MoistAirDiscussion/MoistAirIsentropicExponent.mo @@ -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=" +

Check isentropic exponent kappa and relative humidity phi versus time.

+

Isentropic exponent kappa 'jumps' at approximatly phi=1. Therefor the calculation of isentropic exponent kappa should be limited. +I suggest a limit of phimax=0.998, we could of course also choose one that is more on the 'safe side', but phimax may not be 1!

")); +end MoistAirIsentropicExponent; diff --git a/ThermofluidStream/Media/Tests/MoistAirDiscussion/package.mo b/ThermofluidStream/Media/Tests/MoistAirDiscussion/package.mo new file mode 100644 index 00000000..ed871092 --- /dev/null +++ b/ThermofluidStream/Media/Tests/MoistAirDiscussion/package.mo @@ -0,0 +1,6 @@ +within ThermofluidStream.Media.Tests; +package MoistAirDiscussion + extends Modelica.Icons.ExamplesPackage; + + +end MoistAirDiscussion; diff --git a/ThermofluidStream/Media/Tests/MoistAirDiscussion/package.order b/ThermofluidStream/Media/Tests/MoistAirDiscussion/package.order new file mode 100644 index 00000000..c6bf8b09 --- /dev/null +++ b/ThermofluidStream/Media/Tests/MoistAirDiscussion/package.order @@ -0,0 +1,3 @@ +MoistAirEntropyAndIsentropicExponent +MoistAirIsentropicExponent +MoistAirEntropy diff --git a/ThermofluidStream/Media/Tests/TestXRGMedia.mo b/ThermofluidStream/Media/Tests/TestXRGMedia.mo index d16f0fe4..36b398c9 100644 --- a/ThermofluidStream/Media/Tests/TestXRGMedia.mo +++ b/ThermofluidStream/Media/Tests/TestXRGMedia.mo @@ -135,7 +135,7 @@ model TestXRGMedia "Test for five XRG Media with various components" redeclare package Medium = XRGMedia.R1234yf_ph, r(displayUnit="mm") = 0.02, l=20, - redeclare function pLoss = Processes.Internal.FlowResistance.linearQuadraticPressureLoss( + redeclare function pLoss = Processes.Internal.FlowResistance.linearQuadraticPressureLoss ( k=500, k2=500)) annotation (Placement(transformation( extent={{-10,-10},{10,10}}, diff --git a/ThermofluidStream/Media/Tests/package.order b/ThermofluidStream/Media/Tests/package.order index 025ce1f6..46a52cdd 100644 --- a/ThermofluidStream/Media/Tests/package.order +++ b/ThermofluidStream/Media/Tests/package.order @@ -1 +1,2 @@ TestXRGMedia +MoistAirDiscussion diff --git a/ThermofluidStream/Media/myMedia/Air/MoistAir.mo b/ThermofluidStream/Media/myMedia/Air/MoistAir.mo index 8dac15fe..40197a8b 100644 --- a/ThermofluidStream/Media/myMedia/Air/MoistAir.mo +++ b/ThermofluidStream/Media/myMedia/Air/MoistAir.mo @@ -880,7 +880,11 @@ Derivative function for Date: Mon, 11 Mar 2024 10:53:37 +0100 Subject: [PATCH 2/3] Restored TestXRGMedia.mo (concerning spaces) --- ThermofluidStream/Media/Tests/TestXRGMedia.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThermofluidStream/Media/Tests/TestXRGMedia.mo b/ThermofluidStream/Media/Tests/TestXRGMedia.mo index 36b398c9..d16f0fe4 100644 --- a/ThermofluidStream/Media/Tests/TestXRGMedia.mo +++ b/ThermofluidStream/Media/Tests/TestXRGMedia.mo @@ -135,7 +135,7 @@ model TestXRGMedia "Test for five XRG Media with various components" redeclare package Medium = XRGMedia.R1234yf_ph, r(displayUnit="mm") = 0.02, l=20, - redeclare function pLoss = Processes.Internal.FlowResistance.linearQuadraticPressureLoss ( + redeclare function pLoss = Processes.Internal.FlowResistance.linearQuadraticPressureLoss( k=500, k2=500)) annotation (Placement(transformation( extent={{-10,-10},{10,10}}, From 805345515fbc33180b24f5dcac5177fde25e28be Mon Sep 17 00:00:00 2001 From: Raphael Gebhart Date: Mon, 11 Mar 2024 10:56:17 +0100 Subject: [PATCH 3/3] Corrected MoistAir.specificEntropy assertion message (PsiX<1 to PsiX<=1) --- ThermofluidStream/Media/myMedia/Air/MoistAir.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThermofluidStream/Media/myMedia/Air/MoistAir.mo b/ThermofluidStream/Media/myMedia/Air/MoistAir.mo index 40197a8b..2b6d80d0 100644 --- a/ThermofluidStream/Media/myMedia/Air/MoistAir.mo +++ b/ThermofluidStream/Media/myMedia/Air/MoistAir.mo @@ -1065,7 +1065,7 @@ Derivative function for