28 #ifndef ANTIOCH_STAT_MECH_THERMO_H
29 #define ANTIOCH_STAT_MECH_THERMO_H
46 template<
typename CoeffType=
double>
47 class StatMechThermodynamics
65 CoeffType
cv_trans(
const unsigned int species )
const;
88 CoeffType
cv_rot(
const unsigned int species )
const;
107 CoeffType
cv_tr (
const unsigned int species)
const;
113 CoeffType
cv_tr_over_R (
const unsigned int species)
const;
120 template<
typename VectorStateType>
121 typename enable_if_c<
122 has_size<VectorStateType>::value,
125 cv_tr (
const VectorStateType& mass_fractions)
const;
131 template<
typename StateType>
132 StateType
cv_vib (
const unsigned int species,
const StateType& Tv)
const;
138 template<
typename StateType>
139 StateType
cv_vib_over_R (
const unsigned int species,
const StateType& Tv)
const;
145 template<
typename VectorStateType>
146 typename enable_if_c<
147 has_size<VectorStateType>::value,
151 const VectorStateType& mass_fractions)
const;
156 template<
typename StateType>
157 StateType
cv_el (
const unsigned int species,
const StateType& Te)
const;
162 template<
typename VectorStateType>
163 typename enable_if_c<
164 has_size<VectorStateType>::value,
168 const VectorStateType& mass_fractions)
const;
174 template<
typename StateType>
175 StateType
cv_ve (
const unsigned int species,
const StateType& Tv)
const;
181 template<
typename VectorStateType>
182 typename enable_if_c<
183 has_size<VectorStateType>::value,
187 const VectorStateType& mass_fractions)
const;
195 template<
typename StateType>
196 StateType
cv (
const unsigned int species,
const StateType& T,
const StateType& Tv)
const;
204 template<
typename VectorStateType>
205 typename enable_if_c<
206 has_size<VectorStateType>::value,
211 const VectorStateType& mass_fractions)
const;
216 template<
typename VectorStateType>
217 typename enable_if_c<
218 has_size<VectorStateType>::value,
223 const VectorStateType& mass_fractions)
const;
228 template<
typename StateType>
229 StateType
h_tot (
const unsigned int species,
const StateType& T,
const StateType& Tv)
const;
235 template<
typename StateType>
236 StateType
h_tot (
const unsigned int species,
const StateType& T)
const;
241 template<
typename VectorStateType>
242 typename enable_if_c<
243 has_size<VectorStateType>::value,
248 const VectorStateType& mass_fractions)
const;
254 template<
typename VectorStateType>
255 typename enable_if_c<
256 has_size<VectorStateType>::value,
260 const VectorStateType& mass_fractions)
const;
265 template<
typename StateType>
266 StateType
e_tot (
const unsigned int species,
const StateType& T,
const StateType& Tv)
const;
271 template<
typename VectorStateType>
272 typename enable_if_c<
273 has_size<VectorStateType>::value,
278 const VectorStateType& mass_fractions)
const;
284 template<
typename StateType>
285 StateType
e_tot (
const unsigned int species,
const StateType& T)
const;
291 template<
typename VectorStateType>
292 typename enable_if_c<
293 has_size<VectorStateType>::value,
297 const VectorStateType& mass_fractions)
const;
302 template<
typename StateType>
303 StateType
e_tr (
const unsigned int species,
const StateType& T)
const;
308 template<
typename VectorStateType>
309 typename enable_if_c<
310 has_size<VectorStateType>::value,
314 const VectorStateType& mass_fractions)
const;
319 template<
typename StateType>
320 StateType
e_vib (
const unsigned int species,
const StateType& Tv)
const;
325 template<
typename VectorStateType>
326 typename enable_if_c<
327 has_size<VectorStateType>::value,
331 const VectorStateType& mass_fractions)
const;
336 template<
typename StateType>
337 StateType
e_el (
const unsigned int species,
const StateType& Te)
const;
342 template<
typename VectorStateType>
343 typename enable_if_c<
344 has_size<VectorStateType>::value,
348 const VectorStateType& mass_fractions)
const;
353 template<
typename StateType>
354 StateType
e_ve (
const unsigned int species,
const StateType& Tv)
const;
359 template<
typename VectorStateType>
360 typename enable_if_c<
361 has_size<VectorStateType>::value,
365 const VectorStateType& mass_fractions)
const;
382 template<
typename VectorStateType>
384 const VectorStateType& mass_fractions,
391 CoeffType
e_0 (
const unsigned int species)
const;
396 template<
typename VectorStateType>
397 typename enable_if_c<
398 has_size<VectorStateType>::value,
401 e_0 (
const VectorStateType& mass_fractions)
const;
407 template<
typename VectorStateType>
408 typename enable_if_c<
409 has_size<VectorStateType>::value,
413 const VectorStateType& mass_fractions,
420 template<
typename VectorStateType>
421 typename enable_if_c<
422 has_size<VectorStateType>::value,
426 const VectorStateType& mass_fractions,
433 template<
typename VectorStateType>
434 typename enable_if_c<
435 has_size<VectorStateType>::value,
439 const VectorStateType& mass_fractions,
446 template<
typename VectorStateType>
447 typename enable_if_c<
448 has_size<VectorStateType>::value,
452 const VectorStateType& mass_fractions,
460 template<
typename VectorStateType>
461 typename enable_if_c<
462 has_size<VectorStateType>::value,
467 const VectorStateType& mass_fractions,
474 template<
typename VectorStateType>
475 typename enable_if_c<
476 has_size<VectorStateType>::value,
481 const VectorStateType& mass_fractions)
const;
497 template<
typename CoeffType>
500 : _chem_mixture(chem_mixture)
505 template<
typename CoeffType>
512 template<
typename CoeffType>
516 return CoeffType(1.5)*_chem_mixture.R(species);
519 template<
typename CoeffType>
523 return CoeffType(1.5);
526 template<
typename CoeffType>
532 return max(this->cv_tr(species) - this->cv_trans(species), CoeffType(0) );
535 template<
typename CoeffType>
541 return max(this->cv_tr_over_R(species) - this->cv_trans_over_R(species), CoeffType(0) );
544 template<
typename CoeffType>
548 return _chem_mixture.R(species)*(_chem_mixture.chemical_species()[species])->n_tr_dofs();
551 template<
typename CoeffType>
555 return (_chem_mixture.chemical_species()[species])->n_tr_dofs();
558 template<
typename CoeffType>
559 template<
typename VectorStateType>
568 cv_tr = mass_fractions[0]*this->cv_tr(0);
570 for(
unsigned int s = 1; s < _chem_mixture.n_species(); s++ )
572 cv_tr += mass_fractions[s]*this->cv_tr(s);
578 template<
typename CoeffType>
579 template<
typename StateType>
582 const StateType& Tv)
const
584 return this->cv_vib_over_R(species,Tv) * (_chem_mixture.chemical_species()[species])->gas_constant();
587 template<
typename CoeffType>
588 template<
typename StateType>
591 const StateType& Tv)
const
597 const std::vector<CoeffType>& theta_v = chem_species.
theta_v();
598 const std::vector<unsigned int>& ndg_v = chem_species.
ndg_v();
606 return cv_vib_over_R;
608 for (
unsigned int level=0; level<ndg_v.size(); level++)
611 const StateType expval = exp(theta_v[level]/Tv);
612 const StateType expvalminusone = expval - raw_type(1);
614 cv_vib_over_R += (
static_cast<CoeffType
>(ndg_v[level])*
615 theta_v[level]*theta_v[level]*expval/(expvalminusone*expvalminusone)/(Tv*Tv));
618 return cv_vib_over_R;
621 template<
typename CoeffType>
622 template<
typename VectorStateType>
625 has_size<VectorStateType>::value,
629 const VectorStateType& mass_fractions)
const
632 cv_vib = mass_fractions[0]*this->cv_vib(0, Tv);
634 for(
unsigned int s = 1; s < _chem_mixture.n_species(); s++ )
636 cv_vib += mass_fractions[s]*this->cv_vib(s, Tv);
642 template<
typename CoeffType>
643 template<
typename StateType>
646 const StateType& Te)
const
652 const std::vector<CoeffType>& theta_e = chem_species.
theta_e();
653 const std::vector<unsigned int>& ndg_e = chem_species.
ndg_e();
661 if (theta_e.size() < 2)
return cv_el;
664 const raw_type one =
static_cast<raw_type
>(1);
666 const StateType Teinv = one/Te;
667 const StateType Te2inv = Teinv*Teinv;
673 for (
unsigned int level=0; level<theta_e.size(); level++)
676 expval = exp (-theta_e[level] * Teinv),
677 den_l =
static_cast<raw_type
>(ndg_e[level])*expval,
678 num_l = den_l*theta_e[level],
679 dden_l = num_l*Te2inv,
680 dnum_l = dden_l*theta_e[level];
689 const StateType invden = one/den;
691 cv_el = chem_species.
gas_constant()*(dnum - num*dden*invden) * invden;
696 template<
typename CoeffType>
697 template<
typename VectorStateType>
700 has_size<VectorStateType>::value,
704 const VectorStateType& mass_fractions)
const
707 cv_el = mass_fractions[0]*this->cv_el(0, Te);
709 for(
unsigned int s = 1; s < _chem_mixture.n_species(); s++ )
711 cv_el += mass_fractions[s]*this->cv_el(s, Te);
717 template<
typename CoeffType>
718 template<
typename StateType>
721 const StateType& Tv)
const
723 return (this->cv_vib(species, Tv) + this->cv_el(species, Tv));
726 template<
typename CoeffType>
727 template<
typename VectorStateType>
730 has_size<VectorStateType>::value,
734 const VectorStateType& mass_fractions)
const
737 return (this->cv_vib(Tv, mass_fractions) + this->cv_el(Tv, mass_fractions));
740 template<
typename CoeffType>
741 template<
typename StateType>
745 const StateType& Tv)
const
747 return (this->cv_tr(species) + this->cv_ve(species, Tv));
750 template<
typename CoeffType>
751 template<
typename VectorStateType>
754 has_size<VectorStateType>::value,
759 const VectorStateType& mass_fractions)
const
761 return (this->cv_tr(mass_fractions) + this->cv_ve(Tv, mass_fractions));
764 template<
typename CoeffType>
765 template<
typename VectorStateType>
768 has_size<VectorStateType>::value,
773 const VectorStateType& mass_fractions)
const
775 return (this->cv(T,Tv,mass_fractions) + this->_chem_mixture.R(mass_fractions));
778 template<
typename CoeffType>
779 template<
typename StateType>
783 const StateType& Tv)
const
786 return (this->e_tot(species, T, Tv) + chem_species.
gas_constant()*T);
790 template<
typename CoeffType>
791 template<
typename StateType>
794 const StateType& T)
const
796 return this->h_tot(species, T, T);
799 template<
typename CoeffType>
800 template<
typename VectorStateType>
803 has_size<VectorStateType>::value,
808 const VectorStateType& mass_fractions)
const
811 h_tot = mass_fractions[0]*this->h_tot(0, T, Tv);
813 for(
unsigned int s = 1; s < _chem_mixture.n_species(); s++ )
815 h_tot += mass_fractions[s]*this->h_tot(s, T, Tv);
821 template<
typename CoeffType>
822 template<
typename VectorStateType>
825 has_size<VectorStateType>::value,
829 const VectorStateType& mass_fractions)
const
831 return this->h_tot(T, T, mass_fractions);
834 template<
typename CoeffType>
835 template<
typename StateType>
839 const StateType& Tv)
const
841 return (this->e_tr(species, T) + this->e_ve(species, Tv) + this->e_0(species));
845 template<
typename CoeffType>
846 template<
typename VectorStateType>
849 has_size<VectorStateType>::value,
854 const VectorStateType& mass_fractions)
const
856 return (this->e_tr(T, mass_fractions) + this->e_ve(Tv, mass_fractions) + this->e_0(mass_fractions));
859 template<
typename CoeffType>
860 template<
typename StateType>
863 const StateType& T)
const
865 return this->e_tot(species, T, T);
868 template<
typename CoeffType>
869 template<
typename VectorStateType>
872 has_size<VectorStateType>::value,
876 const VectorStateType& mass_fractions)
const
878 return this->e_tot(T, T, mass_fractions);
881 template<
typename CoeffType>
882 template<
typename StateType>
885 const StateType& T)
const
887 return this->cv_tr(species)*T;
890 template<
typename CoeffType>
891 template<
typename VectorStateType>
894 has_size<VectorStateType>::value,
898 const VectorStateType& mass_fractions)
const
901 e_tr = mass_fractions[0]*this->e_tr(0, T);
903 for(
unsigned int s = 1; s < _chem_mixture.n_species(); s++ )
905 e_tr += mass_fractions[s]*this->e_tr(s, T);
911 template<
typename CoeffType>
912 template<
typename StateType>
915 const StateType& Tv)
const
921 const std::vector<CoeffType>& theta_v = chem_species.
theta_v();
922 const std::vector<unsigned int>& ndg_v = chem_species.
ndg_v();
926 StateType e_vib = 0.0;
928 if (theta_v.empty())
return e_vib;
930 for (
unsigned int level=0; level<ndg_v.size(); level++)
931 e_vib += ndg_v[level]*chem_species.
gas_constant()*theta_v[level]/(exp(theta_v[level]/Tv) - 1.);
936 template<
typename CoeffType>
937 template<
typename VectorStateType>
940 has_size<VectorStateType>::value,
944 const VectorStateType& mass_fractions)
const
947 e_vib = mass_fractions[0]*this->e_vib(0, Tv);
949 for(
unsigned int s = 1; s < _chem_mixture.n_species(); s++ )
951 e_vib += mass_fractions[s]*this->e_vib(s, Tv);
957 template<
typename CoeffType>
958 template<
typename StateType>
961 const StateType& Te)
const
967 const std::vector<CoeffType>& theta_e = chem_species.
theta_e();
968 const std::vector<unsigned int>& ndg_e = chem_species.
ndg_e();
974 if (theta_e.size() < 2)
return e_el;
978 for (
unsigned int level=0; level<theta_e.size(); level++)
980 const StateType expval = exp (-theta_e[level] / Te);
981 num +=
static_cast<StateType
>(ndg_e[level])*theta_e[level]*expval;
982 den +=
static_cast<StateType
>(ndg_e[level])*expval;
988 template<
typename CoeffType>
989 template<
typename VectorStateType>
992 has_size<VectorStateType>::value,
996 const VectorStateType& mass_fractions)
const
999 e_el = mass_fractions[0]*this->e_el(0, Te);
1001 for(
unsigned int s = 1; s < _chem_mixture.n_species(); s++ )
1003 e_el += mass_fractions[s]*this->e_el(s, Te);
1009 template<
typename CoeffType>
1010 template<
typename StateType>
1013 const StateType& Tv)
const
1015 return (this->e_vib(species,Tv) + this->e_el(species,Tv));
1018 template<
typename CoeffType>
1019 template<
typename VectorStateType>
1022 has_size<VectorStateType>::value,
1026 const VectorStateType& mass_fractions)
const
1028 return (this->e_vib(Tv,mass_fractions) + this->e_el(Tv,mass_fractions));
1031 template<
typename CoeffType>
1038 template<
typename CoeffType>
1039 template<
typename VectorStateType>
1042 const VectorStateType& mass_fractions,
1046 e_ve = this->e_ve (Tv, mass_fractions);
1047 cv_ve = this->cv_ve(Tv, mass_fractions);
1050 template<
typename CoeffType>
1058 template<
typename CoeffType>
1059 template<
typename VectorStateType>
1062 has_size<VectorStateType>::value,
1068 e_0 = mass_fractions[0]*this->e_0(0);
1070 for(
unsigned int s = 1; s < _chem_mixture.n_species(); s++ )
1072 e_0 += mass_fractions[s]*this->e_0(s);
1078 template<
typename CoeffType>
1079 template<
typename VectorStateType>
1082 has_size<VectorStateType>::value,
1087 const VectorStateType& mass_fractions,
1093 template<
typename CoeffType>
1094 template<
typename VectorStateType>
1097 has_size<VectorStateType>::value,
1101 const VectorStateType& mass_fractions,
1114 Cv_tr = this->cv_tr(mass_fractions);
1118 E_0 = this->e_0(mass_fractions);
1124 T = (e_tot - E_0) / Cv_tr;
1125 T =
min(
max(T,StateType(10.)),StateType(20000.));
1132 T =
max(T, StateType(10.));
1133 T =
min(T, StateType(2.e4));
1138 const unsigned int max_iterations = 100;
1140 const CoeffType dT_reltol= std::numeric_limits<CoeffType>::epsilon() * 100;
1144 for (
unsigned int iter = 0;
1145 abs(delta_T/T) > dT_reltol &&
1149 if (iter == max_iterations)
1155 Re = 0., dRevdT = 0.;
1157 this->e_and_cv_ve(T, mass_fractions, Re, dRevdT);
1158 Re += this->e_tr(T, mass_fractions) + E_0 - e_tot;
1161 delta_T = -Re / dRevdT;
1168 template<
typename CoeffType>
1169 template<
typename VectorStateType>
1172 has_size<VectorStateType>::value,
1177 const VectorStateType& mass_fractions,
1183 template<
typename CoeffType>
1184 template<
typename VectorStateType>
1187 has_size<VectorStateType>::value,
1192 const VectorStateType& mass_fractions,
1198 template<
typename CoeffType>
1199 template<
typename VectorStateType>
1202 has_size<VectorStateType>::value,
1208 const VectorStateType& mass_fractions,
1215 template<
typename CoeffType>
1216 template<
typename VectorStateType>
1219 has_size<VectorStateType>::value,
1225 const VectorStateType& mass_fractions)
const
1232 #endif // ANTIOCH_STAT_MECH_THERMO_H
const ChemicalMixture< CoeffType > & _chem_mixture
Antioch::enable_if_c< is_eigen< T >::value, typename value_type< T >::type >::type max(const T &in)
enable_if_c< has_size< VectorStateType >::value, typename Antioch::value_type< VectorStateType >::type >::type T_from_e_tr(const typename Antioch::value_type< VectorStateType >::type &e_tr, const VectorStateType &mass_fractions, typename Antioch::value_type< VectorStateType >::type T=-1) const
CoeffType e_ve_min() const
#define antioch_not_implemented()
CoeffType formation_enthalpy() const
Returns formation enthalpy in units of [J/kg].
CoeffType cv_tr(const unsigned int species) const
enable_if_c< has_size< VectorStateType >::value, typename Antioch::value_type< VectorStateType >::type >::type cp(const typename Antioch::value_type< VectorStateType >::type &T, const typename Antioch::value_type< VectorStateType >::type &Tv, const VectorStateType &mass_fractions) const
#define antioch_assert_equal_to(expr1, expr2)
enable_if_c< has_size< VectorStateType >::value, typename Antioch::value_type< VectorStateType >::type >::type s(const typename Antioch::value_type< VectorStateType >::type &T, const typename Antioch::value_type< VectorStateType >::type &p, const VectorStateType &mass_fractions) const
CoeffType cv_tr_over_R(const unsigned int species) const
A class representing failed Newton convergence in T/Tv inversion.
enable_if_c< has_size< VectorStateType >::value, typename Antioch::value_type< VectorStateType >::type >::type T_from_e_tot(const typename Antioch::value_type< VectorStateType >::type &e_tot, const VectorStateType &mass_fractions, typename Antioch::value_type< VectorStateType >::type T=-1) const
StateType h_tot(const unsigned int species, const StateType &T, const StateType &Tv) const
StateType e_ve(const unsigned int species, const StateType &Tv) const
StateType e_vib(const unsigned int species, const StateType &Tv) const
Antioch::enable_if_c< is_eigen< T >::value, typename value_type< T >::type >::type min(const T &in)
StateType cv_el(const unsigned int species, const StateType &Te) const
CoeffType cv_rot_over_R(const unsigned int species) const
StatMechThermodynamics()
Default constructor.
StateType e_el(const unsigned int species, const StateType &Te) const
enable_if_c< has_size< VectorStateType >::value, typename Antioch::value_type< VectorStateType >::type >::type T_from_h_tot_Tv(const typename Antioch::value_type< VectorStateType >::type &h_tot, const typename Antioch::value_type< VectorStateType >::type &Tv, const VectorStateType &mass_fractions, typename Antioch::value_type< VectorStateType >::type T=-1) const
const std::vector< CoeffType > & theta_v() const
Characteristic vibrational temperature [K].
const std::vector< unsigned int > & ndg_v() const
Degeneracies for each vibrational mode.
max(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a, const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &b) ANTIOCH_AUTOFUNC(_Matrix< _Scalar ANTIOCH_COMMA _Rows ANTIOCH_COMMA _Cols ANTIOCH_COMMA _Options ANTIOCH_COMMA _MaxRows ANTIOCH_COMMA _MaxCols >
CoeffType cv_rot(const unsigned int species) const
Class to encapsulate data for each chemical species.
virtual ~StatMechThermodynamics()
Destructor.
enable_if_c< has_size< VectorStateType >::value, typename Antioch::value_type< VectorStateType >::type >::type Tv_from_e_ve(const typename Antioch::value_type< VectorStateType >::type &e_ve, const VectorStateType &mass_fractions, typename Antioch::value_type< VectorStateType >::type Tv=-1) const
StateType e_tot(const unsigned int species, const StateType &T, const StateType &Tv) const
StateType e_tr(const unsigned int species, const StateType &T) const
StateType cv(const unsigned int species, const StateType &T, const StateType &Tv) const
StateType cv_ve(const unsigned int species, const StateType &Tv) const
CoeffType cv_trans_over_R(const unsigned int species) const
const std::vector< unsigned int > & ndg_e() const
Degeneracies for each electronic modes.
CoeffType cv_trans(const unsigned int species) const
StateType cv_vib(const unsigned int species, const StateType &Tv) const
CoeffType gas_constant() const
Returns the species ideal gas constant in [J/kg-K].
Class storing chemical mixture properties.
The parameters are reduced parameters.
typename _Scalar int _Rows int _Cols int _Options int _MaxRows int _MaxCols inline min(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a, const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &b) ANTIOCH_AUTOFUNC(_Matrix< _Scalar ANTIOCH_COMMA _Rows ANTIOCH_COMMA _Cols ANTIOCH_COMMA _Options ANTIOCH_COMMA _MaxRows ANTIOCH_COMMA _MaxCols >
CoeffType e_0(const unsigned int species) const
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > zero_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex)
enable_if_c< has_size< VectorStateType >::value, typename Antioch::value_type< VectorStateType >::type >::type T_from_h_tot(const typename Antioch::value_type< VectorStateType >::type &h_tot, const VectorStateType &mass_fractions, typename Antioch::value_type< VectorStateType >::type T=-1) const
void e_and_cv_ve(const typename Antioch::value_type< VectorStateType >::type &Tv, const VectorStateType &mass_fractions, typename Antioch::value_type< VectorStateType >::type &e_ve, typename Antioch::value_type< VectorStateType >::type &cv_ve) const
const std::vector< CoeffType > & theta_e() const
Characteristic electronic excitation temperatures [K].
StateType cv_vib_over_R(const unsigned int species, const StateType &Tv) const