-
Notifications
You must be signed in to change notification settings - Fork 3
/
mpopt2pneopt.m
79 lines (75 loc) · 2.88 KB
/
mpopt2pneopt.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
function pneopt = mpopt2pneopt(mpopt, model, alg)
% mpopt2pneopt Create/modify pnes_master options struct from ``mpopt``.
% ::
%
% PNEOPT = MPOPT2PNEOPT(MPOPT, MODEL)
% PNEOPT = MPOPT2PNEOPT(MPOPT, MODEL, ALG)
%
% Uses a MATPOWER options struct, MPOPT, to create or modify an
% PNES_MASTER options struct.
%
% Inputs (default values in parentheses):
% MPOPT : MATPOWER options struct
% MODEL ('PNE') : (optional) one of the following model types, required
% for selection of solver in case ALG is 'DEFAULT' (solver
% precedence for each model type list in parentheses):
% 'PNE' - nonlinear equation with all continuous variables
% (NEWTON, FSOLVE)
% ALG ('DEFAULT') : (optional) any valid value of OPT.alg for
% PNES_MASTER.
%
% Output:
% PNEOPT : an options struct for use by PNES_MASTER and friends
%
% See also pnes_master, mpoption.
% MP-Opt-Model
% Copyright (c) 2015-2024, Power Systems Engineering Research Center (PSERC)
% by Ray Zimmerman, PSERC Cornell
%
% This file is part of MP-Opt-Model.
% Covered by the 3-clause BSD License (see LICENSE file for details).
% See https://github.com/MATPOWER/mp-opt-model for more info.
%% set default args
if nargin < 3
alg = 'DEFAULT';
if nargin < 2
model = '';
end
end
%% use pf.alg to set nleqs_opt for corrector
switch mpopt.pf.alg
case 'FSOLVE'
nleqs_alg = 'FSOLVE';
otherwise
nleqs_alg = 'NEWTON';
end
%% create PNES_MASTER options struct
pneopt = struct( ...
'alg', alg, ...
'verbose', mpopt.verbose, ...
'nleqs_opt', struct( ...
'alg', nleqs_alg, ...
'tol', mpopt.pf.tol ), ...
'stop_at', mpopt.cpf.stop_at, ...
'solve_base', 1, ...
'parameterization', mpopt.cpf.parameterization, ...
'step', mpopt.cpf.step, ...
'step_min', mpopt.cpf.step_min, ...
'step_max', mpopt.cpf.step_max, ...
'adapt_step', mpopt.cpf.adapt_step, ...
'adapt_step_damping', mpopt.cpf.adapt_step_damping, ...
'adapt_step_tol', mpopt.cpf.adapt_step_tol, ...
'target_lam_tol', mpopt.cpf.target_lam_tol, ...
'nose_tol', mpopt.cpf.nose_tol, ...
'output_fcn', @(varargin)cpf_pne_output_fcn(obj, ad, varargin{:}), ...
'plot', struct( ...
'level', mpopt.cpf.plot.level, ...
'idx', mpopt.cpf.plot.bus, ...
'idx_default', @()cpf_plot_idx_default(obj, dm, ad), ...
'yname', 'V', ...
'yfcn', @(v_,idx)cpf_plot_yfcn(obj, dm, ad, v_, idx), ...
'title', 'Voltage at Bus %d', ...
'title2', 'Voltage at Multiple Buses', ...
'ylabel', 'Voltage Magnitude', ...
'legend', 'Bus %d' ) ...
);