35 template <
typename Scalar>
42 const Scalar Cf = 1.4L;
43 const Scalar Ea = 5.0L;
44 const Scalar beta = 1.2L;
45 const Scalar
D = 2.5e-2L;
47 const std::string equation(
"A + B -> C + D");
48 const unsigned int n_species(4);
51 std::vector<Scalar> mol_densities;
52 mol_densities.push_back(1e-2L);
53 mol_densities.push_back(1e-2L);
54 mol_densities.push_back(1e-2L);
55 mol_densities.push_back(1e-2L);
57 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
59 for(Scalar T = 300.1; T <= 2500.1; T += 10.)
64 for(
unsigned int ikinmod = 0; ikinmod < 6; ikinmod++)
78 rate_exact = Cf *
pow(T,beta);
79 derive_exact = Cf *
pow (T,beta) * beta/T;
86 rate_exact = Cf * exp(D*T);
87 derive_exact = Cf * exp(D*T) *
D;
94 rate_exact = Cf * exp(-Ea/T);
95 derive_exact = Cf * exp(-Ea/T) * Ea/
pow(T,2);
102 rate_exact = Cf *
pow(T,beta) * exp(D * T);
103 derive_exact = Cf *
pow(T,beta) * exp(D * T) * (beta/T +
D);
110 rate_exact = Cf *
pow(T,beta) * exp(-Ea/T);
111 derive_exact = Cf *
pow(T,beta) * exp(-Ea/T) * (beta/T + Ea/
pow(T,2));
118 rate_exact = Cf *
pow(T,beta) * exp(-Ea/T + D * T);
119 derive_exact = Cf *
pow(T,beta) * exp(-Ea/T + D * T) * (D + beta/T + Ea/
pow(T,2));
129 std::vector<Scalar> drate_dx;
130 drate_dx.resize(n_species);
133 if( abs( (rate1 - rate_exact)/rate_exact ) > tol )
135 std::cout << std::scientific << std::setprecision(16)
136 <<
"Error: Mismatch in rate values." << std::endl
137 <<
"Kinetics model (see enum) " << kin_mod << std::endl
138 <<
"T = " << T <<
" K" << std::endl
139 <<
"rate(T) = " << rate1 << std::endl
140 <<
"rate_exact = " << rate_exact << std::endl;
144 if( abs( (rate - rate_exact)/rate_exact ) > tol )
146 std::cout << std::scientific << std::setprecision(16)
147 <<
"Error: Mismatch in rate values." << std::endl
148 <<
"Kinetics model (see enum) " << kin_mod << std::endl
149 <<
"T = " << T <<
" K" << std::endl
150 <<
"rate(T) = " << rate << std::endl
151 <<
"rate_exact = " << rate_exact << std::endl;
155 if( abs( (drate_dT - derive_exact)/derive_exact ) > tol )
157 std::cout << std::scientific << std::setprecision(16)
158 <<
"Error: Mismatch in rate derivative values." << std::endl
159 <<
"Kinetics model (see enum) " << kin_mod << std::endl
160 <<
"T = " << T <<
" K" << std::endl
161 <<
"drate_dT(T) = " << drate_dT << std::endl
162 <<
"derive_exact = " << derive_exact << std::endl;
166 delete elem_reaction;
167 if(return_flag)
return return_flag;
176 return (tester<double>() ||
177 tester<long double>() ||
base class for kinetics models
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)
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.
A single reaction mechanism.
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 &dkfwd_dX) const
This class contains the conditions of the chemistry.