GRINS-0.7.0
Functions
antioch_mixture.C File Reference
#include "grins_config.h"
#include <iomanip>
#include <limits>
#include <vector>
#include "grins/antioch_mixture.h"
#include "grins/materials_parsing.h"
#include "grins/physics_naming.h"
#include "libmesh/getpot.h"
Include dependency graph for antioch_mixture.C:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 42 of file antioch_mixture.C.

References GRINS::AntiochChemistry::M_mix(), GRINS::AntiochChemistry::R_mix(), and GRINS::AntiochChemistry::X().

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

Generated on Thu Jun 2 2016 21:52:29 for GRINS-0.7.0 by  doxygen 1.8.10