From 35aa9f8e081e7f6d000536bda7779648a6aca60e Mon Sep 17 00:00:00 2001 From: chrisgs Date: Tue, 18 Aug 2020 16:44:33 +0100 Subject: [PATCH] Fix vmin calculation Multiply area by `Hmin - elevation` instead of just `Hmin`. --- src/epanet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/epanet.c b/src/epanet.c index be8c83d..0f6fb12 100644 --- a/src/epanet.c +++ b/src/epanet.c @@ -2411,7 +2411,7 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int property, double valu // Since the volume curve no longer applies we assume that the tank's // shape below Hmin is cylindrical and Vmin equals area times Hmin - Tank[j].Vmin = Tank[j].A * Tank[j].Hmin; + Tank[j].Vmin = Tank[j].A * (Tank[j].Hmin - Node[index].El); } // Since tank's area has changed its volumes must be updated // NOTE: For a non-volume curve tank we can't change the Vmin @@ -2444,7 +2444,7 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int property, double valu // If the volume supplied by the function is 0 then the tank shape // below Hmin is assumed to be cylindrical and a new Vmin value is // computed. Otherwise Vmin is set to the supplied value. - if (value == 0.0) Tank[j].Vmin = Tank[j].A * Tank[j].Hmin; + if (value == 0.0) Tank[j].Vmin = Tank[j].A * (Tank[j].Hmin - Node[index].El); else Tank[j].Vmin = value / Ucf[VOLUME]; // Since Vmin changes the other volumes need updating @@ -2672,7 +2672,7 @@ int DLLEXPORT EN_settankdata(EN_Project p, int index, double elev, if (curveIndex == 0) { if (minvol > 0.0) Tank[j].Vmin = minvol / Ucf[VOLUME]; - else Tank[j].Vmin = Tank[j].A * Tank[j].Hmin; + else Tank[j].Vmin = Tank[j].A * (Tank[j].Hmin - elev / Ucf[ELEV]); } else Tank[j].Vmin = tankvolume(p, j, Tank[j].Hmin); Tank[j].V0 = tankvolume(p, j, Tank[j].H0);