From GridLAB-D Wiki
Jump to: navigation, search

MatPower - solve optimal powerflow using the MatPOWER solver


This module uses the MatPOWER solver to allow simulation of transmission networks and solving optimal power flow. In particular, this module makes it possible to cosimulate transmission and distribution by attaching distribution networks to the transmission buses. In order to handle the increased computational complexity, the distribution networks can be run on a separate system from the transmission simulation. Please see the whitepaper on the MatPOWER website for performance estimates based on the size of the transmission network.

System Requirements

Your system must have either Matlab OR the Matlab Runtime Compiler (MCR) installed in order to use this module. MCR can be downloaded for free from Mathworks [1].

Compiling MatPOWER Using MCC

This step is not normally necessary. The matpower module includes a precompiled shared object for Linux (32-bit and 64-bit) for the MatPower 4.0 solver. If you would like to use this module on a different system or use a different version of MatPOWER, you can use the Matlab MCC Compiler to generate a new shared object or DLL. You must compile the functions in "opf.m". We have included the matpower4.0 source files which we used to generate our shared objects.

From the /matpower/mcc_out directory, run the following command:

 mcc ../matpower40_src/opf.m -B macro_default -W cpplib:libopf -T link:lib


The MatPOWER solver was developed by Ray D. Zimmerman, Carlos E. Murillo-Sánchez & Deqiang (David) Gan. See Cornell MatPower website for more information. This module enables co-simulation between MatPower and GridLAB-D and was developed by Kyle Anderson as part of the GridSpice project (

Example GLM

object bus {
       name "Palo Alto Generator";
       BUS_TYPE    "REF";
       PD          0MW;
       QD          0MVAr;
       GS          0MW;
       BS          0MVAr;
       BUS_AREA    1;
       VM          1;
       VA          0;
       BASE_KV     345kV;
       ZONE        1;
       VMAX        1.1;
       VMIN        0.9;

object branch {
       F_BUS_NAME      "Palo Alto Generator";
       T_BUS_NAME      "Packard Building";
       BR_R        0;
       BR_X        0.0576;
       BR_B        0;
       RATE_A      250;
       RATE_B      250;
       RATE_C      250;
       TAP         0;
       SHIFT       0;
       BR_STATUS   1;
       ANGMIN      -360;
       ANGMAX      360;

object gen {
       name "Generator 2";
       parent "Stanford Generator";
       PG          163MW;
       QG          0MVAr;
       QMAX        300MVAr;
       QMIN        -300MVAr;
       VG          1;
       MBASE       100;
       GEN_STATUS  1;
       PMAX        300MW;
       PMIN        10MW;
       PC1         0MVAr;
       PC2         0MVAr;
       QC1MIN      0MVAr;
       QC1MAX      0MVAr;
       QC2MIN      0MVAr;
       QC2MAX      0MVAr;
       RAMP_AGC    0;
       RAMP_10     0MW;
       RAMP_30     0MW;
       RAMP_Q      0;
       APF         0;
       MODEL       2;
       STARTUP     2000;
       SHUTDOWN    0;
       NCOST       3;
       COST        0.085,1.2,600;

See also