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;
63 arrhenius_rate.rate_and_derivative(T,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;
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)