42 template <
typename Scalar>
51 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
53 for(Scalar T = 300.1L; T <= 2500.1L; T += 10.L)
56 const Scalar rate_exact = Cf*
pow(T/Tref,eta)*exp(-Ea/(R*T) + D * T);
57 const Scalar derive_exact = exp(-Ea/(R*T) + D * T) *
pow(T/Tref,eta) * Cf * (Ea/(R*T*T) + eta/T + D );
61 Scalar rate1 = rate_base(cond);
62 Scalar deriveRate1 = rate_base.
derivative(cond);
68 if( abs( (rate1 - rate_exact)/rate_exact ) > tol )
70 std::cerr << std::scientific << std::setprecision(16)
71 <<
"Error: Mismatch in rate values." << std::endl
72 <<
"T = " << T <<
" K" << std::endl
73 <<
"rate(T) = " << rate1 << std::endl
74 <<
"rate_exact = " << rate_exact << std::endl
75 <<
"relative difference = " << abs( (rate1 - rate_exact)/rate_exact ) << std::endl
76 <<
"tolerance = " << tol << std::endl
77 <<
"on rate " << rate_base << std::endl << std::endl;
81 if( abs( (rate - rate_exact)/rate_exact ) > tol )
83 std::cerr << std::scientific << std::setprecision(16)
84 <<
"Error: Mismatch in rate values." << std::endl
85 <<
"T = " << T <<
" K" << std::endl
86 <<
"rate(T) = " << rate << std::endl
87 <<
"rate_exact = " << rate_exact << std::endl
88 <<
"relative difference = " << abs( (rate - rate_exact)/rate_exact ) << std::endl
89 <<
"tolerance = " << tol << std::endl
90 <<
"on rate " << rate_base << std::endl << std::endl;
94 if( abs( (deriveRate1 - derive_exact)/derive_exact ) > tol )
96 std::cerr << std::scientific << std::setprecision(16)
97 <<
"Error: Mismatch in rate derivative values." << std::endl
98 <<
"T = " << T <<
" K" << std::endl
99 <<
"drate_dT(T) = " << deriveRate1 << std::endl
100 <<
"derive_exact = " << derive_exact << std::endl
101 <<
"relative difference = " << abs( (deriveRate1 - derive_exact)/derive_exact ) << std::endl
102 <<
"tolerance = " << tol << std::endl
103 <<
"on rate " << rate_base << std::endl << std::endl;
107 if( abs( (deriveRate - derive_exact)/derive_exact ) > tol )
109 std::cerr << std::scientific << std::setprecision(16)
110 <<
"Error: Mismatch in rate derivative values." << std::endl
111 <<
"T = " << T <<
" K" << std::endl
112 <<
"drate_dT(T) = " << deriveRate << std::endl
113 <<
"derive_exact = " << derive_exact << std::endl
114 <<
"relative difference = " << abs( (deriveRate - derive_exact)/derive_exact ) << std::endl
115 <<
"tolerance = " << tol << std::endl
116 <<
"on rate " << rate_base << std::endl << std::endl;
121 if(return_flag)
break;
126 template <
typename Scalar>
130 const Scalar zero(0.L);
138 Scalar Cf_reset = 1e-7L;
139 Scalar eta_reset = 1.5L;
140 Scalar Ea_reset = 36000;
141 Scalar D_reset = -5e-2L;
142 Scalar Tref_reset = 298;
148 std::vector<Scalar> coeffs(1,Cf);
152 int return_flag =
test_values(Cf,zero,zero,zero,Tref,R,*kin_base);
156 return_flag =
test_values(Cf_reset,zero,zero,zero,Tref,R,*kin_base) || return_flag;
168 return_flag =
test_values(Cf,eta,zero,zero,Tref,R,*kin_base) || return_flag;
172 return_flag =
test_values(Cf,eta,zero,zero,Tref_reset,R,*kin_base) || return_flag;
184 return_flag =
test_values(Cf,zero,Ea,zero,Tref,R,*kin_base) || return_flag;
188 return_flag =
test_values(Cf,zero,Ea_reset,zero,Tref,R,*kin_base) || return_flag;
199 return_flag =
test_values(Cf,zero,zero,D,Tref,R,*kin_base) || return_flag;
203 return_flag =
test_values(Cf,zero,zero,D_reset,Tref,R,*kin_base) || return_flag;
216 return_flag =
test_values(Cf,eta,zero,D,Tref,R,*kin_base) || return_flag;
222 return_flag =
test_values(Cf_reset,eta,zero,D_reset,Tref,R,*kin_base) || return_flag;
236 return_flag =
test_values(Cf,eta,Ea,zero,Tref,R,*kin_base) || return_flag;
242 return_flag =
test_values(Cf,eta,Ea_reset,zero,Tref,R_reset,*kin_base) || return_flag;
257 return_flag =
test_values(Cf,eta,Ea,D,Tref,R,*kin_base) || return_flag;
265 return_flag =
test_values(Cf_reset,eta,Ea,D_reset,Tref_reset,R,*kin_base) || return_flag;
269 coeffs[0] = Cf_reset;
270 coeffs[1] = eta_reset;
271 coeffs[2] = Ea_reset;
273 coeffs[4] = Tref_reset;
277 return_flag =
test_values(Cf_reset,eta_reset,Ea_reset,D_reset,Tref_reset,R_reset,*kin_base) || return_flag;
284 return (tester<double>() ||
285 tester<long double>() ||
StateType derivative(const KineticsConditions< StateType, VectorStateType > &conditions) const
void compute_rate_and_derivative(const KineticsConditions< StateType, VectorStateType > &conditions, StateType &rate, StateType &drate_dT) const
base class for kinetics models
void reset_parameter_of_rate(KineticsType< CoeffType, VectorCoeffType > &rate, KineticsModel::Parameters parameter, const CoeffType new_value, const std::string &unit="SI")
The rate constant models derived from the Arrhenius model have an activation energy which is stored a...
int test_values(const Scalar &Cf, const Scalar &eta, const Scalar &Ea, const Scalar &D, const Scalar &Tref, const Scalar &R, const Antioch::KineticsType< Scalar > &rate_base)
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
T get_SI_factor() const
Multiplicative coefficient getter.
void reset_rate(KineticsType< CoeffType, VectorCoeffType > &kin, const VectorType &coefs)
This class contains the conditions of the chemistry.