antioch-0.4.0
berthelothercourtessen_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_BERTHELOT_HERCOURT_ESSEN_RATE_H
28 #define ANTIOCH_BERTHELOT_HERCOURT_ESSEN_RATE_H
29 
30 //Antioch
32 #include "antioch/kinetics_type.h"
33 #include "antioch/cmath_shims.h"
34 
35 // C++
36 #include <cmath>
37 #include <iostream>
38 #include <sstream>
39 
40 namespace Antioch
41 {
43 
56  template<typename CoeffType=double>
57  class BerthelotHercourtEssenRate: public KineticsType<CoeffType>
58  {
59 
60  private:
61 
62  CoeffType _raw_Cf;
63  CoeffType _Cf;
64  CoeffType _eta;
65  CoeffType _D;
66  CoeffType _Tref;
67 
68  public:
69 
70  BerthelotHercourtEssenRate (const CoeffType Cf=0., const CoeffType eta=0., const CoeffType D=0., const CoeffType Tref = 1.);
72 
73  void set_Cf( const CoeffType Cf );
74  void set_eta( const CoeffType eta );
75  void set_D( const CoeffType D );
76  void set_Tref(const CoeffType Tref );
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 
100  template <typename VectorCoeffType>
101  void reset_coefs(const VectorCoeffType & coefficients);
102 
103  CoeffType Cf() const;
104  CoeffType eta() const;
105  CoeffType D() const;
106  CoeffType Tref() const;
107 
109  template <typename StateType>
110  ANTIOCH_AUTO(StateType)
111  rate(const StateType& T) const
112  ANTIOCH_AUTOFUNC(StateType, _Cf*(ant_pow(T,_eta)*ant_exp(_D*T)))
113 
115  template <typename StateType>
116  ANTIOCH_AUTO(StateType)
117  operator()(const StateType& T) const
118  ANTIOCH_AUTOFUNC(StateType, this->rate(T))
119 
121  template <typename StateType>
122  ANTIOCH_AUTO(StateType)
123  derivative( const StateType& T ) const
124  ANTIOCH_AUTOFUNC(StateType, (*this)(T)*(_eta/T + _D))
125 
127  template <typename StateType>
128  void rate_and_derivative(const StateType& T, StateType& rate, StateType& drate_dT) const;
129 
130 //KineticsConditions overloads
131 
133  template <typename StateType, typename VectorStateType>
134  ANTIOCH_AUTO(StateType)
135  rate(const KineticsConditions<StateType,VectorStateType>& T) const
136  ANTIOCH_AUTOFUNC(StateType, _Cf * ant_exp(_eta * T.temp_cache().lnT + _D*T.T()))
137 
139  template <typename StateType, typename VectorStateType>
140  ANTIOCH_AUTO(StateType)
141  operator()(const KineticsConditions<StateType,VectorStateType>& T) const
142  ANTIOCH_AUTOFUNC(StateType, this->rate(T))
143 
145  template <typename StateType, typename VectorStateType>
146  ANTIOCH_AUTO(StateType)
147  derivative( const KineticsConditions<StateType,VectorStateType>& T ) const
148  ANTIOCH_AUTOFUNC(StateType, (*this)(T)*(_eta/T.T() + _D))
149 
151  template <typename StateType,typename VectorStateType>
152  void rate_and_derivative(const KineticsConditions<StateType,VectorStateType>& T, StateType& rate, StateType& drate_dT) const;
153 
155  const std::string numeric() const;
156 
157  private:
158 
159  void compute_cf();
160  };
161 
162  template<typename CoeffType>
163  BerthelotHercourtEssenRate<CoeffType>::BerthelotHercourtEssenRate(const CoeffType Cf, const CoeffType eta, const CoeffType D, const CoeffType Tref)
164  : KineticsType<CoeffType>(KineticsModel::BHE),
165  _raw_Cf(Cf),
166  _eta(eta),
167  _D(D),
168  _Tref(Tref)
169  {
170  this->compute_cf();
171  return;
172  }
173 
174  template<typename CoeffType>
176  {
177  return;
178  }
179 
180  template<typename CoeffType>
182  {
183  std::stringstream os;
184  os << _raw_Cf;
185  if (_eta != 0.) os << "*(T/" << _Tref << ")^" << _eta;
186  os << "*exp(" << _D << "*T)";
187 
188  return os.str();
189  }
190 
191  /* ------------------------- Inline Functions -------------------------*/
192  template<typename CoeffType>
193  inline
195  {
196  _raw_Cf = Cf;
197  this->compute_cf();
198  return;
199  }
200 
201  template<typename CoeffType>
202  inline
204  {
205  _Tref = Tref;
206  this->compute_cf();
207  return;
208  }
209 
210  template<typename CoeffType>
211  inline
213  {
214  _eta = eta;
215  this->compute_cf();
216  return;
217  }
218 
219  template<typename CoeffType>
220  inline
222  {
223  _D = D;
224  return;
225  }
226 
227  template<typename CoeffType>
228  template <typename VectorCoeffType>
229  inline
230  void BerthelotHercourtEssenRate<CoeffType>::reset_coefs(const VectorCoeffType & coefficients)
231  {
232  antioch_assert_greater(coefficients.size(),2);
233  antioch_assert_less(coefficients.size(),5);
234 
235  if(coefficients.size() == 4)this->set_Tref(coefficients[3]);
236  this->set_Cf(coefficients[0]);
237  this->set_eta(coefficients[1]);
238  this->set_D(coefficients[2]);
239  }
240 
241  template<typename CoeffType>
242  inline
244  {
245  switch(parameter)
246  {
248  {
249  this->set_Cf(new_value);
250  }
251  break;
253  {
254  this->set_eta(new_value);
255  }
256  break;
258  {
259  this->set_D(new_value);
260  }
261  break;
263  {
264  this->set_Tref(new_value);
265  }
266  break;
267  default:
268  {
269  antioch_error();
270  }
271  break;
272  }
273  }
274 
275  template<typename CoeffType>
276  inline
278  {
279  switch(parameter)
280  {
282  {
283  return this->Cf();
284  }
285  break;
287  {
288  return this->eta();
289  }
290  break;
292  {
293  return this->D();
294  }
295  break;
297  {
298  return this->Tref();
299  }
300  break;
301  default:
302  {
303  antioch_error();
304  }
305  break;
306  }
307  return 0;
308  }
309 
310  template<typename CoeffType>
311  inline
313  { return _Cf; }
314 
315  template<typename CoeffType>
316  inline
318  { return _eta; }
319 
320  template<typename CoeffType>
321  inline
323  { return _D; }
324 
325  template<typename CoeffType>
326  inline
328  { return _Tref; }
329 
330  template<typename CoeffType>
331  template<typename StateType>
332  inline
334  StateType& rate,
335  StateType& drate_dT) const
336  {
337  rate = (*this)(T);
338  drate_dT = rate*(_eta/T + _D);
339  return;
340  }
341 
342  template<typename CoeffType>
343  template<typename StateType, typename VectorStateType>
344  inline
345  void BerthelotHercourtEssenRate<CoeffType>::rate_and_derivative( const KineticsConditions<StateType,VectorStateType>& T,
346  StateType& rate,
347  StateType& drate_dT) const
348  {
349  rate = (*this)(T);
350  drate_dT = rate*(_eta/T.T() + _D);
351  return;
352  }
353 
354  template<typename CoeffType>
355  inline
357  {
358  _Cf = _raw_Cf * ant_pow(KineticsModel::Tref<CoeffType>()/_Tref,_eta);
359  return;
360  }
361 
362 } // end namespace Antioch
363 
364 #endif // ANTIOCH_BERTHELOT_HERCOURT_ESSEN_RATE_H
_Cf VectorStateType VectorStateType(*) VectorStateType voi rate_and_derivative)(const KineticsConditions< StateType, VectorStateType > &T, StateType &rate, StateType &drate_dT) const
_Cf * ant_pow(T, _eta)*ant_exp(_D *T))) template< typename StateType > operator()(const StateType &T) const template< typename StateType > derivative(const StateType &T) const ANTIOCH_AUTOFUNC(StateType
_Cf * ant_exp(_eta *T.temp_cache().lnT+_D *T.T())) template< typename StateType
_Cf(* this)(T)*(_eta/T+_D)) template< typename StateType > void rate_and_derivative(const StateType &T
Simultaneously evaluate the rate and its derivative at T.
base class for kinetics models
Definition: kinetics_type.h:82
#define antioch_assert_greater(expr1, expr2)
Berthelot Hercourt-Essen rate equation.
#define antioch_assert_less(expr1, expr2)
#define antioch_error()
Scalar BHE(const Scalar &T, const Scalar &Cf, const Scalar &eta, const Scalar &D, const Scalar &Tf=1.)
Definition: parsing_xml.C:55
CoeffType get_parameter(KineticsModel::Parameters parameter) const
get one parameter, characterized by enum
BerthelotHercourtEssenRate(const CoeffType Cf=0., const CoeffType eta=0., const CoeffType D=0., const CoeffType Tref=1.)
_Cf VectorStateType VectorStateType derivative(const KineticsConditions< StateType, VectorStateType > &T) const ANTIOCH_AUTOFUNC(StateType
void reset_coefs(const VectorCoeffType &coefficients)
reset the coeffs
#define ANTIOCH_AUTOFUNC(Type, Expr)
const ANTIOCH_AUTO(StateType) KineticsTheoryThermalConductivity< ThermoEvaluator
void set_parameter(KineticsModel::Parameters parameter, CoeffType new_value)
set one parameter, characterized by enum
const std::string numeric() const
print equation
The parameters are reduced parameters.
This class contains the conditions of the chemistry.
void set_parameter(KineticsModel::Parameters parameter, VectorCoeffType new_value)
for compatibility purpose with photochemistry (particle flux reactions)
_Cf(*) StateType StateType &drate_d const)

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