antioch-0.4.0
nasa7_curve_fit_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/temp_cache.h"
37 #include "nasa7_thermo_test_base.h"
38 
39 namespace AntiochTesting
40 {
41  template<typename Scalar>
42  class NASA7CurveFitTest : public NASA7ThermoTestBase<Scalar>
43  {
44  public:
45 
47  {
49  this->N2_test(curve_fit);
50  }
51 
53  {
54  std::vector<Scalar> temp(3);
55  temp[0] = 200;
56  temp[1] = 1000;
57  temp[2] = 3500;
58 
60  this->H2_test(curve_fit);
61  }
62 
63  void N2_test( const Antioch::NASA7CurveFit<Scalar>& curve_fit )
64  {
65  Scalar T = 352.0;
66  this->test_cp( T, this->_N2_coeffs_300_1000, curve_fit );
67  this->test_h( T, this->_N2_coeffs_300_1000, curve_fit );
68  this->test_s( T, this->_N2_coeffs_300_1000, curve_fit );
69 
70  T = 3002.0;
71  this->test_cp( T, this->_N2_coeffs_1000_5000, curve_fit );
72  this->test_h( T, this->_N2_coeffs_1000_5000, curve_fit );
73  this->test_s( T, this->_N2_coeffs_1000_5000, curve_fit );
74  }
75 
76  void H2_test( const Antioch::NASA7CurveFit<Scalar>& curve_fit )
77  {
78  Scalar T = 352.0;
79  this->test_cp( T, this->_H2_coeffs_200_1000, curve_fit );
80  this->test_h( T, this->_H2_coeffs_200_1000, curve_fit );
81  this->test_s( T, this->_H2_coeffs_200_1000, curve_fit );
82 
83  T = 2002.0;
84  this->test_cp( T, this->_H2_coeffs_1000_3500, curve_fit );
85  this->test_h( T, this->_H2_coeffs_1000_3500, curve_fit );
86  this->test_s( T, this->_H2_coeffs_1000_3500, curve_fit );
87  }
88 
89  void test_cp( Scalar T,
90  const std::vector<Scalar>& exact_coeffs,
91  const Antioch::NASA7CurveFit<Scalar>& curve_fit )
92  {
94  Scalar cp = this->cp_exact( T,
95  exact_coeffs[0],
96  exact_coeffs[1],
97  exact_coeffs[2],
98  exact_coeffs[3],
99  exact_coeffs[4] );
100 
101  CPPUNIT_ASSERT_DOUBLES_EQUAL( cp, curve_fit.cp_over_R(cache), this->tol() );
102  }
103 
104  void test_h( Scalar T,
105  const std::vector<Scalar>& exact_coeffs,
106  const Antioch::NASA7CurveFit<Scalar>& curve_fit )
107  {
109  Scalar h = this->h_exact( T,
110  exact_coeffs[0],
111  exact_coeffs[1],
112  exact_coeffs[2],
113  exact_coeffs[3],
114  exact_coeffs[4],
115  exact_coeffs[5] );
116 
117  CPPUNIT_ASSERT_DOUBLES_EQUAL( h, curve_fit.h_over_RT(cache), this->tol() );
118  }
119 
120  void test_s( Scalar T,
121  const std::vector<Scalar>& exact_coeffs,
122  const Antioch::NASA7CurveFit<Scalar>& curve_fit )
123  {
125  Scalar s = this->s_exact( T,
126  exact_coeffs[0],
127  exact_coeffs[1],
128  exact_coeffs[2],
129  exact_coeffs[3],
130  exact_coeffs[4],
131  exact_coeffs[6] );
132 
133  CPPUNIT_ASSERT_DOUBLES_EQUAL( s, curve_fit.s_over_R(cache), this->tol() );
134  }
135 
136  Scalar tol()
137  { return std::numeric_limits<Scalar>::epsilon() * 500; }
138 
139  Scalar cp_exact( Scalar T, Scalar a0, Scalar a1, Scalar a2, Scalar a3, Scalar a4 )
140  {
141  return a0 + a1*T + a2*T*T + a3*T*T*T + a4*(T*T*T*T);
142  }
143 
144  Scalar h_exact( Scalar T, Scalar a0, Scalar a1, Scalar a2, Scalar a3, Scalar a4, Scalar a5 )
145  {
146  return a0 + a1/2.0L*T + a2/3.0L*T*T + a3/4.0L*T*T*T + a4/5.0L*(T*T*T*T) + a5/T;
147  }
148 
149  Scalar s_exact( Scalar T, Scalar a0, Scalar a1, Scalar a2, Scalar a3, Scalar a4, Scalar a6 )
150  {
151  return a0*std::log(T) + a1*T + a2/2.0L*T*T + a3/3.0L*T*T*T + a4/4.0L*(T*T*T*T) + a6;
152  }
153 
154  };
155 
157  {
158  public:
160 
163 
165 
166  };
167 
169  {
170  public:
172 
175 
177 
178  };
179 
180  class NASA7CurveFitTestLongDouble : public NASA7CurveFitTest<long double>
181  {
182  public:
184 
187 
189 
190  };
191 
195 
196 } // end namespace AntiochTesting
197 
198 #endif // ANTIOCH_HAVE_CPPUNIT
CPPUNIT_TEST(test_nasa7_default_temp_intervals)
void test_h(Scalar T, const std::vector< Scalar > &exact_coeffs, const Antioch::NASA7CurveFit< Scalar > &curve_fit)
Scalar s_exact(Scalar T, Scalar a0, Scalar a1, Scalar a2, Scalar a3, Scalar a4, Scalar a6)
void test_s(Scalar T, const std::vector< Scalar > &exact_coeffs, const Antioch::NASA7CurveFit< Scalar > &curve_fit)
StateType s_over_R(const TempCache< StateType > &cache) const
Scalar cp_exact(Scalar T, Scalar a0, Scalar a1, Scalar a2, Scalar a3, Scalar a4)
Scalar cp(Scalar T, Scalar a0, Scalar a1, Scalar a2, Scalar a3, Scalar a4, Scalar a5, Scalar a6)
CPPUNIT_TEST_SUITE(NASA7CurveFitTestLongDouble)
void test_cp(Scalar T, const std::vector< Scalar > &exact_coeffs, const Antioch::NASA7CurveFit< Scalar > &curve_fit)
CPPUNIT_TEST(test_nasa7_default_temp_intervals)
StateType h_over_RT(const TempCache< StateType > &cache) const
CPPUNIT_TEST_SUITE_REGISTRATION(ArrheniusRateEigenFloatTest)
Scalar h_exact(Scalar T, Scalar a0, Scalar a1, Scalar a2, Scalar a3, Scalar a4, Scalar a5)
CPPUNIT_TEST_SUITE(NASA7CurveFitTestDouble)
const StateType cp_over_R(const TempCache< StateType > &cache) const
void N2_test(const Antioch::NASA7CurveFit< Scalar > &curve_fit)
CPPUNIT_TEST_SUITE(NASA7CurveFitTestFloat)
CPPUNIT_TEST(test_nasa7_default_temp_intervals)
void H2_test(const Antioch::NASA7CurveFit< Scalar > &curve_fit)

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