Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPF: Change the continuation direction when the operating point moves… #25

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 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
------------------

#### 12/6/17
- Fix bug #23 where the continuation power flow could switch
directions unexpectedly when the operating point switched from
stable to unstable manifold or vice-versa after hitting a limit.

#### 11/29/17
- Add new option `knitro.maxit` to set maximum number of iterations
for AC OPF solver using Knitro.
Expand Down
10 changes: 6 additions & 4 deletions lib/cpf_tangent.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function z = cpf_tangent(V, lam, Ybus, Sbusb, Sbust, pv, pq, ...
zprv, Vprv, lamprv, parameterization)
zprv, Vprv, lamprv, parameterization, direction)
%CPF_TANGENT Computes normalized tangent predictor for continuation power flow
% Z = CPF_TANGENT(V, LAM, YBUS, SBUSB, SBUST, PV, PQ, ...
% Z, VPRV, LAMPRV, PARAMETERIZATION)
% ZPRV, VPRV, LAMPRV, PARAMETERIZATION, DIRECTION)
%
% Computes a normalized tangent predictor for the continuation power flow.
%
Expand All @@ -19,7 +19,9 @@
% ZPRV : normalized tangent prediction vector from previous step
% VPRV : complex bus voltage vector at previous solution
% LAMPRV : scalar lambda value at previous solution
% PARAMETERIZATION : Value of cpf.parameterization option.
% PARAMETERIZATION : value of cpf.parameterization option.
% DIRECTION: continuation direction (+1 for postive lambda
% increase, -1 otherwise)
%
% Outputs:
% Z : the normalized tangent prediction vector
Expand Down Expand Up @@ -68,6 +70,6 @@
%% compute normalized tangent predictor
z = zprv;
s = zeros(npv+2*npq+1, 1);
s(end,1) = 1; %% increase in the direction of lambda
s(end,1) = sign(direction);
z([pv; pq; nb+pq; 2*nb+1]) = J\s; %% tangent vector
z = z/norm(z); %% normalize tangent predictor
2 changes: 1 addition & 1 deletion lib/mpver.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
v{1} = struct( 'Name', 'MATPOWER', ...
'Version', '6.1-dev', ...
'Release', '', ...
'Date', '22-Nov-2017' );
'Date', '06-Dec-2017' );
if nargout > 0
if nargin > 0
rv = v{1};
Expand Down
22 changes: 19 additions & 3 deletions lib/runcpf.m
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@

%% initialize tangent predictor: z = [dx;dlam]
z = [zeros(2*nb, 1); 1];
z = cpf_tangent(V, lam, Ybus, Sbusb, Sbust, pv, pq, z, V, lam, parm);
direction = 1;
z = cpf_tangent(V, lam, Ybus, Sbusb, Sbust, pv, pq, ...
z, V, lam, parm, direction);

%% initialize state for current continuation step
cx = struct(... %% current state
Expand Down Expand Up @@ -456,8 +458,9 @@
else %% otherwise
tx = cx; %% use cx as the previous state
end
nx.z = cpf_tangent(nx.V, nx.lam, Ybus, cb_data.Sbusb, cb_data.Sbust, cb_data.pv, cb_data.pq, ...
cx.z, tx.V, tx.lam, nx.parm);
nx.z = cpf_tangent(nx.V, nx.lam, Ybus, cb_data.Sbusb, cb_data.Sbust, ...
cb_data.pv, cb_data.pq, ...
cx.z, tx.V, tx.lam, nx.parm, direction);

%% detect events
for k = 1:nef
Expand Down Expand Up @@ -507,6 +510,7 @@
end
else
loc_msg = '';
direction = 1;
end

%% invoke callbacks - "iterations" context
Expand All @@ -522,6 +526,18 @@
done.msg = 'Too many rollback steps triggered by callbacks!';
end
else
if ~done.flag && evnts(1).zero
mpce = cpf_current_mpc(cb_data.mpc_base, cb_data.mpc_target, Ybus, Yf, Yt, cb_data.ref, cb_data.pv, cb_data.pq, nx.V, nx.lam, mpopt);
J = makeJac(mpce);
opts.tol = 1e-3;
opts.it = 2*nb;
%% retain original direction for buses with negative V-Q
%% sensitivity, otherwise change direction based on tangent
%% direction and manifold (eigenvalue)
if isempty(find(nx.z(nb+pq) > 0, 1))
direction = sign(nx.z(end)*min(real(eigs(J,1,'SR',opts))));
end
end
rb_cnt_cb = 0; %% reset rollback counter for callbacks
end

Expand Down