MATPOWER 
一种基于 matlab 的电力系统仿真组件 
版本 3.1b2 
2006-9-15 
 
 
 
手 
 
 
册 
 
 
 
 
Ray D. Zimmerman  ,Carlos E. Murillo-Sánchez,甘德强 
@1997-2006 卡奈尔大学电气学院电力系统工程研究中心(PSERC) 
 
 
中文翻译制作:中国电力市场论坛(www.dlscbbs.net) 
 
一切版权属于原作者。 
PDF 文件使用 "pdfFactory Pro" 试用版本创建 www.fineprint.cn
MATPOWER手册(中文版)                                  
版本 3.1b2 
目录 
                                                                           
1  绪论 ..............................................................................................................................................3 
什么是 MATPOWER? ...................................................................................................3 
它从哪里来?...................................................................................................................3 
2  开始 ..............................................................................................................................................3 
2.1  系统要求 ...........................................................................................................................3 
2.2  安装 ...................................................................................................................................4 
2.3  执行电力常规潮流运算....................................................................................................4 
2.4  执行最优潮流程序............................................................................................................4 
2.5  获得帮助 ...........................................................................................................................4 
3  技术规则 ......................................................................................................................................5 
3.1  数据文件格式....................................................................................................................5 
3.2  模型 ...................................................................................................................................8 
交流模型(AC).............................................................................................................8 
直流公式(DC).............................................................................................................9 
3.3  电力潮流 .........................................................................................................................10 
3.4  最优潮流 .........................................................................................................................10 
传统的交流 OPF 方程 ...................................................................................................12 
基于最优化工具箱的 OPF 解法(constr)..................................................................13 
基于线性规划的 OPF 解法(LPconstr) .....................................................................14 
3.4.2  广义交流最优潮流解法...............................................................................................16 
通用线性约束(一般线性约束).................................................................................17 
通用成本函数.................................................................................................................18 
通用 P-Q 容量曲线......................................................................................................19 
可调度负荷.....................................................................................................................20 
支路相角差限制.............................................................................................................22 
问题数据转换.................................................................................................................22 
附加线性约束的例子.....................................................................................................23 
3.4.3  直流 OPF 方法 .............................................................................................................23 
机组组合算法.................................................................................................................24 
3.6 MATPOWER选项 ...........................................................................................................24 
3.7  文件汇总 .........................................................................................................................27 
4  致谢 ............................................................................................................................................31 
5  参考文献 ....................................................................................................................................31 
中国电力市场论坛(www.dlscbbs.net)翻译制作               一切版权归属原作者                   2 
PDF 文件使用 "pdfFactory Pro" 试用版本创建 www.fineprint.cn
MATPOWER手册(中文版)                                  
版本 3.1b2 
译者的话: 
  在做项目和实验的过程中,偶然使用到 MATPOWER 软件,发现该软件功能强大,但
是操作还是比较的复杂,而 MATPOWER 本身的说明文档还没有中文版本,因此,译者产
生了翻译用户手册的想法,促使了这个文档的诞生。 
由于翻译时间仓促,这个版本几乎没有任何校正,还有大量的错误,随后会对原始版本
进行修正,恳请各位网友将错误发送到 wolflove941@163.com 或者直接登陆中国电力市场论
坛(www.dlscbbs.net)提出宝贵的意见。 
1  绪论 
什么是 MATPOWER? 
MATPOWER 是一个基于 matlab  m 文件的组建包,用来解决电力潮流和优化潮流的问
题。它致力于为研究人员和教育从业者提供一种易于使用和可更新的仿真工具。Matpower
的设计理念是用尽可能简单、易懂,可更新的代码来实现最优秀的功能。MATPOWER的主
页为: 
http://www.pserc.cornell.edu/matpower/ 
它从哪里来? 
MATPOWER 是 由 卡奈尔 大 学 电气学 院 电力系 统 工 程 研 究中心 的
RAY D. 
ZIMMENRman,CARLOS E.Murillo 和甘德强在 ROBERT THOMAS的指导下开发出来的。
最初的基于 MATLAB的电力潮流和最优潮流代码是为 POWERWEB 项目的需要而编写的。 
谁能够使用它? 
·MATPOWER是完全免费的,任何人都可以使用。 
·我们对 MATPOWER的代码和作为特殊用途的可行性不作任何保障,授权与暗示。 
· 任 何 使 用 MATPOWER 的 出 版 物 都 必 须 标 注 MATPOWER 
http://www.pserc.cornell.edu/matpower/。 
·任何出于某种需要而对 MATLAB进行的修改必须在适当的位置保留初始版权标志。 
·MATPOWER在没有书面许可的情况下不宜私自发布与转让。 
·MATPOWER改进版或源于 MATPOWER的成果在没有书面许可的情况下不能私自转让或
发布。 
2  开始 
2.1  系统要求 
·MATLAB 5.0或以上版本 1 
·MATLAB  最优化工具箱(一小部分最优潮流算法需要) 
两者都可以从 MathWorks 获得(见 http://www.mathworks.com/)。 
中国电力市场论坛(www.dlscbbs.net)翻译制作               一切版权归属原作者                   3 
PDF 文件使用 "pdfFactory Pro" 试用版本创建 www.fineprint.cn
MATPOWER手册(中文版)                                  
版本 3.1b2 
2.2  安装 
步骤一:到 MATPOWER主页(http://www.pserc.cornell.edu/mathpower/)上按照下载指导下
载。 
步骤二:解压下载的文件。 
步骤三:将解压后的文件放到 MATLAB的 PATH路径下。 
2.3  执行电力常规潮流运算 
运行一个简单的在文件 case9.m 中有详细的说明 9 节点牛顿潮流,包括默认的运算法则
选项,以 matlab 的命令,输入: 
>>runpf(‘case9’) 
2.4  执行最优潮流程序 
计算一个数据在 case30.m 文件中的 30 节点的最优潮流系统,以默认的算法选项,以
maitlab 的命令,输入: 
>>runopf(‘case30’) 
计算相同的系统,但是以关闭高耗机组处理的方式运行,输入: 
>>runuopf(‘case30’)   
2.5  获得帮助 
当拥有 MATLAB的内部函数和工具箱代码时,通过输入 help 加上命令或者 M-文件的
名称可以获得详细的函数说明,几乎所有的 MATPOWER 的 M-文件都有这样的文档。比
如,runopf 的帮助如下: 
>> help runopf 
 
 RUNOPF   Runs an optimal power flow. 
   
       [baseMVA, bus, gen, gencost, branch, f, success, et] = ... 
                     runopf(casename, mpopt, fname, solvedcase) 
   
       Runs an optimal power flow and optionally returns the solved values in 
       the data matrices, the objective function value, a flag which is true if 
       the algorithm was successful in finding a solution, and the elapsed time 
       in seconds. All input arguments are optional. If casename is provided it 
       specifies the name of the input data file or struct (see also 'help 
       caseformat' and 'help loadcase') containing the opf data. The default 
       value is 'case9'. If the mpopt is provided it overrides the default 
       MATPOWER options vector and can be used to specify the solution 
       algorithm and output options among other things (see 'help mpoption' for 
       details). If the 3rd argument is given the pretty printed output will be 
中国电力市场论坛(www.dlscbbs.net)翻译制作               一切版权归属原作者                   4 
PDF 文件使用 "pdfFactory Pro" 试用版本创建 www.fineprint.cn
MATPOWER手册(中文版)                                  
版本 3.1b2 
       appended to the file whose name is given in fname. If solvedcase is 
       specified the solved case will be written to a case file in MATPOWER 
       format with the specified name. If solvedcase ends with '.mat' it saves 
the case as a MAT-file otherwise it saves it as an M-file. 
 
MATPOWER 还提供许多想想用来选择算法和输出,输入 
>>help mpoption 
更多信息详见 3.6 节:MATPOWER的选项。 
3  技术规则 
3.1  数据文件格式 
MATPOWER 所用的所有数据文件均为 MATLAB的 M 文件或者 MAT 文件,他们用来
定义和返回变量:baseMVA,bus,branch,gen,areas 和 gencost。变量 baseMVA 是标量,
其他的都是矩阵。矩阵的每一行都对应于一个单一的母线,线路或者发电机组。列的数据类
似 于标准 的 IEEE 和 PTI 列 的数 据格式 。MATPOWER 案 例文件的规 范细 节 可以 在
caseformat.m 中看到: 
>> help runopf 
 
 RUNOPF   Runs an optimal power flow. 
   
       [baseMVA, bus, gen, gencost, branch, f, success, et] = ... 
                     runopf(casename, mpopt, fname, solvedcase) 
   
       Runs an optimal power flow and optionally returns the solved values in 
       the data matrices, the objective function value, a flag which is true if 
       the algorithm was successful in finding a solution, and the elapsed time 
       in seconds. All input arguments are optional. If casename is provided it 
       specifies the name of the input data file or struct (see also 'help 
       caseformat' and 'help loadcase') containing the opf data. The default 
       value is 'case9'. If the mpopt is provided it overrides the default 
       MATPOWER options vector and can be used to specify the solution 
       algorithm and output options among other things (see 'help mpoption' for 
       details). If the 3rd argument is given the pretty printed output will be 
       appended to the file whose name is given in fname. If solvedcase is 
       specified the solved case will be written to a case file in MATPOWER 
       format with the specified name. If solvedcase ends with '.mat' it saves 
       the case as a MAT-file otherwise it saves it as an M-file. 
 
>> help ceseformat 
 
ceseformat.m not found. 
中国电力市场论坛(www.dlscbbs.net)翻译制作               一切版权归属原作者                   5 
PDF 文件使用 "pdfFactory Pro" 试用版本创建 www.fineprint.cn
MATPOWER手册(中文版)                                  
版本 3.1b2 
 
>> help caseformat 
 
 CASEFORMAT       Defines the MATPOWER case file format. 
       A MATPOWER case file is an M-file or MAT-file which defines the variables 
       baseMVA, bus, gen, branch, areas, and gencost. With the exception of 
       baseMVA, a scalar, each data variable is a matrix, where a row corresponds 
       to a single bus, branch, gen, etc. The format of the data is similar to 
       the PTI format described in 
                http://www.ee.washington.edu/research/pstca/formats/pti.txt 
       except where noted. An item marked with (+) indicates that it is included 
       in this data but is not part of the PTI format. An item marked with (-) is 
       one that is in the PTI format but is not included here. The columns for 
       each data matrix are given below. 
   
       See also IDX_BUS, IDX_BRCH, IDX_GEN, IDX_AREA and IDX_COST regarding 
       constants which can be used as named column indices for the data matrices. 
       Also described in the first three are additional columns that are added 
       to the bus, branch and gen matrices by the power flow and OPF solvers. 
   
       Bus Data Format 
               1   bus number (1 to 29997) 
               2   bus type 
                             PQ bus                 = 1 
                             PV bus                   = 2 
                             reference bus     = 3 
                             isolated bus       = 4 
               3   Pd, real power demand (MW) 
               4   Qd, reactive power demand (MVAr) 
               5   Gs, shunt conductance (MW (demanded) at V = 1.0 p.u.) 
               6   Bs, shunt susceptance (MVAr (injected) at V = 1.0 p.u.) 
               7   area number, 1-100 
               8   Vm, voltage magnitude (p.u.) 
               9   Va, voltage angle (degrees) 
       (-)        (bus name) 
               10  baseKV, base voltage (kV) 
               11  zone, loss zone (1-999) 
       (+) 12   maxVm, maximum voltage magnitude (p.u.) 
       (+) 13   minVm, minimum voltage magnitude (p.u.) 
   
       Generator Data Format 
               1   bus number 
       (-)        (machine identifier, 0-9, A-Z) 
               2   Pg, real power output (MW) 
中国电力市场论坛(www.dlscbbs.net)翻译制作               一切版权归属原作者                   6 
PDF 文件使用 "pdfFactory Pro" 试用版本创建 www.fineprint.cn
MATPOWER手册(中文版)                                  
版本 3.1b2 
               3   Qg, reactive power output (MVAr) 
               4   Qmax, maximum reactive power output (MVAr) 
               5   Qmin, minimum reactive power output (MVAr) 
               6   Vg, voltage magnitude setpoint (p.u.) 
       (-)        (remote controlled bus index) 
               7   mBase, total MVA base of this machine, defaults to baseMVA 
       (-)        (machine impedance, p.u. on mBase) 
       (-)        (step up transformer impedance, p.u. on mBase) 
       (-)        (step up transformer off nominal turns ratio) 
               8   status,   >   0 - machine in service 
                                     <= 0 - machine out of service 
       (-)        (% of total VAr's to come from this gen in order to hold V at 
                             remote bus controlled by several generators) 
               9   Pmax, maximum real power output (MW) 
               10  Pmin, minimum real power output (MW) 
   
       Branch Data Format 
               1   f, from bus number 
               2   t, to bus number 
       (-)        (circuit identifier) 
               3   r, resistance (p.u.) 
               4   x, reactance (p.u.) 
               5   b, total line charging susceptance (p.u.) 
               6   rateA, MVA rating A (long term rating) 
               7   rateB, MVA rating B (short term rating) 
               8   rateC, MVA rating C (emergency rating) 
               9   ratio, transformer off nominal turns ratio ( = 0 for lines ) 
                     (taps at 'from' bus, impedance at 'to' bus, i.e. ratio = Vf / Vt) 
               10  angle, transformer phase shift angle (degrees) 
       (-)        (Gf, shunt conductance at from bus p.u.) 
       (-)        (Bf, shunt susceptance at from bus p.u.) 
       (-)        (Gt, shunt conductance at to bus p.u.) 
       (-)        (Bt, shunt susceptance at to bus p.u.) 
               11   initial branch status, 1 - in service, 0 - out of service 
   
   (+) Area Data Format 
               1   i, area number 
               2   price_ref_bus, reference bus for that area 
     
   (+) Generator Cost Data Format 
               NOTE: If gen has n rows, then the first n rows of gencost contain 
               the cost for active power produced by the corresponding generators. 
               If gencost has 2*n rows then rows n+1 to 2*n contain the reactive 
               power costs in the same format. 
中国电力市场论坛(www.dlscbbs.net)翻译制作               一切版权归属原作者                   7 
PDF 文件使用 "pdfFactory Pro" 试用版本创建 www.fineprint.cn
MATPOWER手册(中文版)                                  
版本 3.1b2 
               1   model, 1 - piecewise linear, 2 - polynomial 
               2   startup, startup cost in US dollars 
               3   shutdown, shutdown cost in US dollars 
               4   n, number of cost coefficients to follow for polynomial 
                     cost function, or number of data points for piecewise linear 
               5 and following, cost data defining total cost function 
                     For polynomial cost: 
                                   c2, c1, c0 
                     where the polynomial is c0 + c1*P + c2*P^2 
                     For piecewise linear cost: 
                                   x0, y0, x1, y1, x2, y2, ... 
                     where x0 < x1 < x2 < ... and the points (x0,y0), (x1,y1), 
                     (x2,y2), ... are the end- and break-points of the cost function. 
某些列被加入到了母线,线路和发电机组矩阵当中,通过查看 idx_bus,idx_brch 和
idx_gen 可以获得更多细节。 
3.2  模型 
交流模型(AC) 
=
+
GjB
shsh
baseMVA
固定负荷被当作恒定有功和无功功率注入,Pd 和 Qd 分别被指定为 bus 矩阵的第三列和
第四列。任何母线的恒阻抗泄漏元件的泄漏导纳都通过 Gsh 和 Bsh 被指定到第五和第六列。 
 
Y
sh
所有的线路,包括输电线路、变压器和调相机,都通过标准的“p ”模型建立包括串
联电阻 R 和电抗 X 以及所有的线路充电电容 Bc,和理想的变压器串联,对于调相机包括调
节比例t 移相角 shiftq 。参数 R,X,B,t 和 shiftq ,在线路矩阵 branch 的第 3,4,5,9 和
10 列。线路首端和末端的电压和电流通过线路导纳矩阵 Ybr 通过以下公式相关联: 
I
I
f
t
=
Y
br
f
V
V
t
            (1) 
其中:       
=
Y
br
B
c
2
1
ej
q
+
Yj
s
YsY
t -
1
2
t
Y
1
ej
q
shift
s
t
j
shift
+
s
B
c
2
      ,
sY
=
1
+
RjX
  。 
分散的线路导纳矩阵和母线泄漏导纳矩阵被 MATPOWER 联合成为复合母线导纳矩阵
Ybus,并以它来关联母线电压向量 Vbus 和母线电流向量 Ibus: 
IY V=
busbusbus
 
类似的,通过形成导纳矩阵 Yf 和 Yt 来计算线路首末端的电流向量,在给定母线电压
Vbus 的情况下: 
中国电力市场论坛(www.dlscbbs.net)翻译制作               一切版权归属原作者                   8 
PDF 文件使用 "pdfFactory Pro" 试用版本创建 www.fineprint.cn
Ø
ø
Ø
ø
Œ
œ
Œ
œ
º
ß
º
ß
Ø
ø
-
Œ
œ
Ł
ł
Œ
œ
Œ
œ
-
Œ
œ
º
ß