Closed Shang2000 closed 3 months ago
Yes, this should be corrected in the tankmix1
function of qualreact.c as follows:
if (seg)
{
vnew = seg->v + vin;
if (vnew > 0.0) seg->c = (seg->c * seg->v + win) / vnew;
seg->v += vnet;
seg->v = MAX(0.0, seg->v);
seg->v = MIN(seg->v, tank->Vmax); // <--- new line
tank->C = seg->c;
}
The chart below shows the tracer concentration in a 50-ft diameter tank receiving a constant 109.3 gpm inflow with 100 mg/L of tracer in it. The tank has a maximum depth of 20 ft and is initially filled to 18 ft with a tracer concentration of 50 mg/L. It takes 4 hours for the tank to become full after which it overflows. The original and corrected results are compared on the chart.
We see that because the corrected code limits the volume of the tank's single water quality segment the concentration from mixing its inflow with its current volume produces a larger concentration than the unrestricted volume from the original code since that segment volume (plus the inflow volume) appears in the denominator of the mixing equation.
A similar update should be added to tankmix2
as follows:
if (vt > 0.0)
{
mixzone->v = vmz;
if (vnet > 0.0) stagzone->v += vt;
else stagzone->v = MAX(0.0, ((stagzone->v) - vt));
stagzone->v = MIN(stagzone->v, ((tank->Vmax) - vmz)); //<--- new line
}
Thank you Lew. I would suggest adding the overflown mass into Massbalance.outflow. That will make the mass balance ratio to be 1.
if (seg)
{
vnew = seg->v + vin;
if (vnew > 0.0) seg->c = (seg->c * seg->v + win) / vnew;
seg->v += vnet;
seg->v = MAX(0.0, seg->v);
pr->quality.MassBalance.outflow += (seg->v - MIN(seg->v, tank->Vmax)) * seg->c; //<--- newline
seg->v = MIN(seg->v, tank->Vmax); // <--- newline
tank->C = seg->c;
}
This issue has been addressed in PR #771 and can be closed.
I am not sure whether it is a known issue. I searched and did not find related information. When a tank is overflowing, the volume in Tank (STANK.V) is kept constant. However the WQ segment volume (Pseg->v) in the tankmix function keeps increasing, leading to very large volume used in tank water quality calculation. Should overflown volume be taken out of the segment volume?