39 size_t r = coeffs.rows(),
c = coeffs.cols();
40 if (
strict && (r != 3 ||
c != 1)) {
41 throw ValueError(
format(
"%s (%d): You have to provide a 3,1 matrix of coefficients, not (%d,%d).", __FILE__, __LINE__, r,
c));
45 auto fnc = [&](
double x) {
return exp((
double)(coeffs[0] / (x) - coeffs[2])); } ;
46 double x_den = (y - ybase) + coeffs[1];
49 if (x_den < x_lo || x_den > x_hi) {
56 const double f_lo = fnc(x_lo);
57 const double f_hi = fnc(x_hi);
59 return (f_hi - f_lo) / (x_hi - x_lo) * (x_den - x_lo) + f_lo;
65 size_t r = coeffs.rows(),
c = coeffs.cols();
66 if (
strict && (r != 3 ||
c != 1)) {
67 throw ValueError(
format(
"%s (%d): You have to provide a 3,1 matrix of coefficients, not (%d,%d).", __FILE__, __LINE__, r,
c));
71 auto fnc = [&](
double x) {
return exp((
double)(log((
double)(1.0 / (x) + 1.0 / (x) / (x))) * coeffs[1] + coeffs[2])); } ;
72 double x_den = (y - ybase) + coeffs[0];
75 if (x_den < x_lo || x_den > x_hi) {
82 const double f_lo = fnc(x_lo);
83 const double f_hi = fnc(x_hi);
85 return (f_hi - f_lo) / (x_hi - x_lo) * (x_den - x_lo) + f_lo;
92 Eigen::MatrixXd coeffs;
94 offset = data.
coeffs(0, 0);
95 if (r == 1 &&
c > 1) {
96 coeffs = Eigen::MatrixXd(data.
coeffs.block(0, 1, r,
c - 1));
98 }
else if (r > 1 &&
c == 1) {
99 coeffs = Eigen::MatrixXd(data.
coeffs.block(1, 0, r - 1,
c));
102 throw ValueError(
format(
"%s (%d): You have to provide a vector (1D matrix) of coefficients, not (%d,%d).", __FILE__, __LINE__, r,
c));
106 throw ValueError(
format(
"%s (%d): You have to provide a vector (1D matrix) of coefficients, not (%d,%d).", __FILE__, __LINE__, r,
c));
123 throw ValueError(
format(
"%s (%d): The function type is not specified (\"[%d]\"), are you sure the coefficients have been set?", __FILE__,
137 throw ValueError(
format(
"%s (%d): The function type is not specified (\"[%d]\"), are you sure the coefficients have been set?", __FILE__,
140 throw ValueError(
format(
"%s (%d): There is no predefined way to use this function type \"[%d]\" for specific heat.", __FILE__, __LINE__,
159 throw ValueError(
format(
"%s (%d): The function type is not specified (\"[%d]\"), are you sure the coefficients have been set?", __FILE__,
179 throw ValueError(
format(
"%s (%d): The function type is not specified (\"[%d]\"), are you sure the coefficients have been set?", __FILE__,
187 if (T <= this->
TminPsat)
return 0.0;
200 throw ValueError(
format(
"%s (%d): The function type is not specified (\"[%d]\"), are you sure the coefficients have been set?", __FILE__,
220 throw ValueError(
format(
"%s (%d): The function type is not specified (\"[%d]\"), are you sure the coefficients have been set?", __FILE__,
237 throw ValueError(
format(
"%s (%d): The function type is not specified (\"[%d]\"), are you sure the coefficients have been set?", __FILE__,
241 format(
"%s (%d): There is no predefined way to use this function type \"[%d]\" for density.", __FILE__, __LINE__,
density.
type));
252 throw ValueError(
format(
"%s (%d): The function type is not specified (\"[%d]\"), are you sure the coefficients have been set?", __FILE__,
256 format(
"%s (%d): There is no predefined way to use this function type \"[%d]\" for entropy.", __FILE__, __LINE__,
specific_heat.
type));
267 throw ValueError(
format(
"%s (%d): The function type is not specified (\"[%d]\"), are you sure the coefficients have been set?", __FILE__,
271 format(
"%s (%d): There is no predefined way to use this function type \"[%d]\" for entropy.", __FILE__, __LINE__,
specific_heat.
type));
395 double d_raw = Dmass;
400 throw ValueError(
format(
"%s (%d): The function type is not specified (\"[%d]\"), are you sure the coefficients have been set?", __FILE__,
403 throw ValueError(
format(
"%s (%d): There is no predefined way to use this function type \"[%d]\" for inverse density.", __FILE__, __LINE__,
409 double c_raw = Cmass;
414 throw ValueError(
format(
"%s (%d): The function type is not specified (\"[%d]\"), are you sure the coefficients have been set?", __FILE__,
417 throw ValueError(
format(
"%s (%d): There is no predefined way to use this function type \"[%d]\" for inverse specific heat.", __FILE__,
433 if (
Tmin <= 0.)
throw ValueError(
"Please specify the minimum temperature.");
434 if (
Tmax <= 0.)
throw ValueError(
"Please specify the maximum temperature.");
438 if (T < TF)
throw ValueError(
format(
"Your temperature %f is below the freezing point of %f.", T, TF));
452 if (p < 0.0)
throw ValueError(
format(
"You cannot use negative pressures: %f < %f. ", p, 0.0));
453 if (ps > 0.0 && p < ps)
throw ValueError(
format(
"Equations are valid for liquid phase only: %f < %f (psat). ", p, ps));
462 if (xmin < 0.0 || xmin > 1.0)
throw ValueError(
"Please specify the minimum concentration between 0 and 1.");
463 if (xmax < 0.0 || xmax > 1.0)
throw ValueError(
"Please specify the maximum concentration between 0 and 1.");
478 # include <catch2/catch_all.hpp>
481 Eigen::MatrixXd makeMatrix(
const std::vector<double>& coefficients) {
483 std::vector<std::vector<double>> matrix;
484 std::vector<double> tmpVector;
487 tmpVector.push_back(coefficients[0]);
488 tmpVector.push_back(coefficients[6]);
489 tmpVector.push_back(coefficients[11]);
490 tmpVector.push_back(coefficients[15]);
491 matrix.push_back(tmpVector);
494 tmpVector.push_back(coefficients[1] * 100.0);
495 tmpVector.push_back(coefficients[7] * 100.0);
496 tmpVector.push_back(coefficients[12] * 100.0);
497 tmpVector.push_back(coefficients[16] * 100.0);
498 matrix.push_back(tmpVector);
501 tmpVector.push_back(coefficients[2] * 100.0 * 100.0);
502 tmpVector.push_back(coefficients[8] * 100.0 * 100.0);
503 tmpVector.push_back(coefficients[13] * 100.0 * 100.0);
504 tmpVector.push_back(coefficients[17] * 100.0 * 100.0);
505 matrix.push_back(tmpVector);
508 tmpVector.push_back(coefficients[3] * 100.0 * 100.0 * 100.0);
509 tmpVector.push_back(coefficients[9] * 100.0 * 100.0 * 100.0);
510 tmpVector.push_back(coefficients[14] * 100.0 * 100.0 * 100.0);
511 tmpVector.push_back(0.0);
512 matrix.push_back(tmpVector);
515 tmpVector.push_back(coefficients[4] * 100.0 * 100.0 * 100.0 * 100.0);
516 tmpVector.push_back(coefficients[10] * 100.0 * 100.0 * 100.0 * 100.0);
517 tmpVector.push_back(0.0);
518 tmpVector.push_back(0.0);
519 matrix.push_back(tmpVector);
522 tmpVector.push_back(coefficients[5] * 100.0 * 100.0 * 100.0 * 100.0 * 100.0);
523 tmpVector.push_back(0.0);
524 tmpVector.push_back(0.0);
525 tmpVector.push_back(0.0);
526 matrix.push_back(tmpVector);
532 TEST_CASE(
"Internal consistency checks and example use cases for the incompressible fluids",
"[IncompressibleFluids]") {
535 std::vector<double> tmpVector;
536 std::vector<std::vector<double>> tmpMatrix;
538 SECTION(
"Test case for \"SylthermXLT\" by Dow Chemicals") {
540 std::vector<double> cRho;
541 cRho.push_back(+1.1563685145E+03);
542 cRho.push_back(-1.0269048032E+00);
543 cRho.push_back(-9.3506079577E-07);
544 cRho.push_back(+1.0368116627E-09);
549 std::vector<double> cHeat;
550 cHeat.push_back(+1.1562261074E+03);
551 cHeat.push_back(+2.0994549103E+00);
552 cHeat.push_back(+7.7175381057E-07);
553 cHeat.push_back(-3.7008444051E-20);
558 std::vector<double> cCond;
559 cCond.push_back(+1.6121957379E-01);
560 cCond.push_back(-1.3023781944E-04);
561 cCond.push_back(-1.4395238766E-07);
566 std::vector<double> cVisc;
567 cVisc.push_back(+1.0337654989E+03);
568 cVisc.push_back(-4.3322764383E+01);
569 cVisc.push_back(+1.0715062356E+01);
604 double T = 273.15 + 50;
609 val = 824.4615702148608;
610 res = XLT.
rho(T, p, x);
619 val = 1834.7455527670554;
620 res = XLT.
c(T, p, x);
629 CHECK_THROWS(XLT.
s(T, p, x));
630 CHECK_THROWS(XLT.
h(T, p, x));
631 CHECK_THROWS(XLT.
u(T, p, x));
634 val = 0.0008931435169681835;
635 res = XLT.
visc(T, p, x);
644 val = 0.10410086156049088;
645 res = XLT.
cond(T, p, x);
654 SECTION(
"Test case for Methanol from SecCool") {
660 double T = 273.15 + 10;
667 expected = 963.2886528091547;
668 actual = CH3OH.
rho(T, p, x);
679 expected = 3993.9748117022423;
680 actual = CH3OH.
c(T, p, x);
691 CHECK_THROWS(CH3OH.
s(T, p, x));
692 CHECK_THROWS(CH3OH.
h(T, p, x));
693 CHECK_THROWS(CH3OH.
u(T, p, x));
696 expected = 0.0023970245009602097;
697 actual = CH3OH.
visc(T, p, x) / 1e3;
710 expected = 0.44791148414693727;
711 actual = CH3OH.
cond(T, p, x);
724 expected = -20.02 + 273.15;