23 #define LIST_OF_DERIVATIVE_VARIABLES \
29 X(d2alphar_ddelta_dtau) \
31 X(d3alphar_ddelta_dtau2) \
32 X(d3alphar_ddelta2_dtau) \
35 X(d4alphar_ddelta3_dtau) \
36 X(d4alphar_ddelta2_dtau2) \
37 X(d4alphar_ddelta_dtau3) \
39 X(delta_x_dalphar_ddelta) \
40 X(tau_x_dalphar_dtau) \
41 X(delta2_x_d2alphar_ddelta2) \
42 X(deltatau_x_d2alphar_ddelta_dtau) \
43 X(tau2_x_d2alphar_dtau2)
47 #define X(name) CoolPropDbl name;
53 #define X(name) name = v;
59 #define X(name) _new.name = name + other.name;
66 #define X(name) _new.name = name * other;
77 double get(std::size_t itau, std::size_t idelta) {
81 }
else if (idelta == 1) {
82 return dalphar_ddelta;
83 }
else if (idelta == 2) {
84 return d2alphar_ddelta2;
85 }
else if (idelta == 3) {
86 return d3alphar_ddelta3;
87 }
else if (idelta == 4) {
88 return d4alphar_ddelta4;
92 }
else if (itau == 1) {
95 }
else if (idelta == 1) {
96 return d2alphar_ddelta_dtau;
97 }
else if (idelta == 2) {
98 return d3alphar_ddelta2_dtau;
99 }
else if (idelta == 3) {
100 return d4alphar_ddelta3_dtau;
104 }
else if (itau == 2) {
106 return d2alphar_dtau2;
107 }
else if (idelta == 1) {
108 return d3alphar_ddelta_dtau2;
109 }
else if (idelta == 2) {
110 return d4alphar_ddelta2_dtau2;
114 }
else if (itau == 3) {
116 return d3alphar_dtau3;
117 }
else if (idelta == 1) {
118 return d4alphar_ddelta_dtau3;
122 }
else if (itau == 4) {
124 return d4alphar_dtau4;
133 #undef LIST_OF_DERIVATIVE_VARIABLES
173 all(tau, delta, deriv);
182 all(tau, delta, deriv);
183 return deriv.dalphar_dtau;
191 all(tau, delta, deriv);
192 return deriv.d2alphar_dtau2;
200 all(tau, delta, deriv);
201 return deriv.d2alphar_ddelta_dtau;
209 all(tau, delta, deriv);
210 return deriv.dalphar_ddelta;
218 all(tau, delta, deriv);
219 return deriv.d2alphar_ddelta2;
227 all(tau, delta, deriv);
228 return deriv.d3alphar_ddelta2_dtau;
236 all(tau, delta, deriv);
237 return deriv.d3alphar_ddelta_dtau2;
245 all(tau, delta, deriv);
246 return deriv.d3alphar_dtau3;
254 all(tau, delta, deriv);
255 return deriv.d3alphar_ddelta3;
263 all(tau, delta, deriv);
264 return deriv.d4alphar_dtau4;
268 all(tau, delta, deriv);
269 return deriv.d4alphar_ddelta_dtau3;
273 all(tau, delta, deriv);
274 return deriv.d4alphar_ddelta2_dtau2;
278 all(tau, delta, deriv);
279 return deriv.d4alphar_ddelta3_dtau;
283 all(tau, delta, deriv);
284 return deriv.d4alphar_ddelta4;
296 CoolPropDbl c,
l_double,
omega,
m_double,
eta1,
epsilon1,
eta2,
epsilon2,
beta1,
gamma1,
beta2,
gamma2;
337 std::vector<CoolPropDbl>
s;
342 std::vector<double>
n,
d,
t,
c,
l_double,
omega,
m_double,
eta1,
epsilon1,
eta2,
epsilon2,
beta1,
gamma1,
beta2,
gamma2;
348 std::vector<ResidualHelmholtzGeneralizedExponentialElement>
elements;
357 void add_Power(
const std::vector<CoolPropDbl>&
n,
const std::vector<CoolPropDbl>&
d,
const std::vector<CoolPropDbl>&
t,
358 const std::vector<CoolPropDbl>& l) {
359 for (std::size_t i = 0; i <
n.size(); ++i) {
379 void add_Exponential(
const std::vector<CoolPropDbl>&
n,
const std::vector<CoolPropDbl>&
d,
const std::vector<CoolPropDbl>&
t,
380 const std::vector<CoolPropDbl>& g,
const std::vector<CoolPropDbl>& l) {
381 for (std::size_t i = 0; i <
n.size(); ++i) {
398 void add_Gaussian(
const std::vector<CoolPropDbl>&
n,
const std::vector<CoolPropDbl>&
d,
const std::vector<CoolPropDbl>&
t,
399 const std::vector<CoolPropDbl>& eta,
const std::vector<CoolPropDbl>& epsilon,
const std::vector<CoolPropDbl>& beta,
400 const std::vector<CoolPropDbl>& gamma) {
401 for (std::size_t i = 0; i <
n.size(); ++i) {
420 void add_GERG2008Gaussian(
const std::vector<CoolPropDbl>&
n,
const std::vector<CoolPropDbl>&
d,
const std::vector<CoolPropDbl>&
t,
421 const std::vector<CoolPropDbl>& eta,
const std::vector<CoolPropDbl>& epsilon,
const std::vector<CoolPropDbl>& beta,
422 const std::vector<CoolPropDbl>& gamma) {
423 for (std::size_t i = 0; i <
n.size(); ++i) {
442 void add_Lemmon2005(
const std::vector<CoolPropDbl>&
n,
const std::vector<CoolPropDbl>&
d,
const std::vector<CoolPropDbl>&
t,
443 const std::vector<CoolPropDbl>& l,
const std::vector<CoolPropDbl>& m) {
444 for (std::size_t i = 0; i <
n.size(); ++i) {
476 for (std::size_t i = 0; i <
elements.size(); ++i) {
505 void to_json(rapidjson::Value& el, rapidjson::Document& doc);
520 std::vector<CoolPropDbl>
s;
521 std::vector<ResidualHelmholtzNonAnalyticElement>
elements;
530 const std::vector<CoolPropDbl>& beta,
const std::vector<CoolPropDbl>& A,
const std::vector<CoolPropDbl>& B,
531 const std::vector<CoolPropDbl>& C,
const std::vector<CoolPropDbl>& D) {
534 for (std::size_t i = 0; i < n.size(); ++i) {
547 void to_json(rapidjson::Value& el, rapidjson::Document& doc);
555 std::vector<double>
z;
566 z = std::vector<double>(1, 1);
569 void to_json(rapidjson::Value& el, rapidjson::Document& doc);
588 const std::vector<CoolPropDbl>&
eta,
const std::vector<CoolPropDbl>&
beta,
const std::vector<CoolPropDbl>&
gamma,
589 const std::vector<CoolPropDbl>&
epsilon,
const std::vector<CoolPropDbl>&
b)
594 void to_json(rapidjson::Value& el, rapidjson::Document& doc);
670 void to_json(rapidjson::Value& el, rapidjson::Document& doc);
720 if (!
_base || dont_use_cache)
721 return all(tau, delta,
false).alphar;
726 if (!
_dDelta || dont_use_cache)
727 return all(tau, delta,
false).dalphar_ddelta;
732 if (!
_dTau || dont_use_cache)
733 return all(tau, delta,
false).dalphar_dtau;
739 return all(tau, delta,
false).d2alphar_ddelta2;
745 return all(tau, delta,
false).d2alphar_ddelta_dtau;
750 if (!
_dTau2 || dont_use_cache)
751 return all(tau, delta,
false).d2alphar_dtau2;
757 return all(tau, delta,
false).d3alphar_ddelta3;
763 return all(tau, delta,
false).d3alphar_ddelta2_dtau;
769 return all(tau, delta,
false).d3alphar_ddelta_dtau2;
774 if (!
_dTau3 || dont_use_cache)
775 return all(tau, delta,
false).d3alphar_dtau3;
780 return all(tau, delta,
false).d4alphar_ddelta4;
783 return all(tau, delta,
false).d4alphar_ddelta3_dtau;
786 return all(tau, delta,
false).d4alphar_ddelta2_dtau2;
789 return all(tau, delta,
false).d4alphar_ddelta_dtau3;
792 return all(tau, delta,
false).d4alphar_dtau4;
824 _base = derivs.alphar;
825 _dDelta = derivs.dalphar_ddelta;
826 _dTau = derivs.dalphar_dtau;
828 _dTau2 = derivs.d2alphar_dtau2;
831 _dTau3 = derivs.d3alphar_dtau3;
871 void to_json(rapidjson::Value& el, rapidjson::Document& doc) {
872 el.AddMember(
"type",
"IdealHelmholtzLead", doc.GetAllocator());
873 el.AddMember(
"a1",
static_cast<double>(a1), doc.GetAllocator());
874 el.AddMember(
"a2",
static_cast<double>(a2), doc.GetAllocator());
890 std::string reference;
902 if (enabled ==
false) {
906 }
else if (ref ==
"DEF") {
916 this->reference = ref;
923 void to_json(rapidjson::Value& el, rapidjson::Document& doc) {
924 el.AddMember(
"type",
"IdealHelmholtzEnthalpyEntropyOffset", doc.GetAllocator());
925 el.AddMember(
"a1",
static_cast<double>(a1), doc.GetAllocator());
926 el.AddMember(
"a2",
static_cast<double>(a2), doc.GetAllocator());
953 void to_json(rapidjson::Value& el, rapidjson::Document& doc) {
954 el.AddMember(
"type",
"IdealHelmholtzLogTau", doc.GetAllocator());
955 el.AddMember(
"a1",
static_cast<double>(a1), doc.GetAllocator());
969 std::vector<CoolPropDbl> n, t;
976 IdealHelmholtzPower(
const std::vector<CoolPropDbl>& n,
const std::vector<CoolPropDbl>& t) : n(n), t(t), N(n.size()), enabled(true){};
982 void to_json(rapidjson::Value& el, rapidjson::Document& doc) {
983 el.AddMember(
"type",
"IdealHelmholtzPower", doc.GetAllocator());
1040 std::vector<CoolPropDbl> n, theta, c, d;
1048 const std::vector<CoolPropDbl>& c,
const std::vector<CoolPropDbl>& d)
1049 : n(n), theta(theta), c(c), d(d), N(n.size()), enabled(true) {}
1052 void extend(
const std::vector<CoolPropDbl>& n,
const std::vector<CoolPropDbl>& theta,
const std::vector<CoolPropDbl>& c,
1053 const std::vector<CoolPropDbl>& d) {
1054 this->n.insert(this->n.end(), n.begin(), n.end());
1055 this->theta.insert(this->theta.end(), theta.begin(), theta.end());
1056 this->c.insert(this->c.end(), c.begin(), c.end());
1057 this->d.insert(this->d.end(), d.begin(), d.end());
1065 void to_json(rapidjson::Value& el, rapidjson::Document& doc) {
1066 el.AddMember(
"type",
"IdealHelmholtzPlanckEinsteinGeneralized", doc.GetAllocator());
1077 double cp_over_R, Tc, T0, tau0;
1099 void to_json(rapidjson::Value& el, rapidjson::Document& doc) {
1100 el.AddMember(
"type",
"IdealGasHelmholtzCP0Constant", doc.GetAllocator());
1101 el.AddMember(
"cp_over_R", cp_over_R, doc.GetAllocator());
1102 el.AddMember(
"Tc", Tc, doc.GetAllocator());
1103 el.AddMember(
"T0", T0, doc.GetAllocator());
1112 std::vector<CoolPropDbl> c, t;
1122 : c(c), t(t), Tc(Tc), T0(T0), tau0(Tc / T0), N(c.size()), enabled(true) {
1123 assert(c.size() == t.size());
1126 void extend(
const std::vector<CoolPropDbl>& c,
const std::vector<CoolPropDbl>& t) {
1127 this->c.insert(this->c.end(), c.begin(), c.end());
1128 this->t.insert(this->t.end(), t.begin(), t.end());
1136 void to_json(rapidjson::Value& el, rapidjson::Document& doc);
1145 std::vector<CoolPropDbl> n, theta;
1155 : n(n), theta(theta), Tc(Tc), _Tr(_HUGE), N(n.size()), enabled(true) {
1156 assert(n.size() == theta.size());
1159 void extend(
const std::vector<CoolPropDbl>& c,
const std::vector<CoolPropDbl>& t) {
1160 this->n.insert(this->n.end(), n.begin(), n.end());
1161 this->theta.insert(this->theta.end(), theta.begin(), theta.end());
1177 std::vector<CoolPropDbl> n, theta;
1187 : n(n), theta(theta), Tc(Tc), _Tr(_HUGE), N(n.size()), enabled(true) {
1188 assert(n.size() == theta.size());
1191 void extend(
const std::vector<CoolPropDbl>& n,
const std::vector<CoolPropDbl>& theta) {
1192 this->n.insert(this->n.end(), n.begin(), n.end());
1193 this->theta.insert(this->theta.end(), theta.begin(), theta.end());
1359 _prefactor = prefactor;
1394 _base = derivs.alphar * _prefactor;
1395 _dDelta = derivs.dalphar_ddelta * _prefactor;
1396 _dTau = derivs.dalphar_dtau * _prefactor;
1397 _dDelta2 = derivs.d2alphar_ddelta2 * _prefactor;
1398 _dTau2 = derivs.d2alphar_dtau2 * _prefactor;
1399 _dDelta_dTau = derivs.d2alphar_ddelta_dtau * _prefactor;
1400 _dDelta3 = derivs.d3alphar_ddelta3 * _prefactor;
1401 _dTau3 = derivs.d3alphar_dtau3 * _prefactor;
1405 return derivs * _prefactor;