teqp 0.22.0
Loading...
Searching...
No Matches
ECSHuberEly.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "nlohmann/json.hpp"
4
6
7namespace teqp{
8namespace ECSHuberEly{
9
14private:
15 using multifluid_t = decltype(multifluidfactory(nlohmann::json{}));
16
17 double acentric_reference, Z_crit_reference, T_crit_reference, rhomolar_crit_reference;
18 multifluid_t reference_model;
19 double acentric_fluid, Z_crit_fluid, T_crit_fluid, rhomolar_crit_fluid;
20 std::vector<double> f_T_coeffs, h_T_coeffs;
21
22public:
23 ECSHuberEly1994(const nlohmann::json& j): reference_model(build_multifluid_model({j.at("reference_fluid").at("name")}, "")) {
24 const auto& ref = j.at("reference_fluid");
25 acentric_reference = ref.at("acentric");
26 Z_crit_reference = ref.at("Z_crit");
27 T_crit_reference = ref.at("T_crit / K");
28 rhomolar_crit_reference = ref.at("rhomolar_crit / mol/m^3");
29
30 const auto& fl = j.at("fluid");
31 acentric_fluid = fl.at("acentric");
32 Z_crit_fluid = fl.at("Z_crit");
33 T_crit_fluid = fl.at("T_crit / K");
34 rhomolar_crit_fluid = fl.at("rhomolar_crit / mol/m^3");
35 f_T_coeffs = fl.at("f_T_coeffs").get<std::vector<double>>();
36 h_T_coeffs = fl.at("h_T_coeffs").get<std::vector<double>>();
37 }
38
39 template<class VecType>
40 auto R(const VecType& molefrac) const {
42 }
43
44 template<typename TTYPE, typename RhoType, typename VecType>
45 auto alphar(const TTYPE& T, const RhoType& rhomolar, const VecType& mole_fractions) const {
46
47 auto Tri = T/T_crit_fluid;
48
49 // These are the basic definitions from Huber and Ely
50 auto theta = 1.0 + (acentric_fluid-acentric_reference)*(f_T_coeffs[0] + f_T_coeffs[1]*log(Tri)); // Eq. 30
51 auto phi = Z_crit_reference/Z_crit_fluid*(1.0 + (acentric_fluid - acentric_reference)*(h_T_coeffs[0] + h_T_coeffs[1]*log(Tri))); // Eq. 31
52
53 auto f = T_crit_fluid/T_crit_reference*theta;
54 auto h = rhomolar_crit_reference/rhomolar_crit_fluid*phi;
55
56 // Calculate the effective temperature and density (sometimes called conformal temperature and conformal density)
57 auto T_effective = forceeval(T/f);
58 auto rho_effective = forceeval(rhomolar*h);
59
60 return reference_model.alphar(T_effective, rho_effective, mole_fractions);
61 }
62};
63
64
65}
66}
ECSHuberEly1994(const nlohmann::json &j)
auto R(const VecType &molefrac) const
auto alphar(const TTYPE &T, const RhoType &rhomolar, const VecType &mole_fractions) const
auto multifluidfactory(const nlohmann::json &spec)
Load a model from a JSON data structure.
auto build_multifluid_model(const std::vector< std::string > &components, const std::string &root, const std::string &BIPcollectionpath={}, const nlohmann::json &flags={}, const std::string &departurepath={})
auto forceeval(T &&expr)
Definition types.hpp:52
auto get_R_gas()
< Gas constant, according to CODATA 2019, in the given number type
Definition constants.hpp:22