Skip to content

Commit

Permalink
Fix #57 - save2psse() used 1 for CKT num, even for parallel branches …
Browse files Browse the repository at this point in the history
…or transformers.

Thanks to Amin Gholami.

Ref: #57
  • Loading branch information
rdzman committed Jan 18, 2019
1 parent 62da553 commit 7841457
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ For change history for [MOST][3], see [most/CHANGES.md](most/CHANGES.md).
Since last release
------------------

#### 1/17/19
- Fix [bug #57][16] where `save2psse()` always used 1 for the CKT
number, even for parallel branches or transformers.
*Thanks to Amin Gholami.*

#### 1/17/19
- Fix [bug #56][15] where `save2psse()` was missing entries for two
transformer columns (`VMA1` and `VMI1`).
Expand Down Expand Up @@ -2802,3 +2807,4 @@ First Public Release – *Jun 25, 1997*
[13]: https://github.com/MATPOWER/matpower/issues/53
[14]: https://github.com/MATPOWER/matpower/issues/52
[15]: https://github.com/MATPOWER/matpower/issues/56
[16]: https://github.com/MATPOWER/matpower/issues/57
3 changes: 2 additions & 1 deletion docs/src/MATPOWER-manual/MATPOWER-manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
%\title{\hl{--- DRAFT ---}\\\hl{\em do not distribute}\\~\\\matpower{} \mpver{}\\User's Manual}
\title{User's Manual}
\author{Ray~D.~Zimmerman \and Carlos~E.~Murillo-S\'anchez}
\date{October 31, 2018} % comment this line to display the current date
%\date{October 31, 2018} % comment this line to display the current date
%\date{December 14, 2011\thanks{Second revision. First revision was December 13, 2011}} % comment this line to display the current date

%%% BEGIN DOCUMENT
Expand Down Expand Up @@ -8036,6 +8036,7 @@ \subsubsection*{Bugs Fixed}
\item Fix bug \#26 where, in a continuation power flow, a reactive limit at a bus could be detected in error if multiple generators at the bus had reactive ranges of very different sizes. \emph{Thanks to Elis Nycander and Shrirang Abhyankar.}
\item Fix \code{runpf} handling of case where individual power flow fails during Q limit enforcement.
\item Fix bug \#56 where \code{save2psse} was missing entries for two transformer columns, namely, \code{VMA1} and \code{VMI1}). \emph{Thanks to Amin Gholami.}
\item Fix bug \#57 where \code{save2psse} always used 1 for the \code{CKT} number, even for parallel branches or transformers. \emph{Thanks to Amin Gholami.}
\end{itemize}

\subsubsection*{Incompatible Changes}
Expand Down
21 changes: 19 additions & 2 deletions lib/save2psse.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@
if nl
%% I, J,CKT, R, X, B,RATEA,RATEB,RATEC,GI,BI,GJ, BJ, ST,MET,LEN, O1, F1,..., O4, F4
fprintf(fd, '%6d, %6d, %d, %8.7g, %8.7g, %8.7g, %7g, %7g, %7g, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n', ...
[ mpc.branch(il, [F_BUS T_BUS]) ones(nl, 1) ...
[ mpc.branch(il, [F_BUS T_BUS]) ...
generate_ckt_num(mpc.branch(il, [F_BUS T_BUS])) ...
mpc.branch(il, [BR_R BR_X BR_B RATE_A RATE_B RATE_C]) ...
zeros(nl, 4) mpc.branch(il, [BR_STATUS]) ones(nl, 1) ...
zeros(nl, 1) ones(nl, 2) zeros(nl, 1) ones(nl, 1) ...
Expand All @@ -159,7 +160,8 @@
%% I, J, K,CKT, CW, CZ, CM, MAG2, 'NAME', O1, F1, O2, F2, O3, F3, O4, F4, VECGRP\n X1-2, NOMV1,ANG1, RATB1, COD1, RMA1, VMA1, NTP1, CR1,CX1, WINDV2,
%% MAG1, NMETR, STAT, R1-2,SBASE1-2\n WINDV1,RATA1, RATC1, CONT1, RMI1, VMI1, TAB1, CNXA1\n NOMV2\n
fprintf(fd, '%6d, %6d, %d, %d, %d, %d, %d, %d, %d, %d, '' '', %d, %d, %d, %d, %d, %d, %d, %d, %d, '' ''\n%g, %g, %g\n%5g, %d, %5g, %7g, %7g, %7g, %d, %d, %g, %g, %g, %g, %d, %d, %g, %g, %g\n%5g, %g\n', ...
[ mpc.branch(it, [F_BUS T_BUS]) zeros(nt, 1) ones(nt, 4) ...
[ mpc.branch(it, [F_BUS T_BUS]) zeros(nt, 1) ...
generate_ckt_num(mpc.branch(it, [F_BUS T_BUS])) ones(nt, 3) ...
zeros(nt, 2) 2*ones(nt, 1) mpc.branch(it, BR_STATUS) ones(nt, 2) ...
zeros(nt, 1) ones(nt, 1) zeros(nt, 1) ones(nt, 1) ...
zeros(nt, 1) ones(nt, 1) ... %% end of line 1
Expand Down Expand Up @@ -255,3 +257,18 @@
if nargout > 0
fname_out = fname;
end


function ckt = generate_ckt_num(ft, ckt)
% returns a vector of circuit numbers given a 2-col matrix of from/to bus nums
% where duplicate pairs get incremented ckt numbers
n = size(ft, 1);
if nargin < 2
ckt = zeros(n, 1);
end
ckt = ckt + 1;
[Au, iA, iAu] = unique(ft, 'rows', 'first');
k = find(~ismember([1:n]', iA));
if k
ckt(k) = generate_ckt_num(ft(k, :), ckt(k));
end
3 changes: 3 additions & 0 deletions lib/t/t_case9_save2psse.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@
1 4 0 0.0576 0 250 250 250 0 0 1 -360 360;
4 5 0.017 0.092 0.158 250 250 250 0 0 1 -360 360;
5 6 0.039 0.17 0.358 150 150 150 0 0 1 -360 360;
4 5 0.017 0.092 0.158 250 250 250 0 0 1 -360 360;
3 6 0 0.0586 0 300 300 300 0 0 1 -360 360;
6 7 0.0119 0.1008 0.209 40 150 150 0 0 1 -360 360;
6 7 0.0119 0.1008 0.209 40 150 150 0 0 1 -360 360;
7 8 0.0085 0.072 0.149 250 250 250 0 0 1 -360 360;
6 7 0.0119 0.1008 0.209 40 150 150 0 0 1 -360 360;
8 2 0 0.0625 0 250 250 250 0 0 1 -360 360;
8 9 0.032 0.161 0 250 250 250 0.935 0 1 -360 360;
9 4 0.01 0.085 0 250 250 250 0 5 1 -360 360;
Expand Down
3 changes: 3 additions & 0 deletions lib/t/t_case9_save2psse.raw
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
1, 4, 1, 0, 0.0576, 0, 250, 250, 250, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1
4, 5, 1, 0.017, 0.092, 0.158, 250, 250, 250, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1
5, 6, 1, 0.039, 0.17, 0.358, 150, 150, 150, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1
4, 5, 2, 0.017, 0.092, 0.158, 250, 250, 250, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1
3, 6, 1, 0, 0.0586, 0, 300, 300, 300, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1
6, 7, 1, 0.0119, 0.1008, 0.209, 40, 150, 150, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1
6, 7, 2, 0.0119, 0.1008, 0.209, 40, 150, 150, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1
7, 8, 1, 0.0085, 0.072, 0.149, 250, 250, 250, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1
6, 7, 3, 0.0119, 0.1008, 0.209, 40, 150, 150, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1
8, 2, 1, 0, 0.0625, 0, 250, 250, 250, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1
0 / END OF BRANCH DATA, BEGIN TRANSFORMER DATA
8, 9, 0, 1, 1, 1, 1, 0, 0, 2, ' ', 1, 1, 1, 0, 1, 0, 1, 0, 1, ' '
Expand Down

0 comments on commit 7841457

Please sign in to comment.