How can I change/replace the values of multiplier demand pattern in epanet matlab toolkit

Hello all,
I have a EPANET file (Net1.inp) with a multiplier demand pattern(1). I want to replace it with new values. How can I change/replace the values of multiplier demand pattern (1) in EPANET-Matlab toolkit?

Thanks in advance,
Fatemeh Ata

Hello Fatemeh,
To do so, define your multipliers in a variable ‘x’, For example x = [0.5, 0.25, 0.1], then define the pattern as follows:

  • patternindex = d.addPattern(‘patternname’, x);

Afterwards, let y be the node indices you desire to change their demand pattern, for example y=[1,2,3], then use the following code:

  • d.setNodeDemandPatternIndex(y, repmat(patternindex,1,3))

Note that 3 is related to the three node indices in y.

Regards.

2 Likes

Hi,
I suggest the below function:

d.setPatternMatrix (x)

which x is the matrix of multiplier factors for all patterns.

2 Likes

Hi @Fatemeh,

Also, you can try
% Use d.getPatternIndex to get the patternIndex
d.setPattern(patternIndex, patternMult)

Sets all of the multiplier factors for a specific time pattern.
 
  Example:
    patternID = 'new_pattern';
    patternIndex = d.addPattern(patternID)    % Adds a new time pattern
    patternMult = [1.56, 1.36, 1.17, 1.13, 1.08, ...
        1.04, 1.2, 0.64, 1.08, 0.53, 0.29, 0.9, 1.11, ...
        1.06, 1.00, 1.65, 0.55, 0.74, 0.64, 0.46, ...
        0.58, 0.64, 0.71, 0.66];
    d.setPattern(patternIndex, patternMult)   % Sets the multiplier factors for the new time pattern
    d.getPattern                              % Retrieves the multiplier factor for all patterns and all times
1 Like

Thanks ever so much @mosi2x @alireza2032 @Mariosmsk
Regard,
Fatemeh Ata

Dear @Mariosmsk
I changed the value of Multiplier demand pattern in (Net1.inp) and ran the MATLAB code. but the pressure values in all nodes did not change during 24 hours. How can I solve the problem?
Thanks,

% load net
d = epanet(‘Net1.inp’);

demand_pattern_old = d.getPattern;

d.openHydraulicAnalysis;
d.initializeHydraulicAnalysis;
d.runHydraulicAnalysis;
ComputedNodePressure=d.getBinComputedNodePressure

% change Multiplier demand pattern
x=[0.1,0.25,0.2,0.3,0.4,0.2,0.1,0.2,0.6,0.5,0.7,0.3]

d.setPatternMatrix (x)
values = d.getPattern;

d.openHydraulicAnalysis;
d.initializeHydraulicAnalysis;
d.runHydraulicAnalysis;
New_ComputedNodePressure=d.getBinComputedNodePressure

Hi @Fatemeh,

I made some changes in your code, you can find below:

% load net
d = epanet('Net1.inp');

demand_pattern_old = d.getPattern;

res = d.getComputedTimeSeries;
ComputedNodePressure = res.Pressure;

% change Multiplier demand pattern
x = [0.1,0.25,0.2,0.3,0.4,0.2,0.1,0.2,0.6,0.5,0.7,0.3]

d.setPatternMatrix(x)
values = d.getPattern;

res = d.getComputedTimeSeries;
ComputedNodePressureNew = res.Pressure;
d.unload;

% Plots
figure;
plot(ComputedNodePressure);
title('With old patern');
figure;
plot(ComputedNodePressureNew);
title('With new patern');

Regards,
Marios

Hello,
Thank you very much for this code.It helped me a lot.