28 #ifndef ANTIOCH_CEA_THERMO_H
29 #define ANTIOCH_CEA_THERMO_H
32 #include "antioch_config.h"
49 template<
typename CoeffType>
52 template<
typename CoeffType=
double>
53 class CEAThermodynamics
64 template<
typename StateType=CoeffType>
74 explicit Cache(
const StateType &T_in)
75 : T(T_in), T2(T*T), T3(T2*T), T4(T2*T2), lnT(T_in) {
81 const StateType &T2_in,
82 const StateType &T3_in,
83 const StateType &T4_in,
84 const StateType &lnT_in)
85 : T(T_in), T2(T2_in), T3(T3_in), T4(T4_in), lnT(lnT_in) {
92 void add_curve_fit(
const std::string& species_name,
const std::vector<CoeffType>& coeffs );
95 void add_curve_fit(
const std::string& species_name,
const std::vector<CoeffType>& coeffs,
const std::vector<CoeffType> & )
102 template<
typename StateType>
104 cp(
const Cache<StateType> &cache,
unsigned int species )
const;
106 template<
typename StateType,
typename VectorStateType>
110 cp(
const Cache<StateType> &cache,
const VectorStateType& mass_fractions )
const;
112 template<
typename StateType>
113 StateType
cv(
const Cache<StateType> &cache,
unsigned int species )
const;
115 template<
typename StateType,
typename VectorStateType>
117 has_size<VectorStateType>::value, StateType
119 cv(
const Cache<StateType> &cache,
const VectorStateType& mass_fractions )
const;
121 template<
typename StateType>
122 StateType
h(
const Cache<StateType> &cache,
unsigned int species )
const;
124 template<
typename StateType,
typename VectorStateType>
126 has_size<VectorStateType>::value,
void
128 h(
const Cache<StateType> &cache, VectorStateType&
h )
const;
131 template<
typename StateType>
133 h_RT_minus_s_R(
const Cache<StateType> &cache,
unsigned int species )
const;
135 template<
typename StateType,
typename VectorStateType>
137 has_size<VectorStateType>::value,
void
144 template<
typename StateType>
148 template<
typename StateType,
typename VectorStateType>
150 has_size<VectorStateType>::value,
void
155 template<
typename StateType>
156 StateType
cp_over_R(
const Cache<StateType> &cache,
unsigned int species )
const;
158 template<
typename StateType>
159 StateType
h_over_RT(
const Cache<StateType> &cache,
unsigned int species )
const;
161 template<
typename StateType>
162 StateType
s_over_R(
const Cache<StateType> &cache,
unsigned int species )
const;
184 template<
typename CoeffType>
187 : _chem_mixture(chem_mixture),
188 _species_curve_fits(chem_mixture.n_species(), NULL)
210 template<
typename CoeffType>
216 it < _species_curve_fits.end(); ++it )
225 template<
typename CoeffType>
228 const std::vector<CoeffType>& coeffs )
230 antioch_assert( _chem_mixture.species_name_map().find(species_name) !=
231 _chem_mixture.species_name_map().end() );
233 unsigned int s = _chem_mixture.species_name_map().find(species_name)->second;
243 template<
typename CoeffType>
250 it != _species_curve_fits.end(); ++ it )
260 template<
typename CoeffType>
261 template<
typename StateType>
271 (cache.
T < ScalarType(200.1),
273 (cache.
T,_cp_at_200p1[species]),
275 (this->_chem_mixture.R(species) *
276 this->cp_over_R(cache, species)));
280 template<
typename CoeffType>
281 template<
typename StateType,
typename VectorStateType>
287 const VectorStateType& mass_fractions )
const
292 StateType
cp = mass_fractions[0]*this->
cp(cache,0);
294 for(
unsigned int s = 1; s < _species_curve_fits.size(); s++ )
296 cp += mass_fractions[s]*this->
cp(cache,s);
303 template<
typename CoeffType>
304 template<
typename StateType>
308 return this->_chem_mixture.R(species)*cache.
T*this->h_over_RT(cache,species);
312 template<
typename CoeffType>
313 template<
typename StateType,
typename VectorStateType>
316 has_size<VectorStateType>::value,
void
322 for(
unsigned int s = 0; s < _species_curve_fits.size(); s++ )
324 h[s] = this->_chem_mixture.R(s)*cache.
T*this->h_over_RT(cache,s);
331 template<
typename CoeffType>
332 template<
typename StateType>
344 const UIntType interval = this->_species_curve_fits[species]->interval(cache.
T);
346 const unsigned int begin_interval =
Antioch::min(interval);
347 const unsigned int end_interval =
Antioch::max(interval)+1;
354 for (
unsigned int i=begin_interval; i != end_interval; ++i)
356 const CoeffType *
const a =
357 this->_species_curve_fits[species]->coefficients(i);
360 StateType(a[0]/cache.
T2 + a[1]/cache.
T + a[2] + a[3]*cache.
T +
361 a[4]*cache.
T2 + a[5]*cache.
T3 + a[6]*cache.
T4),
369 template<
typename CoeffType>
370 template<
typename StateType>
376 _species_curve_fits[species]->n_intervals() );
378 const unsigned int interval = this->_species_curve_fits[species]->interval(cache.
T);
380 const CoeffType *a = this->_species_curve_fits[species]->coefficients(interval);
386 return -a[0]/cache.
T2 + a[1]*cache.
lnT/cache.
T + a[2] +
387 a[3]*cache.
T/raw_type(2) + a[4]*cache.
T2/raw_type(3) +
388 a[5]*cache.
T3/raw_type(4) + a[6]*cache.
T4/raw_type(5) +
393 template<
typename CoeffType>
394 template<
typename StateType>
400 _species_curve_fits[species]->n_intervals() );
402 const unsigned int interval = this->_species_curve_fits[species]->interval(cache.
T);
404 const CoeffType *a = this->_species_curve_fits[species]->coefficients(interval);
410 return -a[0]/cache.
T2/raw_type(2) - a[1]/cache.
T +
411 a[2]*cache.
lnT + a[3]*cache.
T + a[4]*cache.
T2/raw_type(2) +
412 a[5]*cache.
T3/raw_type(3) + a[6]*cache.
T4/raw_type(4) + a[8];
416 template<
typename CoeffType>
417 template<
typename StateType>
429 const UIntType interval = this->_species_curve_fits[species]->interval(cache.
T);
430 const unsigned int begin_interval =
Antioch::min(interval);
431 const unsigned int end_interval =
Antioch::max(interval)+1;
442 for (
unsigned int i=begin_interval; i != end_interval; ++i)
444 const CoeffType *
const a =
445 this->_species_curve_fits[species]->coefficients(i);
448 StateType(-a[0]/cache.
T2/raw_type(2) +
449 (a[1] + a[7])/cache.
T +
450 a[1]*cache.
lnT/cache.
T - a[2]*cache.
lnT +
451 (a[2] - a[8]) - a[3]*cache.
T/raw_type(2) -
452 a[4]*cache.
T2/raw_type(6) -
453 a[5]*cache.
T3/raw_type(12) -
454 a[6]*cache.
T4/raw_type(20)),
462 template<
typename CoeffType>
463 template<
typename StateType,
typename VectorStateType>
466 has_size<VectorStateType>::value,
void
469 VectorStateType& h_RT_minus_s_R )
const
473 for(
unsigned int s = 0; s < _species_curve_fits.size(); s++ )
475 h_RT_minus_s_R[s] = this->h_RT_minus_s_R(cache,s);
483 template<
typename CoeffType>
484 template<
typename StateType>
496 const UIntType interval = this->_species_curve_fits[species]->interval(cache.
T);
498 const unsigned int begin_interval =
Antioch::min(interval);
499 const unsigned int end_interval =
Antioch::max(interval)+1;
510 for (
unsigned int i=begin_interval; i != end_interval; ++i)
512 const CoeffType *
const a =
513 this->_species_curve_fits[species]->coefficients(i);
516 StateType(a[0]/cache.
T3 - a[7]/cache.
T2 -
517 a[1]*cache.
lnT/cache.
T2 - a[2]/cache.
T -
518 a[3]/raw_type(2) - a[4]*cache.
T/raw_type(3) -
519 a[5]*cache.
T2/raw_type(4) -
520 a[6]*cache.
T3/raw_type(5)),
528 template<
typename CoeffType>
529 template<
typename StateType,
typename VectorStateType>
532 has_size<VectorStateType>::value,
void
535 VectorStateType& dh_RT_minus_s_R_dT )
const
539 for(
unsigned int s = 0; s < _species_curve_fits.size(); s++ )
541 dh_RT_minus_s_R_dT[s] = this->dh_RT_minus_s_R_dT(cache,s);
550 template<
typename CoeffType>
551 template<
typename StateType>
555 return this->
cp(cache,species) - _chem_mixture.R(species);
558 template<
typename CoeffType>
559 template<
typename StateType,
typename VectorStateType>
562 has_size<VectorStateType>::value, StateType
565 const VectorStateType& mass_fractions )
const
567 return this->
cp(cache,mass_fractions) - _chem_mixture.R(mass_fractions);
570 template<
typename CoeffType>
574 return _chem_mixture;
579 #endif //ANTIOCH_CEA_THERMO_H
Cache(const StateType &T_in, const StateType &T2_in, const StateType &T3_in, const StateType &T4_in, const StateType &lnT_in)
Antioch::enable_if_c< is_eigen< T >::value, typename value_type< T >::type >::type max(const T &in)
#define antioch_assert(asserted)
std::vector< CEACurveFit< CoeffType > * > _species_curve_fits
#define antioch_assert_equal_to(expr1, expr2)
#define antioch_assert_greater(expr1, expr2)
const ChemicalMixture< CoeffType > & _chem_mixture
StateType cp_over_R(const Cache< StateType > &cache, unsigned int species) const
virtual ~CEAThermodynamics()
Destructor.
#define antioch_assert_less(expr1, expr2)
#define antioch_assert_less_equal(expr1, expr2)
Scalar cp(Scalar T, Scalar a0, Scalar a1, Scalar a2, Scalar a3, Scalar a4, Scalar a5, Scalar a6)
Antioch::enable_if_c< is_eigen< T >::value, typename value_type< T >::type >::type min(const T &in)
StateType cv(const Cache< StateType > &cache, unsigned int species) const
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > constant_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex, const Scalar &value)
Cache(const StateType &T_in)
enable_if_c< is_eigen< T1 >::value &&is_eigen< T2 >::value, typename state_type< T1 >::type >::type if_else(const Condition &condition, const T1 &if_true, const T2 &if_false)
StateType dh_RT_minus_s_R_dT(const Cache< StateType > &cache, unsigned int species) const
We currently need different specializations for scalar vs vector inputs here.
This class only differs from NASA9CurveFit in the construction.
void add_curve_fit(const std::string &species_name, const std::vector< CoeffType > &coeffs, const std::vector< CoeffType > &)
static const std::string & thermo_data()
const ChemicalMixture< CoeffType > & chemical_mixture() const
#define antioch_deprecated()
StateType h(const Cache< StateType > &cache, unsigned int species) const
std::vector< CoeffType > _cp_at_200p1
CEAThermodynamics()
Default constructor.
void add_curve_fit(const std::string &species_name, const std::vector< CoeffType > &coeffs)
Class storing chemical mixture properties.
The parameters are reduced parameters.
StateType h_RT_minus_s_R(const Cache< StateType > &cache, unsigned int species) const
We currently need different specializations for scalar vs vector inputs here.
void read_cea_mixture_data_ascii(CEAThermoMixture< NumericType > &thermo, const std::string &filename)
bool check() const
Checks that curve fits have been specified for all species in the mixture.
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > zero_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex)
StateType h_over_RT(const Cache< StateType > &cache, unsigned int species) const
StateType s_over_R(const Cache< StateType > &cache, unsigned int species) const
StateType cp(const Cache< StateType > &cache, unsigned int species) const
We currently need different specializations for scalar vs vector inputs here.