GRINS-0.6.0
Public Types | Public Member Functions | Protected Attributes | Private Member Functions | List of all members
GRINS::CanteraMixture Class Reference

Wrapper class for storing state for computing thermochemistry and transport properties using Cantera. More...

#include <cantera_mixture.h>

Public Types

typedef CanteraMixture ChemistryParent
 This is basically dummy, but is needed for template games elsewhere. More...
 

Public Member Functions

 CanteraMixture (const GetPot &input)
 
 ~CanteraMixture ()
 
Cantera::IdealGasMix & get_chemistry ()
 
const Cantera::IdealGasMix & get_chemistry () const
 
Cantera::Transport & get_transport ()
 
libMesh::Real M (unsigned int species) const
 
libMesh::Real M_mix (const std::vector< libMesh::Real > &mass_fractions) const
 
libMesh::Real R (unsigned int species) const
 
libMesh::Real R_mix (const std::vector< libMesh::Real > &mass_fractions) const
 
libMesh::Real X (unsigned int species, libMesh::Real M, libMesh::Real mass_fraction) const
 
void X (libMesh::Real M, const std::vector< libMesh::Real > &mass_fractions, std::vector< libMesh::Real > &mole_fractions) const
 
unsigned int n_species () const
 
unsigned int species_index (const std::string &species_name) const
 
std::string species_name (unsigned int species_index) const
 
const CanteraMixturechemistry () const
 

Protected Attributes

boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
 
boost::scoped_ptr< Cantera::Transport > _cantera_transport
 

Private Member Functions

 CanteraMixture ()
 

Detailed Description

Wrapper class for storing state for computing thermochemistry and transport properties using Cantera.

This class is expected to be constructed before threads have been forked and will live during the whole program. Note that this documentation will always be built regardless if Cantera is included in the GRINS build or not. Check configure output to confirm that Cantera was included in the build if you wish to use it.

Definition at line 62 of file cantera_mixture.h.

Member Typedef Documentation

This is basically dummy, but is needed for template games elsewhere.

Definition at line 96 of file cantera_mixture.h.

Constructor & Destructor Documentation

GRINS::CanteraMixture::CanteraMixture ( const GetPot &  input)

Definition at line 38 of file cantera_mixture.C.

References _cantera_gas, and _cantera_transport.

39  : _cantera_gas(NULL),
40  _cantera_transport(NULL)
41  {
42  const std::string cantera_chem_file = input( "Physics/Chemistry/chem_file", "DIE!" );
43  const std::string mixture = input( "Physics/Chemistry/mixture", "DIE!" );
44 
45  try
46  {
47  _cantera_gas.reset( new Cantera::IdealGasMix( cantera_chem_file, mixture ) );
48  }
49  catch(Cantera::CanteraError)
50  {
51  Cantera::showErrors(std::cerr);
52  libmesh_error();
53  }
54 
55  try
56  {
57  _cantera_transport.reset( Cantera::newTransportMgr("Mix", _cantera_gas.get()) );
58  }
59  catch(Cantera::CanteraError)
60  {
61  Cantera::showErrors(std::cerr);
62  libmesh_error();
63  }
64 
65  return;
66  }
boost::scoped_ptr< Cantera::Transport > _cantera_transport
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
GRINS::CanteraMixture::~CanteraMixture ( )

Definition at line 68 of file cantera_mixture.C.

69  {
70  return;
71  }
GRINS::CanteraMixture::CanteraMixture ( )
private

Member Function Documentation

const CanteraMixture & GRINS::CanteraMixture::chemistry ( ) const
inline

Definition at line 171 of file cantera_mixture.h.

172  {
173  return *this;
174  }
Cantera::IdealGasMix & GRINS::CanteraMixture::get_chemistry ( )
inline

Definition at line 112 of file cantera_mixture.h.

References _cantera_gas.

Referenced by main().

113  {
114  return (*_cantera_gas);
115  }
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
const Cantera::IdealGasMix & GRINS::CanteraMixture::get_chemistry ( ) const
inline

Definition at line 118 of file cantera_mixture.h.

References _cantera_gas.

119  {
120  return (*_cantera_gas);
121  }
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
Cantera::Transport & GRINS::CanteraMixture::get_transport ( )
inline

Definition at line 124 of file cantera_mixture.h.

References _cantera_transport.

125  {
126  return (*_cantera_transport);
127  }
boost::scoped_ptr< Cantera::Transport > _cantera_transport
libMesh::Real GRINS::CanteraMixture::M ( unsigned int  species) const
inline

Definition at line 130 of file cantera_mixture.h.

References _cantera_gas.

Referenced by GRINS::CanteraEvaluator::M(), M_mix(), and X().

131  {
132  // Cantera returns molar mass in kg/kmol
133  return _cantera_gas->molecularWeight(species);
134  }
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
libMesh::Real GRINS::CanteraMixture::M_mix ( const std::vector< libMesh::Real > &  mass_fractions) const

Definition at line 73 of file cantera_mixture.C.

References _cantera_gas, and M().

Referenced by GRINS::CanteraEvaluator::M_mix(), and main().

74  {
75  libmesh_assert_equal_to( mass_fractions.size(), _cantera_gas->nSpecies() );
76 
77  libMesh::Real M = 0;
78  for( unsigned int s = 0; s < mass_fractions.size(); s++ )
79  {
80  M += mass_fractions[s]/(this->M(s));
81  }
82 
83  return 1.0/M;
84  }
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
libMesh::Real M(unsigned int species) const
unsigned int GRINS::CanteraMixture::n_species ( ) const
inline

Definition at line 153 of file cantera_mixture.h.

References _cantera_gas.

Referenced by main().

154  {
155  return _cantera_gas->nSpecies();
156  }
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
libMesh::Real GRINS::CanteraMixture::R ( unsigned int  species) const
inline

Definition at line 137 of file cantera_mixture.h.

References _cantera_gas.

Referenced by GRINS::CanteraThermodynamics::h(), GRINS::CanteraEvaluator::R(), and R_mix().

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  }
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
libMesh::Real GRINS::CanteraMixture::R_mix ( const std::vector< libMesh::Real > &  mass_fractions) const

Definition at line 86 of file cantera_mixture.C.

References _cantera_gas, and R().

Referenced by main(), and GRINS::CanteraEvaluator::R_mix().

87  {
88  libmesh_assert_equal_to( mass_fractions.size(), _cantera_gas->nSpecies() );
89 
90  libMesh::Real R = 0.0;
91  for( unsigned int s = 0; s < mass_fractions.size(); s++ )
92  {
93  R += mass_fractions[s]*this->R(s);
94  }
95 
96  return R;
97  }
libMesh::Real R(unsigned int species) const
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
unsigned int GRINS::CanteraMixture::species_index ( const std::string &  species_name) const
inline

Definition at line 159 of file cantera_mixture.h.

References _cantera_gas.

Referenced by GRINS::CanteraEvaluator::species_index().

160  {
161  return _cantera_gas->speciesIndex( species_name );
162  }
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
std::string species_name(unsigned int species_index) const
std::string GRINS::CanteraMixture::species_name ( unsigned int  species_index) const
inline

Definition at line 165 of file cantera_mixture.h.

References _cantera_gas.

Referenced by main(), and GRINS::CanteraEvaluator::species_name().

166  {
167  return _cantera_gas->speciesName( species_index );
168  }
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
unsigned int species_index(const std::string &species_name) const
libMesh::Real GRINS::CanteraMixture::X ( unsigned int  species,
libMesh::Real  M,
libMesh::Real  mass_fraction 
) const
inline

Definition at line 145 of file cantera_mixture.h.

References M().

Referenced by main(), GRINS::CanteraEvaluator::X(), and X().

148  {
149  return mass_fraction*M_mix/this->M(species);
150  }
libMesh::Real M_mix(const std::vector< libMesh::Real > &mass_fractions) const
libMesh::Real M(unsigned int species) const
void GRINS::CanteraMixture::X ( libMesh::Real  M,
const std::vector< libMesh::Real > &  mass_fractions,
std::vector< libMesh::Real > &  mole_fractions 
) const

Definition at line 99 of file cantera_mixture.C.

References _cantera_gas, and X().

101  {
102  libmesh_assert_equal_to( mass_fractions.size(), _cantera_gas->nSpecies() );
103 
104  libmesh_assert_equal_to( mole_fractions.size(), mass_fractions.size() );
105 
106  for( unsigned int s = 0; s < mass_fractions.size(); s++ )
107  {
108  mole_fractions[s] = this->X(s, M_mix, mass_fractions[s]);
109  }
110 
111  return;
112  }
libMesh::Real X(unsigned int species, libMesh::Real M, libMesh::Real mass_fraction) const
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
libMesh::Real M_mix(const std::vector< libMesh::Real > &mass_fractions) const

Member Data Documentation

boost::scoped_ptr<Cantera::IdealGasMix> GRINS::CanteraMixture::_cantera_gas
protected
boost::scoped_ptr<Cantera::Transport> GRINS::CanteraMixture::_cantera_transport
protected

Definition at line 102 of file cantera_mixture.h.

Referenced by CanteraMixture(), and get_transport().


The documentation for this class was generated from the following files:

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