GRINS-0.8.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-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 // 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"
39 #include "grins/physics_naming.h"
40 
41 // libMesh
42 #include "libmesh/getpot.h"
43 #include "libmesh/libmesh_common.h"
44 
45 int main(int argc, char* argv[])
46 {
47  // Check command line count.
48  if( argc < 2 )
49  {
50  // TODO: Need more consistent error handling.
51  std::cerr << "Error: Must specify input file." << std::endl;
52  exit(1);
53  }
54 
55  GetPot input( argv[1] );
56 
58 
59  GRINS::CanteraKinetics kinetics( mixture );
60 
61  libMesh::Real T0 = input( "Conditions/T0", 300.0 );
62  libMesh::Real T1 = input( "Conditions/T1", 300.0 );
63  libMesh::Real T_inc = input( "Conditions/T_increment", 100.0 );
64 
65  libMesh::Real rho = input( "Conditions/density", 1.0e-3 );
66 
67  const unsigned int n_species = mixture.n_species();
68 
69  std::vector<double> Y(n_species,0.0);
70  for( unsigned int s = 0; s < n_species; s++ )
71  {
72  Y[s] = input( "Conditions/mass_fractions", 0.0, s );
73  }
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  kinetics.omega_dot( T, rho, Y, omega_dot );
95 
96  output.open( "omega_dot.dat", std::ios::app );
97  output << T << " ";
98 
99  for( unsigned int i = 0; i < n_species; i++ )
100  {
101  output << std::scientific << std::setprecision(16)
102  << omega_dot[i] << " ";
103  }
104 
105  output << std::endl;
106 
107  output.close();
108 
109  T += T_inc;
110  }
111 
112 
113  return 0;
114 }
115 
116 #endif //GRINS_HAVE_CANTERA
static PhysicsName reacting_low_mach_navier_stokes()
void omega_dot(const libMesh::Real &T, const libMesh::Real rho, const std::vector< libMesh::Real > &mass_fractions, std::vector< libMesh::Real > &omega_dot) const
std::string species_name(unsigned int species_index) const
int main(int argc, char *argv[])
unsigned int n_species() const
Wrapper class for storing state for computing thermochemistry and transport properties using Cantera...
static std::string material_name(const GetPot &input, const std::string &physics)
Get the name of the material in the Physics/physics section.

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