47 const Scalar Cf1 = 1.135e36L * 1e6L * 1e-12L;
48 const Scalar beta1 = 1.246L;
49 const Scalar Ea1 = 1704.8L / 1.9858775L;
50 const Scalar D1 = -4e-2L;
51 const Scalar Cf2 = 6.22e16L * 1e3L * 1e-12L;
52 const Scalar beta2 = -1.174L;
53 const Scalar Ea2 = 635.8L / 1.9858775L;
54 const Scalar D2 = -5e-3L;
55 const Scalar alpha = 0.405L;
56 const Scalar T3 = 1120L;
57 const Scalar T1 = 69.6L;
60 const std::string equation(
"A + B -> AB");
61 const unsigned int n_species(3);
64 std::vector<Scalar> mol_densities;
65 mol_densities.push_back(1e-2L);
66 mol_densities.push_back(1e-2L);
67 mol_densities.push_back(1e-2L);
69 std::vector<Scalar> epsilon;
70 epsilon.push_back(2.L);
71 epsilon.push_back(8.5L);
72 epsilon.push_back(40.L);
74 Scalar M = epsilon[0] * mol_densities[0];
75 for(
unsigned int i = 1; i < n_species; i++)
77 M += epsilon[i] * mol_densities[i];
80 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 2000;
82 std::cout << type <<
", tolerance = " << tol;
83 Scalar max_diff(-1.L);
85 for(Scalar T = 300.1L; T <= 1500.1L; T += 10.L)
87 for(
unsigned int ikinmod = 0; ikinmod < 6; ikinmod++)
92 Scalar k0,kinf,dk0_dT,dkinf_dT;
95 std::vector<Scalar> derive_dX_exact;
96 derive_dX_exact.resize(n_species);
98 Scalar Fcent = (1.L - alpha) * exp(-T/T3) + alpha * exp(-T/T1);
99 Scalar dFcent_dT = (alpha - 1.L)/T3 * exp(-T/T3) - alpha/T1 * exp(-T/T1);
100 Scalar dlog10Fcent_dT = Antioch::Constants::log10_to_log<Scalar>()/Fcent * dFcent_dT;
101 Scalar n = 0.75L - 1.27L * Antioch::Constants::log10_to_log<Scalar>()*log(Fcent);
102 Scalar c = - 0.40L - 0.67L * Antioch::Constants::log10_to_log<Scalar>()*log(Fcent);
104 Scalar dn_dT = -1.27L * dlog10Fcent_dT;
105 Scalar dc_dT = -0.67L * dlog10Fcent_dT;
116 k0 = Cf1 *
pow(T,beta1); kinf = Cf2 *
pow(T,beta2);
117 dk0_dT = Cf1 *
pow (T,beta1) * beta1/T; dkinf_dT = Cf2 *
pow (T,beta2) * beta2/T;
125 k0 = Cf1 * exp(D1*T); kinf = Cf2 * exp(D2*T);
126 dk0_dT = Cf1 * exp(D1*T) * D1; dkinf_dT = Cf2 * exp(D2*T) * D2;
134 k0 = Cf1 * exp(-Ea1/T); kinf = Cf2 * exp(-Ea2/T);
135 dk0_dT = Cf1 * exp(-Ea1/T) * Ea1/
pow(T,2); dkinf_dT = Cf2 * exp(-Ea2/T) * Ea2/
pow(T,2);
143 k0 = Cf1 *
pow(T,beta1) * exp(D1 * T); kinf = Cf2 *
pow(T,beta2) * exp(D2 * T);
144 dk0_dT = Cf1 *
pow(T,beta1) * exp(D1 * T) * (beta1/T + D1); dkinf_dT = Cf2 *
pow(T,beta2) * exp(D2 * T) * (beta2/T + D2);
152 k0 = Cf1 *
pow(T,beta1) * exp(-Ea1/T); kinf = Cf2 *
pow(T,beta2) * exp(-Ea2/T);
153 dk0_dT = Cf1 *
pow(T,beta1) * exp(-Ea1/T) * (beta1/T + Ea1/
pow(T,2)); dkinf_dT = Cf2 *
pow(T,beta2) * exp(-Ea2/T) * (beta2/T + Ea2/
pow(T,2));
161 k0 = Cf1 *
pow(T,beta1) * exp(-Ea1/T + D1 * T); kinf = Cf2 *
pow(T,beta2) * exp(-Ea2/T + D2 * T);
162 dk0_dT = Cf1 *
pow(T,beta1) * exp(-Ea1/T + D1 * T) * (D1 + beta1/T + Ea1/
pow(T,2));
163 dkinf_dT = Cf2 *
pow(T,beta2) * exp(-Ea2/T + D2 * T) * (D2 + beta2/T + Ea2/
pow(T,2));
168 Scalar Pr = M * k0/kinf;
169 Scalar dPr_dT = Pr * (dk0_dT/k0 - dkinf_dT/kinf);
170 Scalar log10Pr = Antioch::Constants::log10_to_log<Scalar>() * log(Pr);
171 Scalar dlog10Pr_dT = Antioch::Constants::log10_to_log<Scalar>() / Pr * dPr_dT;
172 std::vector<Scalar> dlog10Pr_dX(n_species,0);
173 for(
unsigned int i = 0; i < n_species; i++)
175 dlog10Pr_dX[i] = Antioch::Constants::log10_to_log<Scalar>()/M;
177 Scalar logF = log(Fcent)/(1.L +
pow(((log10Pr + c)/(n - d*(log10Pr + c) )),2));
178 Scalar dlogF_dT = logF * (dlog10Fcent_dT / Fcent
179 - 2.L *
pow((log10Pr + c)/(n - d * (log10Pr + c)),2)
180 * ((dlog10Pr_dT + dc_dT)/(log10Pr + c) -
181 (dn_dT - d * (dlog10Pr_dT + dc_dT))/(n - d * (log10Pr + c))
183 / (1.L +
pow((log10Pr + c)/(n - d * (log10Pr + c)),2))
185 Scalar
F = exp(logF);
186 Scalar dF_dT = F * dlogF_dT;
187 std::vector<Scalar> dF_dX(n_species,0.L);
188 for(
unsigned int i = 0; i < n_species; i++)
190 dF_dX[i] = - F * logF * logF/log(Fcent) * dlog10Pr_dX[i] * (1.L - 1.L/(n - d * (log10Pr + c))) * (log10Pr + c);
193 rate_exact = k0 / (1.L/M + k0/kinf);
195 derive_exact = rate_exact * ( (dk0_dT/k0 - dk0_dT/(kinf/M + k0) + k0 * dkinf_dT/(kinf*(kinf/M + k0))) * F + dF_dT );
197 for(
unsigned int i = 0; i < n_species; i++)
199 derive_dX_exact[i] = epsilon[i] * rate_exact * (F/(M +
pow(M,2)*k0/kinf) + dF_dX[i]);
209 fall_reaction->
F().set_alpha(alpha);
210 fall_reaction->
F().set_T1(T1);
211 fall_reaction->
F().set_T3(T3);
212 for(
unsigned int s = 0; s < n_species; s++)
221 std::vector<Scalar> drate_dx;
222 drate_dx.resize(n_species);
225 for(
unsigned int i = 0; i < n_species; i++)
227 Scalar diff = abs( (drate_dx[i] - derive_dX_exact[i])/derive_dX_exact[i] );
228 if(max_diff < diff)max_diff = diff;
231 std::cout << std::scientific << std::setprecision(16)
232 <<
"\nError: Mismatch in rate values." << std::endl
233 <<
"Kinetics model (see enum) " << kin_mod << std::endl
234 <<
"species " << i << std::endl
235 <<
"T = " << T <<
" K" << std::endl
236 <<
"drate_dc(T) = " << drate_dx[i] << std::endl
237 <<
"drate_dc_exact = " << derive_dX_exact[i] << std::endl
238 <<
"tolerance is " << tol << std::endl
239 <<
"criteria is " << abs( (drate_dx[i] - derive_dX_exact[i])/derive_dX_exact[i]) << std::endl
240 <<
"parameters are\nrate: " << rate_exact <<
"\n and " << rate_exact << std::endl
241 <<
"total density: " << M <<
" species " << mol_densities[i] << std::endl;
245 Scalar diff = abs( (rate1 - rate_exact)/rate_exact );
246 if(max_diff < diff)max_diff = diff;
249 std::cout << std::scientific << std::setprecision(16)
250 <<
"\nError: Mismatch in rate values." << std::endl
251 <<
"Kinetics model (see enum) " << kin_mod << std::endl
252 <<
"T = " << T <<
" K" << std::endl
253 <<
"rate(T) = " << rate1 << std::endl
254 <<
"rate_exact = " << rate_exact << std::endl
255 <<
"tolerance is " << tol << std::endl
256 <<
"criteria is " << abs( (rate1 - rate_exact)/rate_exact ) << std::endl;
260 diff = abs( (rate - rate_exact)/rate_exact );
261 if(max_diff < diff)max_diff = diff;
264 std::cout << std::scientific << std::setprecision(16)
265 <<
"\nError: Mismatch in rate values." << std::endl
266 <<
"Kinetics model (see enum) " << kin_mod << std::endl
267 <<
"T = " << T <<
" K" << std::endl
268 <<
"rate(T) = " << rate << std::endl
269 <<
"rate_exact = " << rate_exact << std::endl
270 <<
"tolerance is " << tol << std::endl
271 <<
"criteria is " << abs( (rate - rate_exact)/rate_exact ) << std::endl;
275 diff = abs( (drate_dT - derive_exact)/derive_exact );
276 if(max_diff < diff)max_diff = diff;
279 std::cout << std::scientific << std::setprecision(16)
280 <<
"\nError: Mismatch in rate derivative values." << std::endl
281 <<
"Kinetics model (see enum) " << kin_mod << std::endl
282 <<
"T = " << T <<
" K" << std::endl
283 <<
"drate_dT(T) = " << drate_dT << std::endl
284 <<
"derive_exact = " << derive_exact << std::endl
285 <<
"tolerance is " << tol << std::endl
286 <<
"criteria is " << abs( (drate_dT - derive_exact)/derive_exact ) << std::endl;
290 delete fall_reaction;
294 std::cout <<
" and maximum difference = " << max_diff << std::endl;
base class for kinetics models
Base class for falloff processes coupled with efficiencies.
Berthelot Hercourt-Essen rate equation.
Scalar F(const Scalar &x)
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
const FalloffType & F() const
Return const reference to the falloff object.
void compute_forward_rate_coefficient_and_derivatives(const VectorStateType &molar_densities, const KineticsConditions< StateType, VectorStateType > &conditions, StateType &kfwd, StateType &dkfwd_dT, VectorStateType &dkfkwd_dX) const
StateType compute_forward_rate_coefficient(const VectorStateType &molar_densities, const KineticsConditions< StateType, VectorStateType > &conditions) const
void add_forward_rate(KineticsType< CoeffType, VectorCoeffType > *rate)
Add a forward rate object.
Van't Hoff rate equation.
Hercourt-Essen rate equation.
void set_efficiency(const std::string &, const unsigned int s, const CoeffType efficiency)
This class contains the conditions of the chemistry.