12 namespace cppinterface {
14 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_SAFTVRMie(
const nlohmann::json &);
15 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_PCSAFT(
const nlohmann::json &);
17 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_SOFTSAFT(
const nlohmann::json &);
18 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_genericSAFT(
const nlohmann::json &);
20 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_GERG2004resid(
const nlohmann::json &);
21 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_GERG2008resid(
const nlohmann::json &);
24 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_LKP(
const nlohmann::json &);
25 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_multifluid(
const nlohmann::json &);
36 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_Mie_Pohl2023(
const nlohmann::json &);
38 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_2CLJF(
const nlohmann::json &);
39 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_2CLJF_Dipole(
const nlohmann::json &);
42 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_CPA(
const nlohmann::json &);
43 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_IdealHelmholtz(
const nlohmann::json &);
52 static std::unordered_map<std::string, makefunc> pointer_factory = {
53 {
"vdW1", [](
const nlohmann::json& spec){
return make_owned(
vdWEOS1(spec.at(
"a"), spec.at(
"b"))); }},
54 {
"vdW", [](
const nlohmann::json& spec){
return make_owned(
vdWEOS<double>(spec.at(
"Tcrit / K"), spec.at(
"pcrit / Pa"))); }},
65 {
"SAFT-VR-Mie", [](
const nlohmann::json& spec){
return make_SAFTVRMie(spec); }},
67 {
"PCSAFT", [](
const nlohmann::json& spec){
return make_PCSAFT(spec); }},
69 {
"SoftSAFT", [](
const nlohmann::json& spec){
return make_SOFTSAFT(spec); }},
70 {
"genericSAFT", [](
const nlohmann::json& spec){
return make_genericSAFT(spec); }},
77 {
"LKP", [](
const nlohmann::json& spec){
return make_LKP(spec);}},
79 {
"multifluid", [](
const nlohmann::json& spec){
return make_multifluid(spec);}},
90 {
"Mie_Pohl2023", [](
const nlohmann::json& spec){
return make_Mie_Pohl2023(spec); }},
92 {
"2CLJF", [](
const nlohmann::json& spec){
return make_2CLJF(spec); }},
93 {
"2CLJF-Dipole", [](
const nlohmann::json& spec){
return make_2CLJF_Dipole(spec); }},
96 {
"CPA", [](
const nlohmann::json& spec){
return make_CPA(spec); }},
101 std::unique_ptr<teqp::cppinterface::AbstractModel>
build_model_ptr(
const nlohmann::json& json,
const bool validate) {
104 std::string kind = json.at(
"kind");
105 auto spec = json.at(
"model");
107 auto itr = pointer_factory.find(kind);
108 if (itr != pointer_factory.end()){
109 bool do_validation = validate;
110 if (json.contains(
"validate")){
111 do_validation = json[
"validate"];
122 return (itr->second)(spec);
125 throw std::invalid_argument(
"Don't understand \"kind\" of: " + kind);
129 std::unique_ptr<AbstractModel>
make_multifluid_model(
const std::vector<std::string>& components,
const std::string& root,
const std::string& BIP,
const nlohmann::json& flags,
const std::string& departurepath) {
130 return make_multifluid({{
"components", components}, {
"root",root}, {
"BIP", BIP}, {
"flags", flags}, {
"departure", departurepath}});
133 std::unique_ptr<AbstractModel>
make_model(
const nlohmann::json& j,
const bool validate) {
138 if (pointer_factory.find(key) == pointer_factory.end()){
139 pointer_factory[key] = func;
Validation of a JSON schema failed.
bool is_valid(const nlohmann::json &j) const
std::vector< std::string > get_validation_errors(const nlohmann::json &j) const
A (very) simple implementation of the van der Waals EOS.
A slightly more involved implementation of van der Waals, this time with mixture properties.
auto make_owned(const TemplatedModel &tmodel)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_Mie_Pohl2023(const nlohmann::json &spec)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_SOFTSAFT(const nlohmann::json &spec)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_2CLJF(const nlohmann::json &spec)
std::unique_ptr< AbstractModel > make_model(const nlohmann::json &, bool validate=true)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_LJ126_TholJPCRD2016()
std::unique_ptr< teqp::cppinterface::AbstractModel > make_2CLJF_Dipole(const nlohmann::json &spec)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_multifluid_activity(const nlohmann::json &j)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_GERG2004idealgas(const nlohmann::json &spec)
std::function< std::unique_ptr< teqp::cppinterface::AbstractModel >(const nlohmann::json &j)> ModelPointerFactoryFunction
std::unique_ptr< teqp::cppinterface::AbstractModel > make_multifluid_association(const nlohmann::json &j)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_SW_EspindolaHeredia2009(const nlohmann::json &spec)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_LJ126_Johnson1993()
std::unique_ptr< teqp::cppinterface::AbstractModel > make_SAFTVRMie(const nlohmann::json &j)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_PCSAFTPureGrossSadowski2001(const nlohmann::json &spec)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_multifluid_ECS_HuberEly1994(const nlohmann::json &j)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_multifluid(const nlohmann::json &j)
std::unique_ptr< AbstractModel > make_multifluid_model(const std::vector< std::string > &components, const std::string &coolprop_root, const std::string &BIPcollectionpath={}, const nlohmann::json &flags={}, const std::string &departurepath={})
std::unique_ptr< teqp::cppinterface::AbstractModel > make_EXP6_Kataoka1992(const nlohmann::json &spec)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_2CLJF_Quadrupole(const nlohmann::json &spec)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_GERG2004resid(const nlohmann::json &spec)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_CPA(const nlohmann::json &spec)
void add_model_pointer_factory_function(const std::string &key, ModelPointerFactoryFunction &func)
This function allows you to inject your own model factory function into the set of factory functions ...
ModelPointerFactoryFunction makefunc
std::unique_ptr< teqp::cppinterface::AbstractModel > make_AmmoniaWaterTillnerRoth()
std::unique_ptr< AbstractModel > build_model_ptr(const nlohmann::json &json, bool validate=true)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_LJ126_KolafaNezbeda1994()
std::unique_ptr< teqp::cppinterface::AbstractModel > make_IdealHelmholtz(const nlohmann::json &spec)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_PCSAFT(const nlohmann::json &spec)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_GERG2008resid(const nlohmann::json &spec)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_LKP(const nlohmann::json &j)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_genericSAFT(const nlohmann::json &spec)
std::unique_ptr< teqp::cppinterface::AbstractModel > make_Mie_Chaparro2023(const nlohmann::json &spec)
nlohmann::json get_model_schema(const std::string &kind)
Return the schema for the given model kind.
std::unique_ptr< teqp::cppinterface::AbstractModel > make_GERG2008idealgas(const nlohmann::json &spec)
auto make_generalizedcubic(const nlohmann::json &spec)
A JSON-based factory function for the generalized cubic + alpha.
auto make_AdvancedPRaEres(const nlohmann::json &j)
auto make_canonicalPR(const nlohmann::json &spec)
A JSON-based factory function for the canonical SRK model.
auto make_canonicalSRK(const nlohmann::json &spec)
A JSON-based factory function for the canonical SRK model.
const nlohmann::json model_schema_library