9#include "nlohmann/json.hpp"
15 std::vector<double>
b,
c,
d;
22 {0.0, 0.236744e-1, 0.186984e-1, 0, 0.427240e-1},
23 {0, 0.155428e-4, 0.623689e-4},
24 0.653920, 0.601670e-1, 0.0},
25 ref{{0, 0.2026579, 0.331511, 0.276550e-1, 0.203488},
26 {0, 0.313385e-1, 0.503618e-1, 0.169010e-1,0.41577e-1},
27 {0, 0.487360e-4, 0.740336e-5},
28 1.226, 0.03754, 0.3978};
31 const std::vector<std::vector<double>>
kmat;
34 std::size_t N =
Tcrit.size();
38 std::string kmaterr =
"The kmat is the wrong size. It should be square with dimension " + std::to_string(N);
39 if (
kmat.size() != N){
43 for (
auto& krow:
kmat){
51 template<
class VecType>
52 auto R(
const VecType& )
const {
return m_R; }
55 template<
typename TTYPE,
typename RhoType,
typename ZcType>
57 auto B = params.
b[1] - params.
b[2]*tau - params.
b[3]*
powi(tau, 2) - params.
b[4]*
powi(tau, 3);
58 auto C = params.
c[1] - params.
c[2]*tau + params.
c[3]*
powi(tau, 3);
59 auto D = params.
d[1] + params.
d[2]*tau;
64 template<
typename TTYPE,
typename RhoType,
typename VecType>
65 auto alphar(
const TTYPE& T,
const RhoType& rhomolar,
const VecType& mole_fractions)
const {
67 if (
static_cast<std::size_t
>(mole_fractions.size()) !=
acentric.size()){
71 const VecType& x = mole_fractions;
72 std::decay_t<
decltype(mole_fractions[0])> summer_omega = 0.0, summer_vcmix = 0.0, summer_Tcmix = 0.0;
75 for (
auto i = 0; i < mole_fractions.size(); ++i){
76 summer_omega += mole_fractions[i]*
acentric[i];
78 for (
auto j = 0; j < mole_fractions.size(); ++j){
80 auto v_c_ij = 1.0/8.0*
powi(cbrt(v_ci) + cbrt(v_cj), 3);
82 summer_vcmix += x[i]*x[j]*v_c_ij;
83 summer_Tcmix += x[i]*x[j]*
pow(v_c_ij, 0.25)*T_c_ij;
86 auto omega_mix = summer_omega;
87 auto vc_mix = summer_vcmix;
88 auto Tc_mix = 1.0/
pow(summer_vcmix, 0.25)*summer_Tcmix;
90 auto Zc =
forceeval(0.2905-0.085*omega_mix);
101 return LKPMix(j.at(
"Tcrit / K"), j.at(
"pcrit / Pa"), j.at(
"acentric"), j.at(
"R / J/mol/K"), j.at(
"kmat"));
const LKPFluidParameters ref
auto R(const VecType &) const
const LKPFluidParameters simple
const std::vector< double > acentric
LKPMix(const std::vector< double > &Tcrit, const std::vector< double > &pcrit, const std::vector< double > &acentric, double R, const std::vector< std::vector< double > > &kmat)
const std::vector< double > pcrit
auto alphar(const TTYPE &T, const RhoType &rhomolar, const VecType &mole_fractions) const
const std::vector< double > Tcrit
auto alphar_func(const TTYPE &tau, const RhoType &delta, const ZcType &Zc, const LKPFluidParameters ¶ms) const
Calculate the contribution for one of the fluids, depending on the parameter set passed in.
const double m_R
molar gas constant to be used in this model, in J/mol/K
const std::vector< std::vector< double > > kmat
auto make_LKPMix(const nlohmann::json &j)
T powi(const T &x, int n)
From Ulrich Deiters.
auto pow(const double &x, const double &e)