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

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

#include <cantera_mixture.h>

Inheritance diagram for GRINS::CanteraMixture:
Inheritance graph
[legend]
Collaboration diagram for GRINS::CanteraMixture:
Collaboration graph
[legend]

Public Types

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

Public Member Functions

 CanteraMixture (const GetPot &input, const std::string &material)
 
 ~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
 
- Public Member Functions inherited from GRINS::ParameterUser
 ParameterUser (const std::string &user_name)
 
virtual ~ParameterUser ()
 
virtual void set_parameter (libMesh::Number &param_variable, const GetPot &input, const std::string &param_name, libMesh::Number param_default)
 Each subclass can simultaneously read a parameter value from. More...
 
virtual void set_parameter (libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &func, const GetPot &input, const std::string &func_param_name, const std::string &param_default)
 Each subclass can simultaneously read a parsed function from. More...
 
virtual void set_parameter (libMesh::ParsedFEMFunction< libMesh::Number > &func, const GetPot &input, const std::string &func_param_name, const std::string &param_default)
 Each subclass can simultaneously read a parsed function from. More...
 
virtual void move_parameter (const libMesh::Number &old_parameter, libMesh::Number &new_parameter)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void move_parameter (const libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &old_func, libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &new_func)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void move_parameter (const libMesh::ParsedFEMFunction< libMesh::Number > &old_func, libMesh::ParsedFEMFunction< libMesh::Number > &new_func)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void register_parameter (const std::string &param_name, libMesh::ParameterMultiAccessor< libMesh::Number > &param_pointer) const
 Each subclass will register its copy of an independent. More...
 

Protected Member Functions

std::string parse_mixture (const GetPot &input, const std::string &material)
 

Protected Attributes

libMesh::UniquePtr< Cantera::IdealGasMix > _cantera_gas
 
libMesh::UniquePtr< Cantera::Transport > _cantera_transport
 

Private Member Functions

 CanteraMixture ()
 

Additional Inherited Members

- Static Public Attributes inherited from GRINS::ParameterUser
static std::string zero_vector_function = std::string("{0}")
 A parseable function string with LIBMESH_DIM components, all 0. More...
 

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 65 of file cantera_mixture.h.

Member Typedef Documentation

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

Definition at line 99 of file cantera_mixture.h.

Constructor & Destructor Documentation

GRINS::CanteraMixture::CanteraMixture ( const GetPot &  input,
const std::string &  material 
)

Definition at line 41 of file cantera_mixture.C.

References _cantera_gas, _cantera_transport, GRINS::MaterialsParsing::parse_chemical_kinetics_datafile_name(), and parse_mixture().

42  : ParameterUser("CanteraMixture")
43  {
44  const std::string cantera_chem_file = MaterialsParsing::parse_chemical_kinetics_datafile_name( input, material );
45 
46  std::string mixture = this->parse_mixture(input,material);
47 
48  try
49  {
50  _cantera_gas.reset( new Cantera::IdealGasMix( cantera_chem_file, mixture ) );
51  }
52  catch(Cantera::CanteraError)
53  {
54  Cantera::showErrors(std::cerr);
55  libmesh_error();
56  }
57 
58  try
59  {
60  _cantera_transport.reset( Cantera::newTransportMgr("Mix", _cantera_gas.get()) );
61  }
62  catch(Cantera::CanteraError)
63  {
64  Cantera::showErrors(std::cerr);
65  libmesh_error();
66  }
67 
68  return;
69  }
libMesh::UniquePtr< Cantera::Transport > _cantera_transport
libMesh::UniquePtr< Cantera::IdealGasMix > _cantera_gas
ParameterUser(const std::string &user_name)
static std::string parse_chemical_kinetics_datafile_name(const GetPot &input, const std::string &material)
std::string parse_mixture(const GetPot &input, const std::string &material)
GRINS::CanteraMixture::~CanteraMixture ( )

Definition at line 71 of file cantera_mixture.C.

72  {
73  return;
74  }
GRINS::CanteraMixture::CanteraMixture ( )
private

Member Function Documentation

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

Definition at line 176 of file cantera_mixture.h.

177  {
178  return *this;
179  }
Cantera::IdealGasMix & GRINS::CanteraMixture::get_chemistry ( )
inline

Definition at line 117 of file cantera_mixture.h.

References _cantera_gas.

118  {
119  return (*_cantera_gas);
120  }
libMesh::UniquePtr< Cantera::IdealGasMix > _cantera_gas
const Cantera::IdealGasMix & GRINS::CanteraMixture::get_chemistry ( ) const
inline

Definition at line 123 of file cantera_mixture.h.

References _cantera_gas.

124  {
125  return (*_cantera_gas);
126  }
libMesh::UniquePtr< Cantera::IdealGasMix > _cantera_gas
Cantera::Transport & GRINS::CanteraMixture::get_transport ( )
inline

Definition at line 129 of file cantera_mixture.h.

References _cantera_transport.

130  {
131  return (*_cantera_transport);
132  }
libMesh::UniquePtr< Cantera::Transport > _cantera_transport
libMesh::Real GRINS::CanteraMixture::M ( unsigned int  species) const
inline

Definition at line 135 of file cantera_mixture.h.

References _cantera_gas.

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

136  {
137  // Cantera returns molar mass in kg/kmol
138  return _cantera_gas->molecularWeight(species);
139  }
libMesh::UniquePtr< Cantera::IdealGasMix > _cantera_gas
libMesh::Real GRINS::CanteraMixture::M_mix ( const std::vector< libMesh::Real > &  mass_fractions) const

Definition at line 99 of file cantera_mixture.C.

References _cantera_gas, and M().

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

100  {
101  libmesh_assert_equal_to( mass_fractions.size(), _cantera_gas->nSpecies() );
102 
103  libMesh::Real M = 0;
104  for( unsigned int s = 0; s < mass_fractions.size(); s++ )
105  {
106  M += mass_fractions[s]/(this->M(s));
107  }
108 
109  return 1.0/M;
110  }
libMesh::UniquePtr< Cantera::IdealGasMix > _cantera_gas
libMesh::Real M(unsigned int species) const
unsigned int GRINS::CanteraMixture::n_species ( ) const
inline

Definition at line 158 of file cantera_mixture.h.

References _cantera_gas.

Referenced by main().

159  {
160  return _cantera_gas->nSpecies();
161  }
libMesh::UniquePtr< Cantera::IdealGasMix > _cantera_gas
std::string GRINS::CanteraMixture::parse_mixture ( const GetPot &  input,
const std::string &  material 
)
protected

Definition at line 76 of file cantera_mixture.C.

References GRINS::MaterialsParsing::dep_input_warning().

Referenced by CanteraMixture().

77  {
78  std::string mixture;
79 
80  if( input.have_variable("Physics/Chemistry/mixture") )
81  {
82  MaterialsParsing::dep_input_warning("Physics/Chemistry/mixture",
83  "GasMixture/Cantera/gas_mixture" );
84 
85  mixture = input( "Physics/Chemistry/mixture", "DIE!" );
86  }
87  else if( input.have_variable("Materials/"+material+"/GasMixture/Cantera/gas_mixture") )
88  {
89  mixture = input("Materials/"+material+"/GasMixture/Cantera/gas_mixture", "DIE!");
90  }
91  else
92  {
93  libmesh_error_msg("ERROR: Could not find valid input for Cantera gas_mixture!");
94  }
95 
96  return mixture;
97  }
static void dep_input_warning(const std::string &old_option, const std::string &property)
Helper function for parsing/maintaing backward compatibility.
libMesh::Real GRINS::CanteraMixture::R ( unsigned int  species) const
inline

Definition at line 142 of file cantera_mixture.h.

References _cantera_gas.

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

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

Definition at line 112 of file cantera_mixture.C.

References _cantera_gas, and R().

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

113  {
114  libmesh_assert_equal_to( mass_fractions.size(), _cantera_gas->nSpecies() );
115 
116  libMesh::Real R = 0.0;
117  for( unsigned int s = 0; s < mass_fractions.size(); s++ )
118  {
119  R += mass_fractions[s]*this->R(s);
120  }
121 
122  return R;
123  }
libMesh::Real R(unsigned int species) const
libMesh::UniquePtr< Cantera::IdealGasMix > _cantera_gas
unsigned int GRINS::CanteraMixture::species_index ( const std::string &  species_name) const
inline

Definition at line 164 of file cantera_mixture.h.

References _cantera_gas.

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

165  {
166  return _cantera_gas->speciesIndex( species_name );
167  }
libMesh::UniquePtr< 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 170 of file cantera_mixture.h.

References _cantera_gas.

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

171  {
172  return _cantera_gas->speciesName( species_index );
173  }
libMesh::UniquePtr< 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 150 of file cantera_mixture.h.

References M().

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

153  {
154  return mass_fraction*M_mix/this->M(species);
155  }
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 125 of file cantera_mixture.C.

References _cantera_gas, and X().

127  {
128  libmesh_assert_equal_to( mass_fractions.size(), _cantera_gas->nSpecies() );
129 
130  libmesh_assert_equal_to( mole_fractions.size(), mass_fractions.size() );
131 
132  for( unsigned int s = 0; s < mass_fractions.size(); s++ )
133  {
134  mole_fractions[s] = this->X(s, M_mix, mass_fractions[s]);
135  }
136 
137  return;
138  }
libMesh::Real X(unsigned int species, libMesh::Real M, libMesh::Real mass_fraction) const
libMesh::UniquePtr< Cantera::IdealGasMix > _cantera_gas
libMesh::Real M_mix(const std::vector< libMesh::Real > &mass_fractions) const

Member Data Documentation

libMesh::UniquePtr<Cantera::IdealGasMix> GRINS::CanteraMixture::_cantera_gas
protected
libMesh::UniquePtr<Cantera::Transport> GRINS::CanteraMixture::_cantera_transport
protected

Definition at line 105 of file cantera_mixture.h.

Referenced by CanteraMixture(), and get_transport().


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

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