OpenWaterAnalytics / EPANET

The Water Distribution System Hydraulic and Water Quality Analysis Toolkit
MIT License
279 stars 204 forks source link

EN_saveinpfile creates invalid controls for GPV valves #671

Closed lbutler closed 2 years ago

lbutler commented 2 years ago

If you have a model which uses open/close controls on a GPV valve, using en_saveinpfile will create controls that references the index of the head loss curve instead of the status.

Original Controls

[CONTROLS]
LINK THE_VALVE  Open    If Node VALVE_DOWN  Below   0
LINK THE_VALVE  Closed  If Node VALVE_DOWN  Above   10

EN_saveinpfile Controls

[CONTROLS]
 LINK THE_VALVE 2.0000 IF NODE VALVE_DOWN BELOW 0.0000
 LINK THE_VALVE 2.0000 IF NODE VALVE_DOWN ABOVE 10.0000

The replit below runs a working network with a controlled GPV, saves it as a new INP and attempt to open it, which fails. You can see the original INP network.inp and the generated one network-by-toolkit.inp on the side panel

https://replit.com/@lbutler1/epanet-devGPV-save-inp#main.c

lbutler commented 2 years ago

Fix has now been merged, thanks @eladsal!