GRINS-0.6.0
cantera_mixture.h
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 #ifndef GRINS_CANTERA_MIXTURE_H
27 #define GRINS_CANTERA_MIXTURE_H
28 
29 #include "grins_config.h"
30 
31 #ifdef GRINS_HAVE_CANTERA
32 
33 // libMesh
34 #include "libmesh/threads.h"
35 
36 // Cantera (with compiler warnings disabled)
37 #include "libmesh/ignore_warnings.h"
38 #include "cantera/IdealGasMix.h"
39 #include "cantera/transport.h"
40 #include "libmesh/restore_warnings.h"
41 
42 // Boost
43 #include <boost/scoped_ptr.hpp>
44 
45 // libMesh forward declarations
46 class GetPot;
47 
48 namespace
49 {
50  static libMesh::Threads::spin_mutex cantera_mutex;
51 }
52 
53 namespace GRINS
54 {
56 
63  {
64  public:
65 
66  CanteraMixture( const GetPot& input );
68 
69  Cantera::IdealGasMix& get_chemistry();
70  const Cantera::IdealGasMix& get_chemistry() const;
71 
72  Cantera::Transport& get_transport();
73 
74  libMesh::Real M( unsigned int species ) const;
75 
76  libMesh::Real M_mix( const std::vector<libMesh::Real>& mass_fractions ) const;
77 
78  libMesh::Real R( unsigned int species ) const;
79 
80  libMesh::Real R_mix( const std::vector<libMesh::Real>& mass_fractions ) const;
81 
82  libMesh::Real X( unsigned int species, libMesh::Real M, libMesh::Real mass_fraction ) const;
83 
84  void X( libMesh::Real M, const std::vector<libMesh::Real>& mass_fractions,
85  std::vector<libMesh::Real>& mole_fractions ) const;
86 
87  unsigned int n_species() const;
88 
89  unsigned int species_index( const std::string& species_name ) const;
90 
91  std::string species_name( unsigned int species_index ) const;
92 
93  const CanteraMixture& chemistry() const;
94 
97 
98  protected:
99 
100  boost::scoped_ptr<Cantera::IdealGasMix> _cantera_gas;
101 
102  boost::scoped_ptr<Cantera::Transport> _cantera_transport;
103 
104  private:
105 
106  CanteraMixture();
107 
108  };
109 
110  /* ------------------------- Inline Functions -------------------------*/
111  inline
112  Cantera::IdealGasMix& CanteraMixture::get_chemistry()
113  {
114  return (*_cantera_gas);
115  }
116 
117  inline
118  const Cantera::IdealGasMix& CanteraMixture::get_chemistry() const
119  {
120  return (*_cantera_gas);
121  }
122 
123  inline
124  Cantera::Transport& CanteraMixture::get_transport()
125  {
126  return (*_cantera_transport);
127  }
128 
129  inline
130  libMesh::Real CanteraMixture::M( unsigned int species ) const
131  {
132  // Cantera returns molar mass in kg/kmol
133  return _cantera_gas->molecularWeight(species);
134  }
135 
136  inline
137  libMesh::Real CanteraMixture::R( unsigned int species ) const
138  {
139  // Cantera::GasConstant in J/kmol-K
140  // Cantera returns molar mass in kg/kmol
141  return Cantera::GasConstant/_cantera_gas->molecularWeight(species);
142  }
143 
144  inline
145  libMesh::Real CanteraMixture::X( unsigned int species,
146  libMesh::Real M_mix,
147  libMesh::Real mass_fraction ) const
148  {
149  return mass_fraction*M_mix/this->M(species);
150  }
151 
152  inline
153  unsigned int CanteraMixture::n_species() const
154  {
155  return _cantera_gas->nSpecies();
156  }
157 
158  inline
159  unsigned int CanteraMixture::species_index( const std::string& species_name ) const
160  {
161  return _cantera_gas->speciesIndex( species_name );
162  }
163 
164  inline
165  std::string CanteraMixture::species_name( unsigned int species_index ) const
166  {
167  return _cantera_gas->speciesName( species_index );
168  }
169 
170  inline
172  {
173  return *this;
174  }
175 
176 } // end namespace GRINS
177 
178 #endif // GRINS_HAVE_CANTERA
179 
180 #endif // GRINS_CANTERA_MIXTURE_H
libMesh::Real R(unsigned int species) const
libMesh::Real X(unsigned int species, libMesh::Real M, libMesh::Real mass_fraction) const
boost::scoped_ptr< Cantera::Transport > _cantera_transport
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
std::string species_name(unsigned int species_index) const
unsigned int species_index(const std::string &species_name) const
GRINS namespace.
unsigned int n_species() const
libMesh::Real M_mix(const std::vector< libMesh::Real > &mass_fractions) const
libMesh::Real R_mix(const std::vector< libMesh::Real > &mass_fractions) const
Cantera::IdealGasMix & get_chemistry()
Wrapper class for storing state for computing thermochemistry and transport properties using Cantera...
CanteraMixture ChemistryParent
This is basically dummy, but is needed for template games elsewhere.
Cantera::Transport & get_transport()
const CanteraMixture & chemistry() const
libMesh::Real M(unsigned int species) const

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