32 #include "antioch_config.h"
34 #ifdef ANTIOCH_HAVE_METAPHYSICL
35 #include "metaphysicl/dualnumber.h"
42 template <
typename Scalar>
43 int tester(
const std::string& testname)
48 using MetaPhysicL::DualNumber;
52 const Scalar Cf = 1.4;
53 const Scalar Ea = 5.0;
55 const DualNumber<Scalar> Ea_DN(Ea, 1);
59 const Scalar T = 1500.1;
61 Scalar rate, deriveRate;
67 arrhenius_T_sensitivity(Cf,Ea);
69 const DualNumber<Scalar> T_DN(T, 1);
71 DualNumber<Scalar> rate_DN_T = arrhenius_T_sensitivity(T_DN);
73 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
75 if( abs( (deriveRate - rate_DN_T.derivatives())/deriveRate) > tol )
77 std::cout <<
"Error: Mismatch in " << testname <<
" rate derivatives." << std::endl
78 << std::setprecision(25)
79 <<
"deriveRate(T) = " << deriveRate << std::endl
80 <<
"rate_DN_T' = " << rate_DN_T.derivatives() << std::endl;
87 arrhenius_Ea_sensitivity(Cf,Ea_DN);
89 const Scalar perturb =
90 std::pow(std::numeric_limits<Scalar>::epsilon(), (1./3.)) * 100;
97 DualNumber<Scalar> rate_DN_Ea =
98 arrhenius_Ea_sensitivity(DualNumber<Scalar>(T) );
100 Scalar dR_dEa = (arrhenius_rate_Eaplus(T) -
101 arrhenius_rate_Eaminus(T)) / (2 * perturb);
103 if( abs( (dR_dEa - rate_DN_Ea.derivatives())/dR_dEa) >
104 perturb * perturb * 100)
106 std::cout <<
"Error: Mismatch in " << testname <<
" rate derivatives." << std::endl
107 << std::setprecision(25)
108 <<
"perturb = " << perturb << std::endl
109 <<
"dR_dEa = " << dR_dEa << std::endl
110 <<
"rate_DN_Ea' = " << rate_DN_Ea.derivatives() << std::endl;
121 #ifdef ANTIOCH_HAVE_METAPHYSICL
122 return (tester<double>(
"double") ||
123 tester<long double>(
"long double") ||
124 tester<float>(
"float"));
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
int tester(const std::string &testname)
_Cf VectorStateType VectorStateType(*) VectorStateType voi rate_and_derivative)(const KineticsConditions< StateType, VectorStateType > &T, StateType &rate, StateType &drate_dT) const