From 367d1f90b019fa75403ba687bcc5667dbf042ab4 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Sat, 2 Oct 2010 04:51:00 +0000 Subject: [PATCH] Small changes that I found improved things --- ext/tpx/CarbonDioxide.cpp | 3 ++- ext/tpx/CarbonDioxide.h | 4 +++- ext/tpx/Sub.cpp | 6 ++++++ ext/tpx/Sub.h | 10 ++++++---- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ext/tpx/CarbonDioxide.cpp b/ext/tpx/CarbonDioxide.cpp index d0859aa06..5e717b53b 100755 --- a/ext/tpx/CarbonDioxide.cpp +++ b/ext/tpx/CarbonDioxide.cpp @@ -26,7 +26,8 @@ static const double Gamma=5.0E-6; // [??] static const double u0=3.217405E5; // [] internal energy at To static const double s0=2.1396056E3; // [] entropy at To static const double Tp=250; // [K] ?? -static const double Pc=7.38350E6; // [Pa] critical pressure +//static const double Pc=7.38350E6; // [Pa] critical pressure +static const double Pc=7.3817589E6; // Adjusted to fit the actual functional form static const double M=44.01; // [kg/kmol] molar density /* diff --git a/ext/tpx/CarbonDioxide.h b/ext/tpx/CarbonDioxide.h index ed3467616..945acf24a 100755 --- a/ext/tpx/CarbonDioxide.h +++ b/ext/tpx/CarbonDioxide.h @@ -17,7 +17,9 @@ namespace tpx { class CarbonDioxide : public Substance{ public: - CarbonDioxide() { + CarbonDioxide() : + Substance() + { m_name="CarbonDioxide"; m_formula="CO2"; } diff --git a/ext/tpx/Sub.cpp b/ext/tpx/Sub.cpp index dda02e7ab..e1c91d172 100755 --- a/ext/tpx/Sub.cpp +++ b/ext/tpx/Sub.cpp @@ -398,6 +398,12 @@ namespace tpx { if (sat >= Pcrit()) return 0; psat = sat; T = Tsat(psat); + if (T == Undef) { + Err = 0; + T = Tsave; + Rho = Rhosave; + return 0; + } } else { throw TPX_Error("Substance::Lever","general error"); diff --git a/ext/tpx/Sub.h b/ext/tpx/Sub.h index 3fd40eef8..e15106209 100755 --- a/ext/tpx/Sub.h +++ b/ext/tpx/Sub.h @@ -90,10 +90,12 @@ namespace tpx { void setStdState(double h0 = 0.0, double s0 = 0.0, double t0 = 298.15, double p0 = 1.01325e5) { Set(TP, t0, p0); - double hoff = h0 - h(); - double soff = s0 - s(); - m_entropy_offset = soff; - m_energy_offset = hoff; + double hh = h(); + double ss = s(); + double hoff = h0 - hh; + double soff = s0 - ss; + m_entropy_offset += soff; + m_energy_offset += hoff; } // information about a substance: