antioch-0.4.0
falloff_threebody_reaction.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // Antioch - A Gas Dynamics Thermochemistry Library
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk,
7 // Sylvain Plessis, Roy H. Stonger
8 //
9 // Copyright (C) 2013 The PECOS Development Team
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the Version 2.1 GNU Lesser General
13 // Public License as published by the Free Software Foundation.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
23 // Boston, MA 02110-1301 USA
24 //
25 //-----------------------------------------------------------------------el-
26 
27 #ifndef ANTIOCH_FALLOFF_THREE_BODY_REACTION_H
28 #define ANTIOCH_FALLOFF_THREE_BODY_REACTION_H
29 
30 // Antioch
32 #include "antioch/cmath_shims.h"
34 #include "antioch/reaction.h"
36 #include "antioch/troe_falloff.h"
37 
38 //C++
39 #include <string>
40 #include <vector>
41 #include <iostream>
42 
43 namespace Antioch
44 {
101  template<typename CoeffType=double, typename FalloffType = LindemannFalloff<CoeffType> >
102  class FalloffThreeBodyReaction: public Reaction<CoeffType>
103  {
104  public:
105 
107  FalloffThreeBodyReaction( const unsigned int n_species,
108  const std::string &equation,
109  const bool &reversible = true,
112 
114 
116  template <typename StateType, typename VectorStateType>
117  StateType compute_forward_rate_coefficient( const VectorStateType& molar_densities,
118  const KineticsConditions<StateType,VectorStateType>& conditions ) const;
119 
121  template <typename StateType, typename VectorStateType>
122  void compute_forward_rate_coefficient_and_derivatives( const VectorStateType& molar_densities,
124  StateType& kfwd,
125  StateType& dkfwd_dT,
126  VectorStateType& dkfkwd_dX) const;
127 
128 
130  const FalloffType &F() const;
131 
133  FalloffType &F();
134 
135  protected:
136 
137  FalloffType _F;
138 
139  };
140 
141  /* ------------------------- Inline Functions -------------------------*/
142  template<typename CoeffType, typename FalloffType>
143  inline
145  const std::string &equation,
146  const bool &reversible,
147  const ReactionType::ReactionType &falloffType,
149  :Reaction<CoeffType>(n_species,equation,reversible,falloffType,kin),
150  _F(n_species)
151 
152  {
153  Reaction<CoeffType>::_efficiencies.resize(n_species);
155  }
156 
157 
158  template<typename CoeffType, typename FalloffType>
159  inline
161  {
162  return;
163  }
164 
165  template<typename CoeffType, typename FalloffType>
166  inline
168  {
169  return _F;
170  }
171 
172  template<typename CoeffType, typename FalloffType>
173  inline
175  {
176  return _F;
177  }
178 
179  template<typename CoeffType, typename FalloffType>
180  template<typename StateType, typename VectorStateType>
181  inline
183  const KineticsConditions<StateType,VectorStateType>& conditions ) const
184  {
185 //falloff is k(T,[M]) = k0*[M]/(1 + [M]*k0/kinf) * F = k0 * ([M]^-1 + k0 * kinf^-1)^-1 * F
186  StateType M = Antioch::zero_clone(conditions.T());
187  for(unsigned int s = 0; s < molar_densities.size(); s++)
188  {
189  M += this->efficiency(s) * molar_densities[s];
190  }
191 
192  const StateType k0 = (*this->_forward_rate[0])(conditions);
193  const StateType kinf = (*this->_forward_rate[1])(conditions);
194 
195  return k0 / (ant_pow(M,-1) + k0 / kinf) * _F(conditions.T(),M,k0,kinf);
196  }
197 
198  template<typename CoeffType, typename FalloffType>
199  template<typename StateType, typename VectorStateType>
200  inline
203  StateType& kfwd,
204  StateType& dkfwd_dT,
205  VectorStateType& dkfwd_dX) const
206  {
207  //variables, k0,kinf and derivatives
208  StateType k0 = Antioch::zero_clone(conditions.T());
209  StateType dk0_dT = Antioch::zero_clone(conditions.T());
210  StateType kinf = Antioch::zero_clone(conditions.T());
211  StateType dkinf_dT = Antioch::zero_clone(conditions.T());
212 
213  this->_forward_rate[0]->compute_rate_and_derivative(conditions,k0,dk0_dT);
214  this->_forward_rate[1]->compute_rate_and_derivative(conditions,kinf,dkinf_dT);
215 
216  StateType M = Antioch::zero_clone(conditions.T());
217  for(unsigned int s = 0; s < molar_densities.size(); s++)
218  {
219  M += this->efficiency(s) * molar_densities[s];
220  }
221 
222  //F
223  StateType f = Antioch::zero_clone(conditions.T());
224  StateType df_dT = Antioch::zero_clone(conditions.T());
225  VectorStateType df_dX = Antioch::zero_clone(molar_densities);
226  _F.F_and_derivatives(conditions.T(),M,k0,dk0_dT,kinf,dkinf_dT,f,df_dT,df_dX);
227 
228 // k(T,[M]) = k0*[M]/(1 + [M]*k0/kinf) * F = k0 * ([M]^-1 + k0 * kinf^-1)^-1 * F
229  kfwd = k0 / (ant_pow(M,-1) + k0/kinf); //temp variable here for calculations dk_d{T,X}
230 
231 //dk_dT = F * dkfwd_dT + kfwd * dF_dT
232 // = F * kfwd * (dk0_dT/k0 - dk0_dT/(kinf/[M] + k0) + k0 * dkinf_dT/(kinf * (kinf/[M] + k0) ) )
233 // + dF_dT * kfwd
234  StateType temp = (kinf/M + k0);
235  dkfwd_dT = f * kfwd * (dk0_dT/k0 - dk0_dT/temp + dkinf_dT * k0/(kinf * temp))
236  + df_dT * kfwd;
237 
238  dkfwd_dX.resize(this->n_species(), kfwd);
239 
240  StateType tmp = f * kfwd / (M + ant_pow(M,2) * k0/kinf);
241 //dkfwd_dX = F * dkfwd_dX + kfwd * dF_dX
242 // = F * epsilon_i * kfwd / ([M] + [M]^2 k0/kinf) + kfwd * dF_dX
243  for(unsigned int ic = 0; ic < this->n_species(); ic++)
244  {
245  dkfwd_dX[ic] = this->efficiency(ic) * ( tmp + df_dX[ic] * kfwd );
246  }
247 
248  kfwd *= f; //finalize
249 
250  return;
251  }
252 
253 } // namespace Antioch
254 
255 #endif // ANTIOCH_FALLOFF_REACTION_H
A single reaction mechanism.
Definition: reaction.h:108
const std::string & equation() const
unsigned int n_species() const
Base class for falloff processes coupled with efficiencies.
const FalloffType & F() const
Return const reference to the falloff object.
void compute_forward_rate_coefficient_and_derivatives(const VectorStateType &molar_densities, const KineticsConditions< StateType, VectorStateType > &conditions, StateType &kfwd, StateType &dkfwd_dT, VectorStateType &dkfkwd_dX) const
StateType compute_forward_rate_coefficient(const VectorStateType &molar_densities, const KineticsConditions< StateType, VectorStateType > &conditions) const
FalloffThreeBodyReaction(const unsigned int n_species, const std::string &equation, const bool &reversible=true, const ReactionType::ReactionType &falloffType=ReactionType::LINDEMANN_FALLOFF_THREE_BODY, const KineticsModel::KineticsModel kin=KineticsModel::KOOIJ)
Construct a single reaction mechanism.
The parameters are reduced parameters.
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > zero_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex)
Definition: eigen_utils.h:145
const StateType & T() const
This class contains the conditions of the chemistry.

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