7#include "nlohmann/json.hpp"
15using EArray2 = Eigen::Array<double, 2, 1>;
19using EMatrixd = Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic>;
20using REMatrixd = Eigen::Ref<const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic>>;
56#define ISOCHORIC_double_args \
59 X(get_dpdT_constrhovec)
61#define ISOCHORIC_array_args \
62 X(build_Psir_gradient_autodiff) \
63 X(get_chempotVLE_autodiff) \
64 X(get_dchempotdT_autodiff) \
65 X(get_fugacity_coefficients) \
66 X(get_partial_molar_volumes) \
67 X(build_d2PsirdTdrhoi_autodiff) \
68 X(get_dpdrhovec_constT)
70#define ISOCHORIC_matrix_args \
71 X(build_Psir_Hessian_autodiff) \
72 X(build_Psi_Hessian_autodiff)
74#define ISOCHORIC_multimatrix_args \
75 X(build_Psir_fgradHessian_autodiff)
78 namespace cppinterface {
104 virtual double get_Arxy(
const int,
const int,
const double,
const double,
const EArrayd&)
const = 0;
107 #define X(i,j) virtual double get_Ar ## i ## j(const double T, const double rho, const REArrayd& molefrac) const = 0;
111 #define X(i) virtual EArrayd get_Ar0 ## i ## n(const double T, const double rho, const REArrayd& molefrac) const = 0;
115 #define X(i) virtual EArrayd get_Ar ## i ## 0n(const double T, const double rho, const REArrayd& molefrac) const = 0;
126 virtual std::map<int, double>
get_Bnvir(
const int Nderiv,
const double T,
const EArrayd& z)
const = 0;
131 virtual double get_ATrhoXi(
const double T,
const int NT,
const double rhomolar,
int ND,
const EArrayd& molefrac,
const int i,
const int NXi)
const = 0;
132 virtual double get_ATrhoXiXj(
const double T,
const int NT,
const double rhomolar,
int ND,
const EArrayd& molefrac,
const int i,
const int NXi,
const int j,
const int NXj)
const = 0;
133 virtual double get_ATrhoXiXjXk(
const double T,
const int NT,
const double rhomolar,
int ND,
const EArrayd& molefrac,
const int i,
const int NXi,
const int j,
const int NXj,
const int k,
const int NXk)
const = 0;
135 virtual double get_AtaudeltaXi(
const double tau,
const int Ntau,
const double delta,
int Ndelta,
const EArrayd& molefrac,
const int i,
const int NXi)
const = 0;
136 virtual double get_AtaudeltaXiXj(
const double tau,
const int Ntau,
const double delta,
int Ndelta,
const EArrayd& molefrac,
const int i,
const int NXi,
const int j,
const int NXj)
const = 0;
137 virtual double get_AtaudeltaXiXjXk(
const double tau,
const int Ntau,
const double delta,
int Ndelta,
const EArrayd& molefrac,
const int i,
const int NXi,
const int j,
const int NXj,
const int k,
const int NXk)
const = 0;
140 #define X(f) virtual double f(const double T, const EArrayd& rhovec) const = 0;
143 #define X(f) virtual EArrayd f(const double T, const EArrayd& rhovec) const = 0;
146 #define X(f) virtual EMatrixd f(const double T, const EArrayd& rhovec) const = 0;
149 #define X(f) virtual std::tuple<double, Eigen::ArrayXd, Eigen::MatrixXd> f(const double T, const EArrayd& rhovec) const = 0;
158 std::tuple<double, double>
solve_pure_critical(
const double T,
const double rho,
const std::optional<nlohmann::json>& = std::nullopt)
const ;
159 EArray2 extrapolate_from_critical(
const double Tc,
const double rhoc,
const double Tgiven,
const std::optional<Eigen::ArrayXd>& molefracs = std::nullopt)
const;
160 std::tuple<EArrayd, EMatrixd>
get_pure_critical_conditions_Jacobian(
const double T,
const double rho,
const std::optional<std::size_t>& alternative_pure_index,
const std::optional<std::size_t>& alternative_length)
const;
162 EArray2 pure_VLE_T(
const double T,
const double rhoL,
const double rhoV,
int maxiter,
const std::optional<Eigen::ArrayXd>& molefracs = std::nullopt)
const;
163 double dpsatdT_pure(
const double T,
const double rhoL,
const double rhoV)
const;
169 virtual nlohmann::json
trace_VLE_isobar_binary(
const double p,
const double T0,
const EArrayd& rhovecL0,
const EArrayd& rhovecV0,
const std::optional<PVLEOptions> & = std::nullopt)
const;
170 virtual std::tuple<VLE_return_code,EArrayd,EArrayd>
mix_VLE_Tx(
const double T,
const REArrayd& rhovecL0,
const REArrayd& rhovecV0,
const REArrayd& xspec,
const double atol,
const double reltol,
const double axtol,
const double relxtol,
const int maxiter)
const;
172 virtual std::tuple<VLE_return_code,double,EArrayd,EArrayd>
mixture_VLE_px(
const double p_spec,
const REArrayd& xmolar_spec,
const double T0,
const REArrayd& rhovecL0,
const REArrayd& rhovecV0,
const std::optional<MixVLEpxFlags>& flags = std::nullopt)
const;
174 std::tuple<VLLE::VLLE_return_code,EArrayd,EArrayd,EArrayd>
mix_VLLE_T(
const double T,
const REArrayd& rhovecVinit,
const REArrayd& rhovecL1init,
const REArrayd& rhovecL2init,
const double atol,
const double reltol,
const double axtol,
const double relxtol,
const int maxiter)
const;
175 std::vector<nlohmann::json>
find_VLLE_T_binary(
const std::vector<nlohmann::json>& traces,
const std::optional<VLLE::VLLEFinderOptions> options = std::nullopt)
const;
176 std::vector<nlohmann::json>
find_VLLE_p_binary(
const std::vector<nlohmann::json>& traces,
const std::optional<VLLE::VLLEFinderOptions> options = std::nullopt)
const;
179 virtual nlohmann::json
trace_critical_arclength_binary(
const double T0,
const EArrayd& rhovec0,
const std::optional<std::string>& = std::nullopt,
const std::optional<TCABOptions> & = std::nullopt)
const;
189 std::unique_ptr<AbstractModel>
make_model(
const nlohmann::json &,
bool validate =
true);
196 const std::vector<std::string>& components,
197 const std::string& coolprop_root,
198 const std::string& BIPcollectionpath = {},
199 const nlohmann::json& flags = {},
200 const std::string& departurepath = {}
203 std::unique_ptr<AbstractModel>
build_model_ptr(
const nlohmann::json& json,
bool validate =
true);
std::vector< nlohmann::json > find_VLLE_T_binary(const std::vector< nlohmann::json > &traces, const std::optional< VLLE::VLLEFinderOptions > options=std::nullopt) const
virtual double get_AtaudeltaXi(const double tau, const int Ntau, const double delta, int Ndelta, const EArrayd &molefrac, const int i, const int NXi) const =0
std::tuple< VLLE::VLLE_return_code, EArrayd, EArrayd, EArrayd > mix_VLLE_T(const double T, const REArrayd &rhovecVinit, const REArrayd &rhovecL1init, const REArrayd &rhovecL2init, const double atol, const double reltol, const double axtol, const double relxtol, const int maxiter) const
virtual std::map< int, double > get_Bnvir(const int Nderiv, const double T, const EArrayd &z) const =0
virtual Eigen::ArrayXd get_Psir_sigma_derivs(const double T, const EArrayd &rhovec, const EArrayd &v) const =0
virtual double get_ATrhoXiXjXk(const double T, const int NT, const double rhomolar, int ND, const EArrayd &molefrac, const int i, const int NXi, const int j, const int NXj, const int k, const int NXk) const =0
double dpsatdT_pure(const double T, const double rhoL, const double rhoV) const
virtual std::tuple< VLE_return_code, double, EArrayd, EArrayd > mixture_VLE_px(const double p_spec, const REArrayd &xmolar_spec, const double T0, const REArrayd &rhovecL0, const REArrayd &rhovecV0, const std::optional< MixVLEpxFlags > &flags=std::nullopt) const
virtual double get_Ar02ep(const double, const double, const EArrayd &) const =0
virtual double get_R(const EArrayd &) const =0
virtual double get_ATrhoXiXj(const double T, const int NT, const double rhomolar, int ND, const EArrayd &molefrac, const int i, const int NXi, const int j, const int NXj) const =0
virtual nlohmann::json trace_VLE_isobar_binary(const double p, const double T0, const EArrayd &rhovecL0, const EArrayd &rhovecV0, const std::optional< PVLEOptions > &=std::nullopt) const
virtual double get_dpsat_dTsat_isopleth(const double T, const REArrayd &rhovecL, const REArrayd &rhovecV) const
virtual double get_B2vir(const double T, const EArrayd &z) const =0
virtual double get_AtaudeltaXiXjXk(const double tau, const int Ntau, const double delta, int Ndelta, const EArrayd &molefrac, const int i, const int NXi, const int j, const int NXj, const int k, const int NXk) const =0
double get_neff(const double, const double, const EArrayd &) const
nlohmann::json trace_VLLE_binary(const double T, const REArrayd &rhovecV, const REArrayd &rhovecL1, const REArrayd &rhovecL2, const std::optional< VLLE::VLLETracerOptions > options) const
virtual EArray33d get_deriv_mat2(const double T, double rho, const EArrayd &z) const =0
virtual EArrayd get_drhovec_dT_crit(const double T, const REArrayd &rhovec) const
virtual double get_minimum_eigenvalue_Psi_Hessian(const double T, const REArrayd &rhovec) const
virtual EArray2 get_criticality_conditions(const double T, const REArrayd &rhovec) const
EArray2 extrapolate_from_critical(const double Tc, const double rhoc, const double Tgiven, const std::optional< Eigen::ArrayXd > &molefracs=std::nullopt) const
virtual MixVLEReturn mix_VLE_Tp(const double T, const double pgiven, const REArrayd &rhovecL0, const REArrayd &rhovecV0, const std::optional< MixVLETpFlags > &flags=std::nullopt) const
virtual double get_Ar03ep(const double, const double, const EArrayd &) const =0
virtual nlohmann::json trace_VLE_isotherm_binary(const double T0, const EArrayd &rhovec0, const EArrayd &rhovecV0, const std::optional< TVLEOptions > &=std::nullopt) const
virtual double get_ATrhoXi(const double T, const int NT, const double rhomolar, int ND, const EArrayd &molefrac, const int i, const int NXi) const =0
virtual ~AbstractModel()=default
virtual std::tuple< VLE_return_code, EArrayd, EArrayd > mix_VLE_Tx(const double T, const REArrayd &rhovecL0, const REArrayd &rhovecV0, const REArrayd &xspec, const double atol, const double reltol, const double axtol, const double relxtol, const int maxiter) const
double R(const EArrayd &x) const
virtual EigenData eigen_problem(const double T, const REArrayd &rhovec, const std::optional< REArrayd > &=std::nullopt) const
EArray2 pure_VLE_T(const double T, const double rhoL, const double rhoV, int maxiter, const std::optional< Eigen::ArrayXd > &molefracs=std::nullopt) const
virtual double get_AtaudeltaXiXj(const double tau, const int Ntau, const double delta, int Ndelta, const EArrayd &molefrac, const int i, const int NXi, const int j, const int NXj) const =0
std::tuple< double, double > solve_pure_critical(const double T, const double rho, const std::optional< nlohmann::json > &=std::nullopt) const
virtual double get_dmBnvirdTm(const int Nderiv, const int NTderiv, const double T, const EArrayd &z) const =0
virtual const std::type_index & get_type_index() const =0
virtual double get_dp_dT_crit(const double T, const REArrayd &rhovec) const
virtual std::tuple< EArrayd, EArrayd > get_drhovecdp_Tsat(const double T, const REArrayd &rhovecL, const REArrayd &rhovecV) const
std::tuple< EArrayd, EMatrixd > get_pure_critical_conditions_Jacobian(const double T, const double rho, const std::optional< std::size_t > &alternative_pure_index, const std::optional< std::size_t > &alternative_length) const
virtual double get_Arxy(const int, const int, const double, const double, const EArrayd &) const =0
std::vector< nlohmann::json > find_VLLE_p_binary(const std::vector< nlohmann::json > &traces, const std::optional< VLLE::VLLEFinderOptions > options=std::nullopt) const
virtual nlohmann::json trace_critical_arclength_binary(const double T0, const EArrayd &rhovec0, const std::optional< std::string > &=std::nullopt, const std::optional< TCABOptions > &=std::nullopt) const
virtual double get_B12vir(const double T, const EArrayd &z) const =0
virtual std::tuple< EArrayd, EArrayd > get_drhovecdT_psat(const double T, const REArrayd &rhovecL, const REArrayd &rhovecV) const
virtual double get_Ar01ep(const double, const double, const EArrayd &) const =0
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< 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 ...
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.
#define ISOCHORIC_matrix_args
#define ISOCHORIC_double_args
Eigen::Ref< const Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic > > REMatrixd
Eigen::Ref< const EArrayd > REArrayd
Eigen::Array< double, 3, 3 > EArray33d
Eigen::Array< double, 2, 1 > EArray2
Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic > EMatrixd
#define ISOCHORIC_multimatrix_args
#define ISOCHORIC_array_args
Eigen::ArrayX< double > EArrayd