mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-02-10 05:45:14 -05:00
Added LiBr and some more fitting scripts
This commit is contained in:
@@ -434,6 +434,111 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
}
|
||||
|
||||
|
||||
fluid = std::string("INCOMP::ExampleSecCool");
|
||||
T = -5 + 273.15;
|
||||
p = 10e5;
|
||||
x = 0.4;
|
||||
std::vector<double> x_vec = std::vector<double>(1,x);
|
||||
|
||||
// Compare d
|
||||
val = 9.4844e+02;
|
||||
res = CoolProp::PropsSI("D","T",T,"P",p,fluid,x_vec);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(p);
|
||||
CAPTURE(x);
|
||||
CAPTURE(val);
|
||||
CAPTURE(res);
|
||||
CHECK( check_abs(val,res,acc) );
|
||||
}
|
||||
|
||||
// Compare cp
|
||||
val = 3.6304e+03;
|
||||
res = CoolProp::PropsSI("C","T",T,"P",p,fluid,x_vec);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(p);
|
||||
CAPTURE(x);
|
||||
CAPTURE(val);
|
||||
CAPTURE(res);
|
||||
CHECK( check_abs(val,res,acc) );
|
||||
}
|
||||
|
||||
fluid = std::string("INCOMP::ExamplePure");
|
||||
T = +55 + 273.15;
|
||||
p = 10e5;
|
||||
|
||||
// Compare d
|
||||
val = 7.3646e+02;
|
||||
res = CoolProp::PropsSI("D","T",T,"P",p,fluid);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(p);
|
||||
CAPTURE(x);
|
||||
CAPTURE(val);
|
||||
CAPTURE(res);
|
||||
CHECK( check_abs(val,res,acc) );
|
||||
}
|
||||
|
||||
// Compare cp
|
||||
val = 2.2580e+03;
|
||||
res = CoolProp::PropsSI("C","T",T,"P",p,fluid);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(p);
|
||||
CAPTURE(x);
|
||||
CAPTURE(val);
|
||||
CAPTURE(res);
|
||||
CHECK( check_abs(val,res,acc) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SECTION("Tests for the hardcoded fluids") {
|
||||
|
||||
// Prepare the results and compare them to the calculated values
|
||||
std::string fluid("INCOMP::LiBr");
|
||||
double acc = 0.0001;
|
||||
double T = 50 + 273.15;
|
||||
double p = 10e5;
|
||||
double x = 0.3;
|
||||
double val = 0;
|
||||
double res = 0;
|
||||
|
||||
// Compare different inputs
|
||||
// ... as vector
|
||||
val = 9.6212e+02;
|
||||
res = CoolProp::PropsSI("D","T",T,"P",p,fluid,std::vector<double>(1,x));
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(p);
|
||||
CAPTURE(x);
|
||||
CAPTURE(val);
|
||||
CAPTURE(res);
|
||||
CHECK( check_abs(val,res,acc) );
|
||||
}
|
||||
// ... as %
|
||||
res = CoolProp::PropsSI("D","T",T,"P",p,fluid+format("-%f%s",x*100.0,"%"));
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(p);
|
||||
CAPTURE(x);
|
||||
CAPTURE(val);
|
||||
CAPTURE(res);
|
||||
CHECK( check_abs(val,res,acc) );
|
||||
}
|
||||
// ... as mass fraction
|
||||
res = CoolProp::PropsSI("D","T",T,"P",p,fluid+format("[%f]",x));
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(p);
|
||||
CAPTURE(x);
|
||||
CAPTURE(val);
|
||||
CAPTURE(res);
|
||||
CHECK( check_abs(val,res,acc) );
|
||||
}
|
||||
|
||||
|
||||
fluid = std::string("INCOMP::ExampleSecCool");
|
||||
T = -5 + 273.15;
|
||||
p = 10e5;
|
||||
|
||||
@@ -583,12 +583,13 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
double acc = 0.0001;
|
||||
double T = 273.15+50;
|
||||
double p = 10e5;
|
||||
double x = xref;
|
||||
double val = 0;
|
||||
double res = 0;
|
||||
|
||||
// Compare density
|
||||
val = 824.4615702148608;
|
||||
res = XLT.rho(T,p);
|
||||
res = XLT.rho(T,p,x);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(val);
|
||||
@@ -598,7 +599,7 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
|
||||
// Compare cp
|
||||
val = 1834.7455527670554;
|
||||
res = XLT.c(T,p);
|
||||
res = XLT.c(T,p,x);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(val);
|
||||
@@ -608,7 +609,7 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
|
||||
// Compare s
|
||||
val = 145.59157247249246;
|
||||
res = XLT.s(T,p);
|
||||
res = XLT.s(T,p,x);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(val);
|
||||
@@ -617,7 +618,7 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
}
|
||||
|
||||
val = 0.0;
|
||||
res = XLT.s(Tref,pref);
|
||||
res = XLT.s(Tref,pref,xref);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(val);
|
||||
@@ -627,7 +628,7 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
|
||||
// Compare u
|
||||
val = 45212.407309106304;
|
||||
res = XLT.u(T,p);
|
||||
res = XLT.u(T,p,x);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(val);
|
||||
@@ -635,8 +636,8 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
CHECK( check_abs(val,res,acc) );
|
||||
}
|
||||
|
||||
val = href - pref/XLT.rho(Tref,pref);
|
||||
res = XLT.u(Tref,pref);
|
||||
val = href - pref/XLT.rho(Tref,pref,xref);
|
||||
res = XLT.u(Tref,pref,xref);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(val);
|
||||
@@ -646,7 +647,7 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
|
||||
// Compare h
|
||||
val = 46425.32011926845;
|
||||
res = XLT.h(T,p);
|
||||
res = XLT.h(T,p,x);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(val);
|
||||
@@ -655,7 +656,7 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
}
|
||||
|
||||
val = 0.0;
|
||||
res = XLT.h(Tref,pref);
|
||||
res = XLT.h(Tref,pref,xref);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(val);
|
||||
@@ -665,7 +666,7 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
|
||||
// Compare v
|
||||
val = 0.0008931435169681835;
|
||||
res = XLT.visc(T,p);
|
||||
res = XLT.visc(T,p,x);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(val);
|
||||
@@ -675,7 +676,7 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
|
||||
// Compare l
|
||||
val = 0.10410086156049088;
|
||||
res = XLT.cond(T,p);
|
||||
res = XLT.cond(T,p,x);
|
||||
{
|
||||
CAPTURE(T);
|
||||
CAPTURE(val);
|
||||
|
||||
@@ -5,6 +5,331 @@
|
||||
|
||||
namespace CoolProp{
|
||||
|
||||
/// Class to access Lithium-Bromide solutions
|
||||
/** Employs some basic wrapper-like functionality
|
||||
* to bridge the gap between the solution functions
|
||||
* used in the paper by Pátek and Klomfar:
|
||||
* http://dx.doi.org/10.1016/j.ijrefrig.2005.10.007
|
||||
*
|
||||
* We owe gratitude to the authors for providing
|
||||
* both access to the paper as well as the equations
|
||||
* in the form of C source code. */
|
||||
|
||||
double const LiBrSolution::M_H2O = 0.018015268; /* kg/mol, molar mass of H2O */
|
||||
double const LiBrSolution::M_LiBr = 0.08685; /* kg/mol, molar mass of LiBr */
|
||||
double const LiBrSolution::T0 = 221; /* K, constant */
|
||||
|
||||
/* Critical point of H2O */
|
||||
double const LiBrSolution::Tc_H2O = 647.096; /* K, temperature */
|
||||
double const LiBrSolution::pc_H2O = 22.064; /* MPa, pressure */
|
||||
double const LiBrSolution::rhoc_H2O = 17873; /* mol/m^3 (322 kg/m^3), molar density */
|
||||
double const LiBrSolution::hc_H2O = 37548.5; /* J/mol, molar enthalpy */
|
||||
double const LiBrSolution::sc_H2O = 79.3933; /* J/(mol.K) molar entropy*/
|
||||
|
||||
/*Triple point of H2O */
|
||||
double const LiBrSolution::Tt_H2O = 273.16; /* K, temperature */
|
||||
double const LiBrSolution::cpt_H2O = 76.0226; /* J/(mol.K), molar isobaric heat capacity*/
|
||||
|
||||
double LiBrSolution::ps_mix(double T, double x)
|
||||
/* Equation (1) */
|
||||
{
|
||||
static double m[8] = { 3.0, 4.0, 4.0, 8.0, 1.0, 1.0, 4.0, 6.0 };
|
||||
static double n[8] = { 0.0, 5.0, 6.0, 3.0, 0.0, 2.0, 6.0, 0.0 };
|
||||
static double t[8] = { 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 };
|
||||
static double a[8] = { -2.41303e2, 1.91750e7, -1.75521e8, 3.25430e7,
|
||||
3.92571e2, -2.12626e3, 1.85127e8, 1.91216e3 };
|
||||
double tau, suma = 0.0;
|
||||
int i;
|
||||
|
||||
tau = T / Tc_H2O;
|
||||
for (i = 0; i <= 7; i++)
|
||||
suma += a[i] * pow(x, m[i]) * pow(0.4 - x, n[i]) * pow(tau, t[i]);
|
||||
return (ps_H2O(T - suma));
|
||||
|
||||
} /* end function ps_mix */
|
||||
|
||||
double LiBrSolution::rho_mix(double T, double x)
|
||||
/* Equation (2) */
|
||||
{
|
||||
static double m[2] = { 1.0, 1.0 };
|
||||
static double n[2] = { 0.0, 6.0 };
|
||||
static double a[2] = { 1.746, 4.709 };
|
||||
|
||||
double tau, suma = 0.0;
|
||||
int i;
|
||||
|
||||
tau = T / Tc_H2O;
|
||||
for (i = 0; i <= 1; i++)
|
||||
suma += a[i] * pow(x, m[i]) * pow(tau, n[i]);
|
||||
|
||||
return ((1.0 - x) * rho_H2O(T) + rhoc_H2O * suma);
|
||||
|
||||
} /* end function rho_mix */
|
||||
|
||||
double LiBrSolution::cp_mix(double T, double x)
|
||||
/* Equation (3) */
|
||||
{
|
||||
static double m[8] = { 2.0, 3.0, 3.0, 3.0, 3.0, 2.0, 1.0, 1.0 };
|
||||
static double n[8] = { 0.0, 0.0, 1.0, 2.0, 3.0, 0.0, 3.0, 2.0 };
|
||||
static double t[8] = { 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0 };
|
||||
static double a[8] = { -1.42094e1, 4.04943e1, 1.11135e2, 2.29980e2,
|
||||
1.34526e3, -1.41010e-2, 1.24977e-2, -6.83209e-4 };
|
||||
|
||||
double tau, suma = 0.0;
|
||||
int i;
|
||||
|
||||
tau = Tc_H2O / (T - T0);
|
||||
for (i = 0; i <= 7; i++)
|
||||
suma += a[i] * pow(x, m[i]) * pow(0.4 - x, n[i]) * pow(tau, t[i]);
|
||||
|
||||
return ((1.0 - x) * cp_H2O(T) + cpt_H2O * suma);
|
||||
|
||||
} /* end function cp_mix */
|
||||
|
||||
double LiBrSolution::h_mix(double T, double x)
|
||||
/* Equation (4) */
|
||||
{
|
||||
static double m[30] = { 1.0, 1.0, 2.0, 3.0, 6.0, 1.0, 3.0, 5.0, 4.0,
|
||||
5.0, 5.0, 6.0, 6.0, 1.0, 2.0, 2.0, 2.0, 5.0, 6.0, 7.0, 1.0, 1.0,
|
||||
2.0, 2.0, 2.0, 3.0, 1.0, 1.0, 1.0, 1.0 };
|
||||
|
||||
static double n[30] = { 0.0, 1.0, 6.0, 6.0, 2.0, 0.0, 0.0, 4.0, 0.0,
|
||||
4.0, 5.0, 5.0, 6.0, 0.0, 3.0, 5.0, 7.0, 0.0, 3.0, 1.0, 0.0, 4.0,
|
||||
2.0, 6.0, 7.0, 0.0, 0.0, 1.0, 2.0, 3.0 };
|
||||
|
||||
static double t[30] = { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 2.0,
|
||||
2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0,
|
||||
4.0, 4.0, 4.0, 4.0, 5.0, 5.0, 5.0, 5.0 };
|
||||
|
||||
static double a[30] = { 2.27431, -7.99511, 3.85239e2, -1.63940e4,
|
||||
-4.22562e2, 1.13314e-1, -8.33474, -1.73833e4, 6.49763,
|
||||
3.24552e3, -1.34643e4, 3.99322e4, -2.58877e5, -1.93046e-3,
|
||||
2.80616, -4.04479e1, 1.45342e2, -2.74873, -4.49743e2,
|
||||
-1.21794e1, -5.83739e-3, 2.33910e-1, 3.41888e-1, 8.85259,
|
||||
-1.78731e1, 7.35179e-2, -1.79430e-4, 1.84261e-3, -6.24282e-3,
|
||||
6.84765e-3 };
|
||||
|
||||
double tau, suma = 0.0;
|
||||
int i;
|
||||
|
||||
tau = Tc_H2O / (T - T0);
|
||||
for (i = 0; i <= 29; i++)
|
||||
suma += a[i] * pow(x, m[i]) * pow(0.4 - x, n[i]) * pow(tau, t[i]);
|
||||
|
||||
return ((1.0 - x) * h_H2O(T) + hc_H2O * suma);
|
||||
|
||||
} /* end function h_mix */
|
||||
|
||||
double LiBrSolution::s_mix(double T, double x)
|
||||
/* Equation (5) */
|
||||
{
|
||||
static double m[29] = { 1.0, 1.0, 2.0, 3.0, 6.0, 1.0, 3.0, 5.0, 1.0,
|
||||
2.0, 2.0, 4.0, 5.0, 5.0, 6.0, 6.0, 1.0, 3.0, 5.0, 7.0, 1.0, 1.0,
|
||||
1.0, 2.0, 3.0, 1.0, 1.0, 1.0, 1.0 };
|
||||
|
||||
static double n[29] = { 0.0, 1.0, 6.0, 6.0, 2.0, 0.0, 0.0, 4.0, 0.0,
|
||||
0.0, 4.0, 0.0, 4.0, 5.0, 2.0, 5.0, 0.0, 4.0, 0.0, 1.0, 0.0, 2.0,
|
||||
4.0, 7.0, 1.0, 0.0, 1.0, 2.0, 3.0 };
|
||||
|
||||
static double t[29] = { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 2.0,
|
||||
2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0,
|
||||
4.0, 4.0, 4.0, 5.0, 5.0, 5.0, 5.0 };
|
||||
|
||||
static double a[29] = { 1.53091, -4.52564, 6.98302e+2, -2.16664e+4,
|
||||
-1.47533e+3, 8.47012e-2, -6.59523, -2.95331e+4, 9.56314e-3,
|
||||
-1.88679e-1, 9.31752, 5.78104, 1.38931e+4, -1.71762e+4,
|
||||
4.15108e+2, -5.55647e+4, -4.23409e-3, 3.05242e+1, -1.67620,
|
||||
1.48283e+1, 3.03055e-3, -4.01810e-2, 1.49252e-1, 2.59240,
|
||||
-1.77421e-1, -6.99650e-5, 6.05007e-4, -1.65228e-3, 1.22966e-3 };
|
||||
|
||||
double tau, suma = 0.0;
|
||||
int i;
|
||||
|
||||
tau = Tc_H2O / (T - T0);
|
||||
for (i = 0; i <= 28; i++)
|
||||
suma += a[i] * pow(x, m[i]) * pow(0.4 - x, n[i]) * pow(tau, t[i]);
|
||||
|
||||
return ((1.0 - x) * s_H2O(T) + sc_H2O * suma);
|
||||
|
||||
} /* end function s_mix */
|
||||
|
||||
double LiBrSolution::ps_H2O(double T)
|
||||
/* Equation (28) */
|
||||
{
|
||||
static double a[7] = { 0.0, -7.85951783, 1.84408259, -11.7866497,
|
||||
22.6807411, -15.9618719, 1.80122502 };
|
||||
|
||||
double tau, ps;
|
||||
|
||||
tau = 1 - T / Tc_H2O;
|
||||
|
||||
ps = pc_H2O
|
||||
* exp(
|
||||
Tc_H2O / T
|
||||
* (a[1] * tau + a[2] * pow(tau, 1.5)
|
||||
+ a[3] * pow(tau, 3.0)
|
||||
+ a[4] * pow(tau, 3.5)
|
||||
+ a[5] * pow(tau, 4.0)
|
||||
+ a[6] * pow(tau, 7.5)));
|
||||
|
||||
return (ps * 1.0e6);
|
||||
|
||||
} /* end function ps_H2O */
|
||||
|
||||
double LiBrSolution::rho_H2O(double T)
|
||||
/* Equation (29) */
|
||||
{
|
||||
static double b[7] = { 0.0, 1.99274064, 1.09965342, -0.510839303,
|
||||
-1.75493479, -45.5170352, -6.7469445e5 };
|
||||
double theta, rho;
|
||||
|
||||
theta = 1.0 - T / Tc_H2O;
|
||||
|
||||
rho = rhoc_H2O
|
||||
* (1.0 + b[1] * pow(theta, 1.0 / 3.0)
|
||||
+ b[2] * pow(theta, 2.0 / 3.0)
|
||||
+ b[3] * pow(theta, 5.0 / 3.0)
|
||||
+ b[4] * pow(theta, 16.0 / 3.0)
|
||||
+ b[5] * pow(theta, 43.0 / 3.0)
|
||||
+ b[6] * pow(theta, 110.0 / 3.0));
|
||||
|
||||
return (rho);
|
||||
} /* end function rho_H2O */
|
||||
|
||||
double LiBrSolution::cp_H2O(double T)
|
||||
/* Equation (30) */
|
||||
{
|
||||
static double a[5] =
|
||||
{ 1.38801, -2.95318, 3.18721, -0.645473, 9.18946e5 };
|
||||
static double b[5] = { 0.0, 2.0, 3.0, 6.0, 34.0 };
|
||||
static double c[5] = { 0.0, 2.0, 3.0, 5.0, 0.0 };
|
||||
|
||||
double suma = 0.0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= 4; i++)
|
||||
suma += a[i] * exp(b[i] * log(1.0 - T / Tc_H2O))
|
||||
* exp(c[i] * log(T / Tt_H2O));
|
||||
|
||||
return (cpt_H2O * suma);
|
||||
|
||||
} /* end function cp_H2O */
|
||||
|
||||
double LiBrSolution::h_H2O(double T)
|
||||
/* Equation (31) */
|
||||
{
|
||||
static double a[4] = { -4.37196e-1, 3.03440e-1, -1.29582, -1.76410e-1 };
|
||||
static double alpha[4] = { 1.0 / 3.0, 2.0 / 3.0, 5.0 / 6.0, 21.0 / 6.0 };
|
||||
|
||||
double suma = 0.0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= 3; i++)
|
||||
suma += a[i] * exp(alpha[i] * log(1.0 - T / Tc_H2O));
|
||||
|
||||
return (hc_H2O * (1.0 + suma));
|
||||
|
||||
} /* end function h_H2O */
|
||||
|
||||
double LiBrSolution::s_H2O(double T)
|
||||
/* Equation (32) */
|
||||
{
|
||||
static double a[4] = { -3.34112e-1, -8.47987e-1, -9.11980e-1, -1.64046 };
|
||||
static double alpha[4] = { 1.0 / 3.0, 3.0 / 3.0, 8.0 / 3.0, 24.0 / 3.0 };
|
||||
|
||||
double suma = 0.0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= 3; i++)
|
||||
suma += a[i] * exp(alpha[i] * log(1.0 - T / Tc_H2O));
|
||||
|
||||
return (sc_H2O * (1.0 + suma));
|
||||
|
||||
} /* end function s_H2O */
|
||||
|
||||
|
||||
/** Finished with the code from the paper. Now we need to
|
||||
* convert the molar values to mass-based units. */
|
||||
double LiBrSolution::massToMole(double w)
|
||||
/* Equation (7) */
|
||||
{
|
||||
return (w/M_LiBr)/(w/M_LiBr+(1.-w)/M_H2O);
|
||||
//return (w*M_LiBr)/(w*M_LiBr+(1.-w)*M_H2O);
|
||||
}
|
||||
|
||||
double LiBrSolution::molarToSpecific(double w, double value)
|
||||
/* Equation (7,8) */
|
||||
{
|
||||
double x = massToMole(w);
|
||||
//return w/(x*M_LiBr) * value;
|
||||
return 1. / ( x*M_LiBr + (1.-x)*M_H2O ) * value;
|
||||
}
|
||||
|
||||
bool const LiBrSolution::debug = false;
|
||||
|
||||
|
||||
|
||||
LiBrSolution::LiBrSolution(){
|
||||
name = std::string("LiBr");
|
||||
description = std::string("Lithium-Bromide solution from Patek2006");
|
||||
reference = std::string("Patek2006");
|
||||
|
||||
Tmin = 273.00;
|
||||
Tmax = 500.00;
|
||||
TminPsat = Tmin;
|
||||
|
||||
xmin = 0.0;
|
||||
xmax = 1.0;
|
||||
|
||||
xref = 0.0;
|
||||
Tref = 0.0;
|
||||
pref = 0.0;
|
||||
href = 0.0;
|
||||
sref = 0.0;
|
||||
uref = 0.0;
|
||||
rhoref = 0.0;
|
||||
xbase = 0.0;
|
||||
Tbase = 0.0;
|
||||
|
||||
};
|
||||
|
||||
double LiBrSolution::rho(double T_K, double p, double x){
|
||||
checkTPX(T_K, p, x);
|
||||
return 1./molarToSpecific(x, 1./rho_mix(T_K,massToMole(x)));
|
||||
}
|
||||
double LiBrSolution::c(double T_K, double p, double x){
|
||||
checkTPX(T_K, p, x);
|
||||
return molarToSpecific(x, cp_mix(T_K,massToMole(x)));
|
||||
}
|
||||
//double h(double T_K, double p, double x){
|
||||
// return h_u(T_K,p,x);
|
||||
//}
|
||||
double LiBrSolution::s(double T_K, double p, double x){
|
||||
checkTPX(T_K, p, x);
|
||||
return molarToSpecific(x, s_mix(T_K,massToMole(x)));
|
||||
}
|
||||
double LiBrSolution::visc(double T_K, double p, double x){
|
||||
throw ValueError("Viscosity is not defined for LiBr-solutions.");
|
||||
}
|
||||
double LiBrSolution::cond(double T_K, double p, double x){
|
||||
throw ValueError("Thermal conductivity is not defined for LiBr-solutions.");
|
||||
}
|
||||
double LiBrSolution::u(double T_K, double p, double x){
|
||||
checkTPX(T_K, p, x);
|
||||
return molarToSpecific(x, h_mix(T_K,massToMole(x)));
|
||||
}
|
||||
double LiBrSolution::psat(double T_K, double x){
|
||||
//checkT(T_K,p,x);
|
||||
if (debug) throw ValueError(format("Your concentration is %f in kg/kg and %f in mol/mol.",x,massToMole(x)));
|
||||
return ps_mix(T_K,massToMole(x));
|
||||
};
|
||||
double LiBrSolution::Tfreeze(double p, double x){
|
||||
if (debug) throw ValueError(format("No freezing point data available for Lithium-Bromide: p=%f, x=%f",p,x));
|
||||
return Tmin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// A general function to parse the json files that hold the coefficient matrices
|
||||
IncompressibleData JSONIncompressibleLibrary::parse_coefficients(rapidjson::Value &obj, std::string id, bool vital){
|
||||
IncompressibleData fluidData;
|
||||
@@ -145,6 +470,25 @@ void JSONIncompressibleLibrary::add_one(rapidjson::Value &fluid_json) {
|
||||
|
||||
};
|
||||
|
||||
void JSONIncompressibleLibrary::add_obj(IncompressibleFluid fluid_obj) {
|
||||
_is_empty = false;
|
||||
|
||||
// Get the next index for this fluid
|
||||
std::size_t index = fluid_map.size();
|
||||
|
||||
// Add index->fluid mapping
|
||||
fluid_map[index] = IncompressibleFluid(fluid_obj);
|
||||
|
||||
// Create an instance of the fluid
|
||||
IncompressibleFluid &fluid = fluid_map[index];
|
||||
|
||||
/// A function to check coefficients and equation types.
|
||||
fluid.validate();
|
||||
|
||||
// Add name->index mapping
|
||||
string_to_index_map[fluid.getName()] = index;
|
||||
}
|
||||
|
||||
/// Get an IncompressibleFluid instance stored in this library
|
||||
/**
|
||||
@param name Name of the fluid
|
||||
@@ -219,6 +563,7 @@ void load_incompressible_library()
|
||||
} else{
|
||||
try{library.add_many(dd);}catch(std::exception &e){std::cout << e.what() << std::endl;}
|
||||
}
|
||||
library.add_obj(LiBrSolution());
|
||||
}
|
||||
|
||||
JSONIncompressibleLibrary & get_incompressible_library(void){
|
||||
|
||||
@@ -13,6 +13,139 @@ namespace CoolProp{
|
||||
|
||||
// Forward declaration of the necessary debug function to avoid including the whole header
|
||||
extern int get_debug_level();
|
||||
|
||||
|
||||
/// Class to access Lithium-Bromide solutions
|
||||
/** Employs some basic wrapper-like functionality
|
||||
* to bridge the gap between the solution functions
|
||||
* used in the paper by Pátek and Klomfar:
|
||||
* http://dx.doi.org/10.1016/j.ijrefrig.2005.10.007
|
||||
*
|
||||
* We owe gratitude to the authors for providing
|
||||
* both access to the paper as well as the equations
|
||||
* in the form of C source code. */
|
||||
class LiBrSolution : public IncompressibleFluid{
|
||||
|
||||
protected:
|
||||
static double const M_H2O; /* kg/mol, molar mass of H2O */
|
||||
static double const M_LiBr; /* kg/mol, molar mass of LiBr */
|
||||
static double const T0; /* K, constant */
|
||||
|
||||
/* Critical point of H2O */
|
||||
static double const Tc_H2O; /* K, temperature */
|
||||
static double const pc_H2O; /* MPa, pressure */
|
||||
static double const rhoc_H2O; /* mol/m^3 (322 kg/m^3), molar density */
|
||||
static double const hc_H2O; /* J/mol, molar enthalpy */
|
||||
static double const sc_H2O; /* J/(mol.K) molar entropy*/
|
||||
|
||||
/*Triple point of H2O */
|
||||
static double const Tt_H2O; /* K, temperature */
|
||||
static double const cpt_H2O; /* J/(mol.K), molar isobaric heat capacity*/
|
||||
|
||||
double ps_mix(double T, double x);
|
||||
double rho_mix(double T, double x);
|
||||
double cp_mix(double T, double x);
|
||||
double h_mix(double T, double x);
|
||||
double s_mix(double T, double x);
|
||||
double ps_H2O(double T);
|
||||
double rho_H2O(double T);
|
||||
double cp_H2O(double T);
|
||||
double h_H2O(double T);
|
||||
double s_H2O(double T);
|
||||
|
||||
/** Finished with the code from the paper. Now we need to
|
||||
* convert the molar values to mass-based units. */
|
||||
double massToMole(double w);
|
||||
double molarToSpecific(double w, double value);
|
||||
|
||||
static const bool debug;
|
||||
|
||||
public:
|
||||
|
||||
LiBrSolution();
|
||||
|
||||
double rho(double T, double p, double x);
|
||||
double c(double T, double p, double x);
|
||||
//double h(double T_K, double p, double x);
|
||||
double s(double T, double p, double x);
|
||||
double visc(double T, double p, double x);
|
||||
double cond(double T, double p, double x);
|
||||
double u(double T, double p, double x);
|
||||
double psat(double T, double x);
|
||||
double Tfreeze(double p, double x);
|
||||
|
||||
/* Some functions can be inverted directly, those are listed
|
||||
* here. It is also possible to solve for other quantities, but
|
||||
* that involves some more sophisticated processing and is not
|
||||
* done here, but in the backend, T(h,p) for example.
|
||||
*/
|
||||
/// Temperature as a function of density, pressure and composition.
|
||||
double T_rho (double Dmass, double p, double x){throw NotImplementedError(format("%s (%d): T from density is not implemented for LiBr.",__FILE__,__LINE__));}
|
||||
/// Temperature as a function of heat capacities as a function of temperature, pressure and composition.
|
||||
double T_c (double Cmass, double p, double x){throw NotImplementedError(format("%s (%d): T from heat capacity is not implemented for LiBr.",__FILE__,__LINE__));}
|
||||
/// Temperature as a function of entropy as a function of temperature, pressure and composition.
|
||||
double T_s (double Smass, double p, double x){throw NotImplementedError(format("%s (%d): T from entropy is not implemented for LiBr.",__FILE__,__LINE__));}
|
||||
/// Temperature as a function of internal energy as a function of temperature, pressure and composition.
|
||||
double T_u (double Umass, double p, double x){throw NotImplementedError(format("%s (%d): T from internal energy is not implemented for LiBr.",__FILE__,__LINE__));}
|
||||
/// Temperature as a function of enthalpy, pressure and composition.
|
||||
//double T_h (double Hmass, double p, double x){throw NotImplementedError(format("%s (%d): T from enthalpy is not implemented in the fluid, use the backend.",__FILE__,__LINE__));}
|
||||
/// Viscosity as a function of temperature, pressure and composition.
|
||||
double T_visc(double visc, double p, double x){throw NotImplementedError(format("%s (%d): T from viscosity is not implemented.",__FILE__,__LINE__));}
|
||||
/// Thermal conductivity as a function of temperature, pressure and composition.
|
||||
double T_cond(double cond, double p, double x){throw NotImplementedError(format("%s (%d): T from conductivity is not implemented.",__FILE__,__LINE__));}
|
||||
/// Saturation pressure as a function of temperature and composition.
|
||||
double T_psat(double psat, double x){throw NotImplementedError(format("%s (%d): T from psat is not implemented.",__FILE__,__LINE__));}
|
||||
/// Composition as a function of freezing temperature and pressure.
|
||||
double x_Tfreeze( double Tfreeze, double p){throw NotImplementedError(format("%s (%d): x from T_freeze is not implemented.",__FILE__,__LINE__));}
|
||||
|
||||
|
||||
/// Overwrite some standard functions that cannot be used with LiBr
|
||||
void setName(std::string name){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setDescription(std::string description){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setReference(std::string reference){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setTmax(double Tmax){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setTmin(double Tmin){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setxmax(double xmax){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setxmin(double xmin){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setTminPsat(double TminPsat){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
|
||||
void setTbase(double Tbase){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setxbase(double xbase){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
|
||||
void setDensity(IncompressibleData density){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setSpecificHeat(IncompressibleData specific_heat){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setViscosity(IncompressibleData viscosity){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setConductivity(IncompressibleData conductivity){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setPsat(IncompressibleData p_sat){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setTfreeze(IncompressibleData T_freeze){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setVolToMass(IncompressibleData volToMass){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
void setMassToMole(IncompressibleData massToMole){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
|
||||
|
||||
bool is_pure() {return false;};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// A container for the fluid parameters for the incompressible fluids
|
||||
/**
|
||||
@@ -45,6 +178,7 @@ public:
|
||||
/// Add all the fluid entries in the rapidjson::Value instance passed in
|
||||
void add_many(rapidjson::Value &listing);
|
||||
void add_one(rapidjson::Value &fluid_json);
|
||||
void add_obj(IncompressibleFluid fluid_obj);
|
||||
|
||||
/// Get an IncompressibleFluid instance stored in this library
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user