antioch-0.4.0
Functions
hercourtessen_rate_unit.C File Reference
#include <limits>
#include <vector>
#include "antioch/hercourtessen_rate.h"

Go to the source code of this file.

Functions

template<typename Scalar >
int check_rate_and_derivative (const Scalar &rate_exact, const Scalar &derive_exact, const Scalar &rate, const Scalar &derive, const Scalar &T)
 
template<typename Scalar >
int test_values (const Scalar &Cf, const Scalar &eta, const Scalar &Tref, const Antioch::HercourtEssenRate< Scalar > &hercourtessen_rate)
 
template<typename Scalar >
int tester ()
 
int main ()
 

Function Documentation

template<typename Scalar >
int check_rate_and_derivative ( const Scalar &  rate_exact,
const Scalar &  derive_exact,
const Scalar &  rate,
const Scalar &  derive,
const Scalar &  T 
)

Definition at line 34 of file hercourtessen_rate_unit.C.

Referenced by test_values().

36 {
37  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 2;
38  int return_flag(0);
39  if( abs( (rate - rate_exact)/rate_exact ) > tol )
40  {
41  std::cout << std::scientific << std::setprecision(16)
42  << "Error: Mismatch in rate values." << std::endl
43  << "T = " << T << " K" << std::endl
44  << "rate(T) = " << rate << std::endl
45  << "rate_exact = " << rate_exact << std::endl
46  << "relative difference = " << abs( (rate - rate_exact)/rate_exact ) << std::endl
47  << "tolerance = " << tol << std::endl;
48 
49  return_flag = 1;
50  }
51  if( abs( (derive - derive_exact)/derive_exact ) > tol )
52  {
53  std::cout << std::scientific << std::setprecision(16)
54  << "Error: Mismatch in rate derivative values." << std::endl
55  << "T = " << T << " K" << std::endl
56  << "drate_dT(T) = " << derive << std::endl
57  << "derive_exact = " << derive_exact << std::endl
58  << "relative difference = " << abs( (derive - derive_exact)/derive_exact ) << std::endl
59  << "tolerance = " << tol << std::endl;
60 
61  return_flag = 1;
62  }
63 
64  return return_flag;
65 }
int main ( )

Definition at line 143 of file hercourtessen_rate_unit.C.

144 {
145  return (tester<double>() ||
146  tester<long double>() ||
147  tester<float>());
148 }
template<typename Scalar >
int test_values ( const Scalar &  Cf,
const Scalar &  eta,
const Scalar &  Tref,
const Antioch::HercourtEssenRate< Scalar > &  hercourtessen_rate 
)

Definition at line 68 of file hercourtessen_rate_unit.C.

References check_rate_and_derivative(), Antioch::HercourtEssenRate< CoeffType >::derivative(), std::pow(), and Antioch::HercourtEssenRate< CoeffType >::rate_and_derivative.

Referenced by tester().

69 {
70  using std::abs;
71  using std::pow;
72  int return_flag = 0;
73 
74  for(Scalar T = 300.1L; T <= 2500.1L; T += 10.L)
75  {
76  const Scalar rate_exact = Cf * pow(T/Tref,eta);
77  const Scalar derive_exact = Cf * eta * pow(T/Tref,eta)/T;
79 
80 
81 // KineticsConditions
82  Scalar rate = hercourtessen_rate(cond);
83  Scalar deriveRate = hercourtessen_rate.derivative(cond);
84 
85  return_flag = check_rate_and_derivative(rate_exact,derive_exact,rate,deriveRate,T) || return_flag;
86 
87  hercourtessen_rate.rate_and_derivative(cond,rate,deriveRate);
88 
89  return_flag = check_rate_and_derivative(rate_exact,derive_exact,rate,deriveRate,T) || return_flag;
90 
91 // T
92  rate = hercourtessen_rate(T);
93  deriveRate = hercourtessen_rate.derivative(T);
94 
95  return_flag = check_rate_and_derivative(rate_exact,derive_exact,rate,deriveRate,T) || return_flag;
96 
97  hercourtessen_rate.rate_and_derivative(T,rate,deriveRate);
98 
99  return_flag = check_rate_and_derivative(rate_exact,derive_exact,rate,deriveRate,T) || return_flag;
100 
101  }
102  return return_flag;
103 }
int check_rate_and_derivative(const Scalar &rate_exact, const Scalar &derive_exact, const Scalar &rate, const Scalar &derive, const Scalar &T)
_Cf VectorStateType VectorStateType derivative(const KineticsConditions< StateType, VectorStateType > &T) const ANTIOCH_AUTOFUNC(StateType
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
This class contains the conditions of the chemistry.
_Cf VectorStateType VectorStateType(*) VectorStateType voi rate_and_derivative)(const KineticsConditions< StateType, VectorStateType > &T, StateType &rate, StateType &drate_dT) const
template<typename Scalar >
int tester ( )

Definition at line 106 of file hercourtessen_rate_unit.C.

References Antioch::HercourtEssenRate< CoeffType >::reset_coefs(), Antioch::HercourtEssenRate< CoeffType >::set_Cf(), Antioch::HercourtEssenRate< CoeffType >::set_eta(), Antioch::HercourtEssenRate< CoeffType >::set_Tref(), test_values(), and Antioch::KineticsModel::Tref().

107 {
108 
109  Scalar Cf = 1.4L;
110  Scalar eta = 1.2L;
111  Scalar Tref = 1.L;
112 
113  Antioch::HercourtEssenRate<Scalar> hercourtessen_rate(Cf,eta); // default
114 
115  int return_flag = test_values(Cf,eta,Tref,hercourtessen_rate);
116  Cf = 1e-7L;
117  eta = 0.7L;
118  Tref = 300.L;
119  hercourtessen_rate.set_Cf(Cf);
120  hercourtessen_rate.set_eta(eta);
121  hercourtessen_rate.set_Tref(Tref);
122  return_flag = test_values(Cf,eta,Tref,hercourtessen_rate) || return_flag;
123 
124  Cf = 2.1e-11L;
125  eta = -2.3L;
126  std::vector<Scalar> values(2);
127  values[0] = Cf;
128  values[1] = eta;
129  hercourtessen_rate.reset_coefs(values);
130  return_flag = test_values(Cf,eta,Tref,hercourtessen_rate) || return_flag;
131 
132  Tref = 298.L;
133  values.resize(3);
134  values[0] = Cf;
135  values[1] = eta;
136  values[2] = Tref;
137  hercourtessen_rate.reset_coefs(values);
138  return_flag = test_values(Cf,eta,Tref,hercourtessen_rate) || return_flag;
139 
140  return return_flag;
141 }
Hercourt-Essen rate equation.
int test_values(const Scalar &Cf, const Scalar &eta, const Scalar &Tref, const Antioch::HercourtEssenRate< Scalar > &hercourtessen_rate)

Generated on Thu Jul 7 2016 11:09:47 for antioch-0.4.0 by  doxygen 1.8.8