-
Notifications
You must be signed in to change notification settings - Fork 148
/
t_cpf_cb2.m
41 lines (39 loc) · 1.43 KB
/
t_cpf_cb2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function [nx, cx, done, rollback, evnts, cb_data, results] = t_cpf_cb2(...
k, nx, cx, px, done, rollback, evnts, cb_data, cb_args, results)
% t_cpf_cb2 - User callback function 2 for continuation power flow testing.
% MATPOWER
% Copyright (c) 2013-2024, Power Systems Engineering Research Center (PSERC)
% by Ray Zimmerman, PSERC Cornell
%
% This file is part of MATPOWER.
% Covered by the 3-clause BSD License (see LICENSE file for details).
% See https://matpower.org for more info.
%%----- INITIAL call -----
if k == 0
cxx = struct( 'initial', cb_args.initial, ...
'iteration', 0, ...
'final', 0 );
nxx = cxx;
cx.cb.cb2 = cxx;
nx.cb.cb2 = nxx;
if ~isfield(cx.cb, 'shared')
cx.cb.shared = '';
nx.cb.shared = '';
end
cx.cb.shared = [cx.cb.shared '2'];
nx.cb.shared = [nx.cb.shared '2'];
else
nxx = nx.cb.cb2; %% get next callback state
%%----- ITERATION call -----
if k > 0
nxx.iteration = nxx.iteration + cb_args.iteration;
nx.cb.cb2 = nxx; %% update next callback state
nx.cb.shared = [nx.cb.shared '2']; %% update next callback state
%%----- FINAL call -----
else % k < 0
results.cb2.initial = nxx.initial;
results.cb2.iteration = nxx.iteration;
results.cb2.final = cb_args.final;
results.shared = nx.cb.shared;
end
end