Set multiple base demand and multiple pattern in EPANET-Matlab toolkit


#1

Hello all,

Is it possible to define a example for setting multiple base demand and multiple pattern in EPANET-Matlab toolkit.

Thanks,
Alireza Moghaddam


#2

Hi @alireza2032,

Like that?

% load net
d = epanet('Net1.inp');
% add pattern
d.addPattern('P-2');

% base demands
values = d.getNodeBaseDemands
values{1}(2)=200; 
d.setNodeBaseDemands(values)
d.getNodeBaseDemands{1} %categories 1

% demand patterns
values = d.getNodeDemandPatternIndex
values{1}(1)=2;
d.setNodeDemandPatternIndex(values)
d.getNodeDemandPatternIndex{1}

#3

Thanks Dear Mariosmsk,
It helped me a lot and worked correctly.


#4

Dear @Mariosmsk ,
If there is 2 NodeDemandPatternIndex and I want to make changes in 2th pattern, the code doesn’t work. for example:

I have 3 pattern at my network and I want to change second demand pattern for one of nodes in categories 1:

% demand patterns
values = d.getNodeDemandPatternIndex
values{2}(1)=3;
d.setNodeDemandPatternIndex(values)
d.getNodeDemandPatternIndex{1}

the above code does’t work.


#5

@Mariosmsk ,
Also is it possible to write this example with Bin EPANET-MATLAB toolkit function?
Thanks.


#6

Hi, @alireza2032,
In order to determine the demand in other categories, there must already be a category at the node. You can do the INP and post-processing. Also, there is not a pattern index 3 (eg d.getPatternIndex).


#7

Is not possible with Bin EMT. Categories not supported yet.


#8

Hi, @Mariosmsk
for example, in below pictures:
I created 3 pattern in Net1.inp which called 1, 2_contamin, Fire and is highlighted.
My aim is adding another Basedemand equal to 65 GPM to junction id ‘32’ with pattern ‘Fire’ (is highlighted) using EMT. I can add Basedemand=65 with your code but I couldn’t set pattern Index ‘3’ to it.
This is part of a optimization algorithm process on all of junction as random. For this process firstly, I make a another Basedemand=0 in .inp file for all junction and save it.

% base demands
values = d.getNodeBaseDemands
values{2}(9)=65;
d.setNodeBaseDemands(values)
d.getNodeBaseDemands{2} %categories 1

% demand patterns
values = d.getNodeDemandPatternIndex
values{2}(9)=3;
d.setNodeDemandPatternIndex(values)
d.getNodeDemandPatternIndex{2}

.


#9

net1_v3.inp (7.1 KB)

I 've edited the file to add 2 categories for all junctions. You can test this!

   [DEMANDS]
    ;Junction        	Demand      	Pattern         	Category
     10              	0           	                	; 
     10              	0           	                	; 
     11              	0           	                	; 
     11              	150         	                	; 
     12              	0           	                	; 
     12              	150         	                	; 
     13              	0           	                	; 
     13              	100         	                	; 
     21              	0           	                	; 
     21              	150         	                	; 
     22              	0           	                	; 
     22              	200         	                	; 
     23              	0           	                	; 
     23              	150         	                	; 
     31              	0           	                	; 
     31              	100         	                	; 
     32              	0           	                	; 
     32              	100         	                	;

#10

Thanks @Mariosmsk,
I 've tested but it didn’t work correctly for demand pattern, too. I get below answer:

% base demands
values = d.getNodeBaseDemands
values{1}(9)=65;
d.setNodeBaseDemands(values)
d.getNodeBaseDemands{1} %categories 1

ans =

 0     0     0     0     0     0     0     0    65     0     0

% demand patterns
values = d.getNodeDemandPatternIndex
values{1}(9)=3;
d.setNodeDemandPatternIndex(values)
d.getNodeDemandPatternIndex{1}

ans =

 1     1     1     1     1     1     1     1     1     0     0

#11

It’s good for me. Make sure you use ΕΜΤ v2.1.6


#12

Dear @Mariosmsk,

That’s right. It’s work correctly.

Thanks a lot,
Alireza Moghaddam