Avoid possible divide by zero in hydcoeffs.c
@@ -799,9 +799,13 @@ void pumpcoeff(Project *pr, int k)
// Adjust head loss coefficients for pump speed
h0 = SQR(setting) * pump->H0;
n = pump->N;
+ if (ABS(n - 1.0) < TINY) n = 1.0;
r = pump->R * pow(setting, 2.0 - n);
// Compute head loss and its gradient
+ // ... pump curve is nonlinear
+ if (n != 1.0)
+ {
// ... use linear approx. to pump curve for small flows
qa = pow(hyd->RQtol / n / r, 1.0 / (n - 1.0));
if (q <= qa)
@@ -816,6 +820,13 @@ void pumpcoeff(Project *pr, int k)
hloss = h0 + hgrad * hyd->LinkFlow[k] / n;
}
}
+ // ... pump curve is linear
+ else
+ {
+ hgrad = r;
+ hloss = h0 + hgrad * hyd->LinkFlow[k];
+ }
+ }
// P and Y coeffs.
hyd->P[k] = 1.0 / hgrad;
