teqp 0.22.0
Loading...
Searching...
No Matches
genericsaft.hpp
Go to the documentation of this file.
1#pragma once
2
8
10
12
13public:
15 using NonPolarTerms = std::variant<saft::pcsaft::PCSAFTMixture, SAFTVRMie::SAFTVRMieNonpolarMixture, saft::softsaft::SoftSAFT, TwoCLJ>;
16// using PolarTerms = EOSTermContainer<>;
17 using AssociationTerms = std::variant<association::Association>;
18
19private:
20 auto make_nonpolar(const nlohmann::json &j) -> NonPolarTerms{
21 std::string kind = j.at("kind");
22 if (kind == "PCSAFT" || kind == "PC-SAFT"){
23 return saft::pcsaft::PCSAFTfactory(j.at("model"));
24 }
25 else if (kind == "SAFTVRMie" || kind == "SAFT-VR-Mie"){
26 return SAFTVRMie::SAFTVRMieNonpolarfactory(j.at("model"));
27 }
28 else if (kind == "Johnson+Johnson" || kind == "softSAFT"){
29 return saft::softsaft::SoftSAFT(j.at("model"));
30 }
31 else if (kind == "2CLJF" || kind == "2CLJ"){
32 const auto& model = j.at("model");
33 return twocenterljf::build_two_center_model(model.at("author"), model.at("L^*"));
34 }
35 else{
36 throw std::invalid_argument("Not valid nonpolar kind:" + kind);
37 }
38 };
39 auto make_association(const nlohmann::json &j) -> AssociationTerms{
40 std::string kind = j.at("kind");
41 if (kind == "canonical" || kind == "Dufal"){
42 return association::Association::factory(j.at("model"));
43 }
44 else{
45 throw std::invalid_argument("Not valid association kind:" + kind);
46 }
47 };
48
49public:
50 GenericSAFT(const nlohmann::json&j) : nonpolar(make_nonpolar(j.at("nonpolar"))){
51 if (j.contains("association")){
52 association.emplace(make_association(j.at("association")));
53 }
54 }
55
56 template<class VecType>
57 auto R(const VecType& molefrac) const {
59 }
60
62// std::optional<PolarTerms> polar;
63 std::optional<AssociationTerms> association;
64
65 template <typename TType, typename RhoType, typename MoleFractions>
66 auto alphar(const TType& T, const RhoType& rho, const MoleFractions& molefrac) const {
67 auto contrib = std::visit([&](auto& t) { return t.alphar(T, rho, molefrac); }, nonpolar);
68 if (association){
69 const AssociationTerms& at = association.value();
70 contrib += std::visit([&](auto& t) { return t.alphar(T, rho, molefrac); }, at);
71 }
72 return contrib;
73 }
74};
75
76}
static Association factory(const nlohmann::json &j)
auto SAFTVRMieNonpolarfactory(const nlohmann::json &spec)
auto PCSAFTfactory(const nlohmann::json &spec)
A JSON-based factory function for the PC-SAFT model.
Definition pcsaft.hpp:455
auto build_two_center_model(const std::string &model_version, const double &L=0.0)
auto get_R_gas()
< Gas constant, according to CODATA 2019, in the given number type
Definition constants.hpp:22
auto R(const VecType &molefrac) const
std::variant< association::Association > AssociationTerms
std::variant< saft::pcsaft::PCSAFTMixture, SAFTVRMie::SAFTVRMieNonpolarMixture, saft::softsaft::SoftSAFT, TwoCLJ > NonPolarTerms
std::optional< AssociationTerms > association
GenericSAFT(const nlohmann::json &j)
auto alphar(const TType &T, const RhoType &rho, const MoleFractions &molefrac) const