GRINS-0.8.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-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 #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 // libMesh
43 #include "libmesh/auto_ptr.h" // libMesh::UniquePtr
44 
45 // GRINS
46 #include "grins/parameter_user.h"
47 
48 // libMesh forward declarations
49 class GetPot;
50 
51 namespace
52 {
53  static libMesh::Threads::spin_mutex cantera_mutex;
54 }
55 
56 namespace GRINS
57 {
59 
66  {
67  public:
68 
69  CanteraMixture( const GetPot& input, const std::string& material );
71 
72  Cantera::IdealGasMix& get_chemistry();
73  const Cantera::IdealGasMix& get_chemistry() const;
74 
75  Cantera::Transport& get_transport();
76 
77  libMesh::Real M( unsigned int species ) const;
78 
79  libMesh::Real M_mix( const std::vector<libMesh::Real>& mass_fractions ) const;
80 
81  libMesh::Real R( unsigned int species ) const;
82 
83  libMesh::Real R_mix( const std::vector<libMesh::Real>& mass_fractions ) const;
84 
85  libMesh::Real X( unsigned int species, libMesh::Real M, libMesh::Real mass_fraction ) const;
86 
87  void X( libMesh::Real M, const std::vector<libMesh::Real>& mass_fractions,
88  std::vector<libMesh::Real>& mole_fractions ) const;
89 
90  unsigned int n_species() const;
91 
92  unsigned int species_index( const std::string& species_name ) const;
93 
94  std::string species_name( unsigned int species_index ) const;
95 
96  const CanteraMixture& chemistry() const;
97 
100 
101  protected:
102 
103  libMesh::UniquePtr<Cantera::IdealGasMix> _cantera_gas;
104 
105  libMesh::UniquePtr<Cantera::Transport> _cantera_transport;
106 
107  std::string parse_mixture( const GetPot& input, const std::string& material );
108 
109  private:
110 
111  CanteraMixture();
112 
113  };
114 
115  /* ------------------------- Inline Functions -------------------------*/
116  inline
117  Cantera::IdealGasMix& CanteraMixture::get_chemistry()
118  {
119  return (*_cantera_gas);
120  }
121 
122  inline
123  const Cantera::IdealGasMix& CanteraMixture::get_chemistry() const
124  {
125  return (*_cantera_gas);
126  }
127 
128  inline
129  Cantera::Transport& CanteraMixture::get_transport()
130  {
131  return (*_cantera_transport);
132  }
133 
134  inline
135  libMesh::Real CanteraMixture::M( unsigned int species ) const
136  {
137  // Cantera returns molar mass in kg/kmol
138  return _cantera_gas->molecularWeight(species);
139  }
140 
141  inline
142  libMesh::Real CanteraMixture::R( unsigned int species ) const
143  {
144  // Cantera::GasConstant in J/kmol-K
145  // Cantera returns molar mass in kg/kmol
146  return Cantera::GasConstant/_cantera_gas->molecularWeight(species);
147  }
148 
149  inline
150  libMesh::Real CanteraMixture::X( unsigned int species,
151  libMesh::Real M_mix,
152  libMesh::Real mass_fraction ) const
153  {
154  return mass_fraction*M_mix/this->M(species);
155  }
156 
157  inline
158  unsigned int CanteraMixture::n_species() const
159  {
160  return _cantera_gas->nSpecies();
161  }
162 
163  inline
164  unsigned int CanteraMixture::species_index( const std::string& species_name ) const
165  {
166  return _cantera_gas->speciesIndex( species_name );
167  }
168 
169  inline
170  std::string CanteraMixture::species_name( unsigned int species_index ) const
171  {
172  return _cantera_gas->speciesName( species_index );
173  }
174 
175  inline
177  {
178  return *this;
179  }
180 
181 } // end namespace GRINS
182 
183 #endif // GRINS_HAVE_CANTERA
184 
185 #endif // GRINS_CANTERA_MIXTURE_H
libMesh::UniquePtr< Cantera::Transport > _cantera_transport
libMesh::Real R(unsigned int species) const
libMesh::Real X(unsigned int species, libMesh::Real M, libMesh::Real mass_fraction) const
libMesh::UniquePtr< 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
ParameterUser base class. Utility methods for subclasses.
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
std::string parse_mixture(const GetPot &input, const std::string &material)

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