antioch-0.4.0
duplicate_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_DUPLICATE_REACTION_H
28 #define ANTIOCH_DUPLICATE_REACTION_H
29 
30 // Antioch
31 #include "antioch/reaction.h"
33 
34 //C++
35 #include <string>
36 #include <vector>
37 #include <iostream>
38 
39 namespace Antioch
40 {
42 
63  template <typename CoeffType=double>
64  class DuplicateReaction: public Reaction<CoeffType>
65  {
66  public:
67 
69  DuplicateReaction( const unsigned int n_species,
70  const std::string &equation,
71  const bool &reversible = true,
73 
75 
77  template <typename StateType, typename VectorStateType>
78  StateType compute_forward_rate_coefficient( const VectorStateType& molar_densities,
79  const KineticsConditions<StateType,VectorStateType>& conditions ) const;
80 
82  template <typename StateType, typename VectorStateType>
83  void compute_forward_rate_coefficient_and_derivatives( const VectorStateType& molar_densities,
85  StateType& kfwd,
86  StateType& dkfwd_dT,
87  VectorStateType& dkfwd_dX) const;
88 
89  private:
90 
91  };
92 
93  /* ------------------------- Inline Functions -------------------------*/
94  template <typename CoeffType>
95  inline
96  DuplicateReaction<CoeffType>::DuplicateReaction( const unsigned int n_species,
97  const std::string &equation,
98  const bool &reversible,
100  :Reaction<CoeffType>(n_species,equation,reversible,ReactionType::DUPLICATE,kin){}
101 
102 
103  template <typename CoeffType>
104  inline
106  {
107  return;
108  }
109 
110 
111 
112  template <typename CoeffType>
113  template<typename StateType, typename VectorStateType>
114  inline
116  ( const VectorStateType& /* molar_densities */,
117  const KineticsConditions<StateType,VectorStateType>& conditions) const
118  {
119  StateType kfwd = (*this->_forward_rate[0])(conditions);
120  for(unsigned int ir = 1; ir < this->_forward_rate.size(); ir++)
121  {
122  kfwd += (*this->_forward_rate[ir])(conditions);
123  }
124 
125  return kfwd;
126  }
127 
128  template <typename CoeffType>
129  template<typename StateType, typename VectorStateType>
130  inline
132  ( const VectorStateType& /* molar_densities */,
134  StateType& kfwd,
135  StateType& dkfwd_dT,
136  VectorStateType& dkfwd_dX) const
137  {
138  //dk_dT = sum_p dalpha_p_dT
139  StateType kfwd_tmp = Antioch::zero_clone(conditions.T());
140  StateType dkfwd_dT_tmp = Antioch::zero_clone(conditions.T());
141 
142  this->_forward_rate[0]->compute_rate_and_derivative(conditions,kfwd,dkfwd_dT);
143 
144  for(unsigned int ir = 1; ir < Reaction<CoeffType>::_forward_rate.size(); ir++)
145  {
146  this->_forward_rate[ir]->compute_rate_and_derivative(conditions,kfwd_tmp,dkfwd_dT_tmp);
147  kfwd += kfwd_tmp;
148  dkfwd_dT += dkfwd_dT_tmp;
149  }
150 
151  //dk_dCi = 0
152  antioch_assert_equal_to(dkfwd_dX.size(),this->n_species());
153  Antioch::set_zero(dkfwd_dX);
154 
155  return;
156  }
157 
158 } // namespace Antioch
159 
160 #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
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
DuplicateReaction(const unsigned int n_species, const std::string &equation, const bool &reversible=true, const KineticsModel::KineticsModel kin=KineticsModel::KOOIJ)
Construct a single reaction mechanism.
A single reaction mechanism.
void set_zero(_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a)
Definition: eigen_utils.h:217
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
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