count results that differ more than relative tolerence
This commit is contained in:
parent
1dc3746afd
commit
a551cedeaa
1 changed files with 40 additions and 4 deletions
|
|
@ -47,6 +47,18 @@ Description
|
|||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
const scalar relTol = 1. / 100.;
|
||||
|
||||
inline scalar relError (scalar x, scalar x0)
|
||||
{
|
||||
return (x - x0) / x0;
|
||||
}
|
||||
|
||||
inline bool exceedTolerence (scalar rError)
|
||||
{
|
||||
return rError > relTol || rError < -relTol;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
|
|
@ -93,6 +105,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
Info<< "\nTemperature Loop\n" << endl;
|
||||
|
||||
label errorCount = 0;
|
||||
|
||||
label testCount = 0;
|
||||
|
||||
forAll(T, i)
|
||||
{
|
||||
// OpenFOAM diffusivity model
|
||||
|
|
@ -114,15 +130,35 @@ int main(int argc, char *argv[])
|
|||
|
||||
forAll(thermo.composition().species(), k)
|
||||
{
|
||||
Info << thermo.composition().species()[k] << tab << 100. * (diff.D(k)[0] - Dc[k]) / Dc[k] << endl;
|
||||
// Info << thermo.composition().species()[k] << tab << 100. * (diff.D(k)[0] - Dc[k]) / Dc[k] << endl;
|
||||
if (exceedTolerence(relError(diff.D(k)[0], Dc[k])))
|
||||
{
|
||||
Info << thermo.composition().species()[k] << ", T = " << T[i]
|
||||
<< " relative error = " << (100. * relError(diff.D(k)[0], Dc[k])) << " %" << endl;
|
||||
errorCount++;
|
||||
}
|
||||
testCount++;
|
||||
}
|
||||
|
||||
Info << "mu" << tab << 100.*(diff.mu()[0] - tr_->viscosity())/tr_->viscosity() << endl;
|
||||
// Info << "mu" << tab << 100.*(diff.mu()[0] - tr_->viscosity())/tr_->viscosity() << endl;
|
||||
if (exceedTolerence(relError(diff.mu()[0], tr_->viscosity())))
|
||||
{
|
||||
Info << "T = " << T[i] << " relative error = " << (100. * relError(diff.mu()[0], tr_->viscosity())) << " %"<< endl;
|
||||
errorCount++;
|
||||
}
|
||||
testCount++;
|
||||
}
|
||||
|
||||
Info << "End" << nl << endl;
|
||||
Info << errorCount << " / " << testCount << " End" << nl << endl;
|
||||
|
||||
return 0;
|
||||
if (errorCount == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue