From 0878f890b8aff8622165413e87e34848ad37ed4d Mon Sep 17 00:00:00 2001 From: Ian Bell <ian.bell@nist.gov> Date: Wed, 25 May 2022 09:25:50 -0400 Subject: [PATCH] Add ability to access a single departure term in a multi-fluid model (#14) * Add ability to access a single departure term in a multi-fluid model * Bump version to dev --- include/teqp/models/multifluid.hpp | 14 ++++++++++++++ interface/multifluid.cpp | 1 + interface/multifluid_mutant.cpp | 1 + interface/teqpversion.hpp | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/teqp/models/multifluid.hpp b/include/teqp/models/multifluid.hpp index 4bec7c7..331368a 100644 --- a/include/teqp/models/multifluid.hpp +++ b/include/teqp/models/multifluid.hpp @@ -15,6 +15,7 @@ #include "teqp/constants.hpp" #include "teqp/filesystem.hpp" #include "teqp/json_tools.hpp" +#include "teqp/exceptions.hpp" #include "MultiComplex/MultiComplex.hpp" @@ -108,6 +109,19 @@ public: } return forceeval(alphar); } + + /// Call a single departure term at i,j + template<typename TauType, typename DeltaType> + auto get_alpharij(const int i, const int j, const TauType& tau, const DeltaType& delta) const { + int N = funcs.size(); + if (i < 0 || j < 0){ + throw teqp::InvalidArgument("i or j is negative"); + } + if (i >= N || j >= N){ + throw teqp::InvalidArgument("i or j is invalid; size is " + std::to_string(N)); + } + return forceeval(funcs[i][j].alphar(tau, delta)); + } }; template<typename CorrespondingTerm, typename DepartureTerm> diff --git a/interface/multifluid.cpp b/interface/multifluid.cpp index 594e955..4f09fa4 100644 --- a/interface/multifluid.cpp +++ b/interface/multifluid.cpp @@ -14,6 +14,7 @@ void add_multifluid(py::module& m) { auto wMF = py::class_<MultiFluid>(m, "MultiFluid"); add_derivatives<MultiFluid>(m, wMF); add_multifluid_methods<MultiFluid>(wMF); + wMF.def("get_alpharij", [](const MultiFluid& c, const int i, const int j, const double &tau, const double &delta) { return c.dep.get_alpharij(i, j, tau, delta); }); // Expose some additional functions for working with the JSON data structures and resolving aliases m.def("get_BIPdep", &reducing::get_BIPdep, py::arg("BIPcollection"), py::arg("identifiers"), py::arg("flags") = nlohmann::json{}); diff --git a/interface/multifluid_mutant.cpp b/interface/multifluid_mutant.cpp index f0cd365..bae14c8 100644 --- a/interface/multifluid_mutant.cpp +++ b/interface/multifluid_mutant.cpp @@ -28,6 +28,7 @@ void add_multifluid_mutant(py::module& m) { add_derivatives<BIPmod>(m, wMFBIP); add_multifluid_methods<BIPmod>(wMFBIP); + wMFBIP.def("get_alpharij", [](const BIPmod& c, const int i, const int j, const double &tau, const double &delta) { return c.depfunc.get_alpharij(i, j, tau, delta); }); // Wrap the deprecated function for generating a multifluid mutant called an invariant m.def("build_multifluid_mutant_invariant", &build_multifluid_mutant<MultiFluid>); diff --git a/interface/teqpversion.hpp b/interface/teqpversion.hpp index 1edffdb..635c777 100644 --- a/interface/teqpversion.hpp +++ b/interface/teqpversion.hpp @@ -1,2 +1,2 @@ #include <string> -const std::string TEQPVERSION = "0.8.1"; \ No newline at end of file +const std::string TEQPVERSION = "0.8.1.dev0"; \ No newline at end of file -- GitLab