Merge pull request #879 from OpenWaterAnalytics/dev-leakage_NAN_fix

Avoid possible NAN in leakage.c
This commit is contained in:
Lew Rossman
2025-09-12 13:18:20 -04:00
committed by GitHub

View File

@@ -7,7 +7,7 @@
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 06/14/2024
Last Updated: 09/10/2025
******************************************************************************
*/
/*
@@ -432,12 +432,15 @@ int leakagehasconverged(Project *pr)
// Directly compute a reference leakage at this pressure head
qref = 0.0;
// Contribution from pipes with fixed area leaks
if (hyd->Leakage[i].cfa > 0.0)
qref = sqrt(h / hyd->Leakage[i].cfa);
// Contribution from pipes with variable area leaks
if (hyd->Leakage[i].cva > 0.0)
qref += pow((h / hyd->Leakage[i].cva), 1.5);
if ( h > 0.0)
{
// Contribution from pipes with fixed area leaks
if (hyd->Leakage[i].cfa > 0.0)
qref = sqrt(h / hyd->Leakage[i].cfa);
// Contribution from pipes with variable area leaks
if (hyd->Leakage[i].cva > 0.0)
qref += pow((h / hyd->Leakage[i].cva), 1.5);
}
// Compare reference leakage to solution leakage
qtest = hyd->Leakage[i].qfa + hyd->Leakage[i].qva;