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

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

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

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