45 const Scalar Cf1 = 1.135e36L * 1e6L * 1e-12L;
46 const Scalar beta1 = 1.246L;
47 const Scalar Ea1 = 1704.8L / 1.9858775L;
48 const Scalar D1 = -4e-2L;
49 const Scalar Cf2 = 6.22e16L * 1e3L * 1e-12L;
50 const Scalar beta2 = -1.174L;
51 const Scalar Ea2 = 635.8L / 1.9858775L;
52 const Scalar D2 = -5e-3L;
54 const std::string equation(
"A + B -> C + D");
55 const unsigned int n_species(4);
58 std::vector<Scalar> mol_densities;
59 mol_densities.push_back(1e-2);
60 mol_densities.push_back(1e-2);
61 mol_densities.push_back(1e-2);
62 mol_densities.push_back(1e-2);
63 Scalar M = mol_densities[0];
64 for(
unsigned int i = 1; i < n_species; i++)
66 M += mol_densities[i];
69 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 80;
70 std::cout << type <<
", tolerance = " << tol;
71 Scalar max_diff(-1.L);
73 for(Scalar T = 300.1; T <= 1500.1; T += 10.)
78 for(
unsigned int ikinmod = 0; ikinmod < 6; ikinmod++)
83 Scalar k0,kinf,dk0_dT,dkinf_dT;
86 std::vector<Scalar> derive_dX_exact;
87 derive_dX_exact.resize(n_species);
97 k0 = Cf1 *
pow(T,beta1); kinf = Cf2 *
pow(T,beta2);
98 dk0_dT = Cf1 *
pow (T,beta1) * beta1/T; dkinf_dT = Cf2 *
pow (T,beta2) * beta2/T;
106 k0 = Cf1 * exp(D1*T); kinf = Cf2 * exp(D2*T);
107 dk0_dT = Cf1 * exp(D1*T) * D1; dkinf_dT = Cf2 * exp(D2*T) * D2;
116 k0 = Cf1 * exp(-Ea1/T); kinf = Cf2 * exp(-Ea2/T);
117 dk0_dT = Cf1 * exp(-Ea1/T) * Ea1/
pow(T,2); dkinf_dT = Cf2 * exp(-Ea2/T) * Ea2/
pow(T,2);
125 k0 = Cf1 *
pow(T,beta1) * exp(D1 * T); kinf = Cf2 *
pow(T,beta2) * exp(D2 * T);
126 dk0_dT = Cf1 *
pow(T,beta1) * exp(D1 * T) * (beta1/T + D1); dkinf_dT = Cf2 *
pow(T,beta2) * exp(D2 * T) * (beta2/T + D2);
134 k0 = Cf1 *
pow(T,beta1) * exp(-Ea1/T); kinf = Cf2 *
pow(T,beta2) * exp(-Ea2/T);
135 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));
143 k0 = Cf1 *
pow(T,beta1) * exp(-Ea1/T + D1 * T); kinf = Cf2 *
pow(T,beta2) * exp(-Ea2/T + D2 * T);
144 dk0_dT = Cf1 *
pow(T,beta1) * exp(-Ea1/T + D1 * T) * (D1 + beta1/T + Ea1/
pow(T,2));
145 dkinf_dT = Cf2 *
pow(T,beta2) * exp(-Ea2/T + D2 * T) * (D2 + beta2/T + Ea2/
pow(T,2));
149 rate_exact = k0 / (1.L/M + k0/kinf);
150 derive_exact = rate_exact * (dk0_dT/k0 - dk0_dT/(kinf/M + k0) + k0 * dkinf_dT/(
pow(kinf,2)/M + k0*kinf));
152 for(
unsigned int i = 0; i < n_species; i++)
154 derive_dX_exact[i] = rate_exact/(M +
pow(M,2)*k0/kinf);
165 std::vector<Scalar> drate_dx;
166 drate_dx.resize(n_species);
169 for(
unsigned int i = 0; i < n_species; i++)
171 Scalar diff = abs( (drate_dx[i] - derive_dX_exact[i])/derive_dX_exact[i] );
172 if(diff > max_diff)max_diff = diff;
175 std::cout << std::scientific << std::setprecision(16)
176 <<
"\nError: Mismatch in rate values." << std::endl
177 <<
"Kinetics model (see enum) " << kin_mod << std::endl
178 <<
"species " << i << std::endl
179 <<
"drate_dc(T) = " << drate_dx[i] << std::endl
180 <<
"drate_dc_exact = " << derive_dX_exact[i] << std::endl
181 <<
"relative error = " << abs((drate_dx[i] - derive_dX_exact[i])/derive_dX_exact[i]) << std::endl
182 <<
"tolerance = " << tol << std::endl;
186 Scalar diff = abs( (rate1 - rate_exact)/rate_exact );
187 if(diff > max_diff)max_diff = diff;
190 std::cout << std::scientific << std::setprecision(16)
191 <<
"\nError: Mismatch in rate values." << std::endl
192 <<
"Kinetics model (see enum) " << kin_mod << std::endl
193 <<
"T = " << T <<
" K" << std::endl
194 <<
"rate(T) = " << rate1 << std::endl
195 <<
"rate_exact = " << rate_exact << std::endl
196 <<
"relative error = " << abs((rate1 - rate_exact)/rate_exact) << std::endl
197 <<
"tolerance = " << tol << std::endl;
201 diff = abs( (rate - rate_exact)/rate_exact );
202 if(diff > max_diff)max_diff = diff;
205 std::cout << std::scientific << std::setprecision(16)
206 <<
"\nError: Mismatch in rate values." << std::endl
207 <<
"Kinetics model (see enum) " << kin_mod << std::endl
208 <<
"T = " << T <<
" K" << std::endl
209 <<
"rate(T) = " << rate << std::endl
210 <<
"rate_exact = " << rate_exact << std::endl
211 <<
"relative error = " << abs((rate - rate_exact)/rate_exact) << std::endl
212 <<
"tolerance = " << tol << std::endl;
216 diff = abs( (drate_dT - derive_exact)/derive_exact );
217 if(diff > max_diff)max_diff = diff;
220 std::cout << std::scientific << std::setprecision(16)
221 <<
"\nError: Mismatch in rate derivative values." << std::endl
222 <<
"Kinetics model (see enum) " << kin_mod << std::endl
223 <<
"T = " << T <<
" K" << std::endl
224 <<
"drate_dT(T) = " << drate_dT << std::endl
225 <<
"derive_exact = " << derive_exact << std::endl
226 <<
"relative error = " << abs((drate_dT - derive_exact)/derive_exact) << std::endl
227 <<
"tolerance = " << tol << std::endl;
232 delete fall_reaction;
236 std::cout <<
" and maximum difference = " << max_diff << std::endl;
base class for kinetics models
Berthelot Hercourt-Essen rate equation.
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
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
Base class for falloff processes.
void add_forward_rate(KineticsType< CoeffType, VectorCoeffType > *rate)
Add a forward rate object.
Van't Hoff rate equation.
Hercourt-Essen rate equation.
StateType compute_forward_rate_coefficient(const VectorStateType &molar_densities, const KineticsConditions< StateType, VectorStateType > &conditions) const
This class contains the conditions of the chemistry.