1 #ifndef EXCESSHE_FUNCTIONS_H
2 #define EXCESSHE_FUNCTIONS_H
13 typedef std::vector<std::vector<CoolPropDbl>>
STLMatrix;
33 virtual void update(
double tau,
double delta) {
37 double get(std::size_t itau, std::size_t idelta) {
43 phi.
all(tau, delta, _derivs);
50 return derivs.dalphar_ddelta;
53 return derivs.dalphar_dtau;
57 return derivs.d2alphar_ddelta2;
60 return derivs.d2alphar_ddelta_dtau;
63 return derivs.d2alphar_dtau2;
67 return derivs.d3alphar_dtau3;
70 return derivs.d3alphar_ddelta_dtau2;
73 return derivs.d3alphar_ddelta2_dtau;
76 return derivs.d3alphar_ddelta3;
80 return derivs.d4alphar_dtau4;
83 return derivs.d4alphar_ddelta_dtau3;
86 return derivs.d4alphar_ddelta2_dtau2;
89 return derivs.d4alphar_ddelta3_dtau;
92 return derivs.d4alphar_ddelta4;
109 const std::vector<double>& eta,
const std::vector<double>& epsilon,
const std::vector<double>& beta,
110 const std::vector<double>& gamma, std::size_t Npower) {
113 std::vector<CoolPropDbl> _n(n.begin(), n.begin() + Npower);
114 std::vector<CoolPropDbl> _d(d.begin(), d.begin() + Npower);
115 std::vector<CoolPropDbl> _t(t.begin(), t.begin() + Npower);
116 std::vector<CoolPropDbl> _l(Npower, 0.0);
119 if (n.size() == Npower) {
121 std::vector<CoolPropDbl> _n(n.begin() + Npower, n.end());
122 std::vector<CoolPropDbl> _d(d.begin() + Npower, d.end());
123 std::vector<CoolPropDbl> _t(t.begin() + Npower, t.end());
124 std::vector<CoolPropDbl> _eta(eta.begin() + Npower, eta.end());
125 std::vector<CoolPropDbl> _epsilon(epsilon.begin() + Npower, epsilon.end());
126 std::vector<CoolPropDbl> _beta(beta.begin() + Npower, beta.end());
127 std::vector<CoolPropDbl> _gamma(gamma.begin() + Npower, gamma.end());
147 const std::vector<double>& l,
const std::vector<double>& eta,
const std::vector<double>& epsilon,
148 const std::vector<double>& beta,
const std::vector<double>& gamma, std::size_t Npower) {
151 std::vector<CoolPropDbl> _n(n.begin(), n.begin() + Npower);
152 std::vector<CoolPropDbl> _d(d.begin(), d.begin() + Npower);
153 std::vector<CoolPropDbl> _t(t.begin(), t.begin() + Npower);
154 std::vector<CoolPropDbl> _l(l.begin(), l.begin() + Npower);
157 if (n.size() == Npower) {
159 std::vector<CoolPropDbl> _n(n.begin() + Npower, n.end());
160 std::vector<CoolPropDbl> _d(d.begin() + Npower, d.end());
161 std::vector<CoolPropDbl> _t(t.begin() + Npower, t.end());
162 std::vector<CoolPropDbl> _eta(eta.begin() + Npower, eta.end());
163 std::vector<CoolPropDbl> _epsilon(epsilon.begin() + Npower, epsilon.end());
164 std::vector<CoolPropDbl> _beta(beta.begin() + Npower, beta.end());
165 std::vector<CoolPropDbl> _gamma(gamma.begin() + Npower, gamma.end());
186 const std::vector<double>& l) {
187 std::vector<CoolPropDbl> _n(n.begin(), n.begin() + n.size());
188 std::vector<CoolPropDbl> _d(d.begin(), d.begin() + d.size());
189 std::vector<CoolPropDbl> _t(t.begin(), t.begin() + t.size());
190 std::vector<CoolPropDbl> _l(l.begin(), l.begin() + l.size());
209 for (std::size_t i = 0; i <
N; ++i) {
210 for (std::size_t j = 0; j <
N; ++j) {
222 for (std::size_t i = 0; i <
N; ++i) {
223 for (std::size_t j = 0; j <
N; ++j) {
236 F.resize(
N, std::vector<CoolPropDbl>(
N, 0));
238 for (std::size_t i = 0; i <
N; ++i) {
244 for (std::size_t i = 0; i <
N; i++) {
245 for (std::size_t j = i + 1; j <
N; j++) {
248 for (std::size_t j = 0; j < i; j++) {
256 bool cache_values =
false) {
264 if (cache_values ==
true) {
268 derivs.alphar =
alphar(mole_fractions);
297 for (std::size_t i = 0; i <
N - 1; i++) {
298 for (std::size_t j = i + 1; j <
N; j++) {
301 summer = summer + term * x[i] * x[j] *
F[i][j];
312 for (std::size_t i = 0; i <
N - 1; i++) {
313 for (std::size_t j = i + 1; j <
N; j++) {
320 double alphar(
const std::vector<CoolPropDbl>& x) {
373 for (std::size_t k = 0; k <
N; k++) {
385 dar_dxi += (1 - 2 * x[i]) * FiNariN;
386 for (std::size_t k = 0; k <
N - 1; ++k) {
387 if (i == k)
continue;
390 dar_dxi += x[k] * (Fikarik - FiNariN - FkNarkN);
412 std::size_t
N = x.size();
413 if (i ==
N - 1 || j ==
N - 1) {
422 return Fijarij - FiNariN - FjNarjN;
442 std::size_t
N = x.size();
443 if (i ==
N - 1 || j ==
N - 1) {
452 return Fijarij - FiNariN - FjNarjN;
503 CoolPropDbl d3ar_dxi_dDelta_dTau = (1 - 2 * x[i]) * FiNariN;
504 for (std::size_t k = 0; k <
N - 1; ++k) {
505 if (i == k)
continue;
508 d3ar_dxi_dDelta_dTau += x[k] * (Fikarik - FiNariN - FkNarkN);
510 return d3ar_dxi_dDelta_dTau;
541 for (std::size_t k = 0; k <
N; k++) {
552 CoolPropDbl d2ar_dxi_dTau = (1 - 2 * x[i]) * FiNariN;
553 for (std::size_t k = 0; k <
N - 1; ++k) {
554 if (i == k)
continue;
557 d2ar_dxi_dTau += x[k] * (Fikarik - FiNariN - FkNarkN);
559 return d2ar_dxi_dTau;
571 for (std::size_t k = 0; k <
N; k++) {
583 d2ar_dxi_dDelta += (1 - 2 * x[i]) * FiNariN;
584 for (std::size_t k = 0; k <
N - 1; ++k) {
585 if (i == k)
continue;
588 d2ar_dxi_dDelta += x[k] * (Fikarik - FiNariN - FkNarkN);
590 return d2ar_dxi_dDelta;
602 for (std::size_t k = 0; k <
N; k++) {
613 CoolPropDbl d3ar_dxi_dDelta2 = (1 - 2 * x[i]) * FiNariN;
614 for (std::size_t k = 0; k <
N - 1; ++k) {
615 if (i == k)
continue;
618 d3ar_dxi_dDelta2 += x[k] * (Fikarik - FiNariN - FkNarkN);
620 return d3ar_dxi_dDelta2;
632 for (std::size_t k = 0; k <
N; k++) {
649 for (std::size_t k = 0; k <
N; k++) {
660 CoolPropDbl d3ar_dxi_dTau2 = (1 - 2 * x[i]) * FiNariN;
661 for (std::size_t k = 0; k <
N - 1; ++k) {
662 if (i == k)
continue;
665 d3ar_dxi_dTau2 += x[k] * (Fikarik - FiNariN - FkNarkN);
667 return d3ar_dxi_dTau2;
679 for (std::size_t k = 0; k <
N; k++) {
696 for (std::size_t k = 0; k <
N; k++) {
713 for (std::size_t k = 0; k <
N; k++) {
730 for (std::size_t k = 0; k <
N; k++) {