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

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