Limit relative roughness to avoid singularity in Haaland friction factor calculations

This commit is contained in:
Vegard Kippe
2025-02-03 15:33:31 +01:00
parent 6bdbb6abdf
commit 86e47384dd

View File

@@ -54,12 +54,14 @@ ValueType haalandFormular(const ValueType& re,
const Scalar diameter, const Scalar diameter,
const Scalar roughness) const Scalar roughness)
{ {
const ValueType value = -3.6 * log10(6.9 / re + std::pow(roughness / (3.7 * diameter), 10. / 9.) ); // Since we currently do not guard for high roughness values in input we can end up with unrealistic friction factors.
// In particular, there could be a singularity in f(Re) if 1 \in image(X) in log10(X) below. In calculations we therefore
// sqrt(1/f) should be non-positive // limit the relative roughness to ensure the singularity never occurs in the relevant range (Re >= 4000).
assert(value >= 0.0); assert( re >= 4000. );
constexpr Scalar MAX_REL_ROUGHNESS = 3.7 * std::pow((1.0 - 1.0e-6) - 6.9/4000.0, 9. / 10.);
return 1. / (value * value); const Scalar rel_roughness = std::min(MAX_REL_ROUGHNESS, roughness/diameter);
const ValueType value = -3.6 * log10(6.9 / re + std::pow(rel_roughness / 3.7, 10. / 9.) );
return 1.0 / (value*value);
} }
// water in oil emulsion viscosity // water in oil emulsion viscosity