Skip to content

Commit

Permalink
Corrections to 2-compartment tank mixing
Browse files Browse the repository at this point in the history
Fixes volume remaining in mixing zone when there is net outflow from a 2-compartment tank.
  • Loading branch information
LRossman committed Dec 17, 2024
1 parent fbd005d commit 626b93a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/qualreact.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description: computes water quality reactions within pipes and tanks
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 03/12/2024
Last Updated: 12/16/2024
******************************************************************************
*/

Expand Down Expand Up @@ -566,10 +566,10 @@ void tankmix2(Project *pr, int i, double vin, double win, double vnet)
// Update segment volumes
if (vt > 0.0)
{
mixzone->v = vmz;
if (vnet > 0.0)
{
stagzone->v += vt;
mixzone->v = vmz;
stagzone->v += vt;

// Account for mass lost in overflow from stagnant zone
vsz = (tank->Vmax) - vmz;
Expand All @@ -579,14 +579,18 @@ void tankmix2(Project *pr, int i, double vin, double win, double vnet)
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
{
mixzone->v += vnet;
mixzone->v = MIN(mixzone->v, vmz);
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
Expand Down

0 comments on commit 626b93a

Please sign in to comment.