GRINS-0.8.0
antioch_evaluator.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_ANTIOCH_EVALUATOR_H
27 #define GRINS_ANTIOCH_EVALUATOR_H
28 
29 #include "grins_config.h"
30 
31 #ifdef GRINS_HAVE_ANTIOCH
32 
33 // GRINS
34 #include "grins/antioch_mixture.h"
35 #include "grins/antioch_kinetics.h"
36 #include "grins/cached_values.h"
37 #include "grins/property_types.h"
38 
39 // Antioch
40 #include "antioch/temp_cache.h"
41 #include "antioch/cea_evaluator.h"
42 #include "antioch/stat_mech_thermo.h"
43 #include "antioch/ideal_gas_micro_thermo.h"
44 
45 namespace GRINS
46 {
48 
55  template<typename KineticsThermoCurveFit, typename Thermo>
57  {
58  public:
59 
61 
62  virtual ~AntiochEvaluator(){};
63 
64  // Chemistry
65  libMesh::Real M( unsigned int species ) const;
66 
67  libMesh::Real M_mix( const std::vector<libMesh::Real>& mass_fractions ) const;
68 
69  libMesh::Real R( unsigned int species ) const;
70 
71  libMesh::Real R_mix( const std::vector<libMesh::Real>& mass_fractions ) const;
72 
73  libMesh::Real X( unsigned int species, libMesh::Real M, libMesh::Real mass_fraction ) const;
74 
75  void X( libMesh::Real M, const std::vector<libMesh::Real> & mass_fractions,
76  std::vector<libMesh::Real> & mole_fractions ) const;
77 
78  unsigned int species_index( const std::string& species_name ) const;
79 
80  std::string species_name( unsigned int species_index ) const;
81 
82  // Thermo
83  libMesh::Real cp( const libMesh::Real& T, const libMesh::Real P, const std::vector<libMesh::Real>& Y );
84 
85  libMesh::Real cv( const libMesh::Real& T, const libMesh::Real P, const std::vector<libMesh::Real>& Y );
86 
87  libMesh::Real h_s( const libMesh::Real& T, unsigned int species );
88 
89  // Kinetics
90  void omega_dot( const libMesh::Real& T, libMesh::Real rho,
91  const std::vector<libMesh::Real> mass_fractions,
92  std::vector<libMesh::Real>& omega_dot );
93 
94  protected:
95 
97 
99  libMesh::UniquePtr<Thermo> _thermo;
100 
102  libMesh::UniquePtr<Antioch::NASAEvaluator<libMesh::Real,KineticsThermoCurveFit> > _nasa_evaluator;
103 
104  libMesh::UniquePtr<AntiochKinetics<KineticsThermoCurveFit> > _kinetics;
105 
106  // Temperature should be clipped to positive values for
107  // stability's sake
108  libMesh::Real _clipped_T;
109 
110  // We'll clip temperature at a user-specified minimum if
111  // requested. Some reaction equations give us NaNs at 0K too.
112  const libMesh::Real _minimum_T;
113 
114  libMesh::UniquePtr<Antioch::TempCache<libMesh::Real> > _temp_cache;
115 
117 
119  void check_and_reset_temp_cache( const libMesh::Real& T );
120 
121  /* Below we will specialize the specialized_build_* functions to the appropriate type.
122  This way, we can control how the cached transport objects get constructed
123  based on the template type. This is achieved by the dummy types forcing operator
124  overloading for each of the specialized types. */
126  { specialized_build_thermo( mixture, _thermo, thermo_type<Thermo>() ); }
127 
128  private:
129 
131 
133  libMesh::UniquePtr<Antioch::StatMechThermodynamics<libMesh::Real> >& thermo,
134  thermo_type<Antioch::StatMechThermodynamics<libMesh::Real> > )
135  {
136  thermo.reset( new Antioch::StatMechThermodynamics<libMesh::Real>( mixture.chemical_mixture() ) );
137  }
138 
140  libMesh::UniquePtr<Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,KineticsThermoCurveFit>, libMesh::Real> > & thermo,
141  thermo_type<Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,KineticsThermoCurveFit>, libMesh::Real> > )
142  {
143  _nasa_evaluator.reset( new Antioch::NASAEvaluator<libMesh::Real,KineticsThermoCurveFit>( mixture.nasa_mixture() ) );
144  thermo.reset( new Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,KineticsThermoCurveFit>,libMesh::Real>( *_nasa_evaluator, mixture.chemical_mixture() ) );
145  }
146 
147  };
148 
149  /* ------------------------- Inline Functions -------------------------*/
150  template<typename KineticsThermoCurveFit, typename Thermo>
151  inline
152  libMesh::Real
154  {
155  return _chem.M(species);
156  }
157 
158  template<typename KineticsThermoCurveFit, typename Thermo>
159  inline
160  libMesh::Real
162  M_mix( const std::vector<libMesh::Real>& mass_fractions ) const
163  {
164  return _chem.M_mix(mass_fractions);
165  }
166 
167  template<typename KineticsThermoCurveFit, typename Thermo>
168  inline
169  libMesh::Real
171  {
172  return _chem.R(species);
173  }
174 
175  template<typename KineticsThermoCurveFit, typename Thermo>
176  inline
177  libMesh::Real
179  R_mix( const std::vector<libMesh::Real>& mass_fractions ) const
180  {
181  return _chem.R_mix(mass_fractions);
182  }
183 
184  template<typename KineticsThermoCurveFit, typename Thermo>
185  inline
186  libMesh::Real AntiochEvaluator<KineticsThermoCurveFit,Thermo>::X( unsigned int species,
187  libMesh::Real M,
188  libMesh::Real mass_fraction ) const
189  {
190  return _chem.X(species,M,mass_fraction);
191  }
192 
193  template<typename KineticsThermoCurveFit, typename Thermo>
194  inline
196  const std::vector<libMesh::Real>& mass_fractions,
197  std::vector<libMesh::Real>& mole_fractions ) const
198  {
199  _chem.X(M,mass_fractions,mole_fractions);
200  }
201 
202  template<typename KineticsThermoCurveFit, typename Thermo>
203  inline
204  unsigned int
205  AntiochEvaluator<KineticsThermoCurveFit,Thermo>::species_index( const std::string& species_name ) const
206  {
207  return _chem.species_index(species_name);
208  }
209 
210  template<typename KineticsThermoCurveFit, typename Thermo>
211  inline
212  std::string
214  {
215  return _chem.species_name(species_index);
216  }
217 
218  template<typename KineticsThermoCurveFit, typename Thermo>
219  inline
221  {
222  _clipped_T = std::max(_minimum_T, T);
223 
224  // We can't compare T because it's a reference, so we may have already
225  // changed it upstream. So, we compare the next cheapest thing.
226  if( _temp_cache->T2 != _clipped_T*_clipped_T )
227  _temp_cache.reset( new Antioch::TempCache<libMesh::Real>(_clipped_T) );
228  }
229 
230 } // end namespace GRINS
231 
232 #endif // GRINS_HAVE_ANTIOCH
233 
234 #endif // GRINS_ANTIOCH_EVALUATOR_H
Wrapper class for evaluating chemistry and thermo properties using Antioch.
const libMesh::Real _minimum_T
void build_thermo(const AntiochMixture< KineticsThermoCurveFit > &mixture)
void specialized_build_thermo(const AntiochMixture< KineticsThermoCurveFit > &mixture, libMesh::UniquePtr< Antioch::StatMechThermodynamics< libMesh::Real > > &thermo, thermo_type< Antioch::StatMechThermodynamics< libMesh::Real > >)
libMesh::Real M(unsigned int species) const
const AntiochMixture< KineticsThermoCurveFit > & _chem
const Antioch::ChemicalMixture< libMesh::Real > & chemical_mixture() const
Accessor to underlying Antioch object.
void specialized_build_thermo(const AntiochMixture< KineticsThermoCurveFit > &mixture, libMesh::UniquePtr< Antioch::IdealGasMicroThermo< Antioch::NASAEvaluator< libMesh::Real, KineticsThermoCurveFit >, libMesh::Real > > &thermo, thermo_type< Antioch::IdealGasMicroThermo< Antioch::NASAEvaluator< libMesh::Real, KineticsThermoCurveFit >, libMesh::Real > >)
void check_and_reset_temp_cache(const libMesh::Real &T)
Helper method for managing _temp_cache.
GRINS namespace.
libMesh::Real X(unsigned int species, libMesh::Real M, libMesh::Real mass_fraction) const
std::string species_name(unsigned int species_index) const
libMesh::Real M_mix(const std::vector< libMesh::Real > &mass_fractions) const
void omega_dot(const libMesh::Real &T, libMesh::Real rho, const std::vector< libMesh::Real > mass_fractions, std::vector< libMesh::Real > &omega_dot)
libMesh::UniquePtr< AntiochKinetics< KineticsThermoCurveFit > > _kinetics
libMesh::Real R(unsigned int species) const
const Antioch::NASAThermoMixture< libMesh::Real, KineticsThermoCurveFit > & nasa_mixture() const
libMesh::Real cp(const libMesh::Real &T, const libMesh::Real P, const std::vector< libMesh::Real > &Y)
unsigned int species_index(const std::string &species_name) const
libMesh::Real R_mix(const std::vector< libMesh::Real > &mass_fractions) const
libMesh::UniquePtr< Thermo > _thermo
Primary thermo object.
Wrapper class for storing state for Antioch thermo and kinetics.
libMesh::Real h_s(const libMesh::Real &T, unsigned int species)
libMesh::UniquePtr< Antioch::NASAEvaluator< libMesh::Real, KineticsThermoCurveFit > > _nasa_evaluator
For some Thermo types, we also need to cache a NASAEvaluator.
libMesh::UniquePtr< Antioch::TempCache< libMesh::Real > > _temp_cache
libMesh::Real cv(const libMesh::Real &T, const libMesh::Real P, const std::vector< libMesh::Real > &Y)

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