Cantera  2.1.2
FalloffFactory.h
Go to the documentation of this file.
1 /**
2  * @file FalloffFactory.h
3  * Parameterizations for reaction falloff functions. Used by classes
4  * that implement gas-phase kinetics (GasKinetics, GRI_30_Kinetics)
5  * (see \ref falloffGroup and class \link Cantera::Falloff Falloff\endlink).
6  */
7 // Copyright 2001 California Institute of Technology
8 
9 #ifndef CT_NEWFALLOFF_H
10 #define CT_NEWFALLOFF_H
11 
12 #include "cantera/base/ct_defs.h"
13 #include "reaction_defs.h"
15 #include "cantera/base/ct_thread.h"
16 
17 namespace Cantera
18 {
19 
20 /**
21  * @defgroup falloffGroup Falloff Parameterizations
22  * This section describes the parameterizations used
23  * to describe the fall-off in reaction rate constants
24  * due to intermolecular energy transfer.
25  *
26  * @ingroup chemkinetics
27  */
28 
29 /**
30  * Base class for falloff function calculators. Each instance of a subclass of
31  * Falloff computes one falloff function. This base class implements the
32  * trivial falloff function F = 1.0.
33  *
34  * @ingroup falloffGroup
35  */
36 class Falloff
37 {
38 public:
39  //! Default constructor is empty
40  Falloff() {}
41 
42  //! default destructor is empty
43  virtual ~Falloff() {}
44 
45  /**
46  * Initialize. Must be called before any other method is invoked.
47  *
48  * @param c Vector of coefficients of the parameterization. The number and
49  * meaning of these coefficients is subclass-dependent.
50  */
51  virtual void init(const vector_fp& c) {}
52 
53  /**
54  * Update the temperature-dependent portions of the falloff
55  * function, if any. This method evaluates temperature-dependent
56  * intermediate results and stores them in the 'work' array.
57  * If not overloaded, the default behavior is to do nothing.
58  * @param T Temperature [K].
59  * @param work storage space for intermediate results.
60  */
61  virtual void updateTemp(doublereal T, doublereal* work) const {}
62 
63  /**
64  * The falloff function. This is defined so that the
65  * rate coefficient is
66  *
67  * \f[ k = F(Pr)\frac{Pr}{1 + Pr}. \f]
68  *
69  * Here \f$ Pr \f$ is the reduced pressure, defined by
70  *
71  * \f[
72  * Pr = \frac{k_0 [M]}{k_\infty}.
73  * \f]
74  *
75  * @param pr reduced pressure (dimensionless).
76  * @param work array of size workSize() containing cached
77  * temperature-dependent intermediate results from a prior call
78  * to updateTemp.
79  *
80  * @return Returns the value of the falloff function \f$ F \f$ defined above
81  */
82  virtual doublereal F(doublereal pr, const doublereal* work) const {
83  return 1.0;
84  }
85 
86  //! The size of the work array required.
87  virtual size_t workSize() {
88  return 0;
89  }
90 };
91 
92 /**
93  * Factory class to construct falloff function calculators.
94  * The falloff factory is accessed through static method factory:
95  *
96  * @code
97  * Falloff* f = FalloffFactory::factory()->newFalloff(type, c)
98  * @endcode
99  *
100  * @ingroup falloffGroup
101  */
103 {
104 public:
105  /**
106  * Return a pointer to the factory. On the first call, a new instance is
107  * created. Since there is no need to instantiate more than one factory,
108  * on all subsequent calls, a pointer to the existing factory is returned.
109  */
111  ScopedLock lock(falloff_mutex) ;
112  if (!s_factory) {
114  }
115  return s_factory;
116  }
117 
118  virtual void deleteFactory() {
119  ScopedLock lock(falloff_mutex);
120  if (s_factory) {
121  delete s_factory;
122  s_factory = 0;
123  }
124  }
125 
126  //! Return a pointer to a new falloff function calculator.
127  /*!
128  * @param type Integer flag specifying the type of falloff function. The
129  * standard types are defined in file reaction_defs.h. A
130  * factory class derived from FalloffFactory may define other
131  * types as well.
132  * @param c input vector of doubles which populates the falloff
133  * parameterization.
134  * @return Returns a pointer to a new Falloff class.
135  */
136  virtual Falloff* newFalloff(int type, const vector_fp& c);
137 
138 private:
139  //! Pointer to the single instance of the factory
141 
142  //! default constructor, which is defined as private
144 
145  //! Mutex for use when calling the factory
146  static mutex_t falloff_mutex ;
147 };
148 
149 }
150 #endif
virtual Falloff * newFalloff(int type, const vector_fp &c)
Return a pointer to a new falloff function calculator.
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
Base class for factories.
Definition: FactoryBase.h:18
static mutex_t falloff_mutex
Mutex for use when calling the factory.
FalloffFactory()
default constructor, which is defined as private
static FalloffFactory * factory()
Return a pointer to the factory.
virtual doublereal F(doublereal pr, const doublereal *work) const
The falloff function.
virtual size_t workSize()
The size of the work array required.
This file defines some constants used to specify reaction types.
virtual void deleteFactory()
Virtual abstract function that deletes the factory.
static FalloffFactory * s_factory
Pointer to the single instance of the factory.
Base class for falloff function calculators.
virtual ~Falloff()
default destructor is empty
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:165
Falloff()
Default constructor is empty.
virtual void init(const vector_fp &c)
Initialize.
Factory class to construct falloff function calculators.
File contains the FactoryBase class declarations.
virtual void updateTemp(doublereal T, doublereal *work) const
Update the temperature-dependent portions of the falloff function, if any.