antioch-0.4.0
List of all members | Public Member Functions | Protected Attributes | Private Member Functions
Antioch::MixtureDiffusion< Diffusion, CoeffType > Class Template Reference

Container class for species binary diffusion models. More...

#include <mixture_diffusion.h>

Inheritance diagram for Antioch::MixtureDiffusion< Diffusion, CoeffType >:
Antioch::MixtureTransportBase< CoeffType >

Public Member Functions

 MixtureDiffusion (const TransportMixture< CoeffType > &transport_mixture)
 
virtual ~MixtureDiffusion ()
 
template<typename StateType , typename MatrixStateType >
void compute_binary_diffusion_matrix (const StateType &T, const StateType &molar_density, MatrixStateType &D) const
 Computes the binary diffusion matrix. More...
 
template<typename StateType >
void compute_species_diffusivity (unsigned int s, const StateType &rho, const StateType &cp, const StateType &k, StateType &D) const
 Computes species diffusivity for species s. More...
 
void add_species_diffusion (unsigned int s, const std::vector< CoeffType > &coeffs)
 Add species diffusion model for species s. More...
 
template<typename StateType >
void extrapolate_max_temp (const StateType &Tmax)
 Extrapolate to input maximum temperature, given in [K]. More...
 
const ChemicalMixture
< CoeffType > & 
chemical_mixture () const
 
const TransportMixture
< CoeffType > & 
transport_mixture () const
 
const TransportMixture
< CoeffType > & 
mixture () const
 

Protected Attributes

std::vector
< SpeciesDiffusionBase
< Diffusion, CoeffType > * > 
_species_diffusivities
 Stores species diffusivity models. More...
 
std::vector< std::vector
< BinaryDiffusionBase
< Diffusion, CoeffType > * > > 
_binary_diffusivities
 Stores binary diffusion model for all species pairs. More...
 
const TransportMixture
< CoeffType > & 
_transport_mixture
 

Private Member Functions

void private_init_impl (AntiochPrivate::diffusion_tag< SpeciesDiffusionBase< Diffusion, CoeffType > > &)
 Initialize species diffusion models. More...
 
void private_init_impl (AntiochPrivate::diffusion_tag< BinaryDiffusionBase< Diffusion, CoeffType > > &)
 Initialize binary diffusion models. More...
 
template<typename StateType , typename MatrixStateType >
void private_diff_matrix_impl (const StateType &T, const StateType &molar_density, MatrixStateType &D, AntiochPrivate::diffusion_tag< BinaryDiffusionBase< Diffusion, CoeffType > > &) const
 Compute binary diffusion matrix. More...
 
template<typename StateType , typename MatrixStateType >
void private_diff_matrix_impl (const StateType &, const StateType &, MatrixStateType &, AntiochPrivate::diffusion_tag< SpeciesDiffusionBase< Diffusion, CoeffType > > &) const
 Invalid to call binary diffusion matrix with SpeciesDiffusionBase model. More...
 
template<typename StateType >
void private_species_diff_impl (unsigned int s, const StateType &rho, const StateType &cp, const StateType &k, StateType &D, AntiochPrivate::diffusion_tag< SpeciesDiffusionBase< Diffusion, CoeffType > > &) const
 Compute species diffusivities. More...
 
template<typename StateType >
void private_species_diff_impl (unsigned int, const StateType &, const StateType &, const StateType &, StateType &, AntiochPrivate::diffusion_tag< BinaryDiffusionBase< Diffusion, CoeffType > > &) const
 Invalid to call species diffusivity calculation with BinaryDiffusionBase model. More...
 
 MixtureDiffusion ()
 

Detailed Description

template<typename Diffusion, class CoeffType>
class Antioch::MixtureDiffusion< Diffusion, CoeffType >

Container class for species binary diffusion models.

For the given set of chemical species in the input TransportMixture, this contains the diffusion models for each of those species and provides an interface for computing the species diffusion coefficients/binary diffusion matrix, depending on the Diffusion model template parameter. Total/mixture diffusion coefficients are computed by a mixing model, e.g. MixtureAveragedTransportEvaluator. This class is templated on the diffusion model, so an inherent assumption is that all species diffusions have the same model.

This is intended to only be used through a mixing model, e.g. MixtureAveragedTransportEvaluator.

This class supports interfaces to multiple types of species diffusion models. As such, we use "tagging" mechanisms to defer to the correct, private, implemenation for various functions.

Definition at line 55 of file mixture_diffusion.h.

Constructor & Destructor Documentation

template<typename Diffusion , class CoeffType>
Antioch::MixtureDiffusion< Diffusion, CoeffType >::MixtureDiffusion ( const TransportMixture< CoeffType > &  transport_mixture)

Definition at line 210 of file mixture_diffusion.h.

References antioch_error_msg, antioch_static_assert, and Antioch::MixtureDiffusion< Diffusion, CoeffType >::private_init_impl().

211  : MixtureTransportBase<CoeffType>(transport_mixture)
212 
213  {
214  // This class currenltly only supports species or binary diffusion models
215  if( !DiffusionTraits<Diffusion>::is_species_diffusion &&
216  !DiffusionTraits<Diffusion>::is_binary_diffusion )
217  {
218  antioch_static_assert( DiffusionTraits<Diffusion>::is_species_diffusion ||
219  DiffusionTraits<Diffusion>::is_binary_diffusion,
220  "Can only instantiate MixtureDiffusion with a species or binary diffusion model!" );
221 
222  std::string error = "ERROR: You're trying to construct an object\n";
223  error += " with an unknown diffusion model!\n";
224  error += " Does your compiler not support static_assert?";
225  antioch_error_msg(error);
226  }
227 
228  // Build tag so we defer to the right initialization function
229  AntiochPrivate::diffusion_tag<Diffusion> tag;
230  this->private_init_impl( tag );
231 
232  }
#define antioch_error_msg(errmsg)
#define antioch_static_assert(cond, errmsg)
void private_init_impl(AntiochPrivate::diffusion_tag< SpeciesDiffusionBase< Diffusion, CoeffType > > &)
Initialize species diffusion models.
const TransportMixture< CoeffType > & transport_mixture() const
template<typename Diffusion , class CoeffType >
Antioch::MixtureDiffusion< Diffusion, CoeffType >::~MixtureDiffusion ( )
virtual

Definition at line 235 of file mixture_diffusion.h.

236  {
237  // Clean up species diffusion models
238  if( DiffusionTraits<Diffusion>::is_species_diffusion )
239  {
240  for( typename std::vector<SpeciesDiffusionBase<Diffusion,CoeffType>*>::iterator it = _species_diffusivities.begin();
241  it != _species_diffusivities.end(); ++it )
242  delete *it;
243  }
244 
245  // Clean up binary diffusion models
246  if( DiffusionTraits<Diffusion>::is_binary_diffusion )
247  {
248  for( typename std::vector<std::vector<BinaryDiffusionBase<Diffusion,CoeffType>*> >::iterator it_outer = _binary_diffusivities.begin();
249  it_outer != _binary_diffusivities.end(); ++it_outer )
250  for( typename std::vector<BinaryDiffusionBase<Diffusion,CoeffType>*>::iterator it_inner = it_outer->begin();
251  it_inner != it_outer->end(); ++it_inner )
252  delete *it_inner;
253  }
254  }
std::vector< std::vector< BinaryDiffusionBase< Diffusion, CoeffType > * > > _binary_diffusivities
Stores binary diffusion model for all species pairs.
std::vector< SpeciesDiffusionBase< Diffusion, CoeffType > * > _species_diffusivities
Stores species diffusivity models.
template<typename Diffusion, class CoeffType>
Antioch::MixtureDiffusion< Diffusion, CoeffType >::MixtureDiffusion ( )
private

Member Function Documentation

template<typename Diffusion , class CoeffType>
void Antioch::MixtureDiffusion< Diffusion, CoeffType >::add_species_diffusion ( unsigned int  s,
const std::vector< CoeffType > &  coeffs 
)

Add species diffusion model for species s.

Definition at line 314 of file mixture_diffusion.h.

References antioch_assert_less, and antioch_static_assert_runtime_fallback.

316  {
317  antioch_static_assert_runtime_fallback( DiffusionTraits<Diffusion>::is_species_diffusion,
318  "Invalid to add species diffusion model with Diffusion model is not a species diffusion model!" );
320 
321  _species_diffusivities[s] = new Diffusion( coeffs );
322  }
std::vector< SpeciesDiffusionBase< Diffusion, CoeffType > * > _species_diffusivities
Stores species diffusivity models.
#define antioch_assert_less(expr1, expr2)
#define antioch_static_assert_runtime_fallback(cond, errmsg)
template<class CoeffType >
const ChemicalMixture< CoeffType > & Antioch::MixtureTransportBase< CoeffType >::chemical_mixture ( ) const
inlineinherited

Definition at line 68 of file mixture_transport_base.h.

69  {
70  return _transport_mixture.chemical_mixture();
71  }
const TransportMixture< CoeffType > & _transport_mixture
template<typename Diffusion , class CoeffType >
template<typename StateType , typename MatrixStateType >
void Antioch::MixtureDiffusion< Diffusion, CoeffType >::compute_binary_diffusion_matrix ( const StateType &  T,
const StateType &  molar_density,
MatrixStateType &  D 
) const
inline

Computes the binary diffusion matrix.

Should only be called when using a binary diffusion model.

Definition at line 259 of file mixture_diffusion.h.

References antioch_assert_equal_to, and antioch_assert_greater.

262  {
263  const unsigned int n_cols = D.size();
264  antioch_assert_greater(n_cols,0);
265 
266  // Make sure it's a square matrix
267 #ifndef NDEBUG
268  for( unsigned int r = 0; r < n_cols; r++ )
269  antioch_assert_equal_to(D[r].size(),n_cols);
270 #endif
271 
272  // Build tag so we defer to the right binary diffusion matrix function
273  AntiochPrivate::diffusion_tag<Diffusion> tag;
274  this->private_diff_matrix_impl(T,molar_density,D,tag);
275  }
#define antioch_assert_equal_to(expr1, expr2)
#define antioch_assert_greater(expr1, expr2)
void private_diff_matrix_impl(const StateType &T, const StateType &molar_density, MatrixStateType &D, AntiochPrivate::diffusion_tag< BinaryDiffusionBase< Diffusion, CoeffType > > &) const
Compute binary diffusion matrix.
template<typename Diffusion , class CoeffType >
template<typename StateType >
void Antioch::MixtureDiffusion< Diffusion, CoeffType >::compute_species_diffusivity ( unsigned int  s,
const StateType &  rho,
const StateType &  cp,
const StateType &  k,
StateType &  D 
) const
inline

Computes species diffusivity for species s.

Definition at line 280 of file mixture_diffusion.h.

References antioch_assert, and antioch_assert_less.

285  {
288 
289  // Build tag so we defer to the right species diffusivity function
290  AntiochPrivate::diffusion_tag<Diffusion> tag;
291  this->private_species_diff_impl(s,rho,cp,k,D,tag);
292  }
#define antioch_assert(asserted)
void private_species_diff_impl(unsigned int s, const StateType &rho, const StateType &cp, const StateType &k, StateType &D, AntiochPrivate::diffusion_tag< SpeciesDiffusionBase< Diffusion, CoeffType > > &) const
Compute species diffusivities.
std::vector< SpeciesDiffusionBase< Diffusion, CoeffType > * > _species_diffusivities
Stores species diffusivity models.
#define antioch_assert_less(expr1, expr2)
Scalar cp(Scalar T, Scalar a0, Scalar a1, Scalar a2, Scalar a3, Scalar a4, Scalar a5, Scalar a6)
template<typename Diffusion , class CoeffType >
template<typename StateType >
void Antioch::MixtureDiffusion< Diffusion, CoeffType >::extrapolate_max_temp ( const StateType &  Tmax)
inline

Extrapolate to input maximum temperature, given in [K].

For certain species diffusion models, interpolation of various quantities may be done based on the temperature. This method will use linear extrapolation to extend the range of temperature for all the species diffusion models.

This method is currently only valid for BinaryDiffusionBase subclasses. A static_assert will be throw if the user tries to instantiate a call to this method with a SpeciesDiffusionBase sublass (or runtime error if the compiler does not support static_assert).

Definition at line 297 of file mixture_diffusion.h.

References antioch_static_assert_runtime_fallback.

298  {
299  antioch_static_assert_runtime_fallback( DiffusionTraits<Diffusion>::is_binary_diffusion,
300  "Invalid to extrapolate temperature with a non-binary diffusion model!" );
301 
302  for( typename std::vector<std::vector<BinaryDiffusionBase<Diffusion,CoeffType>*> >::iterator it_outer = _binary_diffusivities.begin();
303  it_outer != _binary_diffusivities.end(); ++it_outer )
304  {
305  for( typename std::vector<BinaryDiffusionBase<Diffusion,CoeffType>*>::iterator it_inner = it_outer->begin();
306  it_inner != it_outer->end(); ++it_inner )
307  {
308  (*it_inner)->extrapolate_max_temp(Tmax);
309  }
310  }
311  }
std::vector< std::vector< BinaryDiffusionBase< Diffusion, CoeffType > * > > _binary_diffusivities
Stores binary diffusion model for all species pairs.
#define antioch_static_assert_runtime_fallback(cond, errmsg)
template<class CoeffType >
const TransportMixture< CoeffType > & Antioch::MixtureTransportBase< CoeffType >::mixture ( ) const
inlineinherited

Definition at line 82 of file mixture_transport_base.h.

83  {
84  return _transport_mixture;
85  }
const TransportMixture< CoeffType > & _transport_mixture
template<typename Diffusion, class CoeffType>
template<typename StateType , typename MatrixStateType >
void Antioch::MixtureDiffusion< Diffusion, CoeffType >::private_diff_matrix_impl ( const StateType &  T,
const StateType &  molar_density,
MatrixStateType &  D,
AntiochPrivate::diffusion_tag< BinaryDiffusionBase< Diffusion, CoeffType > > &   
) const
inlineprivate

Compute binary diffusion matrix.

BinaryDiffusionBase models should've subclassed diffusion_tag so that they call this method.

Definition at line 154 of file mixture_diffusion.h.

158  {
159  for(unsigned int i = 0; i < D.size(); i++)
160  {
161  for(unsigned int j = 0; j < D.size(); j++)
162  {
164 
165  D[i][j] = (*_binary_diffusivities[i][j])(T,molar_density);
166  }
167  }
168  }
#define antioch_assert(asserted)
std::vector< std::vector< BinaryDiffusionBase< Diffusion, CoeffType > * > > _binary_diffusivities
Stores binary diffusion model for all species pairs.
template<typename Diffusion, class CoeffType>
template<typename StateType , typename MatrixStateType >
void Antioch::MixtureDiffusion< Diffusion, CoeffType >::private_diff_matrix_impl ( const StateType &  ,
const StateType &  ,
MatrixStateType &  ,
AntiochPrivate::diffusion_tag< SpeciesDiffusionBase< Diffusion, CoeffType > > &   
) const
inlineprivate

Invalid to call binary diffusion matrix with SpeciesDiffusionBase model.

Definition at line 172 of file mixture_diffusion.h.

176  {
177  antioch_error();
178  }
#define antioch_error()
template<typename Diffusion, class CoeffType>
void Antioch::MixtureDiffusion< Diffusion, CoeffType >::private_init_impl ( AntiochPrivate::diffusion_tag< SpeciesDiffusionBase< Diffusion, CoeffType > > &  )
inlineprivate

Initialize species diffusion models.

SpeciesDiffusionBase models should've subclassed diffusion_tag so that they call this method.

Definition at line 120 of file mixture_diffusion.h.

Referenced by Antioch::MixtureDiffusion< Diffusion, CoeffType >::MixtureDiffusion().

121  {
122  antioch_static_assert( DiffusionTraits<Diffusion>::is_species_diffusion,
123  "This shouldn't happen!" );
124 
125  _species_diffusivities.resize( this->_transport_mixture.n_species(), NULL );
126  }
std::vector< SpeciesDiffusionBase< Diffusion, CoeffType > * > _species_diffusivities
Stores species diffusivity models.
const TransportMixture< CoeffType > & _transport_mixture
#define antioch_static_assert(cond, errmsg)
template<typename Diffusion, class CoeffType>
void Antioch::MixtureDiffusion< Diffusion, CoeffType >::private_init_impl ( AntiochPrivate::diffusion_tag< BinaryDiffusionBase< Diffusion, CoeffType > > &  )
inlineprivate

Initialize binary diffusion models.

BinaryDiffusionBase models should've subclassed diffusion_tag so that they call this method.

Definition at line 130 of file mixture_diffusion.h.

131  {
132  antioch_static_assert( DiffusionTraits<Diffusion>::is_binary_diffusion,
133  "This shouldn't happen!" );
134 
135  // Build up binary diffusion species models
136  _binary_diffusivities.resize( this->_transport_mixture.n_species() );
137  for( unsigned int i = 0; i < this->_transport_mixture.n_species(); i++ )
138  {
139  _binary_diffusivities[i].resize( this->_transport_mixture.n_species(), NULL );
140 
141  for (unsigned int j = 0; j < this->_transport_mixture.n_species(); j++)
142  {
143  const TransportSpecies<CoeffType>& s_i = this->_transport_mixture.transport_species(i);
144  const TransportSpecies<CoeffType>& s_j = this->_transport_mixture.transport_species(j);
145 
146  _binary_diffusivities[i][j] = new Diffusion( s_i, s_j );
147  }
148  }
149  }
std::vector< std::vector< BinaryDiffusionBase< Diffusion, CoeffType > * > > _binary_diffusivities
Stores binary diffusion model for all species pairs.
const TransportMixture< CoeffType > & _transport_mixture
#define antioch_static_assert(cond, errmsg)
template<typename Diffusion, class CoeffType>
template<typename StateType >
void Antioch::MixtureDiffusion< Diffusion, CoeffType >::private_species_diff_impl ( unsigned int  s,
const StateType &  rho,
const StateType &  cp,
const StateType &  k,
StateType &  D,
AntiochPrivate::diffusion_tag< SpeciesDiffusionBase< Diffusion, CoeffType > > &   
) const
inlineprivate

Compute species diffusivities.

SpeciesDiffusionBase models should've subclassed diffusion_tag so that they call this method.

Definition at line 183 of file mixture_diffusion.h.

189  {
190  D = (*_species_diffusivities[s]).D(rho,cp,k);
191  }
std::vector< SpeciesDiffusionBase< Diffusion, CoeffType > * > _species_diffusivities
Stores species diffusivity models.
Scalar cp(Scalar T, Scalar a0, Scalar a1, Scalar a2, Scalar a3, Scalar a4, Scalar a5, Scalar a6)
template<typename Diffusion, class CoeffType>
template<typename StateType >
void Antioch::MixtureDiffusion< Diffusion, CoeffType >::private_species_diff_impl ( unsigned  int,
const StateType &  ,
const StateType &  ,
const StateType &  ,
StateType &  ,
AntiochPrivate::diffusion_tag< BinaryDiffusionBase< Diffusion, CoeffType > > &   
) const
inlineprivate

Invalid to call species diffusivity calculation with BinaryDiffusionBase model.

Definition at line 195 of file mixture_diffusion.h.

201  {
202  antioch_error();
203  }
#define antioch_error()
template<class CoeffType >
const TransportMixture< CoeffType > & Antioch::MixtureTransportBase< CoeffType >::transport_mixture ( ) const
inlineinherited

Definition at line 75 of file mixture_transport_base.h.

76  {
77  return _transport_mixture;
78  }
const TransportMixture< CoeffType > & _transport_mixture

Member Data Documentation

template<typename Diffusion, class CoeffType>
std::vector<std::vector<BinaryDiffusionBase<Diffusion,CoeffType>*> > Antioch::MixtureDiffusion< Diffusion, CoeffType >::_binary_diffusivities
protected

Stores binary diffusion model for all species pairs.

This only gets built if Diffusion is a binary diffusion model.

Todo:
This will always be symmetric so we should make a smarter container that only stores the upper (lower) triangle of the species pairs and use accordingly.

Definition at line 114 of file mixture_diffusion.h.

template<typename Diffusion, class CoeffType>
std::vector<SpeciesDiffusionBase<Diffusion,CoeffType>*> Antioch::MixtureDiffusion< Diffusion, CoeffType >::_species_diffusivities
protected

Stores species diffusivity models.

This only gets built if Diffusion is a species diffusion model. Actually populating this is done in a separate function that calls the add_species_diffusivity method in this class since it depends on user-prescribed coefficients. However, if Diffusion is of species type, then the constructor will allocate space to add species diffusivities later.

Definition at line 106 of file mixture_diffusion.h.

template<class CoeffType = double>
const TransportMixture<CoeffType>& Antioch::MixtureTransportBase< CoeffType >::_transport_mixture
protectedinherited

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

Generated on Thu Jul 7 2016 11:09:49 for antioch-0.4.0 by  doxygen 1.8.8