run_mp

run_mp(task_class, d, mpopt, varargin)

run_mp() - Run any MATPOWER simulation.

run_mp(task_class, d, mpopt)
run_mp(task_class, d, mpopt, ...)
task = run_mp(...)

This is the main function in the flexible framework for running MATPOWER. It creates the task object, applying any specified extensions, runs the task, and prints or saves the solution, if desired.

It is typically called from one of the wrapper functions such as run_pf(), run_cpf(), or run_opf().

Inputs:
  • task_class (function handle) – handle to constructor of default task class for type of task to be run, e.g. mp.task_pf for power flow, mp.task_cpf for CPF, and mp.task_opf for OPF

  • d – data source specification, currently assumed to be a MATPOWER case name or case struct (mpc)

  • mpopt (struct) – MATPOWER options struct

    Additional optional inputs can be provided as <name>, <val> pairs, with the following options:

    • 'print_fname' - file name for saving pretty-printed output

    • 'soln_fname' - file name for saving solved case

    • 'mpx' - MATPOWER extension or cell array of MATPOWER extensions to apply

Output:

task (mp.task) – task object containing the solved run including the data, network, and mathematical model objects.

Solution results are available in the data model, and its elements, contained in the returned task object. For example:

task = run_opf('case9');
lam_p = task.dm.elements.bus.tab.lam_p  % nodal price
pg = task.dm.elements.gen.tab.pg        % generator active dispatch

See also run_pf(), run_cpf(), run_opf(), mp.task.