Skip to content

Commit

Permalink
[unittest] Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Jan 21, 2024
1 parent 542cb52 commit 20be009
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 33 additions & 0 deletions test/clib/test_ctreactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,37 @@ vector<double> T_ctreactor = {
1052.370, 1053.216, 1054.372, 1056.007, 1058.448, 1062.431, 1070.141, 1094.331,
2894.921, 2894.921, 2894.921, 2894.921, 2894.921};

TEST(ctreactor, reactor_simple)
{
double T = 1050;
double P = 5 * 101325;
string X = "CH4:1.0, O2:2.0, N2:7.52";

int sol = soln_newSolution("gri30.yaml", "gri30", "none");
int thermo = soln_thermo(sol);
thermo_setMoleFractionsByName(thermo, X.c_str());
thermo_setTemperature(thermo, T);
thermo_setPressure(thermo, P);

int reactor = reactor_new("IdealGasReactor");
int ret = reactor_setSolution(reactor, sol);
ASSERT_EQ(ret, 0);
int net = reactornet_new();
ret = reactornet_addreactor(net, reactor);
ASSERT_EQ(ret, 0);

double t = 0.0;
int count = 0;
while (t < 0.1) {
double Tref = T_ctreactor[count];
ASSERT_NEAR(reactor_temperature(reactor), Tref, 1e-2);
t = reactornet_time(net) + 5e-3;
ret = reactornet_advance(net, t);
ASSERT_EQ(ret, 0);
count++;
}
}

TEST(ctreactor, reactor_insert)
{
double T = 1050;
Expand All @@ -39,7 +70,9 @@ TEST(ctreactor, reactor_insert)
thermo_setPressure(thermo, P);

int reactor = reactor_new("IdealGasReactor");
suppress_deprecation_warnings();
int ret = reactor_insert(reactor, sol);
make_deprecation_warnings_fatal();
ASSERT_EQ(ret, 0);
int net = reactornet_new();
ret = reactornet_addreactor(net, reactor);
Expand Down
4 changes: 2 additions & 2 deletions test/zeroD/test_zeroD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

using namespace Cantera;

// This test is an exact equivalent of a clib test
// (clib::test_ctreactor.cpp::ctreactor::reactor_insert)
// This test is an (almost) exact equivalent of a clib test
// (clib::test_ctreactor.cpp::ctreactor::reactor_simple)
TEST(zerodim, simple)
{
double T = 1050;
Expand Down

0 comments on commit 20be009

Please sign in to comment.