GRINS-0.6.0
antioch_mixture_unit.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 
36 // libMesh
37 #include "libmesh/getpot.h"
38 
39 int main( int argc, char* argv[] )
40 {
41 #ifdef GRINS_HAVE_ANTIOCH
42  // Check command line count.
43  if( argc < 2 )
44  {
45  // TODO: Need more consistent error handling.
46  std::cerr << "Error: Must specify input file." << std::endl;
47  exit(1);
48  }
49 
50  GetPot input( argv[1] );
51 
52  GRINS::AntiochMixture antioch(input);
53 
54  std::vector<double> mass_fractions( 5, 0.2 );
55 
56  // 1.0e-3 converts from kg/kmol -> kg/mol
57  const double M_N2 = 14.00800*2*1.0e-3;
58  const double M_O2 = 16.0000*2*1.0e-3;
59  const double M_N = 14.00800*1.0e-3;
60  const double M_O = 16.0000*1.0e-3;
61  const double M_NO = 30.00800*1.0e-3;
62 
63  double R_exact = Antioch::Constants::R_universal<double>()*( mass_fractions[0]/M_N2
64  + mass_fractions[1]/M_O2
65  + mass_fractions[3]/M_N
66  + mass_fractions[4]/M_O
67  + mass_fractions[2]/M_NO );
68 
69  double M_exact = 1.0/( mass_fractions[0]/M_N2
70  + mass_fractions[1]/M_O2
71  + mass_fractions[3]/M_N
72  + mass_fractions[4]/M_O
73  + mass_fractions[2]/M_NO );
74 
75  std::vector<double> X_exact(5, 0.0);
76  X_exact[0] = mass_fractions[0]*M_exact/M_N2;
77  X_exact[1] = mass_fractions[1]*M_exact/M_O2;
78  X_exact[3] = mass_fractions[3]*M_exact/M_N;
79  X_exact[4] = mass_fractions[4]*M_exact/M_O;
80  X_exact[2] = mass_fractions[2]*M_exact/M_NO;
81 
82  int return_flag = 0;
83 
84  const double tol = std::numeric_limits<double>::epsilon()*10;
85 
86  if( std::fabs( (antioch.R_mix(mass_fractions) - R_exact)/R_exact) > tol )
87  {
88  std::cerr << "Error: Mismatch in mixture gas constant." << std::endl
89  << std::setprecision(16) << std::scientific
90  << "R = " << antioch.R_mix(mass_fractions) << std::endl
91  << "R_exact = " << R_exact << std::endl;
92  return_flag = 1;
93  }
94 
95  if( std::fabs( (antioch.M_mix(mass_fractions) - M_exact)/M_exact ) > tol )
96  {
97  std::cerr << "Error: Mismatch in mixture molar mass." << std::endl
98  << std::setprecision(16) << std::scientific
99  << "M = " << antioch.M_mix(mass_fractions) << std::endl
100  << "M_exact = " << M_exact << std::endl;
101  return_flag = 1;
102  }
103 
104  std::vector<double> X(5);
105  antioch.X( antioch.M_mix(mass_fractions), mass_fractions, X );
106  for( unsigned int s = 0; s < 5; s++ )
107  {
108  if( std::fabs( (X[s] - X_exact[s])/X_exact[s]) > tol )
109  {
110  std::cerr << "Error: Mismatch in mole fraction for species " << s << std::endl
111  << std::setprecision(16) << std::scientific
112  << "X = " << X[s] << std::endl
113  << "X_exact = " << X_exact[s] << std::endl;
114  return_flag = 1;
115  }
116  }
117 
118 #else //GRINS_HAVE_ANTIOCH
119  // automake expects 77 for a skipped test
120  int return_flag = 77;
121 #endif
122 
123  return return_flag;
124 }
libMesh::Real M_mix(const std::vector< libMesh::Real > &mass_fractions) const
Mixture molar mass (molecular weight), [kg/mol].
int main(int argc, char *argv[])
libMesh::Real R_mix(const std::vector< libMesh::Real > &mass_fractions) const
Mixture gas constant, [J/kg-K].
Wrapper class for storing state for Antioch thermo and kinetics.
libMesh::Real X(unsigned int species, libMesh::Real M, libMesh::Real mass_fraction) const
Species mole fraction, unitless.

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