43 template<
typename Scalar>
44 Scalar
HE(
const Scalar &T,
const Scalar &Cf,
const Scalar &eta,
const Scalar &Tf = 1.L)
49 template<
typename Scalar>
50 Scalar
Arrh(
const Scalar &T,
const Scalar &Cf,
const Scalar &Ea)
52 return Cf * std::exp(-Ea /(Antioch::Constants::R_universal<Scalar>() * T));
55 template<
typename Scalar>
56 Scalar
Kooij(
const Scalar &T,
const Scalar &Cf,
const Scalar &eta,
const Scalar &Ea,
const Scalar &Tf = 1.L)
58 return Cf *
std::pow(T/Tf,eta) * std::exp(-Ea /(Antioch::Constants::R_universal<Scalar>() * T));
61 template<
typename Scalar>
62 Scalar
FcentTroe(
const Scalar &T,
const Scalar &alpha,
const Scalar &T3,
const Scalar &T1,
const Scalar &T2 = -1.L)
64 return (T2 < Scalar(0.))?(Scalar(1.) - alpha) * std::exp(-T/T3) + alpha * std::exp(-T/T1):
65 (Scalar(1.) - alpha) * std::exp(-T/T3) + alpha * std::exp(-T/T1) + std::exp(-T2/T);
68 template<
typename Scalar>
69 Scalar
coeffTroe(
const Scalar &coef1,
const Scalar &coef2,
const Scalar &Fcent)
71 return coef1 + coef2 * std::log10(Fcent);
74 template<
typename Scalar>
75 Scalar
cTroe(
const Scalar &Fcent)
82 template<
typename Scalar>
83 Scalar
nTroe(
const Scalar &Fcent)
90 template<
typename Scalar>
91 Scalar
FTroe(
const Scalar &Fcent,
const Scalar &Pr)
94 return std::pow(10.L,std::log10(Fcent)/(Scalar(1.) +
96 (
nTroe(Fcent) - d * (std::log10(Pr) +
cTroe(Fcent)) ),2)));
99 template<
typename VectorScalar>
101 const VectorScalar &sigma_lambda,
const VectorScalar &sigma_sigma)
104 VectorScalar sigma_rescaled;
108 for(
unsigned int il = 0; il < solar_irr.size() - 1; il++)
110 _k += sigma_rescaled[il] * solar_irr[il] * (solar_lambda[il+1] - solar_lambda[il]);
116 template<
typename Scalar>
120 std::vector<std::string> species_str_list;
121 species_str_list.push_back(
"O2" );
122 species_str_list.push_back(
"OH" );
123 species_str_list.push_back(
"H2" );
124 species_str_list.push_back(
"H2O" );
125 species_str_list.push_back(
"H2O2" );
126 species_str_list.push_back(
"HO2" );
127 species_str_list.push_back(
"O" );
128 species_str_list.push_back(
"CH3" );
129 species_str_list.push_back(
"CH4" );
130 species_str_list.push_back(
"H" );
131 unsigned int n_species = species_str_list.size();
135 Antioch::read_reaction_set_data_chemkin<Scalar>( root_name +
"/test_parsing.chemkin",
true, reaction_set );
139 unitEa_cal(
"cal/mol");
143 std::vector<Scalar> molar_densities(n_species,5e-4);
144 Scalar tot_dens((Scalar)n_species * 5e-4);
147 std::vector<Scalar> k;
153 A = 3.547e15L * unitA_1.get_SI_factor();
156 k.push_back(
Kooij(T,A,b,Ea));
163 A = 0.508e5L * unitA_1.get_SI_factor();
166 k.push_back(
Kooij(T,A,b,Ea));
172 A = 0.216e9L * unitA_1.get_SI_factor();
175 k.push_back(
Kooij(T,A,b,Ea));
181 A = 2.97e6L * unitA_1.get_SI_factor();
184 k.push_back(
Kooij(T,A,b,Ea));
192 A = 4.577e19L * unitA_1.get_SI_factor();
195 Scalar sum_eps = 5e-4L * (2.5L + 12.L + (Scalar)(species_str_list.size() - 2));
196 k.push_back(sum_eps *
Kooij(T,A,b,Ea));
203 A = 6.165e15L * unitA_2.get_SI_factor();
205 k.push_back(sum_eps *
HE(T,A,b));
212 A = 4.714e18L * unitA_2.get_SI_factor();
214 k.push_back(sum_eps *
HE(T,A,b));
222 A = 3.800e22L * unitA_2.get_SI_factor();
224 k.push_back(sum_eps *
HE(T,A,b));
242 A = 6.366e20L * unitA_2.get_SI_factor();
245 Scalar k0 =
Kooij(T,A,b,Ea);
246 A = 1.475e12L * unitA_1.get_SI_factor();
249 Scalar M = tot_dens + Scalar(5.39e-3L);
250 Scalar kinf =
Kooij(T,A,b,Ea);
251 Scalar Pr = M * k0/kinf;
252 Scalar Fc =
FcentTroe(T,(Scalar)0.8L,(Scalar)1e-30L,(Scalar)1e30L);
253 k.push_back(k0 / (1.L/M + k0/kinf) *
FTroe(Fc,Pr));
259 A = 1.66e13L * unitA_1.get_SI_factor();
261 k.push_back(
Arrh(T,A,Ea));
267 A = 7.079e13L * unitA_1.get_SI_factor();
269 k.push_back(
Arrh(T,A,Ea));
275 A = 0.325e14L * unitA_1.get_SI_factor();
282 A = 2.890e13L * unitA_1.get_SI_factor();
284 k.push_back(
Arrh(T,A,Ea));
294 A = 4.200e14L * unitA_1.get_SI_factor();
296 Scalar A2 = 1.300e11L * unitA_1.get_SI_factor();
298 k.push_back(
Arrh(T,A,Ea) +
Arrh(T,A2,Ea2));
308 A = 1.202e17L * unitA_1.get_SI_factor();
311 A = 2.951e14L * unitA_0.get_SI_factor();
313 M = tot_dens + 6.25e-3;
316 Fc =
FcentTroe(T,(Scalar)0.5L,(Scalar)1e-30L,(Scalar)1e30L);
317 k.push_back(k0 / (1.L/M + k0/kinf) *
FTroe(Fc,Pr));
324 A = 0.241e14L * unitA_1.get_SI_factor();
326 k.push_back(
Arrh(T,A,Ea));
332 A = 0.482e14L * unitA_1.get_SI_factor();
334 k.push_back(
Arrh(T,A,Ea));
340 A = 9.550e6L * unitA_1.get_SI_factor();
343 k.push_back(
Kooij(T,A,b,Ea));
352 A = 1.000e12L * unitA_1.get_SI_factor();
354 A2 = 5.800e14L * unitA_1.get_SI_factor();
356 k.push_back(
Arrh(T,A,Ea) +
Arrh(T,A2,Ea2));
362 A = 1e12 * unitA_1.get_SI_factor();
365 k.push_back(
Kooij(T,A,b,Ea));
366 A = 1e8 * unitA_0.get_SI_factor();
369 k.push_back(
Kooij(T,A,b,Ea));
372 const Scalar tol = (std::numeric_limits<Scalar>::epsilon() < 1e-17L)?7e-16L:
373 std::numeric_limits<Scalar>::epsilon() * 100;
378 std::cerr << reaction_set << std::endl;
379 std::cerr <<
"Not the right number of reactions" << std::endl;
380 std::cerr << reaction_set.
n_reactions() <<
" instead of " << k.size() << std::endl;
384 for(
unsigned int ir = 0; ir < k.size(); ir++)
390 std::cout << *reac << std::endl;
391 std::cout << std::scientific << std::setprecision(16)
392 <<
"Error in kinetics comparison\n"
393 <<
"reaction #" << ir <<
"\n"
394 <<
"temperature: " << T <<
" K" <<
"\n"
395 <<
"theory: " << k[ir] <<
"\n"
398 <<
"tolerance = " << tol
408 int main(
int argc,
char* argv[])
410 return (tester<float>(std::string(argv[1])) ||
411 tester<double>(std::string(argv[1])) ||
412 tester<long double>(std::string(argv[1])));
Scalar FTroe(const Scalar &Fcent, const Scalar &Pr)
StateType compute_forward_rate_coefficient(const VectorStateType &molar_densities, const KineticsConditions< StateType, VectorStateType > &conditions) const
A single reaction mechanism.
int tester(const std::string &root_name)
This class encapsulates all the reaction mechanisms considered in a chemical nonequilibrium simulatio...
const Reaction< CoeffType > & reaction(const unsigned int r) const
Scalar Kooij(const Scalar &T, const Scalar &Cf, const Scalar &eta, const Scalar &Ea, const Scalar &Tf=1.L)
int main(int argc, char *argv[])
Scalar Arrh(const Scalar &T, const Scalar &Cf, const Scalar &Ea)
Scalar HE(const Scalar &T, const Scalar &Cf, const Scalar &eta, const Scalar &Tf=1.L)
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
Scalar coeffTroe(const Scalar &coef1, const Scalar &coef2, const Scalar &Fcent)
T get_SI_factor() const
Multiplicative coefficient getter.
Scalar nTroe(const Scalar &Fcent)
unsigned int n_reactions() const
Antioch::value_type< VectorScalar >::type k_photo(const VectorScalar &solar_lambda, const VectorScalar &solar_irr, const VectorScalar &sigma_lambda, const VectorScalar &sigma_sigma)
Scalar cTroe(const Scalar &Fcent)
Scalar FcentTroe(const Scalar &T, const Scalar &alpha, const Scalar &T3, const Scalar &T1, const Scalar &T2=-1.L)
void y_on_custom_grid(const VectorCoeffType &x_old, const VectorCoeffType &y_old, const VectorStateType &x_new, VectorStateType &y_new) const
Class storing chemical mixture properties.
We parse the file here, with an exhaustive unit management.