Corrections to 2-compartment tank mixing

Fixes volume remaining in mixing zone when there is net outflow from a 2-compartment tank.
This commit is contained in:
Lew Rossman
2024-12-16 23:30:32 -05:00
parent fbd005d604
commit 626b93a10f

View File

@@ -7,7 +7,7 @@ Description: computes water quality reactions within pipes and tanks
Authors: see AUTHORS Authors: see AUTHORS
Copyright: see AUTHORS Copyright: see AUTHORS
License: see LICENSE License: see LICENSE
Last Updated: 03/12/2024 Last Updated: 12/16/2024
****************************************************************************** ******************************************************************************
*/ */
@@ -566,10 +566,10 @@ void tankmix2(Project *pr, int i, double vin, double win, double vnet)
// Update segment volumes // Update segment volumes
if (vt > 0.0) if (vt > 0.0)
{ {
mixzone->v = vmz;
if (vnet > 0.0) if (vnet > 0.0)
{ {
stagzone->v += vt; mixzone->v = vmz;
stagzone->v += vt;
// Account for mass lost in overflow from stagnant zone // Account for mass lost in overflow from stagnant zone
vsz = (tank->Vmax) - vmz; vsz = (tank->Vmax) - vmz;
@@ -579,14 +579,18 @@ void tankmix2(Project *pr, int i, double vin, double win, double vnet)
stagzone->v = vsz; stagzone->v = vsz;
} }
} }
else stagzone->v = MAX(0.0, ((stagzone->v) - vt)); else
{
stagzone->v = MAX(0.0, ((stagzone->v) - vt));
mixzone->v = vmz + vt + vnet;
}
} }
else else
{ {
mixzone->v += vnet; mixzone->v += vnet;
mixzone->v = MIN(mixzone->v, vmz); mixzone->v = MIN(mixzone->v, vmz);
mixzone->v = MAX(0.0, mixzone->v); mixzone->v = MAX(0.0, mixzone->v);
stagzone->v = 0.0; if (vmz - mixzone->v > 0.0) stagzone->v = 0.0;
} }
// Use quality of mixing zone to represent quality of // Use quality of mixing zone to represent quality of