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;
56 const std::string equation(
"A + B -> C + D");
57 const unsigned int n_species(4);
60 std::vector<Scalar> mol_densities;
61 mol_densities.push_back(1e-2);
62 mol_densities.push_back(1e-2);
63 mol_densities.push_back(1e-2);
64 mol_densities.push_back(1e-2);
66 std::vector<Scalar> epsilon;
69 epsilon.push_back(8.5);
70 epsilon.push_back(40);
72 Scalar M = epsilon[0] * mol_densities[0];
73 for(
unsigned int i = 1; i < n_species; i++)
75 M += epsilon[i] * mol_densities[i];
78 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 70;
79 std::cout << type <<
", tolerance = " << tol;
80 Scalar max_diff(-1.L);
82 for(Scalar T = 300.1; T <= 1500.1; T += 10.)
84 for(
unsigned int ikinmod = 0; ikinmod < 6; ikinmod++)
89 Scalar k0,kinf,dk0_dT,dkinf_dT;
92 std::vector<Scalar> derive_dX_exact;
93 derive_dX_exact.resize(n_species);
103 k0 = Cf1 *
pow(T,beta1); kinf = Cf2 *
pow(T,beta2);
104 dk0_dT = Cf1 *
pow (T,beta1) * beta1/T; dkinf_dT = Cf2 *
pow (T,beta2) * beta2/T;
112 k0 = Cf1 * exp(D1*T); kinf = Cf2 * exp(D2*T);
113 dk0_dT = Cf1 * exp(D1*T) * D1; dkinf_dT = Cf2 * exp(D2*T) * D2;
121 k0 = Cf1 * exp(-Ea1/T); kinf = Cf2 * exp(-Ea2/T);
122 dk0_dT = Cf1 * exp(-Ea1/T) * Ea1/
pow(T,2); dkinf_dT = Cf2 * exp(-Ea2/T) * Ea2/
pow(T,2);
130 k0 = Cf1 *
pow(T,beta1) * exp(D1 * T); kinf = Cf2 *
pow(T,beta2) * exp(D2 * T);
131 dk0_dT = Cf1 *
pow(T,beta1) * exp(D1 * T) * (beta1/T + D1); dkinf_dT = Cf2 *
pow(T,beta2) * exp(D2 * T) * (beta2/T + D2);
139 k0 = Cf1 *
pow(T,beta1) * exp(-Ea1/T); kinf = Cf2 *
pow(T,beta2) * exp(-Ea2/T);
140 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));
148 k0 = Cf1 *
pow(T,beta1) * exp(-Ea1/T + D1 * T); kinf = Cf2 *
pow(T,beta2) * exp(-Ea2/T + D2 * T);
149 dk0_dT = Cf1 *
pow(T,beta1) * exp(-Ea1/T + D1 * T) * (D1 + beta1/T + Ea1/
pow(T,2));
150 dkinf_dT = Cf2 *
pow(T,beta2) * exp(-Ea2/T + D2 * T) * (D2 + beta2/T + Ea2/
pow(T,2));
154 rate_exact = k0 / (1.L/M + k0/kinf);
155 derive_exact = rate_exact * (dk0_dT/k0 - dk0_dT/(kinf/M + k0) + k0 * dkinf_dT/(
pow(kinf,2)/M + k0*kinf));
157 for(
unsigned int i = 0; i < n_species; i++)
159 derive_dX_exact[i] = epsilon[i] * rate_exact/(M +
pow(M,2)*k0/kinf);
167 for(
unsigned int s = 0; s < n_species; s++)
176 std::vector<Scalar> drate_dx;
177 drate_dx.resize(n_species);
180 for(
unsigned int i = 0; i < n_species; i++)
182 Scalar diff = abs( (drate_dx[i] - derive_dX_exact[i])/derive_dX_exact[i] );
183 if(diff > max_diff)max_diff = diff;
186 std::cout << std::scientific << std::setprecision(16)
187 <<
"\nError: Mismatch in rate values." << std::endl
188 <<
"Kinetics model (see enum) " << kin_mod << std::endl
189 <<
"species " << i << std::endl
190 <<
"drate_dc(T) = " << drate_dx[i] << std::endl
191 <<
"drate_dc_exact = " << derive_dX_exact[i] << std::endl
192 <<
"relative error = " << abs((drate_dx[i] - derive_dX_exact[i])/derive_dX_exact[i]) << std::endl
193 <<
"tolerance = " << tol << std::endl;
197 Scalar diff = abs( (rate1 - rate_exact)/rate_exact );
198 if(diff > max_diff)max_diff = diff;
201 std::cout << std::scientific << std::setprecision(16)
202 <<
"\nError: Mismatch in rate values." << std::endl
203 <<
"Kinetics model (see enum) " << kin_mod << std::endl
204 <<
"T = " << T <<
" K" << std::endl
205 <<
"rate(T) = " << rate1 << std::endl
206 <<
"rate_exact = " << rate_exact << std::endl
207 <<
"relative error = " << abs((rate1 - rate_exact)/rate_exact) << std::endl
208 <<
"tolerance = " << tol << std::endl;
212 diff = abs( (rate - rate_exact)/rate_exact );
213 if(diff > max_diff)max_diff = diff;
216 std::cout << std::scientific << std::setprecision(16)
217 <<
"\nError: Mismatch in rate values." << std::endl
218 <<
"Kinetics model (see enum) " << kin_mod << std::endl
219 <<
"T = " << T <<
" K" << std::endl
220 <<
"rate(T) = " << rate << std::endl
221 <<
"rate_exact = " << rate_exact << std::endl
222 <<
"relative error = " << abs((rate - rate_exact)/rate_exact) << std::endl
223 <<
"tolerance = " << tol << std::endl;
227 diff = abs( (drate_dT - derive_exact)/derive_exact );
228 if(diff > max_diff)max_diff = diff;
231 std::cout << std::scientific << std::setprecision(16)
232 <<
"\nError: Mismatch in rate derivative values." << std::endl
233 <<
"Kinetics model (see enum) " << kin_mod << std::endl
234 <<
"T = " << T <<
" K" << std::endl
235 <<
"drate_dT(T) = " << drate_dT << std::endl
236 <<
"derive_exact = " << derive_exact << std::endl
237 <<
"relative error = " << abs((drate_dT - derive_exact)/derive_exact) << std::endl
238 <<
"tolerance = " << tol << std::endl;
243 delete fall_reaction;
247 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.
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
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.