antioch-0.4.0
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 
28 #ifndef ANTIOCH_THREEBODY_REACTION_H
29 #define ANTIOCH_THREEBODY_REACTION_H
30 
31 // Antioch
32 #include "antioch/reaction.h"
34 
35 //C++
36 #include <string>
37 #include <vector>
38 #include <iostream>
39 
40 namespace Antioch
41 {
43 
64  template <typename CoeffType=double>
65  class ThreeBodyReaction: public Reaction<CoeffType>
66  {
67  public:
68 
70  ThreeBodyReaction( const unsigned int n_species,
71  const std::string &equation,
72  const bool &reversible = true,
74 
76 
78  template <typename StateType, typename VectorStateType>
79  StateType compute_forward_rate_coefficient( const VectorStateType& molar_densities,
80  const KineticsConditions<StateType,VectorStateType>& conditions ) const;
81 
83  template <typename StateType, typename VectorStateType>
84  void compute_forward_rate_coefficient_and_derivatives( const VectorStateType& molar_densities,
85  const KineticsConditions<StateType,VectorStateType>& conditions,
86  StateType& kfwd,
87  StateType& dkfwd_dT,
88  VectorStateType& dkfwd_dX) const;
89 
90  };
91 
92  /* ------------------------- Inline Functions -------------------------*/
93  template <typename CoeffType>
94  inline
95  ThreeBodyReaction<CoeffType>::ThreeBodyReaction( const unsigned int n_species,
96  const std::string &equation ,
97  const bool &reversible,
99  :Reaction<CoeffType>(n_species,equation,reversible,ReactionType::THREE_BODY,kin)
100  {
101  Reaction<CoeffType>::_efficiencies.resize(n_species);
103  return;
104  }
105 
106  template <typename CoeffType>
107  inline
109  {
110  return;
111  }
112 
113 
114 
115  template <typename CoeffType>
116  template<typename StateType, typename VectorStateType>
117  inline
118  StateType ThreeBodyReaction<CoeffType>::compute_forward_rate_coefficient( const VectorStateType& molar_densities,
119  const KineticsConditions<StateType,VectorStateType>& conditions ) const
120  {
121  //k(T,[M]) = (sum eff_i * C_i) * ...
122  StateType kfwd = (this->efficiency(0) * molar_densities[0] );
123 
124  for (unsigned int s=1; s<this->n_species(); s++)
125  {
126  kfwd += ( this->efficiency(s) * molar_densities[s] );
127  }
128 
129  //... alpha(T)
130  return (kfwd * (*this->_forward_rate[0])(conditions));
131  }
132 
133 
134  template <typename CoeffType>
135  template<typename StateType, typename VectorStateType>
136  inline
139  StateType& kfwd,
140  StateType& dkfwd_dT,
141  VectorStateType& dkfwd_dX) const
142  {
143  antioch_assert_equal_to(dkfwd_dX.size(),this->n_species());
144 
145  //dk_dT = dalpha_dT * [sum_s (eps_s * X_s)]
146  //dk_dCi = alpha(T) * eps_i
147  this->_forward_rate[0]->compute_rate_and_derivative(conditions,kfwd,dkfwd_dT);
148 
149  dkfwd_dX[0] = kfwd;
150  StateType coef = (this->efficiency(0) * molar_densities[0]);
151 
152  for (unsigned int s=1; s<this->n_species(); s++)
153  {
154  coef += ( this->efficiency(s) * molar_densities[s] );
155  dkfwd_dX[s] = kfwd;
156  }
157 
158  kfwd *= coef;
159  dkfwd_dT *= coef;
160 
161  for (unsigned int s=0; s<this->n_species(); s++)
162  {
163  dkfwd_dX[s] *= this->efficiency(s);
164  }
165 
166  return;
167  }
168 
169 } // namespace Antioch
170 
171 #endif // ANTIOCH_ELEMENTARY_REACTION_H
A single reaction mechanism.
Definition: reaction.h:108
const std::string & equation() const
#define antioch_assert_equal_to(expr1, expr2)
unsigned int n_species() const
ThreeBodyReaction(const unsigned int n_species, const std::string &equation, const bool &reversible=true, const KineticsModel::KineticsModel kin=KineticsModel::KOOIJ)
Construct a single reaction mechanism.
void compute_forward_rate_coefficient_and_derivatives(const VectorStateType &molar_densities, const KineticsConditions< StateType, VectorStateType > &conditions, StateType &kfwd, StateType &dkfwd_dT, VectorStateType &dkfwd_dX) const
The parameters are reduced parameters.
StateType compute_forward_rate_coefficient(const VectorStateType &molar_densities, const KineticsConditions< StateType, VectorStateType > &conditions) 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