Skip to content

Commit

Permalink
Switch from arrays to vectors, update regression test tolerances
Browse files Browse the repository at this point in the history
  • Loading branch information
paulblum committed Sep 2, 2020
1 parent cdd8069 commit 2224aed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions samples/cxx/custom/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ class ReactorODEs : public FuncEval {
// number of chemical species in the system.
nSpecies = gas->nSpecies();

// resize the vector_fp storage containers for species partial molar enthalpies
// and net production rates. internal values are updated and used by the solver
// per iteration.
hbar.resize(nSpecies);
wdot.resize(nSpecies);

// number of equations in the ODE system. a conservation equation for each
// species, plus a single energy conservation equation for the system.
nEqs = nSpecies + 1;
Expand Down Expand Up @@ -67,10 +73,8 @@ class ReactorODEs : public FuncEval {
/* ----------------------- GET REQ'D PROPERTIES ----------------------- */
double rho = gas->density();
double cp = gas->cp_mass();
double hbar[nSpecies];
gas->getPartialMolarEnthalpies(hbar);
double wdot[nSpecies];
kinetics->getNetProductionRates(wdot);
gas->getPartialMolarEnthalpies(&hbar[0]);
kinetics->getNetProductionRates(&wdot[0]);

/* -------------------------- ENERGY EQUATION ------------------------- */
// the rate of change of the system temperature is found using the energy
Expand Down Expand Up @@ -117,6 +121,8 @@ class ReactorODEs : public FuncEval {
// private member variables, to be used internally.
shared_ptr<ThermoPhase> gas;
shared_ptr<Kinetics> kinetics;
vector_fp hbar;
vector_fp wdot;
double pressure;
int nSpecies;
int nEqs;
Expand Down
3 changes: 2 additions & 1 deletion test_problems/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ Test('cxx-combustor', 'cxx_samples', '#build/samples/cxx/combustor/combustor', N
comparisons=[('combustor_cxx_blessed.csv', 'combustor_cxx.csv')],
threshold=1e-10, tolerance=2e-4)
Test('cxx-custom', 'cxx_samples', '#build/samples/cxx/custom/custom', None,
comparisons=[('custom_cxx_blessed.csv', 'custom_cxx.csv')])
comparisons=[('custom_cxx_blessed.csv', 'custom_cxx.csv')],
threshold=1e-10, tolerance=2e-4)
Test('cxx-flamespeed', 'cxx_samples', '#build/samples/cxx/flamespeed/flamespeed',
'cxx_flamespeed_blessed.txt',
comparisons=[('flamespeed_blessed.csv', 'flamespeed.csv')],
Expand Down

0 comments on commit 2224aed

Please sign in to comment.