ENH: distributionModel: add new sanity checks

This commit is contained in:
Kutalmis Bercin
2021-08-23 17:01:22 +01:00
parent 839a52ee16
commit 0feb0e4d7b
6 changed files with 64 additions and 1 deletions

View File

@ -52,6 +52,26 @@ Foam::distributionModels::RosinRammler::RosinRammler
d_(distributionModelDict_.get<scalar>("d")),
n_(distributionModelDict_.get<scalar>("n"))
{
const word parcelBasisType =
dict.getOrDefault<word>("parcelBasisType", "none");
if (parcelBasisType == "mass")
{
WarningInFunction
<< "Selected parcel basis type: " << parcelBasisType << nl
<< " Please consider to use massRosinRammler distribution model"
<< endl;
}
if (d_ < VSMALL || n_ < VSMALL)
{
FatalErrorInFunction
<< "Scale/Shape parameter cannot be equal to or less than zero:"
<< " d = " << d_
<< " n = " << n_
<< exit(FatalError);
}
check();
}

View File

@ -58,6 +58,16 @@ void Foam::distributionModels::binned::initialise()
// Normalise
scalar sumProb = xy_.last()[1];
if (sumProb < VSMALL)
{
FatalErrorInFunction
<< type() << "distribution: "
<< "The sum of elements in the second column cannot be zero." << nl
<< "sum = " << sumProb
<< exit(FatalError);
}
forAll(xy_, bini)
{
xy_[bini][1] /= sumProb;

View File

@ -51,6 +51,14 @@ Foam::distributionModels::exponential::exponential
distributionModel(typeName, dict, rndGen),
lambda_(distributionModelDict_.get<scalar>("lambda"))
{
if (lambda_ < VSMALL)
{
FatalErrorInFunction
<< "Rate parameter cannot be equal to or less than zero:" << nl
<< " lambda = " << lambda_
<< exit(FatalError);
}
check();
}

View File

@ -49,7 +49,15 @@ Foam::distributionModels::fixedValue::fixedValue
:
distributionModel(typeName, dict, rndGen),
value_(distributionModelDict_.get<scalar>("value"))
{}
{
if (value_ < VSMALL)
{
FatalErrorInFunction
<< "Fixed value cannot be equal to or less than zero:" << nl
<< " value = " << value_
<< exit(FatalError);
}
}
Foam::distributionModels::fixedValue::fixedValue(const fixedValue& p)

View File

@ -53,6 +53,15 @@ Foam::distributionModels::massRosinRammler::massRosinRammler
d_(distributionModelDict_.get<scalar>("d")),
n_(distributionModelDict_.get<scalar>("n"))
{
if (d_ < VSMALL || n_ < VSMALL)
{
FatalErrorInFunction
<< "Scale/Shape parameter cannot be equal to or less than zero:"
<< " d = " << d_
<< " n = " << n_
<< exit(FatalError);
}
check();
}

View File

@ -54,6 +54,14 @@ Foam::distributionModels::normal::normal
variance_(distributionModelDict_.get<scalar>("variance")),
a_(0.147)
{
if (mag(variance_) == 0)
{
FatalErrorInFunction
<< "Standard deviation cannot be zero." << nl
<< " variance = " << variance_ << nl
<< exit(FatalError);
}
check();
}