antioch-0.4.0
constant_rate.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_CONSTANT_RATE_H
28 #define ANTIOCH_CONSTANT_RATE_H
29 
30 //Antioch
32 #include "antioch/kinetics_type.h"
33 
34 // C++
35 #include <cmath>
36 #include <iostream>
37 #include <sstream>
38 
39 namespace Antioch
40 {
42 
54  template<typename CoeffType=double>
55  class ConstantRate : public KineticsType<CoeffType>
56  {
57 
58  private:
59 
60  CoeffType _Cf;
61 
62  public:
63 
64  ConstantRate (const CoeffType Cf=0.);
65  ~ConstantRate();
66 
67  void set_Cf( const CoeffType Cf );
68 
73  template <typename VectorCoeffType>
74  void reset_coefs(const VectorCoeffType & coefficients);
75 
76  CoeffType Cf() const;
77 
79  void set_parameter(KineticsModel::Parameters parameter, CoeffType new_value);
80 
82  CoeffType get_parameter(KineticsModel::Parameters parameter) const;
83 
85  //
86  // \todo, solve this
87  template <typename VectorCoeffType>
88  void set_parameter(KineticsModel::Parameters parameter, VectorCoeffType new_value){antioch_error();}
89 
91  template <typename StateType>
92  ANTIOCH_AUTO(StateType)
93  rate(const StateType& T) const
94  ANTIOCH_AUTOFUNC(StateType, constant_clone(T,_Cf))
95 
97  template <typename StateType>
98  ANTIOCH_AUTO(StateType)
99  operator()(const StateType& T) const
100  ANTIOCH_AUTOFUNC(StateType, this->rate(T))
101 
103  template <typename StateType>
104  ANTIOCH_AUTO(StateType)
105  derivative( const StateType& T ) const
106  ANTIOCH_AUTOFUNC(StateType, zero_clone(T))
107 
109  template <typename StateType>
110  void rate_and_derivative(const StateType& T, StateType& rate, StateType& drate_dT) const;
111 
112  // KineticsConditions overloads
114  template <typename StateType, typename VectorStateType>
115  ANTIOCH_AUTO(StateType)
116  rate(const KineticsConditions<StateType,VectorStateType>& cond) const
117  ANTIOCH_AUTOFUNC(StateType, constant_clone(cond.T(),_Cf))
118 
120  template <typename StateType, typename VectorStateType>
121  ANTIOCH_AUTO(StateType)
122  operator()(const KineticsConditions<StateType,VectorStateType>& cond) const
123  ANTIOCH_AUTOFUNC(StateType, this->rate(cond))
124 
126  template <typename StateType, typename VectorStateType>
127  ANTIOCH_AUTO(StateType)
128  derivative( const KineticsConditions<StateType,VectorStateType>& cond ) const
129  ANTIOCH_AUTOFUNC(StateType, zero_clone(cond.T()))
130 
132  template <typename StateType, typename VectorStateType>
133  void rate_and_derivative(const KineticsConditions<StateType,VectorStateType>& cond, StateType& rate, StateType& drate_dT) const;
134 
136  const std::string numeric() const;
137 
138  };
139 
140  template<typename CoeffType>
141  ConstantRate<CoeffType>::ConstantRate(const CoeffType Cf)
142  : KineticsType<CoeffType>(KineticsModel::CONSTANT),
143  _Cf(Cf)
144  {
145  return;
146  }
147 
148  template<typename CoeffType>
150  {
151  return;
152  }
153 
154  template<typename CoeffType>
155  const std::string ConstantRate<CoeffType>::numeric() const
156  {
157  std::stringstream os;
158  os << _Cf;
159 
160  return os.str();
161  }
162 
163  /* ------------------------- Inline Functions -------------------------*/
164  template<typename CoeffType>
165  inline
166  void ConstantRate<CoeffType>::set_Cf( const CoeffType Cf )
167  {
168  _Cf = Cf;
169 
170  return;
171  }
172 
173  template<typename CoeffType>
174  inline
176  {
178 
179  this->set_Cf(new_value);
180 
181  return;
182  }
183 
184  template<typename CoeffType>
185  inline
187  {
189 
190  return this->Cf();
191  }
192 
193  template<typename CoeffType>
194  template <typename VectorCoeffType>
195  inline
196  void ConstantRate<CoeffType>::reset_coefs(const VectorCoeffType & coefficients)
197  {
198  antioch_assert_equal_to(coefficients.size(),1);
199 
200  this->set_Cf(coefficients[0]);
201  }
202 
203  template<typename CoeffType>
204  inline
205  CoeffType ConstantRate<CoeffType>::Cf() const
206  { return _Cf; }
207 
208  template<typename CoeffType>
209  template<typename StateType>
210  inline
211  void ConstantRate<CoeffType>::rate_and_derivative( const StateType& /*T*/,
212  StateType& rate,
213  StateType& drate_dT) const
214  {
215  Antioch::constant_fill(rate, _Cf);
216  Antioch::set_zero(drate_dT);
217  return;
218  }
219 
220  template<typename CoeffType>
221  template<typename StateType, typename VectorStateType>
222  inline
224  StateType& rate,
225  StateType& drate_dT) const
226  {
227  Antioch::constant_fill(rate, _Cf);
228  Antioch::set_zero(drate_dT);
229  return;
230  }
231 
232 } // end namespace Antioch
233 
234 #endif // ANTIOCH_HERCOURT_ESSEN_RATE_H
Constant rate equation.
Definition: constant_rate.h:55
base class for kinetics models
Definition: kinetics_type.h:82
StateType StateType &drate_dT const
#define antioch_assert_equal_to(expr1, expr2)
CoeffType Cf() const
const std::string numeric() const
print equation
constant_clone(cond.T(), _Cf)) template< typename StateType
#define antioch_error()
ConstantRate(const CoeffType Cf=0.)
void set_parameter(KineticsModel::Parameters parameter, VectorCoeffType new_value)
for compatibility purpose with photochemistry (particle flux reactions)
Definition: constant_rate.h:88
VectorStateType VectorStateType zero_clone(cond.T())) template< typename StateType
Simultaneously evaluate the rate and its derivative at T.
void set_Cf(const CoeffType Cf)
CoeffType get_parameter(KineticsModel::Parameters parameter) const
get one parameter, characterized by enum
VectorStateType VectorStateType derivative(const KineticsConditions< StateType, VectorStateType > &cond) const ANTIOCH_AUTOFUNC(StateType
VectorStateType VectorStateType VectorStateType void rate_and_derivative(const KineticsConditions< StateType, VectorStateType > &cond, StateType &rate, StateType &drate_dT) const
void set_zero(_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a)
Definition: eigen_utils.h:217
#define ANTIOCH_AUTOFUNC(Type, Expr)
void reset_coefs(const VectorCoeffType &coefficients)
reset the coeffs
void constant_fill(_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &output, const Scalar &value)
Definition: eigen_utils.h:204
const ANTIOCH_AUTO(StateType) KineticsTheoryThermalConductivity< ThermoEvaluator
The parameters are reduced parameters.
This class contains the conditions of the chemistry.
void set_parameter(KineticsModel::Parameters parameter, CoeffType new_value)
set one parameter, characterized by enum

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