10 namespace cppinterface {
12 std::unique_ptr<teqp::cppinterface::AbstractModel>
make_SAFTVRMie(
const nlohmann::json &j);
21 static std::unordered_map<std::string, makefunc> pointer_factory = {
22 {
"vdW1", [](
const nlohmann::json& spec){
return make_owned(
vdWEOS1(spec.at(
"a"), spec.at(
"b"))); }},
23 {
"vdW", [](
const nlohmann::json& spec){
return make_owned(
vdWEOS<double>(spec.at(
"Tcrit / K"), spec.at(
"pcrit / Pa"))); }},
40 {
"AmmoniaWaterTillnerRoth", [](
const nlohmann::json& ){
return make_owned(AmmoniaWaterTillnerRoth());}},
55 {
"SAFT-VR-Mie", [](
const nlohmann::json& spec){
return make_SAFTVRMie(spec); }}
58 std::unique_ptr<teqp::cppinterface::AbstractModel>
build_model_ptr(
const nlohmann::json& json,
const bool validate) {
61 std::string kind = json.at(
"kind");
62 auto spec = json.at(
"model");
65 bool validate_in_json = json.value(
"validate",
true);
67 auto itr = pointer_factory.find(kind);
68 if (itr != pointer_factory.end()){
69 if (validate || validate_in_json){
78 return (itr->second)(spec);
81 throw std::invalid_argument(
"Don't understand \"kind\" of: " + kind);
85 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) {
89 std::unique_ptr<AbstractModel>
make_model(
const nlohmann::json& j,
const bool validate) {
94 if (pointer_factory.find(key) == pointer_factory.end()){
95 pointer_factory[key] = func;
Ideal-gas Helmholtz energy container.
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 CPAfactory(const nlohmann::json &j)
auto make_LKPMix(const nlohmann::json &j)
auto PCSAFTfactory(const nlohmann::json &spec)
A JSON-based factory function for the PC-SAFT model.
auto make_owned(const TemplatedModel &tmodel)
std::unique_ptr< AbstractModel > make_model(const nlohmann::json &, bool validate=true)
std::function< std::unique_ptr< teqp::cppinterface::AbstractModel >(const nlohmann::json &j)> ModelPointerFactoryFunction
std::unique_ptr< teqp::cppinterface::AbstractModel > make_SAFTVRMie(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={})
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< AbstractModel > build_model_ptr(const nlohmann::json &json, bool validate=true)
nlohmann::json get_model_schema(const std::string &kind)
Return the schema for the given model kind.
auto build_two_center_model_dipole(const std::string &model_version, const double &L=0.0, const double &mu_sq=0.0)
auto build_two_center_model_quadrupole(const std::string &model_version, const double &L=0.0, const double &Q_sq=0.0)
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 build_LJ126_TholJPCRD2016()
auto make_canonicalPR(const nlohmann::json &spec)
A JSON-based factory function for the canonical SRK model.
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 make_canonicalSRK(const nlohmann::json &spec)
A JSON-based factory function for the canonical SRK model.
const nlohmann::json model_schema_library