-
Notifications
You must be signed in to change notification settings - Fork 148
/
task_cpf_legacy.m
94 lines (87 loc) · 3.55 KB
/
task_cpf_legacy.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
classdef task_cpf_legacy < mp.task_cpf & mp.task_shared_legacy
% mp.task_cpf - |MATPOWER| task for legacy continuation power flow (CPF).
%
% Adds functionality needed by the *legacy* |/MATPOWER/| *framework* to the
% task implementation for the continuation power flow problem. This consists
% of pre-processing some input data and exporting and packaging result data.
%
% mp.task_pf Methods:
% * run_pre - pre-process inputs that are for legacy framework only
% * run_post - export results back to data model source
% * legacy_post_run - post-process *legacy framework* outputs
%
% See also mp.task_cpf, mp.task, mp.task_shared_legacy.
% MATPOWER
% Copyright (c) 2020-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.
methods
%%----- task methods -----
function [d, mpopt] = run_pre(obj, d, mpopt)
% Pre-process inputs that are for *legacy framework* only.
% ::
%
% [d, mpopt] = task.run_pre(d, mpopt)
%
% Inputs:
% d : data source specification, currently assumed to be a
% |MATPOWER| case name or case struct (``mpc``)
% mpopt (struct) : |MATPOWER| options struct
%
% Outputs:
% d : updated value of corresponding input
% mpopt (struct) : updated value of corresponding input
%
% Call :meth:`run_pre_legacy() <mp.task_shared_legacy.run_pre_legacy>`
% method for both input cases before calling parent.
[d{1}, mpopt] = obj.run_pre_legacy(d{1}, mpopt);
[d{2}, mpopt] = obj.run_pre_legacy(d{2}, mpopt);
[d, mpopt] = run_pre@mp.task_cpf(obj, d, mpopt);
end
function obj = run_post(obj, mm, nm, dm, mpopt)
% Export results back to data model source.
% ::
%
% task.run_post(mm, nm, dm, mpopt)
%
% Inputs:
% mm (mp.math_model) : mathmatical model object
% nm (mp.net_model) : network model object
% dm (mp.data_model) : data model object
% mpopt (struct) : |MATPOWER| options struct
%
% Output:
% task (mp.task) : task object
%
% Calls mp.dm_converter.export and saves the result
% in the data model ``source`` property.
if obj.nm.np ~= 0
obj.dm.source = obj.dmc.export(obj.dm, obj.dm.source);
end
end
%%----- other methods -----
function [results, success] = legacy_post_run(obj, mpopt)
% Post-process *legacy framework* outputs.
% ::
%
% [results, success] = task.legacy_post_run(mpopt)
%
% Input:
% mpopt (struct) : |MATPOWER| options struct
%
% Outputs:
% results (struct) : results struct for *legacy* |/MATPOWER/|
% *framework*, see Table 5.1 in legacy |MUM|.
% success (integer) : 1 - succeeded, 0 - failed
%
% Extract ``results`` and ``success`` and save the
% task object in ``results.task`` before returning.
success = obj.success;
results = obj.dm.source;
results.task = obj;
end
end %% methods
end %% classdef