GRINS-0.6.0
Functions
cantera_mixture_unit.C File Reference
#include <iomanip>
#include <limits>
#include <vector>
#include "grins/cantera_mixture.h"
#include "libmesh/getpot.h"
Include dependency graph for cantera_mixture_unit.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 38 of file cantera_mixture_unit.C.

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

39 {
40  // Check command line count.
41  if( argc < 2 )
42  {
43  // TODO: Need more consistent error handling.
44  std::cerr << "Error: Must specify input file." << std::endl;
45  exit(1);
46  }
47 
48  GetPot input( argv[1] );
49 
50 
51 
52  GRINS::CanteraMixture cantera(input);
53 
54  std::vector<double> mass_fractions( 5, 0.2 );
55 
56  const double M_N2 = 14.00674*2;
57  const double M_O2 = 15.9994*2;
58  const double M_N = 14.00674;
59  const double M_O = 15.9994;
60  const double M_NO = (14.00674+15.9994);
61 
62  double R_exact = Cantera::GasConstant*( mass_fractions[0]/M_N2
63  + mass_fractions[1]/M_O2
64  + mass_fractions[3]/M_N
65  + mass_fractions[4]/M_O
66  + mass_fractions[2]/M_NO );
67 
68  double M_exact = 1.0/( mass_fractions[0]/M_N2
69  + mass_fractions[1]/M_O2
70  + mass_fractions[3]/M_N
71  + mass_fractions[4]/M_O
72  + mass_fractions[2]/M_NO );
73 
74  std::vector<double> X_exact(5, 0.0);
75  X_exact[0] = mass_fractions[0]*M_exact/M_N2;
76  X_exact[1] = mass_fractions[1]*M_exact/M_O2;
77  X_exact[3] = mass_fractions[3]*M_exact/M_N;
78  X_exact[4] = mass_fractions[4]*M_exact/M_O;
79  X_exact[2] = mass_fractions[2]*M_exact/M_NO;
80 
81  int return_flag = 0;
82 
83  const double tol = std::numeric_limits<double>::epsilon()*10;
84 
85  if( std::fabs( (cantera.R_mix(mass_fractions) - R_exact)/R_exact) > tol )
86  {
87  std::cerr << "Error: Mismatch in mixture gas constant." << std::endl
88  << std::setprecision(16) << std::scientific
89  << "R = " << cantera.R_mix(mass_fractions) << std::endl
90  << "R_exact = " << R_exact << std::endl;
91  return_flag = 1;
92  }
93 
94  if( std::fabs( (cantera.M_mix(mass_fractions) - M_exact)/M_exact ) > tol )
95  {
96  std::cerr << "Error: Mismatch in mixture molar mass." << std::endl
97  << std::setprecision(16) << std::scientific
98  << "M = " << cantera.M_mix(mass_fractions) << std::endl
99  << "M_exact = " << M_exact << std::endl;
100  return_flag = 1;
101  }
102 
103  std::vector<double> X(5);
104  cantera.X( cantera.M_mix(mass_fractions), mass_fractions, X );
105  for( unsigned int s = 0; s < 5; s++ )
106  {
107  if( std::fabs( (X[s] - X_exact[s])/X_exact[s]) > tol )
108  {
109  std::cerr << "Error: Mismatch in mole fraction for species " << s << std::endl
110  << std::setprecision(16) << std::scientific
111  << "X = " << X[s] << std::endl
112  << "X_exact = " << X_exact[s] << std::endl;
113  return_flag = 1;
114  }
115  }
116 
117  return return_flag;
118 }
Wrapper class for storing state for computing thermochemistry and transport properties using Cantera...

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