
MATPOWER
A MATLAB Power System Simulation Package
by Ray D. Zimmerman, Carlos E. MurilloSánchez & others
MATPOWER is a package of MATLAB® Mfiles for solving power flow and optimal power flow problems. It is intended as a simulation tool for researchers and educators that is easy to use and modify. MATPOWER is designed to give the best performance possible while keeping the code simple to understand and modify. It was initially developed as part
of the PowerWeb project.
NOTICE: 
RFF will be hiring an individual to do power system simulation software development.
See the energy job announcement at www.rff.org/about/careers.

You will be asked to fill out a brief form the first time you download certain software from this site.
See also Optional Packages below.
For full documentation, see the MATPOWER Users's Manual.

Terms of Use
Please see the LICENSE file for
the details. But here is the summary ...
 Beginning with version 5.1, the code in MATPOWER is distributed under
the 3clause BSD license.
 MATPOWER is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
 While not required by the terms of the license, we do request that publications derived from the use of MATPOWER explicitly acknowledge that fact by citing [2]. Additionally, we request that publications derived from the use of the MATPOWER Optimal Scheduling Tool (MOST), explicitly acknowledge that fact by citing [4] as well as [2].
[2] 
R. D. Zimmerman, C. E. MurilloSánchez, and R. J. Thomas, "MATPOWER: SteadyState Operations, Planning and Analysis Tools for Power Systems Research and Education," Power Systems, IEEE Transactions on, vol. 26, no. 1, pp. 1219, Feb. 2011. 
[4] 
C. E. MurilloSánchez, R. D. Zimmerman, C. L. Anderson, and R. J. Thomas, "Secure Planning and Operations of Systems with Stochastic Sources, Energy Storage and Active Demand," Smart Grid, IEEE Transactions on, vol. 4, no. 4, pp. 22202229, Dec. 2013. 
Note: Versions 4.0 through 5.0 were licensed under the GNU General Public License (GPL) and versions prior to MATPOWER 4 use a different license.


System Requirements
To use MATPOWER you will need:
The PSS/E RAW data import function psse2mpc currently requires MATLAB 7.3 or newer or Octave 3.8 or newer. The continuation power flow runcpf() is not supported in MATLAB 7.0.x (requires 7.1 or newer).
Note: MATPOWER 4 required MATLAB 6.5, MATPOWER 3.2 required MATLAB 6, MATPOWER 3.0 required MATLAB 5 and MATPOWER 2.0 and earlier only required MATLAB 4. Some parts of MATPOWER may work on earlier versions of Octave, but it but has not been tested on versions prior to 3.4.
Installation
 Download MATPOWER. You should end up with a file named matpowerXXX.zip, where XXX depends on the version of MATPOWER.
 Unzip the downloaded file. Move the resulting matpowerXXX directory to the location of your choice. These files should not need to be modified, so it is recommended that they be kept separate from your own code. Let <MATPOWER> denote the path to this directory.
 Add the following directories to your MATLAB path:
 <MATPOWER> — core MATPOWER functions
 <MATPOWER>/t — test scripts for MATPOWER
 <MATPOWER>/most — core MOST functions
 <MATPOWER>/most/t — test scripts for MOST
 At the MATLAB prompt, type 'test_matpower' (without the quotes) to run the test suite and verify that MATPOWER is properly installed and functioning.
Running MATPOWER
To run a simple Newton power flow on the 9bus system specified in the file case9.m, with the default algorithm options, at the MATLAB prompt, type:
runpf('case9')
To load the 30bus system data from case30.m, increase its real power
demand at bus 2 to 30 MW, then run an AC optimal power flow with
default options, type:
define_constants;
mpc = loadcase('case30');
mpc.bus(2, PD) = 30;
runopf(mpc);
By default, the results of the simulation are prettyprinted to the screen, but the solution can also be optionally returned in a results struct. The following example shows how simple it is, after running a DC OPF on the 118bus system in case118.m, to access the final objective function value, the real power output of generator 6 and the power flow in branch 51.
results = rundcopf('case118');
final_objective = results.f;
gen6_output = results.gen(6, PG);
branch51_flow = results.branch(51, PF);
For additional info, see the User's Manual and the online help documentation for the various MATPOWER functions. For example:
help runpf
help runopf
help mpoption
help caseformat
Below is a summary of the changes since version 6.0b1 of MATPOWER. See the CHANGES file in the docs directory for all the gory details.
New Features:
 Redesigned CPF callback mechanism to handle CPF events such as generator limits, nose point detection, etc. Included event log in CPF results.
 Added options 'cpf.enforce_p_lims' and 'cpf.enforce_q_lims' to enforce generator active and reactive power limts in the continuation power flow.
 Added OPF option 'opf.use_vg' to provide a convenient way to have the OPF respect the generator voltage setpoints specified in the gen matrix.
Other Improvements:
 Added option 'cpf.adapt_step_damping' to control oscillations in adaptive step size control for continuation power flow.
 Added CPF user options for setting tolerances for target lambda detection and nose point detection, 'cpf.target_lam_tol' and 'cpf.nose_tol', respectively.
 Added support for Matlab Optimization Toolbox 7.5 (R2016b).
 Added support for MOSEK v8.x.
 Added tests for power flow with 'pf.enforce_q_lims' option.
 Updated network reduction code to handle cases with radially
connected external buses.
 Updated versions of qcqp_opf() and qcqp_opf() in extras/misc, from Cedric Josz.
Bugs Fixed:
 Fixed shadow prices on variable bounds for AC OPF for fmincon,
IPOPT, and Knitro.
 In savecase() single quotes are now escaped properly in bus names.
 Generator capability curve parameters that define a zeroreactive
power line no longer cause a fatal error.
 Bad bus numbers no longer cause a fatal error (after reporting the
bad bus numbers) in case_info().
Incompatible Changes:
 Removed 'cpf.user_callback_args' option and modified
'cpf.user_callback'.
 Changed name of 'cpf.error_tol' option to 'cpf.adapt_step_tol'.
Below is a summary of the changes since version 5.1 of MATPOWER. See the CHANGES file in the docs directory for all the gory details.
New Case Files:
 Added 9 new case files, 8 cases ranging from 1888 to 6515 buses representing the French system, and a 13,659bus case representing parts of the of the European high voltage transmission network, stemming from the Pan European Grid Advanced Simulation and State Estimation (PEGASE) project. Thanks again to Cédric Josz and colleagues from the French Transmission System Operator. Please cite this paper when publishing results based on these cases.
 Added case145.m, IEEE 145 bus, 50 generator dynamic test case from the U of WA Power Systems Test Case Archive.
New Features:
 MATPOWER Optimal Scheduling Tool (MOST) is a major new feature, implementing a full range of optimal power scheduling problems, from a simple as a deterministic, single period economic dispatch problem with no transmission constraints to as complex as a stochastic, securityconstrained, combined unitcommitment and multiperiod OPF problem with locational contingency and loadfollowing reserves, ramping costs and constraints, deferrable demands, lossy storage resources and uncertain renewable generation. See docs/MOSTmanual.pdf for details.
 General mechanism for applying modifications to an existing MATPOWER case. See apply_changes() and idx_ct().
 Experimental foundation for handling of ZIP load models in power flow (Newton, fastdecoupled only), continuation power flow, and optimal power flow (MIPS, fmincon, Knitro, IPOPT solvers only). Currently, ZIP loads can only be specified on a systemwide basis using the experimental options 'exp.sys_wide_zip_loads.pw' and 'exp.sys_wide_zip_loads.qw'.
 Support for quadprog() under GNU Octave.
 New contributed extras:
 Plot electrically meaningful drawings of a MATPOWER case using plot_mpc() in extras/misc, contributed by Paul Cuffe.
 Find the maximum loadability limit of a system via an optimal power flow and dispatchable loads, using maxloadlim() in extras/maxloadlim, contributed by Camille Hamon.
 Create a quadraticallyconstrained quadratic programming (QCQP) representation of the AC optimal power flow problem using using qcqp_opf() in extras/misc, contributed by Cédric Josz and colleagues.
 New functions:
 apply_changes() and idx_ct() provide a general mechanism for applying modifications to an existing MATPOWER case.
 feval_w_path() evaluates a function located at a specified path, outside of the Matlab path.
 mpopt2qpopt() provides a common interface for creating options struct for mi/qps_matpower() from a MATPOWER options struct.
 New function options:
 Option to call makeB(), makeBdc(), makePTDF(), scale_load(), and total_load() with full case struct (mpc) instead of individual data matrices (bus, branch, etc.).
 total_load(), which now computes voltagedependent load values, accepts the values 'bus' and 'area' as valid values for 'load_zone' argument.
Other Improvements:
 Changed default solver order for LP, QP, MILP, MIQP problems to move Gurobi before CPLEX and BPMPD after OT and GLPK.
 Added some caching to mpoption() and made minor changes to nested_struct_copy() to greatly decrease the overhead added by mpoption() when running many small problems.
 Added "Release History" section to Appendix of manual.
 Many new tests.
Bugs Fixed:
 Fixed bug in toggle_dclines() that resulted in fatal error when used with OPF with reactive power costs. Thanks to Irina Boiarchuk.
 Fixed fatal bug in update_mupq() affecting cases where QMIN is greater than or equal to QC1MIN and QC2MIN (or QMAX is less than or equal to QC1MAX and QC2MAX) for all generators. Thanks Jose Miguel.
 Copying a field containing a struct to a nonstruct field with nested_struct_copy() now overwrites rather than causing a fatal error.
 Fixed a bug in psse_convert_xfmr() where conversion of data for transformers with CZ=3 was done incorrectly. Thanks to Jose Marin and Yujia Zhu.
 Fixed a fatal bug in psse_convert_xfmr() affecting transformers with CW and/or CZ equal to 1. Thanks to Matthias Resch.
 Fixed a crash in have_fcn() caused by changes in OPTI Toolbox v2.15 (or possibly v2.12)
 Commented out isolated bus 10287 in case3375wp.m.
 Added code to DC OPF to return success = 0 for cases where the matrix is singular (e.g. islanded system without slack).
 Fixed problem in have_fcn() where SeDuMi was turning off and leaving off all warnings.
Incompatible Change:
 Removed fairmax() from the public interface by moving it inside uopf(), the only place it was used.
There are four primary sources of documentation for MATPOWER.
The MATPOWER and MOST User's Manuals are included in the distribution (docs/MATPOWERmanual.pdf and docs/MOSTmanual.pdf) or they can be downloaded separately from the links above. Previous versions are available here.
Each Mfile has its own documentation which can be accessed by typing at the MATLAB prompt:
help <name of Mfile>
Documentation for the case data file format can be found by typing:
help caseformat
If something is still unclear after checking the manual and the
help, the source code is the documentation. ;)
There are also two MATPOWER Technical Notes that may be of interest:
[1] 
R. D. Zimmerman, C. E. MurilloSánchez, and R. J. Thomas, "MATPOWER's Extensible Optimal Power Flow Architecture," Power and Energy Society General Meeting, 2009 IEEE, pp. 17, July 2630 2009.
(DOI: 10.1109/PES.2009.5275967)
Presentation: download slides 
[2] 
R. D. Zimmerman, C. E. MurilloSánchez, and R. J. Thomas, "MATPOWER: SteadyState Operations, Planning and Analysis Tools for Power Systems Research and Education," Power Systems, IEEE Transactions on, vol. 26, no. 1, pp. 1219, Feb. 2011.
(DOI: 10.1109/TPWRS.2010.2051168) 
[3] 
H. Wang, C. E. MurilloSánchez, R. D. Zimmerman, R. J. Thomas, "On Computational Issues of MarketBased Optimal Power Flow," Power Systems, IEEE Transactions on, vol. 22, no. 3, pp. 11851193, Aug. 2007.
(DOI: 10.1109/TPWRS.2007.901301) 
[4] 
C. E. MurilloSánchez, R. D. Zimmerman, C. L. Anderson, and R. J. Thomas, "Secure Planning and Operations of Systems with Stochastic Sources, Energy Storage and Active Demand," Smart Grid, IEEE Transactions on, vol. 4, no. 4, pp. 22202229, Dec. 2013. (Digital Object Identifier: 10.1109/TSG.2013.2281001) 
This section links to third party sites providing MATPOWERrelated resources.
 IPOPTPARDISO
 Prebuilt MEX binaries of highperformance IPOPTPARDISO for Mac and Linux from the PARDISO Project.
 OPTI Toolbox by Jonathan Currie
 Provides an easy method to install several highperformance free solvers for MS Windows users, without the hassle of building them from source.
 STAC
 SteadyState AC Network Visualization in the Browser, a webbased visualization tool for MATPOWER test cases, designed to help power system researchers explore and understand the data in their MATPOWER case files.
There are a number of optional packages that MATPOWER can take advantage of to provide additional options for OPF solvers. Each is distributed under its own license and must be obtained separately. Please see the individual Terms of Use for details.
BPMPD_MEX 
MEXfile version of the high performance BPMPD interior point LP and QP solver. Speeds up DC and LPbased OPF solvers, and improves robustness of MINOPF. 
CLP 
COINOR Linear Programming solver implements high performance simplex and barrier LP and QP solvers that MATPOWER can use for the DC OPF. Available from http://www.coinor.org/projects/Clp.xml. 
CPLEX 
Includes highperformance, largescale LP and QP solvers that MATPOWER can use for the DC OPF. Requires the Matlab interface to CPLEX, available from http://www.ibm.com/software/integration/optimization/cplexoptimizer/. 
GLPK 
GNU Linear Programming Kit includes largescale LP solvers that MATPOWER can use for the DC OPF. Included with Octave. 
GUROBI 
Includes highperformance, largescale LP and QP solvers that MATPOWER can use for the DC OPF. Requires the Gurobi MEX Matlab interface. 
IPOPT 
An interior point optimizer for large scale nonlinear optimization that MATPOWER can use for both AC and DC OPF problems. Requires the Matlab MEX interface for IPOPT, available from http://www.coinor.org/projects/Ipopt.xml. Prebuilt MEX binaries for Windows available with OPTI Toolbox and highperformance IPOPTPARDISO prebuilt MEX binaries for Mac and Linux from the PARDISO Project. 
KNITRO 
A general purpose optimization solver specializing in nonlinear problems that MATPOWER can use for AC OPFs. Requires the Knitro libraries, available from http://www.ziena.com/. 
MINOPF 
A MINOSbased AC OPF solver implemented as a Fortran MEX file. 
MOSEK 
Includes highperformance, largescale LP and QP solvers that MATPOWER can use for the DC OPF. Requires the Matlab interface to MOSEK, available from http://www.mosek.com/. 
TSPOPF 
A package of three AC OPF solvers implemented as C MEX files. Suitable for large scale problems. 
Note:
For Windows users, one of the best ways to get access to some high performance solvers, without dealing with the pain of building the MEX interfaces yourself, is to install the OPTI Toolbox by Jonathan Currie. The installation is simple and it includes prebuilt MEX files for several of the above solvers, including CLP, GLPK and IPOPT.
An email list MATPOWERL@cornell.edu has been set up
to facilitate discussion of MATPOWER. Only list subscribers are permitted to post to the list.
Feel free to use this list to discuss anything related to MATPOWER, to ask questions about MATPOWER, or to provide feedback to the developers of MATPOWER, such as bug reports, patches or ideas for improvements (though we make no guarantees about if/when they might be included).
Also, if you have any of your own MATLAB power systems code that you would like to contribute, feel free to contact us via this list about making it available on the MATPOWER web site.
Joining the list
To join the discussion list, please enter your email and name here:
Sending mail to the list
To send an email to all of the subscribers of the MATPOWER mailing list, simply address your email to MATPOWERL@cornell.edu. Only subscribers are permitted to send email to the list.
Leaving the list
You can unsubscribe from the discussion list at any time by entering the email you used to subscribe here:
List Archives
There is an archive of the MATPOWER email list hosted by The Mail Archive.
http://www.mailarchive.com/matpowerl@cornell.edu/
It can be searched or browsed by thread or by date.
Note: There have been two URLs published for these archives, so you may find broken links out there pointing to (1), but (2) is the only one that works currently, so just edit the links accordingly.
(1) http://www.mailarchive.com/matpowerl@list.cornell.edu/
(2) http://www.mailarchive.com/matpowerl@cornell.edu/
Guidelines for posting
If you are going to ask a question on this list, please be sure to give enough information that someone has a chance of giving a helpful response. Be sure to start with ...
 a clear and complete description of what you are trying to accomplish
... and if you have attempted a solution unsuccessfully ...
 a clear and complete description of what you have already attempted (including a code snippet if possible so we have details)
 a clear and complete description of the result you expected vs. the result you got (if you got an error, include the full error message)
If MATPOWER itself is not working as you think it should, include ...
 output of mpver on your system
 operating system version
Including this kind of information in your request will make this forum more useful to everyone by avoiding the added noise of multiple emails back and forth in an attempt to understand the question.
To be notified when new versions of MATPOWER become available, sign up for the MATPOWERANNOUNCEL mailing list by entering your email and name here:
You can unsubscribe from the announcement list at any time by entering the email you used to subscribe here:
There is also an archive of the announcement list hosted by The Mail Archive.
http://www.mailarchive.com/matpowerannouncel@cornell.edu/
 1. How can I use MATPOWER's OPF to minimize transmission losses?
 Assign positive, constant, equal costs to all generators and use the standard OPF. Since generation must equal demand plus losses, if demand is constant, loss is minimized by minimizing overall generation. With equal costs on all generators, MATPOWER's default objective of minimizing total cost is equivalent to minimizing total generation, which is in turn equivalent to minimizing transmission losses.
 2. Would you please show me how to use MATPOWER to solve [my homework problem]?
 If you're thinking of posting a question of that nature to MATPOWERL, please don't ... the answer is "No, we won't". We simply do not have the time to understand every type of problem we are asked about and respond with example code to show you how MATPOWER can be used to solve it. MATPOWER solves power flow and optimal power flow problems and has a number of other related capabilities. You need to determine whether those capabilities are applicable to your problem.
If you have checked the User's Manual and the mailing list archives and still have questions about MATPOWER's specific capabilities, we are happy to clarify. And if you have specific questions, comments, or suggestions related to using MATPOWER, those are also welcome. Just please don't ask us to do your homework for you.
 3. Am I required by the license to cite MATPOWER in publications based on MATPOWER or derived works?
 No, but it's still the right thing to do. Please cite the following in your publications that rely on MATPOWER:

R. D. Zimmerman, C. E. MurilloSánchez, and R. J. Thomas, "MATPOWER: SteadyState Operations, Planning and Analysis Tools for Power Systems Research and Education," Power Systems, IEEE Transactions on, vol. 26, no. 1, pp. 1219, Feb. 2011. (Digital Object Identifier: 10.1109/TPWRS.2010.2051168) 
Additionally, for publications that rely on the MATPOWER Optimal Scheduling Tool (MOST), please also cite the following (in addition to the standard MATPOWER reference above):

C. E. MurilloSánchez, R. D. Zimmerman, C. L. Anderson, and R. J. Thomas, "Secure Planning and Operations of Systems with Stochastic Sources, Energy Storage and Active Demand," Smart Grid, IEEE Transactions on, vol. 4, no. 4, pp. 22202229, Dec. 2013. (Digital Object Identifier: 10.1109/TSG.2013.2281001) 
 4. Can I use MATPOWER 4.0–5.0 with GPLincompatible Mfiles and MEXfiles?
 I am not a lawyer. However, a GPL v3 section 7 "additional
permission" exception is included with the intent to explicitly
permit interfacing of MATPOWER with any Mfiles and MEXfiles,
regardless of licensing, such as MINOPF, BPMPD_MEX and Matlab's
Optimization Toolbox.
MATPOWER 5.1 and later uses the more permissive 3clause BSD license.
 5. Why does MATPOWER power flow not converge?
 While there are many reasons for the nonconvergence of a power flow solution, the following hints/tips may be useful for debugging the problem.
 Check that the data in the case file is consistent with the MATPOWER case data format.
 Check that all transmission line data is in per unit. MATPOWER requires the branch data to be entered in per unit.
 Check whether there are isolated buses in the case file that are not
marked with BUS_TYPE = NONE (4) or if there are islands without generation. This information can be obtained using the routine case_info().
 By default, MATPOWER's AC power flow uses a Newton's method to solve the nonlinear power flow equations and, unfortunately, the Newton's method is sensitive to the initial guess given. There is no way to choose an initial guess that always guarantees convergence. The following experiments may be useful in such a case:
 Change the starting point (voltage angles and magnitudes) and see if the power flow converges.
 Run a fast decoupled power flow (see help mpoption for details).
 Run an OPF with active generation fixed (costcoefficients should not matter), voltage limits relaxed except at generator buses, and reactive generation and branch flow limits relaxed.
 AC power flow does not converge if the system load exceeds the steadystate loading limit. To check if this is the case, run a continuation power flow that gradually increases the loading/generation.
define_constants;
mpcbase = loadcase('casefile');
mpcbase.bus(:, PD) = 0;
mpcbase.bus(:, QD) = 0;
mpcbase.gen(:, PG) = 0;
mpctarget = loadcase('casefile');
results = runcpf(mpcbase, mpctarget);
results.cpf.max_lam
If the resulting value of results.cpf.max_lam (the scaling factor associated with the maximum loading the system can handle) is less than 1, it indicates that the load for the case exceeds the steadystate loading limit, and loads must be scaled down at least by a factor of results.cpf.max_lam to get a convergent power flow solution.
 Try the incremental approach suggested by Jose Marin in these two posts on the MATPOWER discussion mailing list (original outline, additional suggestion).
