exponential.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::distributionModels::exponential
29 
30 Description
31  Particle-size distribution model wherein random samples are drawn
32  from the doubly-truncated exponential probability density function:
33 
34  \f[
35  f(x; \lambda, A, B) =
36  \lambda \frac{\exp(-\lambda (x - A))}{1 - \exp(-\lambda(B-A))}
37  \f]
38  where
39 
40  \vartable
41  f(x; \lambda, A, B) | Exponential probability density function
42  \lambda | Rate parameter
43  x | Sample
44  A | Minimum of the distribution
45  B | Maximum of the distribution
46  \endvartable
47 
48  Constraints:
49  - \f$ \infty > B > A > 0 \f$
50  - \f$ x \in [B,A] \f$
51  - \f$ \lambda > 0 \f$
52 
53  Random samples are generated by the inverse transform sampling technique
54  by using the quantile function of the doubly-truncated exponential
55  probability density function:
56 
57  \f[
58  x = - \frac{1}{\lambda} \ln (r)
59  \f]
60 
61  with
62 
63  \f[
64  r = q_{min} + u (q_{max} - q_{min})
65  \f]
66 
67  \f[
68  q_{min} = \exp(-\lambda A)
69  \f]
70 
71  \f[
72  q_{max} = \exp(-\lambda B)
73  \f]
74  where \f$ u \f$ is a sample drawn from the uniform probability
75  density function on the unit interval \f$ (0, 1) \f$.
76 
77 Usage
78  Minimal example by using \c constant/<CloudProperties>:
79  \verbatim
80  subModels
81  {
82  injectionModels
83  {
84  <name>
85  {
86  ...
87 
88  sizeDistribution
89  {
90  type exponential;
91  exponentialDistribution
92  {
93  lambda <lambdaValue>;
94  minValue <minValue>;
95  maxValue <maxValue>;
96  }
97  }
98  }
99  }
100  }
101  \endverbatim
102 
103  where the entries mean:
104  \table
105  Property | Description | Type | Reqd | Deflt
106  type | Type name: exponential | word | yes | -
107  exponentialDistribution | Distribution settings | dict | yes | -
108  lambda | Rate parameter | scalar | yes | -
109  minValue | Minimum of the distribution | scalar | yes | -
110  maxValue | Maximum of the distribution | scalar | yes | -
111  \endtable
112 
113 SourceFiles
114  exponential.C
115 
116 \*---------------------------------------------------------------------------*/
117 
118 #ifndef distributionModels_exponential_H
119 #define distributionModels_exponential_H
120 
121 #include "distributionModel.H"
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 namespace Foam
126 {
127 namespace distributionModels
128 {
129 
130 /*---------------------------------------------------------------------------*\
131  Class exponential Declaration
132 \*---------------------------------------------------------------------------*/
133 
134 class exponential
135 :
136  public distributionModel
137 {
138  // Private Data
139 
140  //- Rate parameter
141  scalar lambda_;
142 
143 
144 public:
145 
146  //- Runtime type information
147  TypeName("exponential");
148 
149 
150  // Constructors
151 
152  //- Construct from components
153  exponential(const dictionary& dict, Random& rndGen);
154 
155  //- Copy construct
156  exponential(const exponential& p);
157 
158  //- Construct and return a clone
159  virtual autoPtr<distributionModel> clone() const
160  {
161  return autoPtr<distributionModel>(new exponential(*this));
162  }
163 
164  //- No copy assignment
165  void operator=(const exponential&) = delete;
166 
167 
168  //- Destructor
169  virtual ~exponential() = default;
170 
171 
172  // Member Functions
173 
174  //- Sample the distribution
175  virtual scalar sample() const;
176 
177  //- Return the theoretical mean of the distribution
178  virtual scalar meanValue() const;
179 };
180 
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 } // End namespace distributionModels
185 } // End namespace Foam
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 #endif
190 
191 // ************************************************************************* //
Foam::Random
Random number generator.
Definition: Random.H:59
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::distributionModels::exponential::sample
virtual scalar sample() const
Sample the distribution.
Definition: exponential.C:75
Foam::distributionModels::exponential::exponential
exponential(const dictionary &dict, Random &rndGen)
Construct from components.
Definition: exponential.C:46
Foam::distributionModel
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...
Definition: distributionModel.H:72
Foam::distributionModels::exponential::clone
virtual autoPtr< distributionModel > clone() const
Construct and return a clone.
Definition: exponential.H:214
Foam::distributionModels::exponential::TypeName
TypeName("exponential")
Runtime type information.
Foam::distributionModels::exponential::~exponential
virtual ~exponential()=default
Destructor.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::distributionModels::exponential::meanValue
virtual scalar meanValue() const
Return the theoretical mean of the distribution.
Definition: exponential.C:84
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::distributionModels::exponential::operator=
void operator=(const exponential &)=delete
No copy assignment.
rndGen
Random rndGen
Definition: createFields.H:23
Foam::distributionModels::exponential
Particle-size distribution model wherein random samples are drawn from the doubly-truncated exponenti...
Definition: exponential.H:189
distributionModel.H