From 66dbfaddead73169c2c116cd59cf79b7b2cd056f Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Mon, 6 Jan 2025 12:03:00 -0500 Subject: [PATCH] Allow more models to be disabled --- CMakeLists.txt | 2 +- .../CPP/model_factory_model_potentials.cpp | 48 ++++++++++++++++++- .../CPP/model_factory_multifluid_activity.cpp | 11 +++++ 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c972f2f..d25c1c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,7 +155,7 @@ set(JSON_Diagnostics TRUE CACHE BOOL "Turn on more helpful diagnostics in nlohma # Prepare preprocessor macros set(preprocessors) # A comma-delimited, case-insensitive, set of factories to disable" -## set(TEQP_DISABLED_FACTORIES "CPA,SAFTVRMIE") # as an example +## set(TEQP_DISABLED_FACTORIES "CPA,SAFTVRMIE,GENERICSAFT,SQUAREWELL,EXP6,2CLJF,MIE,MULTIFLUIDACTIVITY") # as an example if (TEQP_DISABLED_FACTORIES) string(REGEX MATCHALL "[^,]+" disabled_factories "${TEQP_DISABLED_FACTORIES}") message(STATUS "${disabled_factories}") diff --git a/interface/CPP/model_factory_model_potentials.cpp b/interface/CPP/model_factory_model_potentials.cpp index a674ba0..81634a2 100644 --- a/interface/CPP/model_factory_model_potentials.cpp +++ b/interface/CPP/model_factory_model_potentials.cpp @@ -1,27 +1,62 @@ #include "teqp/cpp/teqpcpp.hpp" #include "teqp/cpp/deriv_adapter.hpp" + +#include "model_flags.hpp" + +#ifndef DISABLE_SQUAREWELL #include "teqp/models/model_potentials/squarewell.hpp" +#endif +#ifndef DISABLE_EXP6 #include "teqp/models/model_potentials/exp6.hpp" +#endif +#ifndef DISABLE_2CLJF #include "teqp/models/model_potentials/2center_ljf.hpp" - +#endif +#ifndef DISABLE_MIE #include "teqp/models/mie/mie.hpp" +#endif namespace teqp{ namespace cppinterface{ using teqp::cppinterface::adapter::make_owned; +#ifndef DISABLE_SQUAREWELL std::unique_ptr make_SW_EspindolaHeredia2009(const nlohmann::json &spec){ return make_owned(squarewell::EspindolaHeredia2009(spec.at("lambda"))); } +#else + std::unique_ptr make_SW_EspindolaHeredia2009(const nlohmann::json &){ + throw teqp::NotImplementedError("The squarewell model from Espindola-Heredia has been disabled"); + } +#endif + +#ifndef DISABLE_EXP6 std::unique_ptr make_EXP6_Kataoka1992(const nlohmann::json &spec){ return make_owned(exp6::Kataoka1992(spec.at("alpha"))); } +#else + std::unique_ptr make_EXP6_Kataoka1992(const nlohmann::json &){ + throw teqp::NotImplementedError("The EXP-6 model from Espindola-Heredia has been disabled"); + } +#endif + +#ifndef DISABLE_MIE std::unique_ptr make_Mie_Pohl2023(const nlohmann::json &spec){ return make_owned(Mie::Mie6Pohl2023(spec.at("lambda_r"))); } std::unique_ptr make_Mie_Chaparro2023(const nlohmann::json &spec){ return make_owned(FEANN::ChaparroJCP2023(spec.at("lambda_r"), spec.at("lambda_a"))); } +#else + std::unique_ptr make_Mie_Pohl2023(const nlohmann::json &){ + throw teqp::NotImplementedError("The Mie model from Pohl has been disabled"); + } + std::unique_ptr make_Mie_Chaparro2023(const nlohmann::json &){ + throw teqp::NotImplementedError("The Mie model from Chaparro has been disabled"); + } +#endif + +#ifndef DISABLE_2CLJF std::unique_ptr make_2CLJF(const nlohmann::json &spec){ return make_owned(twocenterljf::build_two_center_model(spec.at("author"), spec.at("L^*"))); } @@ -31,5 +66,16 @@ namespace teqp{ std::unique_ptr make_2CLJF_Quadrupole(const nlohmann::json &spec){ return make_owned(twocenterljf::build_two_center_model_quadrupole(spec.at("author"), spec.at("L^*"), spec.at("(Q^*)^2"))); } +#else + std::unique_ptr make_2CLJF(const nlohmann::json &){ + throw teqp::NotImplementedError("The 2CLJF model has been disabled"); + } + std::unique_ptr make_2CLJF_Dipole(const nlohmann::json &){ + throw teqp::NotImplementedError("The 2CLJF+dipole model has been disabled"); + } + std::unique_ptr make_2CLJF_Quadrupole(const nlohmann::json &){ + throw teqp::NotImplementedError("The 2CLJF+quadrupole model has been disabled"); + } +#endif } } diff --git a/interface/CPP/model_factory_multifluid_activity.cpp b/interface/CPP/model_factory_multifluid_activity.cpp index d4cb242..ef06d06 100644 --- a/interface/CPP/model_factory_multifluid_activity.cpp +++ b/interface/CPP/model_factory_multifluid_activity.cpp @@ -1,11 +1,22 @@ #include "teqp/cpp/teqpcpp.hpp" #include "teqp/cpp/deriv_adapter.hpp" + +#include "model_flags.hpp" + +#ifndef DISABLE_MULTIFLUIDACTIVITY #include "teqp/models/multifluid/multifluid_activity.hpp" +#endif namespace teqp{ namespace cppinterface{ +#ifndef DISABLE_MULTIFLUIDACTIVITY std::unique_ptr make_multifluid_activity(const nlohmann::json &j){ return teqp::cppinterface::adapter::make_owned(multifluid::multifluid_activity::MultifluidPlusActivity(j)); } +#else + std::unique_ptr make_multifluid_activity(const nlohmann::json &){ + throw teqp::NotImplementedError("The multifluid+activity model has been disabled"); + } +#endif } }