First of all, thank you for your carefully written and detailed report. The
bottom line is … you’re right.
This looks like a classic example of the aphorism “if you didn’t test it, it
doesn’t work”. This undocumented* feature was never covered in the test suite,
so this bug has been there since makePTDF() was first included in MATPOWER
3.1b2 in 2006.
So please do create a GitHub issue for it, as that will help me keep track of
it. I hope to work on the fix shortly.
Once again, thanks for the report.
Ray
*Technically, this ability to use a matrix to specify per-bus slack
distributions was never a supported/documented feature. The paragraph in the
comments that mentions it is intentionally below a blank line, so it does not
appear when you type help makePTDF. But it’s still clearly a bug.
On Feb 7, 2022, at 9:55 AM, Martinez Corral, Jon
<[email protected]<mailto:[email protected]>> wrote:
Hello,
I recently encountered some unexpected behaviour using the makePTDF function
and wasn’t sure if it was working as intended.
I have quite a large grid (22000 branches and 15000 buses) divided up into 21
areas. I would like to calculate the PTDF of the grid so that the slack for a
given bus is equally distributed among all the buses outside of the area the
bus in question belongs to. So if bus 1 belongs to area A the slack for the
calculation of the PTDF for bus 1 should be equally distributed among the buses
that are not inside area A. Making use of the functionalities implemented in
matpower 7.1 I could write a for-loop and create the appropriate slack column
with weights for each bus and then call makePTDF like:
H = MAKEPTDF(MPC, SLACK, BUS_IDX) % SLACK is nb x 1
which is unfortunately very time consuming. It should be able to prepare a
slack matrix of size nb x nb, where nb is the number of buses in the system,
where each column represents the weights of the slack for the given bus. So
basically taking the column vectors of the for-loop approach and concatenating
them horizontally. However, I’m not sure the makePTDF function performs the
calculation correctly when calling
H = MAKEPTDF(MPC, SLACK) % SLACK is nb x nb
with a slack matrix. Line 183 of the current version of makePTDF does
183 H = H * slack;
which differs from the implementation for a column slack in lines 165-181 where
it basically does
171 v = H * slack;
172 for k = 1:nb
173 H(:, k) = H(:, k) - v;
174 end
I believe line 183 should be rewritten to do something similar to lines 171-174
as in:
H = H - H * slack;
This delivers the same result as the first calculation with a for-loop and a
column vector.
Moreover, when working with a column slack, the function makes sure the weights
in the vector are normalized at line 165:
165 slack = slack/sum(slack); "
OutmailID: 126300925, List: 'matpower-l', MemberID: 82861091
SCRIPT: "normalize weights
However, when handling a matrix slack, no normalization is performed. This
could be solved by adding a line before line 183 such as:
slack = slack ./ sum(slack);"
TCL MERGE ERROR ( 02/11/2022 14:26:20 ): "invalid command name "normalize"
normalize weights for each column
If that were the case the normalization would be performed for every case with
a distributed slack, meaning this line would be valid for both a column and a
matrix slack and could be moved higher between both if clauses in lines
163-164, rendering:
163 if length(slack) ~= 1 && ~txfr
slack = slack ./ sum(slack); "
OutmailID: 126300925, List: 'matpower-l', MemberID: 82861091
SCRIPT: "normalize weights
164 if size(slack, 2) == 1"
TCL MERGE ERROR ( 02/11/2022 14:26:20 ): "invalid command name "normalize"
slack is a vector of weights
If the current implementation at line 183 is indeed correct, I would deeply
appreciate some help understanding the meaning of the calculation, because so
far I cannot get a grasp of it. If you need any additional information, a
working example or if I should create an issue on Github, please let me know
and I will gladly do so. I have attached the outcome of mpver in a txt file for
further context.
Thank you very much for the amazing toolbox you have created.
Kind regards,
Jon Martinez Corral
Amprion GmbH
Transmission System Operation
System Analysis
Von-Werth-Str. 274, 50259 Pulheim
T +49 2234 85-55422
M +49 174 2183826
[email protected]<mailto:[email protected]>
www.amprion.net<http://www.amprion.net/>
Information on data protection<https://www.amprion.net/data-protection/>
Aufsichtsrat/Supervisory Board: Uwe Tigges (Vorsitzender/Chairman)
Geschäftsführung/Executive Directors: Dr Hans-Jürgen Brick
(Vorsitzender/Chairman), Dr Hendrik Neumann, Peter Rüth
Sitz der Gesellschaft/Company domicile: Dortmund – Eingetragen beim/Registered
at Amtsgericht Dortmund – Handelsregister-Nr./Commercial Register no. HRB 15940
<Matpower_mpver.txt>