Skip to content

Commit

Permalink
Add CPF test for issue #23 and PR #25.
Browse files Browse the repository at this point in the history
Addresses direction switching based on whether a bus type conversion results in a jump from stable to unstable manifold.

Ref: #23
Ref: #25
  • Loading branch information
rdzman committed May 3, 2021
1 parent 7a458a4 commit 4bda70c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/t/t_cpf.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
quiet = 0;
end

num_tests = 366;
num_tests = 376;
t_begin(num_tests, quiet);

if have_feature('matlab', 'vnum') < 7.001
Expand Down Expand Up @@ -405,6 +405,26 @@
t_ok(0, [t 'unexpected fatal error']);
end

t = 'issues #23,25 : direction switching : ';
mpcbx = loadcase('case4gs');
mpcbx.bus(4, [PD QD]) = [-1820 -1307.2];
mpcbx.gen(1, [PG QMAX QMIN PMAX]) = [300 200 -1e9 250];
mpcbx.gen(2, [QMAX PMAX]) = [1e9 500];
mpctx = mpcbx;
mpctx.bus(3, [PD QD]) = 2 * mpcbx.bus(3, [PD QD]);
r = runcpf(mpcbx, mpctx, mpopt_qlim);
iterations = 46;
t_ok(r.success, [t 'success']);
t_is(r.cpf.iterations, iterations, 12, [t 'iterations']);
t_is(r.cpf.max_lam, 2.98036879, 8, [t 'max_lam']);
t_is(length(r.cpf.events), 2, 12, [t 'length(events) == 2']);
t_is(r.cpf.events(1).k, 25, 12, [t 'events(1).k']);
t_is(r.cpf.events(1).idx, 1, 12, [t 'events(1).idx']);
t_ok(strcmp(r.cpf.events(1).name, 'QLIM'), [t 'events(1).name']);
t_is(r.cpf.events(2).k, iterations, 12, [t 'events(2).k']);
t_is(r.cpf.events(2).idx, 1, 12, [t 'events(1=2).idx']);
t_ok(strcmp(r.cpf.events(2).name, 'TARGET_LAM'), [t 'events(2).name']);

if have_feature('mp_element')
t_skip(88, 'user callbacks')
else
Expand Down

0 comments on commit 4bda70c

Please sign in to comment.