antioch-0.4.0
Functions
berthelot_rate_unit.C File Reference
#include <limits>
#include <vector>
#include "antioch/berthelot_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 &D, const Antioch::BerthelotRate< Scalar > &berthelot_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 berthelot_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 132 of file berthelot_rate_unit.C.

133 {
134  return (tester<double>() ||
135  tester<long double>() ||
136  tester<float>());
137 }
template<typename Scalar >
int test_values ( const Scalar &  Cf,
const Scalar &  D,
const Antioch::BerthelotRate< Scalar > &  berthelot_rate 
)

Definition at line 68 of file berthelot_rate_unit.C.

References check_rate_and_derivative(), Antioch::BerthelotRate< CoeffType >::derivative(), and Antioch::BerthelotRate< CoeffType >::rate_and_derivative.

Referenced by tester().

69 {
70  using std::abs;
71  using std::exp;
72  int return_flag = 0;
73 
74  for(Scalar T = 300.1; T <= 2500.1; T += 10.)
75  {
76  const Scalar rate_exact = Cf*exp(D*T);
77  const Scalar derive_exact = D * Cf * exp(D*T);
79 
80 //KineticsConditions
81  Scalar rate = berthelot_rate(cond);
82  Scalar deriveRate = berthelot_rate.derivative(cond);
83 
84  return_flag = check_rate_and_derivative(rate_exact,derive_exact,rate,deriveRate,T) || return_flag;
85 
86  berthelot_rate.rate_and_derivative(cond,rate,deriveRate);
87 
88  return_flag = check_rate_and_derivative(rate_exact,derive_exact,rate,deriveRate,T) || return_flag;
89 
90 // T
91  rate = berthelot_rate(T);
92  deriveRate = berthelot_rate.derivative(T);
93 
94  return_flag = check_rate_and_derivative(rate_exact,derive_exact,rate,deriveRate,T) || return_flag;
95 
96  berthelot_rate.rate_and_derivative(T,rate,deriveRate);
97 
98  return_flag = check_rate_and_derivative(rate_exact,derive_exact,rate,deriveRate,T) || return_flag;
99 
100  }
101  return return_flag;
102 }
_Cf VectorStateType VectorStateType(*) VectorStateType voi rate_and_derivative)(const KineticsConditions< StateType, VectorStateType > &T, StateType &rate, StateType &drate_dT) const
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.
_Cf VectorStateType VectorStateType derivative(const KineticsConditions< StateType, VectorStateType > &T) const ANTIOCH_AUTOFUNC(StateType
template<typename Scalar >
int tester ( )

Definition at line 105 of file berthelot_rate_unit.C.

References Antioch::KineticsModel::D, Antioch::BerthelotRate< CoeffType >::reset_coefs(), Antioch::BerthelotRate< CoeffType >::set_Cf(), Antioch::BerthelotRate< CoeffType >::set_D(), and test_values().

106 {
107  Scalar Cf = 1.4;
108  Scalar D = -5.0;
109 
110  Antioch::BerthelotRate<Scalar> berthelot_rate(Cf,D);
111 
112  int return_flag = test_values(Cf,D,berthelot_rate);
113 
114  Cf = 1e-7;
115  D = 1e-3;
116  berthelot_rate.set_Cf(Cf);
117  berthelot_rate.set_D(D);
118  return_flag = test_values(Cf,D,berthelot_rate) || return_flag;
119 
120 
121  Cf = 2.1e-11;
122  D = -1.2;
123  std::vector<Scalar> values(2);
124  values[0] = Cf;
125  values[1] = D;
126  berthelot_rate.reset_coefs(values);
127  return_flag = test_values(Cf,D,berthelot_rate) || return_flag;
128 
129  return return_flag;
130 }
Berthelot rate equation.
int test_values(const Scalar &Cf, const Scalar &D, const Antioch::BerthelotRate< Scalar > &berthelot_rate)

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