epanet-dev icon indicating copy to clipboard operation
epanet-dev copied to clipboard

Quality results (inflow junction with quality source "Concentration") are different between EPA 3.0 and 2.0

Open WaterDesk opened this issue 1 year ago • 0 comments

@LRossman We found an issue when run quality simulation on a model with an inflow junction (negative demand). We don't quite understand this and would like to ask for your help. Thanks.

Run the inflow-junction_quality.zip in both epanet 2.0 and epanet 3.0 engines.

The junction J00001 has set with Source Quality as 0.45 and Concentration type. The results are different, see below graphs:

1686481947509

1686482157874

Comparing the source quality code between the two versions:

main code difference

  • EPANET 3.0: quality += strength * (-node->outflow / outflow); the quality is the node's quality plus the source's quality as the code comments.
  • EPANET 2.0: c = -c * hyd->NodeDemand[n] * tstep / volout; the quality is fixed to the source quality as manual said. (without plus current node's quality).

I tried a code change on EPANET3.0, (remove the plus). quality = strength * (-node->outflow / outflow); The result was same as EPANET2.0.

So, there is my puzzle: the code comments for EPANET 3.0 looks reasonable. But the result looks bad, is the quality formula's issue? Take an extreme case, the inflow junction is an end of a pipe and start of another pipe. So, the quality value should be the (quality * pipe_flow + source_quality * node_inflow) / (pipe_flow + node_inflow)? Or it is just a regression from EPANET 2.0? Just fix it by following EPANET 2.0.

code details for reference:

https://github.com/OpenWaterAnalytics/epanet-dev/blob/186744ed252a937398982f6707f5209f03501bd0/src/Elements/qualsource.cpp#L71-L84

https://github.com/OpenWaterAnalytics/EPANET/blob/789d42f2483e5b2a65094469ff964bf04e31a83d/src/quality.c#L487-L502

    // Added source concentration depends on source type
    c = sourcequal(pr, source);
    switch (source->Type)
    {
        // Concentration Source:
        case CONCEN:
        if (net->Node[n].Type == JUNCTION)
        {
            // ... source requires a negative demand at the node
            if (hyd->NodeDemand[n] < 0.0)
            {
                c = -c * hyd->NodeDemand[n] * tstep / volout;
            }
            else c = 0.0;
        }
        break;

In the manual of EPANet 2.0, it says A concentration source fixes the concentration of any external inflow entering the network, such as flow from a reservoir or from a negative demand placed at a junction.

WaterDesk avatar Jun 11 '23 11:06 WaterDesk