antioch-0.4.0
Functions
berthelothercourtessen_rate_unit.C File Reference
#include <limits>
#include <vector>
#include "antioch/berthelothercourtessen_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 &D, const Scalar &Tref, const Antioch::BerthelotHercourtEssenRate< Scalar > &berthelothercourtessen_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 35 of file berthelothercourtessen_rate_unit.C.

Referenced by test_values().

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

Definition at line 159 of file berthelothercourtessen_rate_unit.C.

160 {
161  return (tester<double>() ||
162  tester<long double>() ||
163  tester<float>());
164 }
template<typename Scalar >
int test_values ( const Scalar &  Cf,
const Scalar &  eta,
const Scalar &  D,
const Scalar &  Tref,
const Antioch::BerthelotHercourtEssenRate< Scalar > &  berthelothercourtessen_rate 
)

Definition at line 69 of file berthelothercourtessen_rate_unit.C.

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

Referenced by tester().

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

Definition at line 109 of file berthelothercourtessen_rate_unit.C.

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

110 {
111  Scalar Cf = 1.4L;
112  Scalar eta = 1.2L;
113  Scalar D = -5.0L;
114  Scalar Tref = 1.0L;
115 
116  Antioch::BerthelotHercourtEssenRate<Scalar> berthelothercourtessen_rate(Cf,eta,D);
117 
118  int return_flag = test_values(Cf,eta,D,Tref,berthelothercourtessen_rate);
119 
120  Cf = 1e-7L;
121  eta = 0.6L;
122  D = 1e-3L;
123  Tref = 298.0L;
124  berthelothercourtessen_rate.set_Cf(Cf);
125  berthelothercourtessen_rate.set_eta(eta);
126  berthelothercourtessen_rate.set_D(D);
127  berthelothercourtessen_rate.set_Tref(Tref);
128 
129  return_flag = test_values(Cf,eta,D,Tref,berthelothercourtessen_rate) || return_flag;
130 
131  Cf = 2.1e-7L;
132  eta = 0.35L;
133  D = 8.1e-3L;
134  std::vector<Scalar> values(3);
135  values[0] = Cf;
136  values[1] = eta;
137  values[2] = D;
138  berthelothercourtessen_rate.reset_coefs(values);
139 
140  return_flag = test_values(Cf,eta,D,Tref,berthelothercourtessen_rate) || return_flag;
141 
142  Cf = 2.1e-11L;
143  eta = -0.35L;
144  D = -2.1;
145  Tref = 300.L;
146  values.resize(4);
147  values[0] = Cf;
148  values[1] = eta;
149  values[2] = D;
150  values[3] = Tref;
151  berthelothercourtessen_rate.reset_coefs(values);
152 
153  return_flag = test_values(Cf,eta,D,Tref,berthelothercourtessen_rate) || return_flag;
154 
155 
156  return return_flag;
157 }
Berthelot Hercourt-Essen rate equation.
int test_values(const Scalar &Cf, const Scalar &eta, const Scalar &D, const Scalar &Tref, const Antioch::BerthelotHercourtEssenRate< Scalar > &berthelothercourtessen_rate)

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