32 #include "antioch_config.h"
36 #ifdef ANTIOCH_HAVE_EIGEN
37 #include "Eigen/Dense"
40 #ifdef ANTIOCH_HAVE_METAPHYSICL
41 #include "metaphysicl/numberarray.h"
44 #ifdef ANTIOCH_HAVE_VEXCL
45 #include "vexcl/vexcl.hpp"
71 #ifdef ANTIOCH_HAVE_GRVY
74 GRVY::GRVY_Timer_Class gt;
83 template <
typename PairScalars>
85 const PairScalars& example,
86 const std::string& testname)
92 std::vector<std::string> species_str_list;
93 const unsigned int n_species = 5;
94 species_str_list.reserve(n_species);
95 species_str_list.push_back(
"N2" );
96 species_str_list.push_back(
"O2" );
97 species_str_list.push_back(
"N" );
98 species_str_list.push_back(
"O" );
99 species_str_list.push_back(
"NO" );
105 Antioch::read_reaction_set_data_xml<Scalar>( input_name,
true, reaction_set );
108 std::vector<PairScalars> omega_dot(n_species, example);
110 PairScalars P = example;
113 PairScalars Y_vals = example;
115 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
118 P[2*tuple+1] = 1.2e5;
120 Y_vals[2*tuple ] = 0.2;
121 Y_vals[2*tuple+1] = 0.25;
124 std::vector<PairScalars> Y(n_species,Y_vals);
126 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
129 const unsigned int n_T_samples = 10;
130 const Scalar T0 = 500;
131 const Scalar T_inc = 500;
133 const PairScalars R_mix = chem_mixture.
R(Y);
135 std::vector<PairScalars> molar_densities(n_species,example);
136 std::vector<PairScalars> h_RT_minus_s_R(n_species, example);
140 for(
unsigned int i = 0; i < n_T_samples; i++ )
142 PairScalars T = example;
144 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
146 T[2*tuple ] = T0 + T_inc*
static_cast<Scalar
>(i);
147 T[2*tuple+1] = T[0]+T_inc/2;
152 #ifdef ANTIOCH_HAVE_GRVY
153 const std::string testnormal = testname +
"-normal";
154 gt.BeginTimer(testnormal);
157 const PairScalars rho = P/(R_mix*T);
161 template Cache<PairScalars> Cache;
165 kinetics.compute_mass_sources( cond, molar_densities, h_RT_minus_s_R, omega_dot );
167 #ifdef ANTIOCH_HAVE_GRVY
168 gt.EndTimer(testnormal);
172 PairScalars sum = omega_dot[0];
173 for(
unsigned int s = 1; s < n_species; s++ )
177 const Scalar sum_tol = std::numeric_limits<Scalar>::epsilon() * 5e6;
178 const PairScalars abs_sum = abs(sum);
182 std::cerr <<
"Error: omega_dot did not sum to 0.0." << std::endl
183 << std::scientific << std::setprecision(16)
184 <<
"T = " << T << std::endl
185 <<
"sum = " << sum <<
", sum_tol = " << sum_tol << std::endl;
186 for(
unsigned int s = 0; s < n_species; s++ )
188 std::cerr << std::scientific << std::setprecision(16)
190 << omega_dot[s] << std::endl;
192 std::cout << std::endl << std::endl;
196 #ifdef ANTIOCH_HAVE_EIGEN
200 #endif // ANTIOCH_HAVE_EIGEN
206 int main(
int argc,
char* argv[])
212 std::cerr <<
"Error: Must specify reaction set XML input file." << std::endl;
218 returnval = returnval ||
219 vectester (argv[1], std::valarray<float>(2*ANTIOCH_N_TUPLES),
"valarray<float>");
220 returnval = returnval ||
221 vectester (argv[1], std::valarray<double>(2*ANTIOCH_N_TUPLES),
"valarray<double>");
222 returnval = returnval ||
223 vectester (argv[1], std::valarray<long double>(2*ANTIOCH_N_TUPLES),
"valarray<ld>");
224 #ifdef ANTIOCH_HAVE_EIGEN
225 returnval = returnval ||
226 vectester (argv[1], Eigen::Array<float, 2*ANTIOCH_N_TUPLES, 1>(),
"Eigen::ArrayXf");
227 returnval = returnval ||
228 vectester (argv[1], Eigen::Array<double, 2*ANTIOCH_N_TUPLES, 1>(),
"Eigen::ArrayXd");
229 returnval = returnval ||
230 vectester (argv[1], Eigen::Array<long double, 2*ANTIOCH_N_TUPLES, 1>(),
"Eigen::ArrayXld");
232 #ifdef ANTIOCH_HAVE_METAPHYSICL
233 returnval = returnval ||
234 vectester (argv[1], MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, float>(0),
"NumberArray<float>");
235 returnval = returnval ||
236 vectester (argv[1], MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, double>(0),
"NumberArray<double>");
237 returnval = returnval ||
238 vectester (argv[1], MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, long double>(0),
"NumberArray<ld>");
240 #ifdef ANTIOCH_HAVE_VEXCL
241 vex::Context ctx_f (vex::Filter::All);
243 returnval = returnval ||
244 vectester (argv[1], vex::vector<float> (ctx_f, 2*ANTIOCH_N_TUPLES),
"vex::vector<float>");
246 vex::Context ctx_d (vex::Filter::DoublePrecision);
248 returnval = returnval ||
249 vectester (argv[1], vex::vector<double> (ctx_d, 2*ANTIOCH_N_TUPLES),
"vex::vector<double>");
252 #ifdef ANTIOCH_HAVE_GRVY
Antioch::enable_if_c< is_eigen< T >::value, typename value_type< T >::type >::type max(const T &in)
This class encapsulates all the reaction mechanisms considered in a chemical nonequilibrium simulatio...
int main(int argc, char *argv[])
CoeffType R(const unsigned int s) const
Gas constant for species s in [J/kg-K].
Class to handle computing mass source terms for a given ReactionSet.
X(const unsigned int species, const StateType &M, const StateType &mass_fraction) const template< typename VectorStateType > void X(typename Antioch VectorStateType void molar_densities(const StateType &rho, const VectorStateType &mass_fractions, VectorStateType &molar_densities) const
Class storing chemical mixture properties.
StateType h_RT_minus_s_R(const Cache< StateType > &cache, unsigned int species) const
We currently need different specializations for scalar vs vector inputs here.
const std::vector< ChemicalSpecies< CoeffType > * > & chemical_species() const
This class contains the conditions of the chemistry.
We parse the file here, with an exhaustive unit management.
int vectester(const std::string &input_name, const PairScalars &example, const std::string &testname)