GRINS-0.6.0
cantera_kinetic_rates.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 // GRINS
27 #include "grins_config.h"
28 
29 #ifdef GRINS_HAVE_CANTERA
30 
31 // C++
32 #include <fstream>
33 #include <iomanip>
34 
35 // GRINS
36 #include "grins/cantera_mixture.h"
37 #include "grins/cantera_kinetics.h"
38 
39 // libMesh
40 #include "libmesh/getpot.h"
41 #include "libmesh/libmesh_common.h"
42 
43 int main(int argc, char* argv[])
44 {
45  // Check command line count.
46  if( argc < 2 )
47  {
48  // TODO: Need more consistent error handling.
49  std::cerr << "Error: Must specify input file." << std::endl;
50  exit(1);
51  }
52 
53  GetPot input( argv[1] );
54 
55  GRINS::CanteraMixture mixture( input );
56 
57  GRINS::CanteraKinetics kinetics( mixture );
58 
59  libMesh::Real T0 = input( "Conditions/T0", 300.0 );
60  libMesh::Real T1 = input( "Conditions/T1", 300.0 );
61  libMesh::Real T_inc = input( "Conditions/T_increment", 100.0 );
62 
63  libMesh::Real rho = input( "Conditions/density", 1.0e-3 );
64 
65  const unsigned int n_species = mixture.n_species();
66 
67  std::vector<double> Y(n_species,0.0);
68  for( unsigned int s = 0; s < n_species; s++ )
69  {
70  Y[s] = input( "Conditions/mass_fractions", 0.0, s );
71  }
72 
73  libMesh::Real R_mix = mixture.R_mix(Y);
74 
75  std::vector<double> omega_dot(n_species,0.0);
76 
77  libMesh::Real T = T0;
78 
79  std::ofstream output;
80  output.open( "omega_dot.dat", std::ios::trunc );
81 
82  output << "# Species names" << std::endl;
83  for( unsigned int s = 0; s < n_species; s++ )
84  {
85  output << mixture.species_name( s ) << " ";
86  }
87  output << std::endl;
88  output << "# T [K] omega_dot [kg/m^3-s]" << std::endl;
89 
90  output.close();
91 
92  while( T < T1 )
93  {
94  libMesh::Real p = rho*R_mix*T;
95 
96  kinetics.omega_dot_TPY( T, p, Y, omega_dot );
97 
98  output.open( "omega_dot.dat", std::ios::app );
99  output << T << " ";
100 
101  for( unsigned int i = 0; i < n_species; i++ )
102  {
103  output << std::scientific << std::setprecision(16)
104  << omega_dot[i] << " ";
105  }
106 
107  output << std::endl;
108 
109  output.close();
110 
111  T += T_inc;
112  }
113 
114 
115  return 0;
116 }
117 
118 #endif //GRINS_HAVE_CANTERA
std::string species_name(unsigned int species_index) const
int main(int argc, char *argv[])
void omega_dot_TPY(const libMesh::Real T, const libMesh::Real P, const std::vector< libMesh::Real > &mass_fractions, std::vector< libMesh::Real > &omega_dot) const
unsigned int n_species() const
libMesh::Real R_mix(const std::vector< libMesh::Real > &mass_fractions) const
Wrapper class for storing state for computing thermochemistry and transport properties using Cantera...

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