GRINS-0.6.0
antioch_kinetics_regression.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 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 
26 #include "grins_config.h"
27 
28 // C++
29 #include <iomanip>
30 #include <limits>
31 #include <vector>
32 
33 // GRINS
34 #include "grins/antioch_mixture.h"
35 #include "grins/antioch_kinetics.h"
36 
37 // libMesh
38 #include "libmesh/getpot.h"
39 
40 int main( int argc, char* argv[] )
41 {
42 #ifdef GRINS_HAVE_ANTIOCH
43  // Check command line count.
44  if( argc < 2 )
45  {
46  // TODO: Need more consistent error handling.
47  std::cerr << "Error: Must specify input file." << std::endl;
48  exit(1);
49  }
50 
51  GetPot input( argv[1] );
52 
53  GRINS::AntiochMixture antioch_mixture(input);
54 
55  GRINS::AntiochKinetics antioch_kinetics( antioch_mixture );
56 
57  libMesh::Real T = 1000;
58 
59  Antioch::TempCache<libMesh::Real> T_cache(T);
60 
61  libMesh::Real rho = 1.0e-3;
62 
63  const unsigned int n_species = 5;
64 
65  std::vector<libMesh::Real> Y(n_species,0.2);
66 
67  std::vector<libMesh::Real> omega_dot(n_species,0.0);
68 
69  antioch_kinetics.omega_dot( T_cache, rho, Y, omega_dot );
70 
71  for( unsigned int i = 0; i < n_species; i++ )
72  {
73  std::cout << std::scientific << std::setprecision(16)
74  << "omega_dot(" << i << ") = " << omega_dot[i] << std::endl;
75  }
76 
77  int return_flag = 0;
78  double tol = std::numeric_limits<double>::epsilon()*40;
79 
80  // Check that omega_dot sums to 1
81  libMesh::Real sum = 0.0;
82  for( unsigned int s = 0; s < n_species; s++ )
83  {
84  sum += omega_dot[s];
85  }
86 
87  if( std::fabs(sum) > tol )
88  {
89  std::cout << "Error: Sum of mass sources not equal to zero!" << std::endl
90  << "sum = " << sum << std::endl;
91  return_flag = 1;
92  }
93 
94  // Now check against regression values
95  std::vector<libMesh::Real> omega_dot_reg(n_species,0.0);
96  omega_dot_reg[0] = 4.3561014567820650e-01;
97  omega_dot_reg[1] = -3.6797207156306633e+00;
98  omega_dot_reg[2] = 2.9970582875850726e+00;
99  omega_dot_reg[3] = -1.8346634812051223e+00;
100  omega_dot_reg[4] = 2.0817157635725065e+00;
101 
102  for( unsigned int s = 0; s < n_species; s++ )
103  {
104  if( std::fabs( (omega_dot[s] - omega_dot_reg[s])/omega_dot_reg[s] ) > tol )
105  {
106  std::cerr << "Error: Mismatch in omega_dot." << std::endl
107  << std::setprecision(16) << std::scientific
108  << "s = " << s << std::endl
109  << "omega_dot = " << omega_dot[s] << std::endl
110  << "omega_dot_reg = " << omega_dot_reg[s] << std::endl;
111  return_flag = 1;
112  }
113  }
114 
115 #else //GRINS_HAVE_ANTIOCH
116  // automake expects 77 for a skipped test
117  int return_flag = 77;
118 #endif
119 
120  return return_flag;
121 }
Wrapper class for evaluating chemical kinetics using Antioch.
void omega_dot(const Antioch::TempCache< libMesh::Real > &temp_cache, const libMesh::Real rho, const std::vector< libMesh::Real > &mass_fractions, std::vector< libMesh::Real > &omega_dot)
Wrapper class for storing state for Antioch thermo and kinetics.
int main(int argc, char *argv[])

Generated on Mon Jun 22 2015 21:32:20 for GRINS-0.6.0 by  doxygen 1.8.9.1