teqp
0.23.1
Toggle main menu visibility
Loading...
Searching...
No Matches
include
teqp
models
saft
genericsaft.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
teqp/models/pcsaft.hpp
"
4
#include "
teqp/models/saftvrmie.hpp
"
5
#include "
teqp/models/association/association.hpp
"
6
#include "
teqp/models/saft/softsaft.hpp
"
7
#include "
teqp/models/model_potentials/2center_ljf.hpp
"
8
9
namespace
teqp::saft::genericsaft
{
10
11
struct
GenericSAFT
{
12
13
public
:
14
using
TwoCLJ
=
twocenterljf::Twocenterljf<twocenterljf::DipolarContribution>
;
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
19
private
:
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
49
public
:
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
{
58
return
get_R_gas<decltype(molefrac[0])>
();
59
}
60
61
NonPolarTerms
nonpolar
;
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
}
2center_ljf.hpp
association.hpp
teqp::association::Association::factory
static Association factory(const nlohmann::json &j)
Definition
association.hpp:184
teqp::saft::softsaft::SoftSAFT
Definition
softsaft.hpp:32
teqp::twocenterljf::Twocenterljf
Definition
2center_ljf.hpp:314
teqp::SAFTVRMie::SAFTVRMieNonpolarfactory
auto SAFTVRMieNonpolarfactory(const nlohmann::json &spec)
Definition
saftvrmie.hpp:1114
teqp::saft::genericsaft
Definition
genericsaft.hpp:9
teqp::saft::pcsaft::PCSAFTfactory
auto PCSAFTfactory(const nlohmann::json &spec)
A JSON-based factory function for the PC-SAFT model.
Definition
pcsaft.hpp:455
teqp::twocenterljf::build_two_center_model
auto build_two_center_model(const std::string &model_version, const double &L=0.0)
Definition
2center_ljf.hpp:410
teqp::get_R_gas
auto get_R_gas()
< Gas constant, according to CODATA 2019, in the given number type
Definition
constants.hpp:22
pcsaft.hpp
saftvrmie.hpp
softsaft.hpp
teqp::saft::genericsaft::GenericSAFT::nonpolar
NonPolarTerms nonpolar
Definition
genericsaft.hpp:61
teqp::saft::genericsaft::GenericSAFT::R
auto R(const VecType &molefrac) const
Definition
genericsaft.hpp:57
teqp::saft::genericsaft::GenericSAFT::AssociationTerms
std::variant< association::Association > AssociationTerms
Definition
genericsaft.hpp:17
teqp::saft::genericsaft::GenericSAFT::NonPolarTerms
std::variant< saft::pcsaft::PCSAFTMixture, SAFTVRMie::SAFTVRMieNonpolarMixture, saft::softsaft::SoftSAFT, TwoCLJ > NonPolarTerms
Definition
genericsaft.hpp:15
teqp::saft::genericsaft::GenericSAFT::association
std::optional< AssociationTerms > association
Definition
genericsaft.hpp:63
teqp::saft::genericsaft::GenericSAFT::TwoCLJ
twocenterljf::Twocenterljf< twocenterljf::DipolarContribution > TwoCLJ
Definition
genericsaft.hpp:14
teqp::saft::genericsaft::GenericSAFT::GenericSAFT
GenericSAFT(const nlohmann::json &j)
Definition
genericsaft.hpp:50
teqp::saft::genericsaft::GenericSAFT::alphar
auto alphar(const TType &T, const RhoType &rho, const MoleFractions &molefrac) const
Definition
genericsaft.hpp:66
Generated by
1.17.0