OpenWaterAnalytics / EPANET

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

Model a variable speed pump #530

Open shenh opened 5 years ago

shenh commented 5 years ago

Hello all, I am wondering if modeling a variable speed pump is on the roadmap. I understand you can specify pump utilization pattern or control to adjust pump speed. However, that requires me to know the speed ahead of time. Can we add a feature to have EPANET to automatically adjust pump speed to achieve target tank level, flow, or pressure? Thanks

Hailiang

samhatchett commented 5 years ago

if we can get around the patent issue (or wait on the 2030 expiration), then sure! I am not a Lawyer, but maybe there is a way to formulate the VFD control algorithm that does not infringe. https://patents.google.com/patent/US8265911B1/

shenh commented 5 years ago

This is one of the available algorithms. For example, a variable speed pump can also be modeled in InfoWater and Mike Urban. In EPANET, while iterating time steps for hydraulic simulation with functions EN_runH, EN_nextH, can we provide one function to NOT advance time to next step? This way, API users can try the following workflow: 1 record current time t 2 set one pump speed (e.g. 0.8), run EN_runH, EN_nextH 3 compare model results (e.g. a tank level) with target 4 if not met, restore all system variables (including hydraulics and water quality) to time t 5 loop steps 2-4 until the target is met If this workflow can be supported, some academic users may be able to devise a more efficient algorithm for implementation. At least a bisectional search algorithm can be easily developed - admittedly may not be efficient.

Also, I am not sure whether the PID algorithm in SWMM code can be ported in EPANET.

I know some modelers use other commercial software just to compute the speeds of a variable speed pump and use the calculated speeds for EPANET modeling. I am also not a lawyer, and not sure if this 'qualify' a case of competing with commercial software.

LRossman commented 5 years ago

Attached is source code for a v2.2 Toolkit extension that can model variable speed pumps to meet node pressure targets. It was tested on the example1 (aka net1) network with the storage tank removed. The graph below shows the pump speed needed to maintain 60 psi of pressure at Node 22 (as well as the node pressure for a constant fixed speed of 0.5).

image

The code can be used as a template for including a VSP feature directly into a future update of EPANET. EPANET-VSP.zip

samhatchett commented 5 years ago

@LRossman this is really nicely done. Where is AUTHORS and LICENSE?

shenh commented 5 years ago

Lew, this is excellent - another application of the rich set of APIs!

Can we also add a variable targetFlow to Tvsp? This way a VSP can also work for a target link flow. Alternatively, Tvsp could include a targetType (FLOW/PRESSURE) and a targetValue.

The VSP and its target node/link pressure/flow could be specified in a control rule.

LRossman commented 5 years ago

@shenh my posting was meant mainly to be a "proof of concept", showing how an alternative to the patented "Haestad Methods" procedure would work. If VSP's will actually be included in a future EPANET update then my code can serve as a blueprint for one way to do it. At that time we can address additional details, like adding flow targets, accommodating batteries of parallel pumps, and extending the Rule-Based Control language and the input file format to include VSPs.

By the way, although the secant search I used is not as technically elegant as Todini's method in the patented procedure, it probably requires less code to implement and resulted in only 3 to 4 additional hydraulic iterations per time period in the one example I ran (where the response curve of pressure to pump speed was almost linear - but we shouldn't generalize on this one case and a lot more testing is needed).

@samhatchett I guess I intended that AUTHORSand LICENSEbe the same as those being used by OWA/EPANET. BTW the latter's LICENSEfile still assigns copyright to Open Water Analytics. Shouldn't that be changed to "the authors" since OWA has no formal standing as an actual entity.

shenh commented 5 years ago

@LRossman Great to know it will be included in a future EPANET version. I will also test this template on some real-world networks and report back (e.g. convergence and the number of iterations).