antioch-0.4.0
arrhenius_rate_vector_test_base.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // Antioch - A Gas Dynamics Thermochemistry Library
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk,
7 // Sylvain Plessis, Roy H. Stonger
8 //
9 // Copyright (C) 2013 The PECOS Development Team
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the Version 2.1 GNU Lesser General
13 // Public License as published by the Free Software Foundation.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
23 // Boston, MA 02110-1301 USA
24 //
25 //-----------------------------------------------------------------------el-
26 
27 #ifndef ANTIOCH_ARRHENIUS_RATE_VECTOR_TEST_BASE_H
28 #define ANTIOCH_ARRHENIUS_RATE_VECTOR_TEST_BASE_H
29 
30 #include "antioch_config.h"
31 
32 #ifdef ANTIOCH_HAVE_CPPUNIT
33 
34 // C++
35 #include <limits>
36 
37 // Antioch
39 #include "antioch/units.h"
40 
41 // Base class
44 
45 namespace AntiochTesting
46 {
47  template<typename PairScalars>
48  class ArrheniusRateVectorTestBase : public ArrheniusRateTestHelper</*Scalar*/typename Antioch::value_type<PairScalars>::type>,
49  public ReactionRateVectorTestBase<Antioch::ArrheniusRate</*Scalar*/typename Antioch::value_type<PairScalars>::type>,PairScalars>
50  {
51  public:
52  virtual void init()
53  {
54  typedef typename Antioch::value_type<PairScalars>::type Scalar;
55 
56  Scalar Cf = 1.4L;
57  Scalar Ea = 5.0L;
58  Scalar R = 1.0L; // Ea in K
59 
60  this->reset_params(Cf,Ea,R);
62  }
63 
64  virtual void clear()
65  {
66  delete _rate;
67  }
68 
70  {
71  typedef typename Antioch::value_type<PairScalars>::type Scalar;
72 
73  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
74  PairScalars T = this->setup_T(*(this->_example));
75  this->test_rate( *_rate, T, tol );
76  }
77 
79  {
80  typedef typename Antioch::value_type<PairScalars>::type Scalar;
81 
82  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
83  PairScalars T = this->setup_T(*(this->_example));
84  this->test_deriv( *_rate, T, tol );
85  }
86 
88  {
89  typedef typename Antioch::value_type<PairScalars>::type Scalar;
90 
91  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
92  PairScalars T = this->setup_T(*(this->_example));
93  this->test_rate_and_deriv( *_rate, T, tol );
94  }
95 
96  protected:
97 
99 
100  virtual PairScalars exact_rate( PairScalars T )
101  {
102  PairScalars e_rate = *(this->_example);
103  for (unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
104  {
105  e_rate[2*tuple] = this->value(T[2*tuple]);
106  e_rate[2*tuple+1] = this->value(T[2*tuple+1]);
107  }
108  return e_rate;
109  }
110 
111  virtual PairScalars exact_deriv( PairScalars T )
112  {
113  PairScalars e_deriv = *(this->_example);
114  for (unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
115  {
116  e_deriv[2*tuple] = this->deriv(T[2*tuple]);
117  e_deriv[2*tuple+1] = this->deriv(T[2*tuple+1]);
118  }
119  return e_deriv;
120  }
121 
122  };
123 
124 } // end namespace AntiochTesting
125 
126 #endif // ANTIOCH_HAVE_CPPUNIT
127 
128 #endif // ANTIOCH_ARRHENIUS_RATE_VECTOR_TEST_BASE_H
void test_rate_and_deriv(const Antioch::ArrheniusRate< Antioch::value_type< PairScalars >::type > &reaction_rate, const PairScalars &T, typename Antioch::value_type< PairScalars >::typetol)
void test_deriv(const Antioch::ArrheniusRate< Antioch::value_type< PairScalars >::type > &reaction_rate, const PairScalars &T, typename Antioch::value_type< PairScalars >::typetol)
Antioch::ArrheniusRate< typename Antioch::value_type< PairScalars >::type > * _rate
Advanced unit class.
Antioch::value_type< PairScalars >::type value(Antioch::value_type< PairScalars >::typeT)
void reset_params(Antioch::value_type< PairScalars >::typeCf, Antioch::value_type< PairScalars >::typeEa)
void test_rate(const Antioch::ArrheniusRate< Antioch::value_type< PairScalars >::type > &reaction_rate, const PairScalars &T, typename Antioch::value_type< PairScalars >::typetol)
Antioch::value_type< PairScalars >::type deriv(Antioch::value_type< PairScalars >::typeT)

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