Skip to content

Commit

Permalink
Allow more models to be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhbell committed Jan 6, 2025
1 parent 4533a80 commit 66dbfad
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
48 changes: 47 additions & 1 deletion interface/CPP/model_factory_model_potentials.cpp
Original file line number Diff line number Diff line change
@@ -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<teqp::cppinterface::AbstractModel> make_SW_EspindolaHeredia2009(const nlohmann::json &spec){
return make_owned(squarewell::EspindolaHeredia2009(spec.at("lambda")));
}
#else
std::unique_ptr<teqp::cppinterface::AbstractModel> 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<teqp::cppinterface::AbstractModel> make_EXP6_Kataoka1992(const nlohmann::json &spec){
return make_owned(exp6::Kataoka1992(spec.at("alpha")));
}
#else
std::unique_ptr<teqp::cppinterface::AbstractModel> 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<teqp::cppinterface::AbstractModel> make_Mie_Pohl2023(const nlohmann::json &spec){
return make_owned(Mie::Mie6Pohl2023(spec.at("lambda_r")));
}
std::unique_ptr<teqp::cppinterface::AbstractModel> make_Mie_Chaparro2023(const nlohmann::json &spec){
return make_owned(FEANN::ChaparroJCP2023(spec.at("lambda_r"), spec.at("lambda_a")));
}
#else
std::unique_ptr<teqp::cppinterface::AbstractModel> make_Mie_Pohl2023(const nlohmann::json &){
throw teqp::NotImplementedError("The Mie model from Pohl has been disabled");
}
std::unique_ptr<teqp::cppinterface::AbstractModel> make_Mie_Chaparro2023(const nlohmann::json &){
throw teqp::NotImplementedError("The Mie model from Chaparro has been disabled");
}
#endif

#ifndef DISABLE_2CLJF
std::unique_ptr<teqp::cppinterface::AbstractModel> make_2CLJF(const nlohmann::json &spec){
return make_owned(twocenterljf::build_two_center_model(spec.at("author"), spec.at("L^*")));
}
Expand All @@ -31,5 +66,16 @@ namespace teqp{
std::unique_ptr<teqp::cppinterface::AbstractModel> 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<teqp::cppinterface::AbstractModel> make_2CLJF(const nlohmann::json &){
throw teqp::NotImplementedError("The 2CLJF model has been disabled");
}
std::unique_ptr<teqp::cppinterface::AbstractModel> make_2CLJF_Dipole(const nlohmann::json &){
throw teqp::NotImplementedError("The 2CLJF+dipole model has been disabled");
}
std::unique_ptr<teqp::cppinterface::AbstractModel> make_2CLJF_Quadrupole(const nlohmann::json &){
throw teqp::NotImplementedError("The 2CLJF+quadrupole model has been disabled");
}
#endif
}
}
11 changes: 11 additions & 0 deletions interface/CPP/model_factory_multifluid_activity.cpp
Original file line number Diff line number Diff line change
@@ -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<teqp::cppinterface::AbstractModel> make_multifluid_activity(const nlohmann::json &j){
return teqp::cppinterface::adapter::make_owned(multifluid::multifluid_activity::MultifluidPlusActivity(j));
}
#else
std::unique_ptr<teqp::cppinterface::AbstractModel> make_multifluid_activity(const nlohmann::json &){
throw teqp::NotImplementedError("The multifluid+activity model has been disabled");
}
#endif
}
}

0 comments on commit 66dbfad

Please sign in to comment.