Commit 2afd807f authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: avoid floating point comparison with uint8_t in DSMCCloud

parent 688ff626
......@@ -997,35 +997,32 @@ Foam::scalar Foam::DSMCCloud<ParcelType>::equipartitionInternalEnergy
direction iDof
)
{
scalar Ei = 0.0;
if (iDof < SMALL)
if (iDof == 0)
{
return Ei;
return 0;
}
else if (iDof < 2.0 + SMALL && iDof > 2.0 - SMALL)
else if (iDof == 2)
{
// Special case for iDof = 2, i.e. diatomics;
Ei =
-log(rndGen_.sample01<scalar>())
*physicoChemical::k.value()*temperature;
return
(
-log(rndGen_.sample01<scalar>())
*physicoChemical::k.value()*temperature
);
}
else
{
scalar a = 0.5*iDof - 1;
scalar energyRatio;
scalar P = -1;
do
{
energyRatio = 10*rndGen_.sample01<scalar>();
P = pow((energyRatio/a), a)*exp(a - energyRatio);
} while (P < rndGen_.sample01<scalar>());
Ei = energyRatio*physicoChemical::k.value()*temperature;
}
const scalar a = 0.5*iDof - 1;
scalar energyRatio = 0;
scalar P = -1;
do
{
energyRatio = 10*rndGen_.sample01<scalar>();
P = pow((energyRatio/a), a)*exp(a - energyRatio);
} while (P < rndGen_.sample01<scalar>());
return Ei;
return energyRatio*physicoChemical::k.value()*temperature;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment