Change ValveType with EPANET MATLAB Toolkit (EMT)


#1

Hi all,
Is it possible to change the type of valve with EPANET MATLAB Toolkit (EMT)?
for example I have 2 PRV valves at my network. I want to change them to FCV valve in my code by EMT.?!?

Thanks,
Alireza Moghaddam


#2

Hi,
I don’t know how can I change the type of valve, but if you can’t change them, to delete and create valve can be alternative.
There is command “d.addLinkValve***”.

Thanks,

C.E.Kim


#3

Dear @ChungeonKim,

I set the valves in my network and I want to define the type of valve by EMT.
My aim is pressure engagement and minimization of leakage at network by finding a appropriate combination of control valves such as TCV and PRV.

Thanks,


#4

It is not possible to change valve types in EPANET, though it is trivial to add support for that in EPANET code.


#5

There is a function ENsetlinktype but it does not work. https://github.com/OpenWaterAnalytics/EPANET/issues/305


#6

@alireza2032, you can check this version of EMT v2.1.7

d.setLinkTypePipe(‘Your Link ID’);
d.setLinkTypePipeCV(‘Your Link ID’);
d.setLinkTypePump(‘Your Link ID’);
d.setLinkTypeValveFCV(‘Your Link ID’);
d.setLinkTypeValveGPV(‘Your Link ID’);
d.setLinkTypeValvePBV(‘Your Link ID’);
d.setLinkTypeValvePRV(‘Your Link ID’);
d.setLinkTypeValvePSV(‘Your Link ID’);
d.setLinkTypeValveTCV(‘Your Link ID’);


#7

@Mariosmsk, Thanks a lot for updating EMT to version 2.1.7 and adding new capabilities.

I checked my code with new ‘epanet.m’ but I get a error :

Index exceeds matrix dimensions.
Error in epanet/BinUpdateClass (line 3856)
obj.BinPatternMatrix(i,j)=single(obj.BinPatternValue{i}(j));
Error in leakage(line 12)
d.BinUpdateClass;

I didn’t get this error with the previous version.


#8

Dear Mariosmsk

Dll file of these new functions is available?. which it is used in VBA language environment .


#9

Try now! I have updated the code. epanet.m
thanks!


#10

For these functions, I have mainly used ENgetlinknodes, ENdeletelink and ENaddlink.


#11

Dear @Mariosmsk, Thanks, the problem was solved and It run correctly. That’s perfect.

But in my code I use two function "d.addBinControl and then “d.getControls” for valves setting. For exapmle c=d.getControls, in last epanet.m class the c matrix was cell and when I use new epanet.m class c matrix convert to struct in MATLAB.

I may can solve this problem in another way but I want to share it with you.


#12

@alireza2032, yes this an old update for the control functions issue.
If you use EMT on windows, I suggest you to use this EMT v2.2edit . Contains the current dlls from epanet. Note: The EMT branch dev-2.2-edit it’s my current working branch.

e.g.
d.addControls(‘LINK 9 OPEN IF NODE 2 BELOW 110’)
d.setControls(1, ‘LINK 9 CLOSED IF NODE 2 ABOVE 180’)


#13

@Mariosmsk, I replaced the the EMT v2.2edit files and the problem remains.

I attached both of new and old of c matrix in . mat format for more detail (newc.mat and oldc.mat respectively).
Thanks.


#14

This is not a problem. It’s the update of the function d.getControls.


#15

OK, That’s great.
@Mariosmsk, Thanks a lot for answering to my comments…


#16

@Mariosmsk, I use EMT v2.2edit and I have several controls for PRVs setting.
I add them by d.addControls but when I use the d.getControls function I get a irregular number for time:

e.g.
d.addControls(‘LINK PRV-4 43.2392 AT TIME 4:00:00’)

d.getControls(1)

ans=

   Type: 'TIMER'
 LinkID: 'PRV-4'
Setting: 43.2392
 NodeID: NaN
  Value: -2.1475e+09
Control: 'LINK PRV-4 43.2392 AT TIME -2147483648'

#17

Thanks @alireza2032. Fixed here epanet.m


#18

Thanks @Mariosmsk, It’ solved.
Is it possible to write this example with d.setControls function. I tested but get error.

e.g:
d.setControls(1,‘LINK PRV-4 43.2392 AT TIME 4:00:00’)

Error using epanet>setControlFunction (line 11618)
refers to undefined control

Error in epanet/setControls (line 2416)
setControlFunction(obj, i, tmpC{j});


#19

@alireza2032, “refers to undefined control”. So, your epanet input file haven’t control with index 1.
e.g.
index = d.addControls(‘LINK 9 43.2392 AT TIME 4:00:00’);
d.getControls(index)
d.setControls(index, ‘LINK 9 43.2392 AT TIME 14:00:00’);
d.getControls(index)


#20

@Mariosmsk, Thanks a lot,
As before I said, I have several controls for PRVs which I add them by d.addBinControl function in last version, all-together.
But in new version, I add them by d.addControls function in an iteration loop that the speed of my program reduce.