antioch-0.4.0
reaction_rate_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_REACTION_RATE_TEST_BASE_H
28 #define ANTIOCH_REACTION_RATE_TEST_BASE_H
29 
30 #include "antioch_config.h"
31 
32 #ifdef ANTIOCH_HAVE_CPPUNIT
33 
34 #include <cppunit/extensions/HelperMacros.h>
35 #include <cppunit/TestCase.h>
36 
37 namespace AntiochTesting
38 {
39  template <typename ReactionRate, typename Scalar>
40  class ReactionRateTestBase : public CppUnit::TestCase
41  {
42  public:
43  void test_rate( const ReactionRate& reaction_rate,
44  Scalar tol )
45  {
46  for(Scalar T = 300.1; T <= 2500.1; T += 10.)
47  {
48  {
49  Scalar rate = reaction_rate(T);
50  Scalar exact_rate = this->exact_rate(T);
51 
52  CPPUNIT_ASSERT_DOUBLES_EQUAL( rate,
53  exact_rate,
54  tol );
55  }
56 
57  {
59  Scalar rate = reaction_rate(cond);
60  Scalar exact_rate = this->exact_rate(T);
61 
62  CPPUNIT_ASSERT_DOUBLES_EQUAL( rate,
63  exact_rate,
64  tol );
65  }
66 
67  }
68  }
69 
70  void test_deriv( const ReactionRate& reaction_rate,
71  Scalar tol )
72  {
73  for(Scalar T = 300.1; T <= 2500.1; T += 10.)
74  {
75  {
76  Scalar deriv = reaction_rate.derivative(T);
77  Scalar exact_deriv = this->exact_deriv(T);
78 
79  CPPUNIT_ASSERT_DOUBLES_EQUAL( deriv,
80  exact_deriv,
81  tol );
82  }
83 
84  {
86  Scalar deriv = reaction_rate.derivative(cond);
87  Scalar exact_deriv = this->exact_deriv(T);
88 
89  CPPUNIT_ASSERT_DOUBLES_EQUAL( deriv,
90  exact_deriv,
91  tol );
92  }
93  }
94  }
95 
96  void test_rate_and_deriv( const ReactionRate& reaction_rate,
97  Scalar tol )
98  {
99  for(Scalar T = 300.1; T <= 2500.1; T += 10.)
100  {
101  {
102  Scalar rate;
103  Scalar deriv;
105 
106  reaction_rate.rate_and_derivative(cond,rate,deriv);
107 
108  Scalar exact_rate = this->exact_rate(T);
109  Scalar exact_deriv = this->exact_deriv(T);
110 
111  CPPUNIT_ASSERT_DOUBLES_EQUAL( rate,
112  exact_rate,
113  tol );
114 
115  CPPUNIT_ASSERT_DOUBLES_EQUAL( deriv,
116  exact_deriv,
117  tol );
118  }
119  }
120  }
121 
122  protected:
123 
124  virtual Scalar exact_rate( Scalar T ) =0;
125  virtual Scalar exact_deriv( Scalar T ) =0;
126 
127  };
128 
129 } // end namespace AntiochTesting
130 
131 #endif // ANTIOCH_HAVE_CPPUNIT
132 
133 #endif // ANTIOCH_REACTION_RATE_TEST_BASE_H
void test_rate(const ReactionRate &reaction_rate, Scalar tol)
virtual Scalar exact_deriv(Scalar T)=0
void test_rate_and_deriv(const ReactionRate &reaction_rate, Scalar tol)
void test_deriv(const ReactionRate &reaction_rate, Scalar tol)
virtual Scalar exact_rate(Scalar T)=0
This class contains the conditions of the chemistry.

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