27 #ifndef ANTIOCH_KINETICS_EVALUATOR_H
28 #define ANTIOCH_KINETICS_EVALUATOR_H
41 template<
typename CoeffType>
44 template<
typename CoeffType>
52 template<
typename CoeffType=
double,
typename StateType=CoeffType>
63 const StateType& example );
71 template <
typename VectorStateType,
typename KC>
73 const VectorStateType& molar_densities,
74 const VectorStateType& h_RT_minus_s_R,
75 VectorStateType& mass_sources );
80 template <
typename VectorStateType,
typename KC>
82 const VectorStateType& molar_densities,
83 const VectorStateType& h_RT_minus_s_R,
84 const VectorStateType& dh_RT_minus_s_R_dT,
85 VectorStateType& mass_sources,
86 VectorStateType& dmass_dT,
87 std::vector<VectorStateType>& dmass_drho_s );
91 template <
typename VectorStateType,
typename KC>
93 const VectorStateType& molar_densities,
94 const VectorStateType& h_RT_minus_s_R,
95 VectorStateType& mole_sources );
100 template <
typename VectorStateType,
typename KC>
102 const VectorStateType& molar_densities,
103 const VectorStateType& h_RT_minus_s_R,
104 const VectorStateType& dh_RT_minus_s_R_dT,
105 VectorStateType& mole_sources,
106 VectorStateType& dmole_dT,
107 std::vector<VectorStateType>& dmole_dX_s );
127 template<
typename CoeffType,
typename StateType>
131 return _reaction_set;
134 template<
typename CoeffType,
typename StateType>
138 return _chem_mixture.n_species();
141 template<
typename CoeffType,
typename StateType>
145 return _reaction_set.n_reactions();
149 template<
typename CoeffType,
typename StateType>
153 const StateType& example )
154 : _reaction_set( reaction_set ),
156 _net_reaction_rates( reaction_set.
n_reactions(), example ),
157 _dnet_rate_dT( reaction_set.
n_reactions(), example ),
161 for(
unsigned int r = 0; r < this->n_reactions(); r++ )
163 _dnet_rate_dX_s[r].resize( reaction_set.
n_species(), example );
170 template<
typename CoeffType,
typename StateType>
177 template<
typename CoeffType,
typename StateType>
178 template<
typename VectorStateType,
typename KC>
181 const VectorStateType& molar_densities,
182 const VectorStateType& h_RT_minus_s_R,
183 VectorStateType& mole_sources )
197 kinetics_conditions(conditions);
199 this->_reaction_set.compute_reaction_rates( kinetics_conditions, molar_densities,
200 h_RT_minus_s_R, _net_reaction_rates );
203 for (
unsigned int rxn = 0; rxn < this->n_reactions(); rxn++)
206 const StateType rate = _net_reaction_rates[rxn];
209 for (
unsigned int r = 0; r < reaction.
n_reactants(); r++)
214 mole_sources[r_id] -= (
static_cast<CoeffType
>(r_stoich)*rate);
218 for (
unsigned int p=0; p < reaction.
n_products(); p++)
220 const unsigned int p_id = reaction.
product_id(p);
223 mole_sources[p_id] += (
static_cast<CoeffType
>(p_stoich)*rate);
231 template<
typename CoeffType,
typename StateType>
232 template<
typename VectorStateType,
typename KC>
235 const VectorStateType& molar_densities,
236 const VectorStateType& h_RT_minus_s_R,
237 VectorStateType& mass_sources )
240 this->compute_mole_sources( conditions, molar_densities, h_RT_minus_s_R, mass_sources );
243 for (
unsigned int s=0; s < this->n_species(); s++)
245 mass_sources[s] *= _chem_mixture.M(s);
251 template<
typename CoeffType,
typename StateType>
252 template<
typename VectorStateType,
typename KC>
255 const VectorStateType& molar_densities,
256 const VectorStateType& h_RT_minus_s_R,
257 const VectorStateType& dh_RT_minus_s_R_dT,
258 VectorStateType& mole_sources,
259 VectorStateType& dmole_dT,
260 std::vector<VectorStateType>& dmole_dX_s )
272 for (
unsigned int s=0; s < this->n_species(); s++)
284 for (
unsigned int s=0; s < this->n_species(); s++)
289 for (
unsigned int rxn=0; rxn < this->n_reactions(); rxn++)
296 kinetics_conditions(conditions);
298 this->_reaction_set.compute_reaction_rates_and_derivs( kinetics_conditions, molar_densities,
299 h_RT_minus_s_R, dh_RT_minus_s_R_dT,
304 for (
unsigned int rxn = 0; rxn < this->n_reactions(); rxn++)
310 const StateType rate = _net_reaction_rates[rxn];
311 const StateType drate_dT = _dnet_rate_dT[rxn];
312 const VectorStateType drate_dX_s = _dnet_rate_dX_s[rxn];
315 for (
unsigned int r = 0; r < reaction.
n_reactants(); r++)
320 mole_sources[r_id] -= (
static_cast<CoeffType
>(r_stoich)*rate);
323 dmole_dT[r_id] -= (
static_cast<CoeffType
>(r_stoich)*drate_dT);
326 for (
unsigned int s=0; s < this->n_species(); s++)
328 dmole_dX_s[r_id][s] -= (
static_cast<CoeffType
>(r_stoich)*drate_dX_s[s]);
333 for (
unsigned int p=0; p < reaction.
n_products(); p++)
335 const unsigned int p_id = reaction.
product_id(p);
338 mole_sources[p_id] += (
static_cast<CoeffType
>(p_stoich)*rate);
341 dmole_dT[p_id] += (
static_cast<CoeffType
>(p_stoich)*drate_dT);
344 for (
unsigned int s=0; s < this->n_species(); s++)
346 dmole_dX_s[p_id][s] += (
static_cast<CoeffType
>(p_stoich)*drate_dX_s[s]);
355 template<
typename CoeffType,
typename StateType>
356 template <
typename VectorStateType,
typename KC>
359 const VectorStateType& molar_densities,
360 const VectorStateType& h_RT_minus_s_R,
361 const VectorStateType& dh_RT_minus_s_R_dT,
362 VectorStateType& mass_sources,
363 VectorStateType& dmass_dT,
364 std::vector<VectorStateType>& dmass_drho_s )
367 this->compute_mole_sources_and_derivs( conditions, molar_densities, h_RT_minus_s_R, dh_RT_minus_s_R_dT,
368 mass_sources, dmass_dT, dmass_drho_s );
371 for (
unsigned int s=0; s < this->n_species(); s++)
373 mass_sources[s] *= _chem_mixture.M(s);
374 dmass_dT[s] *= _chem_mixture.M(s);
376 for (
unsigned int t=0; t < this->n_species(); t++)
378 dmass_drho_s[s][t] *= _chem_mixture.M(s)/_chem_mixture.M(t);
388 #endif // ANTIOCH_KINETICS_EVALUATOR_H
unsigned int n_reactions() const
const ChemicalMixture< CoeffType > & _chem_mixture
KineticsEvaluator(const ReactionSet< CoeffType > &reaction_set, const StateType &example)
Constructor. Requires a reaction set to be evaluated later,.
This class encapsulates all the reaction mechanisms considered in a chemical nonequilibrium simulatio...
#define antioch_assert_equal_to(expr1, expr2)
void compute_mole_sources_and_derivs(const KC &conditions, const VectorStateType &molar_densities, const VectorStateType &h_RT_minus_s_R, const VectorStateType &dh_RT_minus_s_R_dT, VectorStateType &mole_sources, VectorStateType &dmole_dT, std::vector< VectorStateType > &dmole_dX_s)
Compute species production/destruction rate derivatives.
void compute_mass_sources(const KC &conditions, const VectorStateType &molar_densities, const VectorStateType &h_RT_minus_s_R, VectorStateType &mass_sources)
Compute species production/destruction rates per unit volume.
void compute_mole_sources(const KC &conditions, const VectorStateType &molar_densities, const VectorStateType &h_RT_minus_s_R, VectorStateType &mole_sources)
Compute species molar production/destruction rates per unit volume.
unsigned int n_species() const
std::vector< StateType > _dnet_rate_dT
unsigned int product_stoichiometric_coefficient(const unsigned int p) const
unsigned int n_species() const
unsigned int reactant_id(const unsigned int r) const
std::vector< StateType > _net_reaction_rates
const ReactionSet< CoeffType > & reaction_set() const
unsigned int n_reactions() const
const ReactionSet< CoeffType > & _reaction_set
const ChemicalMixture< CoeffType > & chemical_mixture() const
unsigned int n_products() const
void set_zero(_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a)
Class to handle computing mass source terms for a given ReactionSet.
std::vector< std::vector< StateType > > _dnet_rate_dX_s
Class storing chemical mixture properties.
The parameters are reduced parameters.
unsigned int product_id(const unsigned int p) const
void compute_mass_sources_and_derivs(const KC &conditions, const VectorStateType &molar_densities, const VectorStateType &h_RT_minus_s_R, const VectorStateType &dh_RT_minus_s_R_dT, VectorStateType &mass_sources, VectorStateType &dmass_dT, std::vector< VectorStateType > &dmass_drho_s)
Compute species production/destruction rate derivatives.
unsigned int reactant_stoichiometric_coefficient(const unsigned int r) const
unsigned int n_reactants() const