33 namespace distributionModels
49 xy_(distributionModelDict_.lookup(
"distribution")),
50 nEntries_(xy_.size()),
52 maxValue_(xy_[nEntries_-1][0]),
61 for (
label i=1; i<nEntries_; i++)
64 scalar
k = (xy_[i][1] - xy_[i-1][1])/(xy_[i][0] - xy_[i-1][0]);
65 scalar d = xy_[i-1][1] - k*xy_[i-1][0];
66 scalar
y1 = xy_[i][0]*(0.5*k*xy_[i][0] + d);
67 scalar
y0 = xy_[i-1][0]*(0.5*k*xy_[i-1][0] + d);
68 scalar area = y1 -
y0;
70 integral_[i] = area + integral_[i-1];
73 scalar sumArea = integral_.last();
75 meanValue_ = sumArea/(maxValue_ - minValue_);
77 for (
label i=0; i<nEntries_; i++)
80 integral_[i] /= sumArea;
90 nEntries_(p.nEntries_),
91 minValue_(p.minValue_),
92 maxValue_(p.maxValue_),
93 integral_(p.integral_)
111 while (integral_[n] <= y)
116 scalar
k = (xy_[
n][1] - xy_[n-1][1])/(xy_[n][0] - xy_[n-1][0]);
117 scalar d = xy_[n-1][1] - k*xy_[n-1][0];
119 scalar
alpha = y + xy_[n-1][0]*(0.5*k*xy_[n-1][0] + d) - integral_[n-1];
126 scalar q = -2.0*alpha/
k;
127 scalar sqrtEr =
sqrt(0.25*p*p - q);
129 scalar x1 = -0.5*p + sqrtEr;
130 scalar x2 = -0.5*p - sqrtEr;
131 if ((x1 >= xy_[n-1][0]) && (x1 <= xy_[n][0]))
virtual scalar maxValue() const
Return the maximum value.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
general(const dictionary &dict, cachedRandom &rndGen)
Construct from components.
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensionedScalar sqrt(const dimensionedScalar &ds)
defineTypeNameAndDebug(distributionModel, 0)
virtual ~general()
Destructor.
dimensionedScalar y0(const dimensionedScalar &ds)
label k
Boltzmann constant.
Macros for easy insertion into run-time selection tables.
Type sample01()
Return a sample whose components lie in the range 0-1.
virtual scalar minValue() const
Return the minimum value.
dimensionedScalar y1(const dimensionedScalar &ds)
virtual scalar sample() const
Sample the distributionModel.
cachedRandom & rndGen_
Reference to the random number generator.
dimensioned< scalar > mag(const dimensioned< Type > &)
addToRunTimeSelectionTable(distributionModel, exponential, dictionary)
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
virtual scalar meanValue() const
Return the mean value.