normal.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-2013 OpenFOAM Foundation
9 Copyright (C) 2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::distributionModels::normal
29
30Description
31 Particle-size distribution model wherein random samples are drawn
32 from the doubly-truncated univariate normal probability density function:
33
34 \f[
35 f(x; \mu, \sigma, A, B) =
36 \frac{1}{\sigma}
37 \frac{
38 \phi \left( \frac{x - \mu}{\sigma} \right)
39 }{
40 \Phi \left( \frac{B - \mu}{\sigma} \right)
41 - \Phi \left( \frac{A - \mu}{\sigma} \right)
42 }
43 \f]
44 where
45
46 \vartable
47 f(x; \mu, \sigma, A, B) | Doubly-truncated univariate normal distribution
48 \mu | Mean of the parent general normal distribution
49 \sigma | Standard deviation of the parent general normal distribution
50 \phi(\cdot) | General normal probability density function
51 \Phi(\cdot) | General normal cumulative distribution function
52 x | Sample
53 A | Minimum of the distribution
54 B | Maximum of the distribution
55 \endvartable
56
57 Constraints:
58 - \f$ \infty > B > A > 0 \f$
59 - \f$ x \in [B,A] \f$
60 - \f$ \sigma^2 > 0 \f$
61
62 Random samples are generated by the inverse transform sampling technique
63 by using the quantile function of the doubly-truncated univariate normal
64 probability density function:
65
66 \f[
67 x = \mu + \sigma \sqrt{2} \, {erf}^{-1} \left( 2 p - 1 \right)
68 \f]
69 with
70
71 \f[
72 p = u \,
73 \left(
74 \Phi\left(
75 \frac{B - \mu}{\sigma}
76 \right)
77 - \Phi\left(
78 \frac{A - \mu}{\sigma}
79 \right)
80 \right)
81 + \Phi\left( \frac{A - \mu}{\sigma} \right)
82 \f]
83
84 \f[
85 \Phi(\xi) =
86 \frac{1}{2}
87 \left(
88 1 + {erf}\left(\frac{\xi - \mu}{\sigma \sqrt{2} }\right)
89 \right)
90 \f]
91 where \f$ u \f$ is sample drawn from the uniform probability
92 density function on the unit interval \f$ (0, 1) \f$.
93
94 Reference:
95 \verbatim
96 Governing expressions (tag:B):
97 Burkardt, J. (2014).
98 The truncated normal distribution.
99 Department of Scientific Computing Website,
100 Florida State University, 1-35.
101 URL:people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf
102 (Retrieved on: 19 Feb 2021)
103 \endverbatim
104
105Usage
106 Minimal example by using \c constant/<CloudProperties>:
107 \verbatim
108 subModels
109 {
110 injectionModels
111 {
112 <name>
113 {
114 ...
115
116 sizeDistribution
117 {
118 type normal;
119 normalDistribution
120 {
121 mu <mean>;
122 sigma <stardard deviation>;
123 minValue <min>;
124 maxValue <max>;
125 }
126 }
127 }
128 }
129 }
130 \endverbatim
131
132 where the entries mean:
133 \table
134 Property | Description | Type | Reqd | Deflt
135 type | Type name: normal | word | yes | -
136 normalDistribution | Distribution settings | dict | yes | -
137 mu | Mean of the parent general normal distribution <!--
138 --> | scalar | yes | -
139 sigma | Standard deviation of the parent general normal <!--
140 --> distribution | scalar | yes | -
141 minValue | Minimum of the distribution | scalar | yes | -
142 maxValue | Maximum of the distribution | scalar | yes | -
143 \endtable
144
145Note
146 - The mean and standard deviation of the parent general normal probability
147 distribution function (i.e. input) are not the same with those of the
148 truncated probability distribution function.
149
150SourceFiles
151 normal.C
152
153\*---------------------------------------------------------------------------*/
154
155#ifndef distributionModels_normal_H
156#define distributionModels_normal_H
157
158#include "distributionModel.H"
159
160// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161
162namespace Foam
163{
164namespace distributionModels
165{
166
167/*---------------------------------------------------------------------------*\
168 Class normal Declaration
169\*---------------------------------------------------------------------------*/
170
171class normal
172:
173 public distributionModel
174{
175 // Private Data
176
177 //- Mean of the parent general normal distribution
178 scalar mu_;
179
180 //- Standard deviation of the parent general normal distribution
181 scalar sigma_;
182
183
184public:
185
186 //- Runtime type information
187 TypeName("normal");
188
189
190 // Constructors
191
192 //- Construct from components
193 normal(const dictionary& dict, Random& rndGen);
194
195 //- Copy construct
196 normal(const normal& p);
197
198 //- Construct and return a clone
199 virtual autoPtr<distributionModel> clone() const
200 {
201 return autoPtr<distributionModel>(new normal(*this));
202 }
203
204 //- No copy assignment
205 void operator=(const normal&) = delete;
206
207
208 //- Destructor
209 virtual ~normal() = default;
210
211
212 // Member Functions
213
214 //- Sample the distribution
215 virtual scalar sample() const;
216
217 //- Return the theoretical mean of the distribution
218 virtual scalar meanValue() const;
219};
220
221
222// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223
224} // End namespace distributionModels
225} // End namespace Foam
226
227// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228
229#endif
230
231// ************************************************************************* //
Random number generator.
Definition: Random.H:60
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...
Particle-size distribution model wherein random samples are drawn from the doubly-truncated univariat...
Definition: normal.H:251
virtual scalar meanValue() const
Return the theoretical mean of the distribution.
Definition: normal.C:115
void operator=(const normal &)=delete
No copy assignment.
virtual autoPtr< distributionModel > clone() const
Construct and return a clone.
Definition: normal.H:276
virtual scalar sample() const
Sample the distribution.
Definition: normal.C:93
normal(const dictionary &dict, Random &rndGen)
Construct from components.
Definition: normal.C:48
virtual ~normal()=default
Destructor.
TypeName("normal")
Runtime type information.
volScalarField & p
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73
Random rndGen
Definition: createFields.H:23