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 bug when cpf_corrector fails on first iteration #21

Closed
ElisNycander opened this issue Sep 3, 2017 · 1 comment
Closed

CPF bug when cpf_corrector fails on first iteration #21

ElisNycander opened this issue Sep 3, 2017 · 1 comment
Assignees
Labels

Comments

@ElisNycander
Copy link

I have found a small bug in the CPF function. Suppose the base case power flow converges but the very first corrector step fails. Then the following happens

  1. cpf loop sets cont_steps = 0 and terminates with break
  2. callback function is called with k=0 and thus executes initialization instead of final callback loop
  3. cpf_results is now missing the field V (and all other fields which are supposed to be set in final callback loop)
  4. missing cpf_results.V causes error on line 634 in runcpf:
    n = size(cpf_results.V, 2);

So the reason for this error is that the first parameter taken by the callback functions has two different functions. It is both

  1. An indicator what stage the cpf is in, i.e. initialization stage, continuation stage, or final stage
  2. A counter for the number of iterations which has been run
    So the possibility of being in the final stage (because the corrector did not converge) in the very first iteration creates problems.

Working example code:

clear;
close all;
define_constants;

mpc = case4gs();

% base case, change bus 4 to PQ, change limits for generator at bus 1
mpc.bus(4,[BUS_TYPE PD QD]) = ...
   [1 -820 238.3673];
mpc.gen(1,GEN_STATUS) = 0;
mpc.gen(2,[QMAX PMAX]) = [1e9 500];

% target case, increase load at bus 3
mpc1 = mpc;
mpc2 = mpc;
mpc2.bus(3,[PD QD]) = 2*mpc.bus(3,[PD QD]);

mpopt = mpoption();
mpopt.cpf.enforce_q_lims = 1;

mpc3 = runcpf(mpc1,mpc2,mpopt);
@rdzman rdzman added the bug label Sep 5, 2017
abhyshr pushed a commit to abhyshr/matpower that referenced this issue Sep 20, 2017
… from stable to unstable manifold.

Elis Nycander, https://www.mail-archive.com/matpower-l@cornell.edu/msg06048.html, brought up a case where the operating point moves from stable to unstable manifold. Once on the unstable manifold, the continuation curve moves in the direction of lambda increase, which seems intuitively opposite to expected behavior (progress along the decreasing lambda direction). The reason for the lambda increase direction when on unstable manifold is because the tangent direction was always set towards lambda increase. This fix checks whether the operating point is on stable or unstable manifold (by checking the sign of minimum eigen value) and changes the direction accordingly. When on stable manifold, an increasing lambda direction is set, while a decreasing lambda direction on unstable manifold.

Relevant discussion can be found here MATPOWER#21
rdzman pushed a commit that referenced this issue Sep 25, 2017
… from stable to unstable manifold.

Elis Nycander, https://www.mail-archive.com/matpower-l@cornell.edu/msg06048.html, brought up a case where the operating point moves from stable to unstable manifold. Once on the unstable manifold, the continuation curve moves in the direction of lambda increase, which seems intuitively opposite to expected behavior (progress along the decreasing lambda direction). The reason for the lambda increase direction when on unstable manifold is because the tangent direction was always set towards lambda increase. This fix checks whether the operating point is on stable or unstable manifold (by checking the sign of minimum eigen value) and changes the direction accordingly. When on stable manifold, an increasing lambda direction is set, while a decreasing lambda direction on unstable manifold.

Relevant discussion can be found here #21
abhyshr pushed a commit to abhyshr/matpower that referenced this issue Oct 13, 2017
… from stable to unstable manifold.

Elis Nycander, https://www.mail-archive.com/matpower-l@cornell.edu/msg06048.html, brought up a case where the operating point moves from stable to unstable manifold. Once on the unstable manifold, the continuation curve moves in the direction of lambda increase, which seems intuitively opposite to expected behavior (progress along the decreasing lambda direction). The reason for the lambda increase direction when on unstable manifold is because the tangent direction was always set towards lambda increase. This fix checks whether the operating point is on stable or unstable manifold (by checking the sign of minimum eigen value) and changes the direction accordingly. When on stable manifold, an increasing lambda direction is set, while a decreasing lambda direction on unstable manifold.

Relevant discussion can be found here MATPOWER#21
abhyshr pushed a commit to abhyshr/matpower that referenced this issue Dec 5, 2017
… from stable to unstable manifold.

Elis Nycander, https://www.mail-archive.com/matpower-l@cornell.edu/msg06048.html, brought up a case where the operating point moves from stable to unstable manifold. Once on the unstable manifold, the continuation curve moves in the direction of lambda increase, which seems intuitively opposite to expected behavior (progress along the decreasing lambda direction). The reason for the lambda increase direction when on unstable manifold is because the tangent direction was always set towards lambda increase. This fix checks whether the operating point is on stable or unstable manifold (by checking the sign of minimum eigen value) and changes the direction accordingly. When on stable manifold, an increasing lambda direction is set, while a decreasing lambda direction on unstable manifold.

Relevant discussion can be found here MATPOWER#21
abhyshr pushed a commit to abhyshr/matpower that referenced this issue Dec 5, 2017
… from stable to unstable manifold.

Elis Nycander, https://www.mail-archive.com/matpower-l@cornell.edu/msg06048.html, brought up a case where the operating point moves from stable to unstable manifold. Once on the unstable manifold, the continuation curve moves in the direction of lambda increase, which seems intuitively opposite to expected behavior (progress along the decreasing lambda direction). The reason for the lambda increase direction when on unstable manifold is because the tangent direction was always set towards lambda increase. This fix checks whether the operating point is on stable or unstable manifold (by checking the sign of minimum eigen value) and changes the direction accordingly. When on stable manifold, an increasing lambda direction is set, while a decreasing lambda direction on unstable manifold.

Relevant discussion can be found here MATPOWER#21
rdzman pushed a commit that referenced this issue Dec 5, 2017
… from stable to unstable manifold.

Elis Nycander, https://www.mail-archive.com/matpower-l@cornell.edu/msg06048.html, brought up a case where the operating point moves from stable to unstable manifold. Once on the unstable manifold, the continuation curve moves in the direction of lambda increase, which seems intuitively opposite to expected behavior (progress along the decreasing lambda direction). The reason for the lambda increase direction when on unstable manifold is because the tangent direction was always set towards lambda increase. This fix checks whether the operating point is on stable or unstable manifold (by checking the sign of minimum eigen value) and changes the direction accordingly. When on stable manifold, an increasing lambda direction is set, while a decreasing lambda direction on unstable manifold.

Relevant discussion can be found here #21
@rdzman rdzman changed the title CPF bug when cpf_corrector failes on first iteration CPF bug when cpf_corrector fails on first iteration Dec 6, 2017
@rdzman
Copy link
Member

rdzman commented Dec 6, 2017

Just to clarify, PR #25 referenced this issue by mistake. It is unrelated.

rdzman added a commit that referenced this issue Dec 6, 2017
…rector step would produce a fatal error.
rdzman added a commit that referenced this issue Dec 6, 2017
…rector step would produce a fatal error.
@rdzman rdzman self-assigned this Dec 6, 2017
@rdzman rdzman closed this as completed Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants