mp.task_opf_legacy

class mp.task_opf_legacy

Bases: mp.task_opf, mp.task_shared_legacy

mp.task_opf - MATPOWER task for legacy optimal power flow (OPF).

Adds functionality needed by the legacy MATPOWER framework to the task implementation for the optimal power flow problem. This consists of pre-processing some input data and exporting and packaging result data, as well as using some legacy specific model sub-classes.

mp.task_pf Methods:

See also mp.task_opf, mp.task, mp.task_shared_legacy.

Method Summary
run_pre(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 run_pre_legacy() method before calling parent.

run_post(mm, nm, dm, mpopt)

Export results back to data model source.

task.run_post(mm, nm, dm, mpopt)
Inputs:
Output:

task (mp.task) – task object

Calls mp.dm_converter.export() and saves the result in the data model source property.

dm_converter_class_mpc2_default()

Set to mp.dm_converter_mpc2_legacy.

dmc_class = task.dm_converter_class_mpc2_default()
data_model_build_post(dm, dmc, mpopt)

Get data model converter to do more input pre-processing after calling superclass data_model_build_post().

math_model_class_default(nm, dm, mpopt)

Use legacy math model subclasses to support legacy costs and callbacks.

Uses math model variations that inherit from mp.mm_shared_opf_legacy (compatible with the legacy opf_model), in order to support legacy cost functions and callback functions that expect to find the MATPOWER case struct in mm.mpc.

legacy_post_run(mpopt)

Post-process legacy framework outputs.

[results, success, raw] = task.legacy_post_run(mpopt)
Input:

mpopt (struct) – MATPOWER options struct

Outputs:
  • results (struct) – results struct for legacy MATPOWER framework, see Table 6.1 in legacy MATPOWER User's Manual.

  • success (integer) – 1 - succeeded, 0 - failed

  • raw (struct) – see raw field in Table 6.1 in legacy MATPOWER User's Manual.

Extract results and success and save the task object in results.task before returning. This method also creates and populates numerous other fields expected in the legacy OPF results struct, such as f, x, om, mu, g, dg, raw, var, nle, nli, lin, and cost. Based on code from the legacy functions opf_execute(), dcopf_solver(), and nlpopf_solver().