antioch-0.4.0
Functions
constant_rate_unit.C File Reference
#include <limits>
#include <vector>
#include "antioch/constant_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 Antioch::ConstantRate< Scalar > &constant_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 constant_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 128 of file constant_rate_unit.C.

129 {
130  return (tester<double>() ||
131  tester<long double>() ||
132  tester<float>());
133 }
template<typename Scalar >
int test_values ( const Scalar &  Cf,
const Antioch::ConstantRate< Scalar > &  constant_rate 
)

Definition at line 69 of file constant_rate_unit.C.

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

Referenced by tester().

70 {
71  int return_flag = 0;
72  for(Scalar T = 300.1; T <= 2500.1; T += 10.)
73  {
74 
75  const Scalar rate_exact = Cf;
76  const Scalar derive_exact = 0.L;
78 
79 // KineticsConditions
80  Scalar rate = constant_rate(cond);
81  Scalar deriveRate = constant_rate.derivative(cond);
82 
83  return_flag = check_rate_and_derivative(rate_exact,derive_exact,rate,deriveRate,T) || return_flag;
84 
85  constant_rate.rate_and_derivative(cond,rate,deriveRate);
86 
87  return_flag = check_rate_and_derivative(rate_exact,derive_exact,rate,deriveRate,T) || return_flag;
88 
89 // T
90  rate = constant_rate(T);
91  deriveRate = constant_rate.derivative(T);
92 
93  return_flag = check_rate_and_derivative(rate_exact,derive_exact,rate,deriveRate,T) || return_flag;
94 
95  constant_rate.rate_and_derivative(T,rate,deriveRate);
96 
97  return_flag = check_rate_and_derivative(rate_exact,derive_exact,rate,deriveRate,T) || return_flag;
98 
99  }
100  return return_flag;
101 }
int check_rate_and_derivative(const Scalar &rate_exact, const Scalar &derive_exact, const Scalar &rate, const Scalar &derive, const Scalar &T)
VectorStateType VectorStateType derivative(const KineticsConditions< StateType, VectorStateType > &cond) const ANTIOCH_AUTOFUNC(StateType
VectorStateType VectorStateType VectorStateType void rate_and_derivative(const KineticsConditions< StateType, VectorStateType > &cond, StateType &rate, StateType &drate_dT) const
This class contains the conditions of the chemistry.
template<typename Scalar >
int tester ( )

Definition at line 104 of file constant_rate_unit.C.

References Antioch::ConstantRate< CoeffType >::reset_coefs(), Antioch::ConstantRate< CoeffType >::set_Cf(), and test_values().

105 {
106  using std::abs;
107 
108  Scalar Cf = 1.4;
109 
110  Antioch::ConstantRate<Scalar> constant_rate(Cf);
111 
112  int return_flag = 0;
113 
114  return_flag = test_values(Cf,constant_rate) || return_flag;
115 
116  Cf = 1e-7;
117  constant_rate.set_Cf(Cf);
118  return_flag = test_values(Cf,constant_rate) || return_flag;
119 
120  Cf = 2.5e-11;
121  std::vector<Scalar> values(1,Cf);
122  constant_rate.reset_coefs(values);
123  return_flag = test_values(Cf,constant_rate) || return_flag;
124 
125  return return_flag;
126 }
Constant rate equation.
Definition: constant_rate.h:55
int test_values(const Scalar &Cf, const Antioch::ConstantRate< Scalar > &constant_rate)

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