mirror of
https://github.com/Cantera/cantera.git
synced 2026-08-10 04:58:04 -05:00
This commit makes requested changes to the reactor initialization test.
This commit changes the former test to use Reactor classes in lieu of IdealGasConstPressureReactor classes because it is the base class. It also changes some of the comparisons between the two reactor objects.
This commit is contained in:
committed by
Bryan W. Weber
parent
b920d62409
commit
b77781dbb9
+20
-10
@@ -14,13 +14,13 @@ TEST(ZeroDim, test_individual_reactor_initialization)
|
||||
double T0 = 1100.0;
|
||||
double P0 = 1013250;
|
||||
std::string X0 = "H2:1.0, O2:0.5, AR:8.0";
|
||||
//IdealGasConstPressureReactor solution, phase, and kinetics objects
|
||||
//Reactor solution, phase, and kinetics objects
|
||||
std::shared_ptr<Solution> sol1 = newSolution("h2o2.yaml");
|
||||
std::shared_ptr<ThermoPhase> gas1 = sol1->thermo();
|
||||
std::shared_ptr<Kinetics> kin1 = sol1->kinetics();
|
||||
gas1->setState_TPX(T0, P0, X0);
|
||||
//Set up reactor object
|
||||
IdealGasConstPressureReactor reactor1;
|
||||
Reactor reactor1;
|
||||
reactor1.setKineticsMgr(*kin1);
|
||||
reactor1.setThermoMgr(*gas1);
|
||||
//initialize reactor at arbitrary value
|
||||
@@ -34,15 +34,25 @@ TEST(ZeroDim, test_individual_reactor_initialization)
|
||||
std::shared_ptr<ThermoPhase> gas2 = sol2->thermo();
|
||||
std::shared_ptr<Kinetics> kin2 = sol2->kinetics();
|
||||
gas2->setState_TPX(T0, P0, X0);
|
||||
gas2->equilibrate("HP");
|
||||
//Compare the two gases.
|
||||
double tol = 1e-8; //relative tolerance from python assertNear test
|
||||
EXPECT_NEAR(gas1->temperature(), gas2->temperature(), tol);
|
||||
EXPECT_NEAR(gas1->density(), gas2->density(), tol);
|
||||
EXPECT_NEAR(gas1->pressure(), P0, tol);
|
||||
for(size_t i = 0; i < gas1->stateSize()-2; i++)
|
||||
gas2->equilibrate("UV");
|
||||
//Secondary reactor for comparison
|
||||
Reactor reactor2;
|
||||
reactor2.setKineticsMgr(*kin2);
|
||||
reactor2.setThermoMgr(*gas2);
|
||||
reactor2.initialize(0);
|
||||
//Get state of reactors
|
||||
double state1 [reactor1.neq()];
|
||||
double state2 [reactor2.neq()];
|
||||
reactor1.getState(state1);
|
||||
reactor2.getState(state2);
|
||||
//Compare the reactors.
|
||||
EXPECT_EQ(reactor1.neq(), reactor2.neq());
|
||||
double tol = 1e-14;
|
||||
EXPECT_NEAR(state1[0], state2[0], tol);
|
||||
EXPECT_NEAR(state1[1], state2[1], tol);
|
||||
for(size_t i = 3; i < reactor2.neq(); i++)
|
||||
{
|
||||
EXPECT_NEAR(gas1->massFraction(i), gas2->massFraction(i), tol);
|
||||
EXPECT_NEAR(state1[i], state2[i], tol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user