34 namespace distributionModels
50 minValue_(
readScalar(distributionModelDict_.lookup(
"minValue"))),
51 maxValue_(
readScalar(distributionModelDict_.lookup(
"maxValue"))),
52 expectation_(
readScalar(distributionModelDict_.lookup(
"expectation"))),
53 variance_(
readScalar(distributionModelDict_.lookup(
"variance"))),
58 FatalErrorIn(
"normal::normal(const dictionary&, Random&)")
59 <<
"Minimum value must be greater than zero. " 60 <<
"Supplied minValue = " << minValue_
64 if (maxValue_ < minValue_)
66 FatalErrorIn(
"normal::normal(const dictionary&, Random&)")
67 <<
"Maximum value is smaller than the minimum value:" 68 <<
" maxValue = " << maxValue_ <<
", minValue = " << minValue_
77 minValue_(p.minValue_),
78 maxValue_(p.maxValue_),
79 expectation_(p.expectation_),
80 variance_(p.variance_),
96 scalar a =
erf((minValue_ - expectation_)/variance_);
97 scalar
b =
erf((maxValue_ - expectation_)/variance_);
100 scalar
x =
erfInv(y*(b - a) + a)*variance_ + expectation_;
105 x =
min(
max(x, minValue_), maxValue_);
132 scalar
h =
log(1.0 - y*y)/a_;
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensionedScalar erf(const dimensionedScalar &ds)
defineTypeNameAndDebug(distributionModel, 0)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
virtual scalar minValue() const
Return the minimum value.
A list of keyword definitions, which are a keyword followed by any number of values (e...
cachedRandom & rndGen_
Reference to the random number generator.
virtual scalar maxValue() const
Return the maximum value.
normal(const dictionary &dict, cachedRandom &rndGen)
Construct from components.
dimensionedScalar log(const dimensionedScalar &ds)
virtual scalar sample() const
Sample the distributionModel.
virtual scalar erfInv(const scalar y) const
virtual ~normal()
Destructor.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
label k
Boltzmann constant.
Macros for easy insertion into run-time selection tables.
errorManip< error > abort(error &err)
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
virtual scalar meanValue() const
Return the mean value.
addToRunTimeSelectionTable(distributionModel, exponential, dictionary)
Type sample01()
Return a sample whose components lie in the range 0-1.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
const dimensionedScalar h
Planck constant.