diff --git a/include/teqp/cpp/deriv_adapter.hpp b/include/teqp/cpp/deriv_adapter.hpp index 55d148ad..04292a5b 100644 --- a/include/teqp/cpp/deriv_adapter.hpp +++ b/include/teqp/cpp/deriv_adapter.hpp @@ -114,7 +114,9 @@ class DerivativeAdapter : public teqp::cppinterface::AbstractModel{ return IsochoricDerivatives::get_Psir_sigma_derivs(mp.get_cref(), T, rhovec, v); }; - virtual EArray33d get_deriv_mat2(const double T, double rho, const EArrayd& z ) const override { throw teqp::NotImplementedError("Not available"); }; + virtual EArray33d get_deriv_mat2(const double T, double rho, const EArrayd& z ) const override { + return DerivativeHolderSquare<2, AlphaWrapperOption::residual>(mp.get_cref(), T, rho, z).derivs; + }; }; template auto view(const TemplatedModel& tp){ diff --git a/src/bench_derivbox.cpp b/src/bench_derivbox.cpp index 2ce8254a..6740a2c7 100644 --- a/src/bench_derivbox.cpp +++ b/src/bench_derivbox.cpp @@ -14,7 +14,7 @@ using namespace teqp; TEST_CASE("multifluid derivatives", "[mf]") { std::vector names = { "Ethane" }; - auto model = build_multifluid_model(names, "../mycp"); + auto model = build_multifluid_model(names, "../teqp/fluiddata"); double T = 300, rho = 2; Eigen::ArrayX z(1); z.fill(1.0); @@ -25,8 +25,8 @@ TEST_CASE("multifluid derivatives", "[mf]") auto aig = teqp::IdealHelmholtz(jigs); using namespace teqp::cppinterface; - std::shared_ptr amm = teqp::cppinterface::make_multifluid_model(names, "../mycp"); - std::shared_ptr aigg = teqp::cppinterface::make_model({{"kind","IdealHelmholtz"}, {"model", jigs}}); + const std::shared_ptr amm = teqp::cppinterface::make_multifluid_model(names, "../teqp/fluiddata"); + const std::shared_ptr aigg = teqp::cppinterface::make_model({{"kind","IdealHelmholtz"}, {"model", jigs}}); std::vector vars = {'P', 'S'}; const auto vals = (Eigen::ArrayXd(2) << 300.0, 400.0).finished(); @@ -37,6 +37,9 @@ TEST_CASE("multifluid derivatives", "[mf]") BENCHMARK("alphar") { return model.alphar(T, rho, z); }; + BENCHMARK("Ar11") { + return amm->get_Ar11(T, rho, z); + }; BENCHMARK("All residual derivatives needed for first derivatives of h,s,u,p w.r.t. T&rho") { return DerivativeHolderSquare<2,AlphaWrapperOption::residual>(model, T, rho, z).derivs; @@ -49,7 +52,7 @@ TEST_CASE("multifluid derivatives", "[mf]") BENCHMARK("All residual derivatives (via AbstractModel) needed for first derivatives of h,s,u,p w.r.t. T&rho") { return amm->get_deriv_mat2(T, rho, z); }; - BENCHMARK("All residual derivatives (via AbstractModel) needed for first derivatives of h,s,u,p w.r.t. T&rho") { + BENCHMARK("All ideal-gas derivatives (via AbstractModel) needed for first derivatives of h,s,u,p w.r.t. T&rho") { return aigg->get_deriv_mat2(T, rho, z); }; @@ -65,5 +68,20 @@ TEST_CASE("multifluid derivatives", "[mf]") BENCHMARK("Newton-Raphson take_steps") { return NR.take_steps(5); }; +} + +TEST_CASE("Time very low level operations", "[mf]"){ + std::unordered_map delta_map{{1, 3.7}, {3,9.7}, {5, -3}}; + std::valarray delta_array{3.7, 3, -6}; + + BENCHMARK("return delta_map") { + return delta_map[3]; + }; + BENCHMARK("return delta_array") { + return delta_array[2]; + }; + BENCHMARK("calc powi(delta, 3)") { + return powi(1.3, 3); + }; }