antioch-0.4.0
arrhenius_rate_test.C
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 #include "antioch_config.h"
28 
29 #ifdef ANTIOCH_HAVE_CPPUNIT
30 
31 // C++
32 #include <limits>
33 
34 // Antioch
36 #include "antioch/units.h"
37 
38 // Base class
41 
42 namespace AntiochTesting
43 {
44  template<typename Scalar>
46  public ReactionRateTestBase<Antioch::ArrheniusRate<Scalar>,Scalar>
47  {
48  public:
49  void setUp()
50  {
51  Scalar Cf = 1.4L;
52  Scalar Ea = 298.0L;
53  Scalar R = 1.0L; // Ea in K
54 
55  this->reset_params(Cf,Ea,R);
57  }
58 
59  void tearDown()
60  {
61  delete _rate;
62  }
63 
65  {
66  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
67 
68  this->test_rate( *_rate, tol );
69  this->test_deriv( *_rate, tol );
70  this->test_rate_and_deriv( *_rate, tol );
71  }
72 
74  {
75  Scalar Cf = 1e-7L;
76  Scalar Ea = 36000.L;
77  Scalar R = Antioch::Constants::R_universal<Scalar>()*Antioch::Units<Scalar>("cal").get_SI_factor();
78 
79  this->reset_params( Cf, Ea, R );
80 
81  _rate->set_Cf(Cf);
82  _rate->set_Ea(Ea);
83  _rate->set_rscale(R);
84 
85  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
86 
87  this->test_rate( *_rate, tol );
88  this->test_deriv( *_rate, tol );
89  this->test_rate_and_deriv( *_rate, tol );
90  }
91 
93  {
94  Scalar Cf = 2.5e-7L;
95  Scalar Ea = 43000.L; //still in cal
96 
97  this->reset_params( Cf, Ea );
98 
99  std::vector<Scalar> values(2);
100  values[0] = Cf;
101  values[1] = Ea;
102  _rate->reset_coefs(values);
103 
104  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
105 
106  this->test_rate( *_rate, tol );
107  this->test_deriv( *_rate, tol );
108  this->test_rate_and_deriv( *_rate, tol );
109  }
110 
112  {
113  Scalar Cf = 2.1e-11L;
114  Scalar Ea = 100000.L;
115  Scalar R = Antioch::Constants::R_universal<Scalar>();
116 
117  this->reset_params( Cf, Ea, R );
118 
119  std::vector<Scalar> values(3);
120  values[0] = Cf;
121  values[1] = Ea;
122  values[2] = R;
123  _rate->reset_coefs(values);
124 
125  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
126 
127  this->test_rate( *_rate, tol );
128  this->test_deriv( *_rate, tol );
129  this->test_rate_and_deriv( *_rate, tol );
130  }
131 
132  protected:
133 
135 
136  virtual Scalar exact_rate( Scalar T )
137  {
138  return this->value(T);
139  }
140 
141  virtual Scalar exact_deriv( Scalar T )
142  {
143  return this->deriv(T);
144  }
145 
146  };
147 
149  {
150  public:
152 
157 
159  };
160 
162  {
163  public:
165 
170 
172  };
173 
174  class ArrheniusRateLongDoubleTest : public ArrheniusRateTest<long double>
175  {
176  public:
178 
183 
185  };
186 
190 
191 } // end namespace AntiochTesting
192 
193 #endif // ANTIOCH_HAVE_CPPUNIT
void test_rate(const Antioch::ArrheniusRate< Scalar > &reaction_rate, Scalar tol)
void set_Cf(const CoeffType Cf)
void test_rate_and_deriv(const Antioch::ArrheniusRate< Scalar > &reaction_rate, Scalar tol)
Antioch::ArrheniusRate< Scalar > * _rate
T get_SI_factor() const
Multiplicative coefficient getter.
Definition: units.h:334
virtual Scalar exact_deriv(Scalar T)
void test_deriv(const Antioch::ArrheniusRate< Scalar > &reaction_rate, Scalar tol)
CPPUNIT_TEST_SUITE_REGISTRATION(ArrheniusRateEigenFloatTest)
virtual Scalar exact_rate(Scalar T)
CPPUNIT_TEST_SUITE(ArrheniusRateFloatTest)
Advanced unit class.
CPPUNIT_TEST_SUITE(ArrheniusRateDoubleTest)
CPPUNIT_TEST_SUITE(ArrheniusRateLongDoubleTest)
An advanced unit class.
Definition: units.h:111
void set_Ea(const CoeffType Ea)
set Ea, rescale the value, unit is known
void set_rscale(const CoeffType rscale)
void reset_coefs(const VectorCoeffType &coefficients)
reset the coeffs

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