Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
WaterDesk opened this issue Jun 11, 2023 · 0 comments

Comments

@WaterDesk
Copy link
Contributor

@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:

case CONCEN:
switch (node->type())
{
// ... for junctions, outflow quality is the node's quality plus the
// source's quality times the fraction of outflow to the network
// contributed by external inflow (i.e., negative demand)
// NOTE: qualSource.outflow is flow in links leaving the node,
// node->outflow is node's external outflow (demands, etc.)
case Node::JUNCTION:
if ( node->outflow < 0.0 )
{
quality += strength * (-node->outflow / outflow);
}
break;

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant