GRINS-0.8.0
hitran_test.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #include "grins_config.h"
26 
27 #ifdef GRINS_HAVE_CPPUNIT
28 
29 #include <libmesh/ignore_warnings.h>
30 #include <cppunit/extensions/HelperMacros.h>
31 #include <cppunit/TestCase.h>
32 #include <libmesh/restore_warnings.h>
33 
34 // Testing headers
35 #include "test_comm.h"
36 #include "grins_test_paths.h"
37 
38 // GRINS
39 #include "grins/hitran.h"
40 
41 // Ignore warnings from auto_ptr in CPPUNIT_TEST_SUITE_END()
42 #include <libmesh/ignore_warnings.h>
43 
44 namespace GRINSTesting
45 {
46  class HITRANtest : public CppUnit::TestCase
47  {
48  public:
50 
52 
54 
55  public:
56 
58  {
59  std::string data_file = std::string(GRINS_TEST_SRCDIR)+"/test_data/CO2_data.dat";
60  std::string partition_file = std::string(GRINS_TEST_SRCDIR)+"/test_data/CO2_partition_function.dat";
61 
62  libMesh::Real T_min = 290;
63  libMesh::Real T_max = 310;
64  libMesh::Real T_step = 0.01;
65 
66  GRINS::HITRAN hitran(data_file,partition_file,T_min,T_max,T_step);
67 
68  libMesh::Real tolerance = 1.0e-9;
69 
70  // test getting arbitrary data values
71  CPPUNIT_ASSERT_DOUBLES_EQUAL(0,hitran.isotopologue(0),tolerance);
72  CPPUNIT_ASSERT_DOUBLES_EQUAL(3,hitran.isotopologue(20),tolerance);
73  CPPUNIT_ASSERT_DOUBLES_EQUAL(3682.70083,hitran.nu0(0),tolerance);
74  CPPUNIT_ASSERT_DOUBLES_EQUAL(3682.761088,hitran.nu0(20),tolerance);
75  CPPUNIT_ASSERT_DOUBLES_EQUAL(1.062e-30,hitran.sw(0),tolerance);
76  CPPUNIT_ASSERT_DOUBLES_EQUAL(1.48e-30,hitran.sw(20),tolerance);
77  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0685,hitran.gamma_air(0),tolerance);
78  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0679,hitran.gamma_air(20),tolerance);
79  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.084,hitran.gamma_self(0),tolerance);
80  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08,hitran.gamma_self(20),tolerance);
81  CPPUNIT_ASSERT_DOUBLES_EQUAL(3253.949,hitran.elower(0),tolerance);
82  CPPUNIT_ASSERT_DOUBLES_EQUAL(1349.8942,hitran.elower(20),tolerance);
83  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.76,hitran.n_air(0),tolerance);
84  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,hitran.n_air(20),tolerance);
85  CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.008269,hitran.delta_air(0),tolerance);
86  CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.004588,hitran.delta_air(20),tolerance);
87 
88 
89  // these T values are explicitly given in the partition sum data
90  CPPUNIT_ASSERT_DOUBLES_EQUAL(279.609573308,hitran.partition_function(290.02,0),tolerance);
91  CPPUNIT_ASSERT_DOUBLES_EQUAL(563.425588693,hitran.partition_function(290.02,1),tolerance);
92  CPPUNIT_ASSERT_DOUBLES_EQUAL(593.852717624,hitran.partition_function(290.02,2),tolerance);
93  CPPUNIT_ASSERT_DOUBLES_EQUAL(3461.78001223,hitran.partition_function(290.02,3),tolerance);
94 
95  // check T value on the ends
96  CPPUNIT_ASSERT_DOUBLES_EQUAL(279.585269287,hitran.partition_function(290.0,0),tolerance);
97  CPPUNIT_ASSERT_DOUBLES_EQUAL(563.375898926,hitran.partition_function(290.0,1),tolerance);
98  CPPUNIT_ASSERT_DOUBLES_EQUAL(593.800881348,hitran.partition_function(290.0,2),tolerance);
99  CPPUNIT_ASSERT_DOUBLES_EQUAL(3461.47846875,hitran.partition_function(290.0,3),tolerance);
100 
101  CPPUNIT_ASSERT_DOUBLES_EQUAL(304.559997559,hitran.partition_function(310.0,0),tolerance);
102  CPPUNIT_ASSERT_DOUBLES_EQUAL(614.489990234,hitran.partition_function(310.0,1),tolerance);
103  CPPUNIT_ASSERT_DOUBLES_EQUAL(647.090026855,hitran.partition_function(310.0,2),tolerance);
104  CPPUNIT_ASSERT_DOUBLES_EQUAL(3771.39990234,hitran.partition_function(310.0,3),tolerance);
105 
106 
107  // partition function values at the reference temperature T=296K
108  CPPUNIT_ASSERT_DOUBLES_EQUAL(286.935573058,hitran.partition_function(296,0),tolerance);
109  CPPUNIT_ASSERT_DOUBLES_EQUAL(578.408361459,hitran.partition_function(296,1),tolerance);
110  CPPUNIT_ASSERT_DOUBLES_EQUAL(609.479752969,hitran.partition_function(296,2),tolerance);
111  CPPUNIT_ASSERT_DOUBLES_EQUAL(3552.67876127,hitran.partition_function(296,3),tolerance);
112 
113  // this T value is not is the partition sum data, and must be (linearly) interpolated
114  CPPUNIT_ASSERT_DOUBLES_EQUAL(593.813840240,hitran.partition_function(290.005,2),tolerance);
115  CPPUNIT_ASSERT_DOUBLES_EQUAL(291.9025545935294,hitran.partition_function(300+1.0e-6,0),1.0e-13);
116  CPPUNIT_ASSERT_DOUBLES_EQUAL(291.9137901096000,hitran.partition_function(300.009,0),1.0e-13);
117 
118  }
119  };
120 
121  CPPUNIT_TEST_SUITE_REGISTRATION( HITRANtest );
122 
123 } // end namespace GRINSTesting
124 
125 #endif // GRINS_HAVE_CPPUNIT
CPPUNIT_TEST_SUITE_REGISTRATION(AntiochAirNASA9ThermoTest)
libMesh::Real elower(unsigned int index)
Lower state energy of transition [ ].
Definition: hitran.C:216
libMesh::Real partition_function(libMesh::Real T, unsigned int iso)
Definition: hitran.C:234
libMesh::Real nu0(unsigned int index)
Linecenter wavenumber [ ].
Definition: hitran.C:192
unsigned int isotopologue(unsigned int index)
Isotopologue ID.
Definition: hitran.C:186
CPPUNIT_TEST_SUITE(HITRANtest)
libMesh::Real delta_air(unsigned int index)
Air pressure-induced line shift [ ].
Definition: hitran.C:228
libMesh::Real n_air(unsigned int index)
Temperature coefficient [].
Definition: hitran.C:222
CPPUNIT_TEST(parse_from_file)
HITRAN interface object.
Definition: hitran.h:58
libMesh::Real gamma_self(unsigned int index)
Self-broadening half-wdith [ ].
Definition: hitran.C:210
libMesh::Real sw(unsigned int index)
Linestrength [ ].
Definition: hitran.C:198
libMesh::Real gamma_air(unsigned int index)
Air-broadening half-width [ ].
Definition: hitran.C:204

Generated on Tue Dec 19 2017 12:47:29 for GRINS-0.8.0 by  doxygen 1.8.9.1