antioch-0.4.0
kinetics_type.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_KINETICS_TYPE_H
28 #define _ANTIOCH_KINETICS_TYPE_H
29 
30 //Antioch
33 #include "antioch/kinetics_enum.h"
35 
36 //C++
37 #include <string>
38 #include <vector>
39 #include <iostream>
40 
41 namespace Antioch{
42 
43  template <typename CoeffType>
44  class ConstantRate;
45 
46  template <typename CoeffType>
47  class HercourtEssenRate;
48 
49  template <typename CoeffType>
50  class BerthelotRate;
51 
52  template <typename CoeffType>
53  class ArrheniusRate;
54 
55  template <typename CoeffType>
56  class BerthelotHercourtEssenRate;
57 
58  template <typename CoeffType>
59  class KooijRate;
60 
61  template <typename CoeffType>
62  class VantHoffRate;
63 
64  template <typename CoeffType, typename VectorCoeffType>
66 
81  template <typename CoeffType, typename VectorCoeffType = std::vector<CoeffType> >
82  class KineticsType{
83  public:
85  virtual ~KineticsType();
86 
88 
90  template <typename StateType, typename VectorStateType>
91  StateType operator()(const KineticsConditions<StateType,VectorStateType> & conditions) const;
92 
93  // Deprecated API for backwards compatibility
94  template <typename StateType>
95  StateType operator()(const StateType& temp) const;
96 
98  template <typename StateType, typename VectorStateType>
99  StateType derivative( const KineticsConditions<StateType,VectorStateType> & conditions ) const;
100 
102  CoeffType get_parameter(KineticsModel::Parameters parameter) const;
103 
105  CoeffType get_parameter(KineticsModel::Parameters parameter, int l) const;
106 
107  // Deprecated API for backwards compatibility
108  template <typename StateType>
109  StateType derivative( const StateType & conditions ) const;
110 
112  template <typename StateType, typename VectorStateType>
113  void compute_rate_and_derivative(const KineticsConditions<StateType, VectorStateType>& conditions, StateType& rate, StateType& drate_dT) const;
114 
115  // Deprecated API for backwards compatibility
116  template <typename StateType>
117  void compute_rate_and_derivative(const StateType & temp,
118  StateType & rate,
119  StateType& drate_dT) const;
120 
122  void set_index(unsigned int nr);
123 
124  virtual const std::string numeric() const = 0;
125 
127  void print(std::ostream& os = std::cout) const;
128 
130  friend std::ostream& operator<<(std::ostream& os, const KineticsType& rate)
131  {
132  rate.print(os);
133  return os;
134  }
135 
136  private:
138  unsigned int my_index;
139  };
140 
141  /* ------------------------- Inline Functions -------------------------*/
142  template <typename CoeffType, typename VectorCoeffType>
143  inline
145  {
146  os << numeric();
147  }
148 
149  template <typename CoeffType, typename VectorCoeffType>
150  inline
152  my_type(type),
153  my_index(0)
154  {
155  return;
156  }
157 
158  template <typename CoeffType, typename VectorCoeffType>
159  inline
161  {
162  return my_type;
163  }
164 
165  template <typename CoeffType, typename VectorCoeffType>
166  inline
168  {
169  return;
170  }
171 
172  template <typename CoeffType, typename VectorCoeffType>
173  inline
175  {
176  my_index = nr;
177  }
178 
179  template <typename CoeffType, typename VectorCoeffType>
180  template <typename StateType, typename VectorStateType>
181  inline
183  {
184  switch(my_type)
185  {
187  {
188  return (static_cast<const ConstantRate<CoeffType>*>(this))->rate(conditions);
189  }
190  break;
191 
193  {
194  return (static_cast<const HercourtEssenRate<CoeffType>*>(this))->rate(conditions);
195  }
196  break;
197 
199  {
200  return (static_cast<const BerthelotRate<CoeffType>*>(this))->rate(conditions);
201  }
202  break;
203 
205  {
206  return (static_cast<const ArrheniusRate<CoeffType>*>(this))->rate(conditions);
207  }
208  break;
209 
210  case(KineticsModel::BHE):
211  {
212  return (static_cast<const BerthelotHercourtEssenRate<CoeffType>*>(this))->rate(conditions);
213  }
214  break;
215 
216  case(KineticsModel::KOOIJ):
217  {
218  return (static_cast<const KooijRate<CoeffType>*>(this))->rate(conditions);
219  }
220  break;
221 
223  {
224  return (static_cast<const VantHoffRate<CoeffType>*>(this))->rate(conditions);
225  }
226  break;
227 
229  {
230  return (static_cast<const PhotochemicalRate<CoeffType,VectorCoeffType>*>(this))->rate(conditions.particle_flux(my_index));
231  }
232  break;
233 
234  default:
235  {
236  antioch_error();
237  }
238 
239  } // switch(my_type)
240 
241  // Dummy
242  return zero_clone(conditions.T());
243  }
244 
245  template <typename CoeffType, typename VectorCoeffType>
246  template <typename StateType>
247  inline
249  (const StateType & temp) const
250  {
252  return operator()
254  }
255 
256  template <typename CoeffType, typename VectorCoeffType>
257  template <typename StateType, typename VectorStateType>
258  inline
260  {
261  switch(my_type)
262  {
264  {
265  return (static_cast<const ConstantRate<CoeffType>*>(this))->derivative(conditions);
266  }
267  break;
268 
270  {
271  return (static_cast<const HercourtEssenRate<CoeffType>*>(this))->derivative(conditions);
272  }
273  break;
274 
276  {
277  return (static_cast<const BerthelotRate<CoeffType>*>(this))->derivative(conditions);
278  }
279  break;
280 
282  {
283  return (static_cast<const ArrheniusRate<CoeffType>*>(this))->derivative(conditions);
284  }
285  break;
286 
287  case(KineticsModel::BHE):
288  {
289  return (static_cast<const BerthelotHercourtEssenRate<CoeffType>*>(this))->derivative(conditions);
290  }
291  break;
292 
293  case(KineticsModel::KOOIJ):
294  {
295  return (static_cast<const KooijRate<CoeffType>*>(this))->derivative(conditions);
296  }
297  break;
298 
300  {
301  return (static_cast<const VantHoffRate<CoeffType>*>(this))->derivative(conditions);
302  }
303  break;
304 
306  {
307  return (static_cast<const PhotochemicalRate<CoeffType,VectorCoeffType>*>(this))->derivative(conditions.particle_flux(my_index));
308  }
309  break;
310 
311  default:
312  {
313  antioch_error();
314  }
315 
316  } // switch(my_type)
317 
318  // Dummy
319  return zero_clone(conditions.T());
320  }
321 
322  template <typename CoeffType, typename VectorCoeffType>
323  template <typename StateType>
324  inline
326  ( const StateType & temp ) const
327  {
329  return derivative
331  }
332 
333  template <typename CoeffType, typename VectorCoeffType>
334  template <typename StateType, typename VectorStateType>
335  inline
337  StateType& rate, StateType& drate_dT) const
338  {
339  switch (my_type)
340  {
342  {
343  (static_cast<const ConstantRate<CoeffType>*>(this))->rate_and_derivative(conditions,rate,drate_dT);
344  }
345  break;
346 
348  {
349  (static_cast<const HercourtEssenRate<CoeffType>*>(this))->rate_and_derivative(conditions,rate,drate_dT);
350  }
351  break;
352 
354  {
355  (static_cast<const BerthelotRate<CoeffType>*>(this))->rate_and_derivative(conditions,rate,drate_dT);
356  }
357  break;
358 
360  {
361  (static_cast<const ArrheniusRate<CoeffType>*>(this))->rate_and_derivative(conditions,rate,drate_dT);
362  }
363  break;
364 
365  case(KineticsModel::BHE):
366  {
367  (static_cast<const BerthelotHercourtEssenRate<CoeffType>*>(this))->rate_and_derivative(conditions,rate,drate_dT);
368  }
369  break;
370 
371  case(KineticsModel::KOOIJ):
372  {
373  (static_cast<const KooijRate<CoeffType>*>(this))->rate_and_derivative(conditions,rate,drate_dT);
374  }
375  break;
376 
378  {
379  (static_cast<const VantHoffRate<CoeffType>*>(this))->rate_and_derivative(conditions,rate,drate_dT);
380  }
381  break;
382 
384  {
385  (static_cast<const PhotochemicalRate<CoeffType,VectorCoeffType>*>(this))->rate_and_derivative(conditions.particle_flux(my_index),rate,drate_dT);
386  }
387  break;
388 
389  default:
390  {
391  antioch_error();
392  }
393 
394  } // switch(my_type)
395 
396  return;
397  }
398 
399  template <typename CoeffType, typename VectorCoeffType>
401  {
402  switch (my_type)
403  {
405  {
406  return (static_cast<const ConstantRate<CoeffType>*>(this))->get_parameter(parameter);
407  }
408  break;
409 
411  {
412  return (static_cast<const HercourtEssenRate<CoeffType>*>(this))->get_parameter(parameter);
413  }
414  break;
415 
417  {
418  return (static_cast<const BerthelotRate<CoeffType>*>(this))->get_parameter(parameter);
419  }
420  break;
421 
423  {
424  return (static_cast<const ArrheniusRate<CoeffType>*>(this))->get_parameter(parameter);
425  }
426  break;
427 
428  case(KineticsModel::BHE):
429  {
430  return (static_cast<const BerthelotHercourtEssenRate<CoeffType>*>(this))->get_parameter(parameter);
431  }
432  break;
433 
434  case(KineticsModel::KOOIJ):
435  {
436  return (static_cast<const KooijRate<CoeffType>*>(this))->get_parameter(parameter);
437  }
438  break;
439 
441  {
442  return (static_cast<const VantHoffRate<CoeffType>*>(this))->get_parameter(parameter);
443  }
444  break;
445 
446  default:
447  {
448  antioch_error();
449  }
450 
451  } // switch(my_type)
452 
453  return 0;
454  }
455 
456 
457  template <typename CoeffType, typename VectorCoeffType>
459  {
460  switch(my_type)
461  {
463  {
464  return (static_cast<const PhotochemicalRate<CoeffType,VectorCoeffType>*>(this))->get_parameter(parameter,l);
465  }
466  break;
467 
468  default:
469  {
470  antioch_error();
471  }
472 
473  } // switch(my_type)
474 
475  return 0;
476  }
477 
478  template <typename CoeffType, typename VectorCoeffType>
479  template <typename StateType>
480  inline
482  (const StateType & temp,
483  StateType& rate, StateType& drate_dT) const
484  {
486  return compute_rate_and_derivative
487  (KineticsConditions<StateType> (temp), rate, drate_dT);
488  }
489 
490 } // end namespace Antioch
491 
492 #endif
Berthelot rate equation.
StateType derivative(const KineticsConditions< StateType, VectorStateType > &conditions) const
KineticsType(const KineticsModel::KineticsModel type)
void compute_rate_and_derivative(const KineticsConditions< StateType, VectorStateType > &conditions, StateType &rate, StateType &drate_dT) const
Constant rate equation.
Definition: constant_rate.h:55
Arrhenius rate equation.
base class for kinetics models
Definition: kinetics_type.h:82
StateType operator()(const KineticsConditions< StateType, VectorStateType > &conditions) const
KineticsModel::KineticsModel type() const
Berthelot Hercourt-Essen rate equation.
void print(std::ostream &os=std::cout) const
Formatted print, by default to std::cout.
const ParticleFlux< VectorStateType > & particle_flux(int nr) const
#define antioch_error()
KineticsModel::KineticsModel my_type
friend std::ostream & operator<<(std::ostream &os, const KineticsType &rate)
Formatted print.
void set_index(unsigned int nr)
CoeffType get_parameter(KineticsModel::Parameters parameter) const
get one parameter, characterized by enum
#define antioch_deprecated()
Van't Hoff rate equation.
Definition: kinetics_type.h:62
Hercourt-Essen rate equation.
The parameters are reduced parameters.
Photochemical rate.
Definition: kinetics_type.h:65
Kooij rate equation.
Definition: kinetics_type.h:59
_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.
virtual const std::string numeric() const =0

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