OpenWaterAnalytics / EPANET

The Water Distribution System Hydraulic and Water Quality Analysis Toolkit
MIT License
283 stars 206 forks source link

Quality simulation exhibits mass imbalance problem #160

Closed samhatchett closed 6 years ago

samhatchett commented 6 years ago

discovered and documented by Rob Janke, USEPA

http://community.wateranalytics.org/t/mass-imbalances-in-epanet-water-quality-simulations/521

samhatchett commented 6 years ago

more info here: https://www.drink-water-eng-sci.net/11/25/2018/

samhatchett commented 6 years ago

The modifications proposed in the referenced paper are quite extensive

A short-term strategy could be to add logic to check for mass imbalance as a halting condition - if such is found, then output the appropriate text into the report file, indicating that the quality timestep should be reduced.

LRossman commented 6 years ago

My testing has shown that using the existing water quality solver with the nodes pre-sorted from upstream to downstream (i.e., processing them topologically instead of in the order they appear in the input file) eliminates the mass balance errors almost entirely. It will still tend to smear out very short term concentration spikes which the Davis/Janke/Taxon method will preserve, but will be faster to run. Plus since the latter method ignores dispersion, it's apparent higher numerical accuracy will not necessarily be what actually occurs.

samhatchett commented 6 years ago

@LRossman - i didn't know you were working to resolve this. Are you doing anything related to Tom Taxon's work? What is your approach? I'm excited!

LRossman commented 6 years ago

@samhatchett see my May 22 comment above. It uses node sorting as in Taxon's approach but otherwise still keeps the same dynamic pipe volume segment methodology of the current EPANET. However the sequence of steps changes. In current EPANET it is:

  1. For all links, accumulate flow volume and mass into their downstream nodes.
  2. For all nodes, compute a new water quality value from their accumulated inflow.
  3. For all links, release flow volume into them at the new upstream node quality.

The new sequence looks as follows:

  1. Examine the next node in topological sequence.
  2. For each of its inflowing links, transport flow volume and mass into the node (where a new quality has already been computed for the upstream end of the link)
  3. Mix together the node's inflows to produce a new quality for the node.
  4. For each outflow link from the node, send flow volume at the new quality into it and proceed to the next topologically sorted node.

This new approach gets around the problem of losing (or gaining) mass flow for links whose time of travel is less than the quality time step. I've already coded it in my private version of the C++ epanet-dev and tested it against the networks in the Davis/Taxon/Janke paper mentioned above.

michaeltryby commented 6 years ago

@LRossman This sounds great! Curious if you are you going to compute the mass balance?

LRossman commented 6 years ago

@michaeltryby yes, definitely -- that's the whole point of doing this. Only it's not possible to compare improvement in mass balance with current EPANET since that metric was never computed (my bad). I added that calculation to a private version of EPANET that I shared with Tom Taxon and Rob Janke when they were doing their work (although I think they moved on to using their own code) and that's how I discovered that for some network models it is indeed an issue. These tend to be the ones with short duration contaminant injections. EPS for continuous releases like for chlorine or source tracing tend to look much better.