teqp
0.23.1
Toggle main menu visibility
Loading...
Searching...
No Matches
interface
CPP
test
bench_teqpcpp.cpp
Go to the documentation of this file.
1
#include <catch2/catch_test_macros.hpp>
2
#include <catch2/benchmark/catch_benchmark_all.hpp>
3
4
#include "
teqpcpp.hpp
"
5
6
using namespace
teqp::cppinterface
;
7
8
#include "
teqp/derivs.hpp
"
9
#include "
teqp/models/multifluid.hpp
"
10
11
using namespace
teqp
;
12
13
TEST_CASE
(
"Test C++ interface"
,
"[C++]"
)
14
{
15
auto
modelnovar =
teqp::build_multifluid_model
({
"Methane"
,
"Ethane"
},
"../mycp"
);
16
auto
model =
teqp::cppinterface::make_multifluid_model
({
"Methane"
,
"Ethane"
},
"../mycp"
);
17
auto
z = (Eigen::ArrayXd(2) << 0.5, 0.5).finished();
18
SECTION(
"Ar01"
) {
19
double
Ar01 = model->get_Arxy(0, 1, 300, 3, z);
20
}
21
SECTION(
"critical trace"
) {
22
double
Tc1 = modelnovar.redfunc.Tc(0);
23
auto
rhovec0 = (Eigen::ArrayXd(2) << 1/modelnovar.redfunc.vc(0), 0).finished();
24
auto
cr = model->trace_critical_arclength_binary(Tc1, rhovec0);
25
std::cout << cr.dump(1) << std::endl;
26
}
27
}
28
29
TEST_CASE
(
"Benchmark C++ interface"
,
"[C++]"
)
30
{
31
auto
model =
teqp::cppinterface::make_multifluid_model
({
"Methane"
,
"Ethane"
},
"../mycp"
);
32
auto
z = (Eigen::ArrayXd(2) << 0.5, 0.5).finished();
33
34
auto
model1novar =
teqp::build_multifluid_model
({
"Methane"
},
"../mycp"
);
35
auto
model1 =
teqp::cppinterface::make_multifluid_model
({
"Methane"
},
"../mycp"
);
36
auto
z1 = (Eigen::ArrayXd(1) << 1).finished();
37
38
BENCHMARK(
"Ar01 two components"
) {
39
return
model->get_Arxy(0, 1, 300, 3, z);
40
};
41
BENCHMARK(
"Ar01 one component w/ Arxy (C++ interface, runtime lookup)"
) {
42
return
model->get_Arxy(0, 1, 300, 3, z1);
43
};
44
BENCHMARK(
"Ar01 one component w/ Ar01 directly"
) {
45
return
TDXDerivatives
<
decltype
(model1novar)>::get_Arxy<0,1,ADBackends::autodiff>(model1novar, 300, 3, z1);
46
};
47
}
TEST_CASE
TEST_CASE("Test C++ interface", "[C++]")
Definition
bench_teqpcpp.cpp:13
derivs.hpp
multifluid.hpp
teqp::cppinterface
Definition
deriv_adapter.hpp:15
teqp::cppinterface::make_multifluid_model
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={})
Definition
teqp_impl_factory.cpp:132
teqp
Definition
ancillary_builder.hpp:8
teqp::build_multifluid_model
auto build_multifluid_model(const std::vector< std::string > &components, const std::string &root, const std::string &BIPcollectionpath={}, const nlohmann::json &flags={}, const std::string &departurepath={})
Definition
multifluid.hpp:1073
teqp::TDXDerivatives
Definition
derivs.hpp:117
teqpcpp.hpp
Generated by
1.17.0