Home
Matpower 5.1 User`s Manual - Power Systems Engineering
Contents
1. o l _ S red shift Combining this and the second assumption with 3 1 yields the following approxi mation for tz 1 1 1 ay Xs Ge Te Osnift E 1 1 y i 04 0sni Zelf MA shitt 3 22 ILT T The approximate real power flow is then derived as follows first applying 3 19 and 3 22 then extracting the real part and applying 3 20 pp R sf R Los i N fer J lestr ainus IST T R J 1 ce 9 O4 Osnitt IST T i fl R E sino 0i Oshift 3 G cos 6 y 0 7 l 1 XL 5T ro Gp b 3 23 25 As expected given the lossless assumption a similar derivation for the power injec tion at the to end of the line leads to leads to p pf The relationship between the real power flows and voltage angles for an individual branch 7 can then be summarized as Pf _ pi 0 i Dt Byr 6 F shift 3 24 where i 1 1 Be ai i i i 1 P shift OcmisDi 1 and b is defined in terms of the series reactance x and tap ratio 7 for branch i as 1 Lor b For a shunt element at bus 2 the amount of complex power consumed is Sin Vi ye vi a e 951 N oe Fn io Up 3 25 So the vector of real power consumed by shunt elements at all buses can be approx imated by Pe Gsh 3 26 With a DC model the linear network equations relate real power to bus voltage angles versus complex currents to complex bus voltages in the AC
2. For opf solver ac option set to KNITRO only Requires the installation of the optional KNITRO package 35 See Appendix G 7 for details t Note that KNITRO uses the opt_fname option slightly differently from other optional solvers Specifically it is the name of a text file processed directly by KNITRO not a MATLAB function that returns an options struct passed to the solver Table C 15 OPF Options for MINOPF name default description minopf feastol 0 1073 primal feasibility tolerance set to value of opf violation by default minopf rowtol 0 1073 row tolerance set to value of opf violation by default minopf xtol 0 107 gz tolerance minopf majdamp 0 0 5 major damping parameter minopf mindamp 0 2 0 minor damping parameter minop penalty 0 1 0 penalty parameter minopf major_it 0 200 major iterations minopf minor_it 0 2500 minor iterations minopf max_it 0 2500 iteration limit minopf verbosity 1 amount of progress output printed by MEX file 1 controlled by verbose option 0 do not print anything 1 print only only termination status message 2 print termination status amp screen progress 3 print screen progress report file usually fort 9 minopf core 0 memory allocation defaults to 1200n 2 n ny minopf supbasic_lim 0 superbasics limit defaults to 2n 2ng minopf mult_price 0 30 multiple price For opf solver ac option set to MINOPF only Requires the install
3. 13 14 15 16 17 3 18 19 ia 20 21 H D Chiang A Flueck K Shah and N Balu CPFLOW A Practical Tool for Tracing Power System Steady State Stationary Behavior Due to Load and Generation Variations Power Systems IEEE Transactions on vol 10 no 2 pp 623 634 May 1995 5 1 S H Li and H D Chiang Nonlinear Predictors and Hybrid Corrector for Fast Continuation Power Flow Generation Transmission Distribution LET 2 3 341 354 2008 5 1 A J Flueck Advances in Numerical Analysis of Nonlinear Dynamical Sys tems and the Application to Transfer Capability of Power Systems Ph D Dissertation Cornell University August 1996 H Mori and S Yamada Continuation Power Flow with the Nonlinear Predictor of the Lagrange s Polynomial Interpolation Formula In Transmission and Distribution Conference and Exhibition 2002 Asia Pacific IEEE PES vol 2 pp 1133 1138 Oct 6 10 2002 5 1 R D Zimmerman C E Murillo S nchez and R J Thomas MATPOWER s Extensible Optimal Power Flow Architecture Power and Energy Society Gen eral Meeting 2009 IEEE pp 1 7 July 26 30 2009 6 3 TSPOPF Online Available http www pserc cornell edu tspopf 6 4 1 6 5 C 17 C 18 G 12 H Wang C E Murillo S nchez R D Zimmerman and R J Thomas On Computational Issues of Market Based Optimal Power Flow Power Systems IEEE Transactions on vol 22
4. The parameter is a constant scalar with a value slightly less than one In MIPS is set to 0 99995 In this method during the Newton like iterations the perturbation parameter y must converge to zero in order to satisfy the first order optimality conditions of the original problem MIPS uses the following rule to update y at each iteration after updating Z and pu ZB ps Ni JEEG A 52 where is a scalar constant between 0 and 1 In MIPS is set to 0 1 108 Appendix B Data File Format There are two versions of the MATPOWER case file format MATPOWER versions 3 0 0 and earlier used the version 1 format internally Subsequent versions of MATPOWER have used the version 2 format described below though version 1 files are still han dled and converted automatically by the loadcase and savecase functions In the version 2 format the input data for MATPOWER are specified in a set of data matrices packaged as the fields of a MATLAB struct referred to as a MAT POWER case struct and conventionally denoted by the variable mpc This struct is typically defined in a case file either a function M file whose return value is the mpc struct or a MAT file that defines a variable named mpc when loaded The fields of this struct are baseMVA bus branch gen and optionally gencost The baseMVA field is a scalar and the rest are matrices Each row in the data matrices corresponds to a single bus branch or generator and
5. if nargout gt 1 hh gradient is required df 4 ax x 1 73 x 1 x 2 2 x 1 2 2xax x 2 x 1 72 1 if nargout gt 2 4 Hessian is required d2f 4 a 3 x 1 72 x 2 1 2 a x 1 x 1 1 2 1 end end 99 Then create a handle to the function defining the value of the paramter a to be 100 set up the starting value of x and call the mips function to solve it gt gt f_fcn x banana x 100 gt gt xO 1 9 2 gt gt x f mips f_fcn x0 x 1 1 f 0 A 2 Example 2 The second example solves the following 3 dimensional constrained optimization printing the details of the solver s progress min f x 11 2 L2L3 A 8 subject to ri a az3 2 lt 0 A 9 cit ta t a23 10 lt 0 A 10 First create a MATLAB function to evaluate the objective function and its gra dients 24 From http en wikipedia org wiki Nonlinear_programming 3 dimensional_example 25Since the problem has nonlinear constraints and the Hessian is provided by hess_fcn this function will never be called with three output arguments so the code to compute d2f is actually not necessary 100 function f df d2f 2 x f x 1 x 2 x 2 x 3 if nargout gt 1 hh gradient is required df x 2 x 1 x 3 x 2 if nargout gt 2 h Hessian is required d2f 0 10 101 01 0 actually not used since end hess_fcn is provided end one to eva
6. 1 Z ye Z Au Z u ye u AZ Ap p 2Z ye 1 AZ A 38 Solving the 4 row of A 37 for AZ yields HANA MS H e Mia AO 2 HR A 39 106 Then substituting A 38 and A 39 into the 1 row of A 37 results in LY AX Gx AA Hx Ap L Lyx AX Gx AA Hx p Z ye u AZ Ly Ly AX Gx AA Hx Z ye u H X Z en Li Lx AX GxTAX Hx u Ax Z Hx Z 7 a H X Ax Z Z u e Z ul HxAX Lx Hx Z a Hx AX Gx AA Hx Z ye u H X ae MAX Gx AA N A 40 where M LYy Hx Z u Hx A 41 fxx Gxx A Hxx u Hx Z 1 Hx A 42 and 45 Hx Z ye 1 H X A 43 fx Gx Hx u Hx Z ye u HOOD A 44 Combining A 40 and the 3 row of A 37 results in a system of equations of reduced size E fax a J l e pa The Newton update can then be computed in the following 3 steps 1 Compute AX and AA from A 45 2 Compute AZ from A 39 3 Compute Ap from A 38 In order to maintain strict feasibility of the trial solution the algorithm truncates the Newton step by scaling the primal and dual variables by a and ag respectively 107 where these scale factors are computed as follows Zm Qp min lt amin 5 a A 46 ia _ Um Qq min lt a E 1 A 47 resulting in the variable updates below X X a AX A 48 Z Z4 a AZ A 49 A agAr A 50 we u aA A 51
7. Input Output Functions lt lt ded eee ee ML Toadcass bo eee ok a eRe RRA A e a A III Mula SARDE e ARE AIR RARA BS PAS Peso lt poa sa ek Pe e ee rar 44 44 45 46 46 47 49 49 49 50 52 52 53 54 59 59 60 61 63 65 67 70 72 74 74 74 75 76 79 82 Of veri ICAO e o eR OSE ER ES ee ee eo 85 Mie Meese ar arras GES 85 0 22 COMPARE ERES or aon ew pop OS eS oe eR eR SS 86 9 23 find islands IET LSE ew a 86 92A pet eee cs bine Oo bee hed A a a 86 UE MA ura eee ewe hee eRe HED Be OSS 87 E oie Ge ak VEY ok ERE eee Derek 2 eZ 87 Be PERPE vora oras Mie oe ete ee a Rc A 87 SEX Total AI 88 ag COBOS o Be 88 93 Modilying a Cabe odos ae aa EAE AA A 88 AA a A PUE 88 Dye IBAN 6d a bee RD RRAAEY AA A 89 Oso PASE Laia a GP Re Oe Eee e Re 89 Mat peale load eoi erea ek eb the ee OE SES AS ERR 89 9 4 Conversion between External and Internal Numbering 90 OA Sa AE 90 942 A E AAA 90 OAD 21 field 1De Tisld ei cw GAA RHEE ARR RRO RS 91 9 5 Forming Standard Power Systems Matrices 91 9 5 1 makeb coca eo REG EHD a amp EO oR 91 952 makeBbdo a eg ante seabed ce bee a we bw boo eH 92 e e e a eae OD koe whee em hee dee eee eS 92 Ooo makeYb s o i e se reos ae RO e p RA 92 9 6 Miscellaneous aoao ee essere a we 92 9 6 1 define constants o o o SE GE BOE PE eee eae 92 Coe BESO oe osaa He oe Soe de amp oe de Re SRS 93 AA 6 64 eee a ee ee Be ROE ee ee E 93 O04 nested StruUctCop
8. om add_constraints om Rreq r zones lreq R om add_costs om Rcost struct N I Cw Cw R 7 2 3 int2ext Callback After the simulation is complete and before the results are printed or saved MAT POWER converts the case data in the results struct back to external indexing by calling the following results int2ext results This conversion essentially undoes everything that was done by ext2int Generators are restored to their original ordering buses to their original numbering and all out of service or isolated generators branches and buses are restored This callback is invoked from int2ext immediately before the resulting case is converted from internal back to external indexing At this point the simulation 65 has been completed and the results struct a superset of the original MATPOWER case struct passed to the OPF contains all of the results This results struct is passed to the callback along with any optional args supplied when the callback was registered via add_userfcn The output of the callback is the updated results struct This is typically used to convert any results to external indexing and populate any corresponding fields in the results struct The results struct contains in addition to the standard OPF results solution in formation related to all of the user defined variables constraints and costs Table 7 2 summarizes where the various data is found Each of the
9. forms linear constraints for piecewise linear generator costs CCV input argument handling for opf constructs an OPF model object from a MATPOWER case executes the OPF specified by an OPF model object evaluates function and gradients for AC OPF nonlinear constraints evaluates function gradients and Hessian for AC OPF objective function evaluates the Hessian of the Lagrangian for AC OPF computes the total cost of generation as a function of generator output updates generator limit prices based on the shadow prices on capability curve constraints Used by fmincon MIPS Ipopr and KNITRO for AC OPF name add_userfcn remove_userfcn run_userfcn toggle_dcline toggle_iflims toggle_reserves toggle_softlims Table D 11 OPF User Callback Functions description appends a user callback function to the list of those to be called for a given case removes a user callback function from the list executes the user callback functions for a given stage enable disable or check the status of the callbacks implementing DC lines enable disable or check the status of the callbacks implementing in terface flow limits enable disable or check the status of the callbacks implementing fixed reserve requirements enable disable or check the status of the callbacks implementing DC OPF branch flow soft limits 138 Table D 12 Power Flow Derivative Functions name description dIbr_dV evaluates the partial derivatives of Ip eval
10. opt gradtol 1076 termination tolerance for gradient condition opt comptol 1076 termination tolerance for complementarity condition opt costtol 1078 termination tolerance for cost condition opt max_it 150 maximum number of iterations opt step_control 0 set to 1 to enable step size control opt sc red_it 20 max number of step size reductions if step control is on opt cost_mult 1 cost multiplier used to scale the objective function for improved conditioning Note This value is also passed as the 3 argu ment to the Hessian evaluation function so that it can appro priately scale the objective function term in the Hessian of the Lagrangian opt xi 0 99995 constant used in a updates in A 46 and A 47 opt sigma 0 1 centering parameter o used in y update in A 52 opt z0 1 used to initialize elements of slack variable Z opt alpha min 1078 algorithm returns Numerically Failed if the a or aq from A 46 and A 47 become smaller than this value opt rho_min 0 95 lower bound on p corresponding to 1 7 in Fig 5 in 18 opt rho_max 1 05 upper bound on p corresponding to 1 7 in Fig 5 in 18 opt mu_threshold 1075 Kuhn Tucker multipliers smaller than this value for non binding constraints are forced to zero opt max stepsize 10 algorithm returns Numerically Failed if the 2 norm of the New ton step me from A 45 exceeds this value function f df d2f banana x a f a x 2 x 1 2 2 1 x 1 72
11. ulations in F Wolf B Mohr and D Mey editors Euro Par 2013 Parallel Processing Vol 8097 Lecture Notes in Computer Science pp 533 544 Springer Berlin Heidelberg 2013 G 6 G 10 R H Byrd J Nocedal and R A Waltz KNITRO An Integrated Package for Nonlinear Optimization Large Scale Nonlinear Optimization G di Pillo and M Roma eds pp 35 59 2006 Springer Verlag http www ziena com papers integratedpackage pdf 6 5 C 14 G 7 168
12. where FP and F ax are the specified lower and upper bounds on the interface flow and Zy is a the set indices of interfaces whose flow limits are to be enforced The data for the problem is specified in an additional if field in the MATPOWER case struct mpc This field is itself a struct with two sub fields map and lims used for input data and two others P and mu used for output data The format of this data is described in detail in Tables 7 4 and 7 5 See help toggle iflims for more information Examples of using this extension and a case file defining the necessary input data for it can be found in t_opf_userfcns and t_case30_userfcns respectively Note that while this extension can be used for AC OPF problems the actual AC interface flows will not necessarily be limited to the specified values since it is a DC flow approximation that is used for the constraint 211f d 1 the definitions of the positive flow direction for the branch and the interface are the same If d 1 they are opposite 75 Table 7 4 Input Data Structures for Interface Flow Limits name description mpc MATPOWER case struct if additional field in mpc containing input parameters for interface flow limits in the following sub fields map p nk x2 matrix defining the interfaces where ng is the number branches that belong to interface k The nz branches of interface k are defined by nj rows in the matrix where the first column in each is equal
13. In addition both ext2int and int2ext can be customized via user supplied callback routines to convert data needed by user supplied variables constraints or costs into internal indexing 56 Table 6 2 Optimal Power Flow Solver Options name default description opf ac solver DEFAULT AC optimal power flow solver DEFAULT choose default solver based on availability in the following order PDIPM MIPS MIPS MIPS MATLAB Interior Point Solver pri mal dual interior point method FMINCON MATLAB Optimization Toolbox fmincon IPOPT IPOPT KNITRO KNITRO MINOPF MINOPF MINOS based solver PDIPM PDIPM primal dual interior point method SDPOPF SDPOPF solver based on semidefinite relax ation TRALM TRALM trust region based augmented Lan grangian method opf dc solver DEFAULT DC optimal power flow solver DEFAULT choose default solver based on availability in the following order CPLEX GUROBI MOSEK BPMPD OT GLPK linear costs only MIPS MIPS MIPS MATLAB Interior Point Solver pri mal dual interior point method BPMPD BPMPD CLP CLP CPLEX CPLEX GLPK GLPK no quadratic costs GUROBI Gurobi IPOPT IPOPT MOSEK MOSEK OT MATLAB Opt Toolbox quadprog linprog Requires the installation of an optional package See Appendix G for details on the corresponding package t For MIPS
14. TN2 OPF Derivatives pdf Tech Note 2 AC Power Flows Generalized OPF Costs and their Derivatives using Complex Matrix Notation For Windows users text file with Windows style line endings D 2 MATPOWER Functions 134 Table D 2 Top Level Simulation Functions name description runpf power flowt runcpf AC continuation power flow runopf optimal power flowt runuopf optimal power flow with unit decommitment rundcpf DC power flow rundcopf DC optimal power flow runduopf DC optimal power flow with unit decommitment runopf_w_res optimal power flow with fixed reserve requirements Uses AC model by default t Simple wrapper function to set option to use DC model before calling the cor responding general function above Table D 3 Input Output Functions name description cdf 2mpc converts power flow data from IEEE Common Data Format CDF to MATPOWER format loadcase loads data from a MATPOWER case file or struct into data matrices or a case struct mpoption sets and retrieves MATPOWER options printpf pretty prints power flow and OPF results psse2mpc converts power flow data from PSS E format to MATPOWER format savecase saves case data to a MATPOWER case file Table D 4 Data Conversion Functions name description ext2int converts case from external to internal indexing e2i_data converts arbitrary data from external to internal indexing e2i field converts fields in mpc from external to internal indexing int2e
15. and the full details are documented in Appendix B and can be accessed at any time via the command help caseformat The MATPOWER distribution also includes many example case files listed in Table D 17 2 3 2 Solving the Case The solver is invoked by calling one of the main simulation functions such as runpf or runopf passing in a case file name or a case struct as the first argument For example to run a simple Newton power flow with default options on the 9 bus system defined in case9 m at the MATLAB prompt type gt gt runp f case9 If on the other hand you wanted to load the 30 bus 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 this could be accomplished as follows 8This describes version 2 of the MATPOWER case format which is used internally and is the default The version 1 format now deprecated but still accessible via the loadcase and savecase functions defines the data matrices as individual variables rather than fields of a struct and some do not include all of the columns defined in version 2 16 gt gt define_constants gt gt mpc loadcase case30 gt gt mpc bus 2 PD 30 gt gt runopf mpc The define_constants in the first line is simply a convenience script that defines a number of variables to serve as named column indices for the data matrices In this example it allows
16. c r 7 3 There are two additional sets of constraints needed The first ensures that for each generator the total amount of energy plus reserve provided does not exceed the capacity of the unit pi r lt g ee i 1 ng 7 4 The second requires that the sum of the reserve allocated within each zone k meets the stated requirements Sori gt Ry k aTi 7 5 1EZk Table 7 1 describes some of the variables and names that are used in the example callback function listings in the sections below 7 2 1 ext2int Callback Before doing any simulation of a case MATPOWER performs some data conversion on the case struct in order to achieve a consistent internal structure by calling the following mpc ext2int mpc 61 Table 7 1 Names Used by Implementation of OPF with Reserves name description mpc MATPOWER Case struct reserves additional field in mpc containing input parameters for zonal reserves in the following sub fields cost Ng X 1 vector of reserve costs c from 7 3 qty Ng X 1 vector of reserve quantity upper bounds ith element is rmx zones Mrz X Ng Matrix of reserve zone definitions 1 if gen j belongs to reserve zone k j Zk zones 0 otherwise j Z req M2 X 1 vector of zonal reserve requirements k element is Ry from 7 5 om OPF model object already includes standard OPF setup results OPF results struct superset of mpc with additional fields for output data ng Ng number of gen
17. control output of voltage limit info 0 do not print 1 print binding constraints only 2 print all constraints control output of line flow limit info control output of gen active power limit info control output of gen reactive power limit infot Overrides individual flags Takes values of 0 1 or 2 as for out lim v 58 7 Extending the OPF The extended OPF formulation described in Section 6 3 allows the user to modify the standard OPF formulation to include additional variables costs and or constraints There are two primary mechanisms available for the user to accomplish this The first is by directly constructing the full parameters for the addional costs or constraints and supplying them either as fields in the case struct or directly as arguments to the opf function The second and more powerful method is via a set of callback functions that customize the OPF at various stages of the execution MATPOWER includes two examples of using the latter method one to add a fixed zonal reserve requirement and another to implement interface flow limits 7 1 Direct Specification To add costs directly the parameters H C N f k d and m of 6 27 6 31 described in Section 6 3 1 are specified as fields or arguments H Cw N and fparm repectively where fparm is the ny x 4 matrix Jem a f k m 7 1 When specifying additional costs N and Cw are required while H and fparm are optional The default value for H i
18. cora bea eee ee we ERE OE HO Power Flow ODIOS 2 44424 24d 0448 24444 h4 84 e ob x Power Plow Output Options sei a we Se ARA Continuation Power Flow Results 2 0000 0s Continuation Power Flow Options 004 Continuation Power Flow Callback Arguments Optimal Power Flow Results 0 0 0002 ee eee Optimal Power Flow Solver Options o o Other OPF Options s s se seu seoa eee ere de eed OPF Output Were vs seraa eee O RANA Names Used by Implementation of OPF with Reserves Results for User Defined Variables Constraints and Costs Callback Functions sos s sa es aa reana Re paa RA eee ES Input Data Structures for Interface Flow Limits Output Data Structures for Interface Flow Limits Input Data Structures for DC OPF Branch Flow Soft Limits Output Data Structures for DC OPF Branch Flow Soft Limits Input Arguments for mips 4 64 eee GA a aoe ew S Output Arpumentes for mips es 2c FASE riores eris iene lor mips s e cce eA EER OER RE PSE EES Dus Data ape bus ia Oo db he e he Oe oS oO ee AG SO B 2 Generator Data mpegen 2 4424 lt 4 85444 4S Cee eo Ss 111 B 3 Branch Data mpc branch o oaoa ee de ew be ee 112 B 4 Generator Cost Data mpc gencost a 113 B 5 DC Line Data mpc dcline o o 114 C 1 Top Level Options orcas erario AR EU 117 C 2 Power Flow Options 2 2 26 e441 eee bee ew be
19. mips sc red_it pdipm sc red_it tralm feastol tralm primaltol tralm dualtol tralm costtol tralm major_it tralm minor_it tralm smooth_ratio pdipm sc smooth_ratio cplex lpmethod cplex qpmethod cplex opt mosek 1lp_alg mosek max_it mosek gap_tol mosek max_time mosek num threads mosek opt 132 for c3sopf not part of MATPOWER continued on next page idx 121 122 123 124 Table C 19 old option GRB_METHOD GRB_TIMELIMIT GRB_THREADS GRB_OPT Old Style to New Style Option Mapping continued new option notes gurobi method gurobi timelimit gurobi threads gurobi opt 133 Appendix D MATPOWER Files and Functions This appendix lists all of the files and functions that MATPOWER provides with the exception of those in the extras directory see Appendix E In most cases the function is found in a MATLAB M file of the same name in the top level of the distri bution where the m extension is omitted from this listing For more information on each at the MATLAB prompt simply type help followed by the name of the function For documentation and data files the filename extensions are included D 1 Documentation Files Table D 1 MATPOWER Documentation Files name description README README txt basic introduction to MATPOWER docs CHANGES CHANGES txt MATPOWER change history manual pdf MATPOWER 5 1 User s Manual TN1 OPF Auctions pdf Tech Note 1 Uniform Price Auctions and Optimal Power Flow
20. 11 lt lt 2X and Mi lt Ma lt lt Mp The basin corresponding to this cost function is formed by the following n constraints on the helper cost variable y y gt mj z zr c j 1 n 6 34 The cost term added to the objective function in place of c x is simply the variable y 49 XO Ly T2 Tn Figure 6 3 Constrained Cost Variable MATPOWER uses this CCV approach internally to automatically generate the appropriate helper variable cost term and corresponding set of constraints for any piecewise linear costs on real or reactive generation All of MATPOWER s OPF solvers for both AC and DC OPF problems use the CCV approach with the ex ception of two that are part of the optional TSPOPF package 17 namely the step controlled primal dual interior point method SCPDIPM and the trust region based augmented Lagrangian method TRALM both of which use a cost smoothing technique instead 18 6 4 2 Dispatchable Loads A simple approach to dispatchable or price sensitive loads is to model them as nega tive real power injections with associated negative costs This is done by specifying a generator with a negative output ranging from a minimum injection equal to the negative of the largest possible load to a maximum injection of zero Consider the example of a price sensitive load whose marginal benefit function is shown in Figure 6 4 The demand pg of this load will be zero for prices above A1 p for prices betw
21. 3 Cin OS ey 6 4 6 1 Standard AC OPF The optimization vector x for the standard AC OPF problem consists of the n x 1 vectors of voltage angles O and magnitudes V and the n x 1 vectors of generator real and reactive power injections P and Q O Vin t p 6 5 g Qy The objective function 6 1 is simply a summation of individual polynomial cost functions f and fo of real and reactive power injections respectively for each generator Ng ov y 2 Fels Sala 6 6 The equality constraints in 6 2 are simply the full set of 2 n nonlinear real and reactive power balance equations from 4 2 and 4 3 The inequality constraints 6 3 consist of two sets of n branch flow limits as nonlinear functions of the bus voltage angles and magnitudes one for the from end and one for the to end of each branch h Vin F 9 Vin Fmax lt 0 6 7 hi Vm F 9 Vin Frnax lt 0 6 8 44 The flows are typically apparent power flows expressed in MVA but can be real power or current flows yielding the following three possible forms for the flow constraints S O Vm apparent power F Vin 3 P O Vm real power 6 9 If O Vin current where Jy is defined in 3 9 Sy in 3 15 Pp R Sf and the vector of flow limits Fmax has the appropriate units for the type of constraint It is likewise for F 0 Vm The values used by MATPOWER s OPF for the flow limits Fmax are specified in the RAT
22. 3d 6d 72d k results gen k GEN_BUS results gen k GEN_STATUS if results gen k GEN_STATUS gt 0 amp amp abs results reserves R k gt 1e 6 fprintf fd 10 2f results reserves R k else fprintf fd sd end fprintf fd 10 2f results reserves prc k end fprintf fd a 0 eee fprintf fd n Total 10 2f Total Cost 2f sum results reserves R r igr results reserves totalcost fprintf fd n fprintf fd nZone Reserves Price fprintf fd n MW MW fprintf fd n DE for k 1 nrz iz find r zones k hh gens in zone k fprintf fd n 3d 10 2f 10 2f k sum results reserves R iz results lin mu 1 Rreq k results baseMVA end fprintf fd n print binding reserve limit multipliers end 69 7 2 5 savecase Callback The savecase is used to save a MATPOWER case struct to an M file for example to save the results of an OPF run The savecase callback is invoked from savecase after printing all of the other data to the file Inputs are the case struct the file descriptor to write to the variable prefix typically mpc and any optional args supplied via add_userfcn Output is the case struct The purpose of this callback is to write any non standard case struct fields to the case file In this example the zones req cost and qty fields of mpc reserves are written to the M file This ensures that a case with reser
23. 6 19 predp ap a Lam 6 20 6 3 Extended OPF Formulation MATPOWER employs an extensible OPF structure 16 to allow the user to modify or augment the problem formulation without rewriting the portions that are shared with the standard OPF formulation This is done through optional input parame ters preserving the ability to use pre compiled solvers The standard formulation is modified by introducing additional optional user defined costs f constraints and variables z and can be written in the following form min f x falz z 6 21 subject to g x 0 6 22 h x lt 0 6 23 Tmin lt x lt Tmax 6 24 isa su 6 25 min lt 2 2max 6 26 Section 7 describes the mechanisms available to the user for taking advantage of the extensible formulation described here 6 3 1 User defined Costs The user defined cost function fu is specified in terms of parameters H C N 7 k d and m All of the parameters are n x 1 vectors except the symmetric ny X Ny matrix H and the n x nz nz matrix N The cost takes the form iia swt Hw Cw 6 27 46 where w is defined in several steps as follows First a new vector u is created by applying a linear transformation N and shift 7 to the full set of optimization variables rea 6 28 u r F 6 29 then a scaled function with a dead zone is applied to each element of u to produce the corresponding element of w Mi fa ui ki Uz lt k Mi fa us
24. By adding a continuation parameter and one more equation to the system x can be traced by varying A The resulting system f z A 0 has n 1 dimensions The additional equation is a parameterized equation which identifies the location of the current solution with respect to the previous or next solution The continuation process can be diagrammatically shown by 5 1 xi A Predictor git Sit Corrector a 7H 5 1 where 17 A7 represents the current solution 2741 J is the predicted solution and x7 M D is the next solution on the curve Continuation methods are employed in power systems to determine steady state stability limits 11 in what is called a continuation power flow The limit is de termined from a nose curve where the nose represents the maximum power transfer that the system can handle given a power transfer schedule To determine the steady state loading limit the basic power flow equations P x P o o i are restructured as f x A g x Ab 0 5 3 where x O Vm and b is a vector of power transfer given by pri pri target base 5 4 One bao l The effects of the variation of loading or generation can be investigated using the continuation method by composing the b vector appropriately 10Thanks to Shrirang Abhyankar Rui Bo and Alexander Flueck for contributions to MAT POWER s continuation power flow feature 35 5 1 Parameterization T
25. Internal Numbering 9 4 1 ext2int int2ext ext2int mpc_ext int2ext mpc_int mpc_int mpc_ext These functions convert a MATPOWER case struct from external to internal and from internal to external numbering respectively ext2int first removes all isolated buses off line generators and branches and any generators or branches connected to isolated buses Then the buses are renumbered consecutively beginning at 1 and the generators are sorted by increasing bus number Any ext2int callback routines registered in the case are also invoked automatically All of the related indexing information and the original data matrices are stored in an order field in the struct to be used later by codeint2ext to perform the reverse conversions If the case is already using internal numbering it is returned unchanged 9 4 2 e2i_data i2e_data val e2i_data mpc val ordering val e2i_data mpc val ordering dim val i2e_data mpc val oldval ordering val i2e_data mpc val oldval ordering dim These functions can be used to convert other data structures from external to internal indexing and vice versa When given a case struct mpc that has already been converted to internal indexing e2i_data can be used to convert other data structures as well by passing in 2 or 3 extra parameters in addition to the case struct If the value passed in the second argument val is a column vector or cell array it will b
26. LP based OPF solvers and it improves the robustness of MINOPF It is also useful outside of MAT POWER as a general purpose QP LP solver This MEX interface for BPMPD was coded by Carlos E Murillo S nchez while he was at Cornell University It does not provide all of the functionality of BPMPD however In particular the stand alone BPMPD program is designed to read and write results and data from MPS and QPS format files but this MEX version does not implement reading data from these files into MATLAB The current version of the MEX interface is based on version 2 21 of the BPMPD solver implemented in Fortran Builds are available for Linux 32 bit Mac OS X PPC Intel 32 bit and Win dows 32 bit at http www pserc cornell edu bpmpd When installed BPMPD_MEX can be selected as the solver for DC OPFs by setting the opf solver dc option to BPMPD It can also be used to solve general LP and QP problems via MATPOWER s common QP solver interface qps matpower with the algorithm option set to BPMPD or 100 for backward compatibility or by calling qps_bpmpd directly G 2 CLP COIN OR Linear Programming The CLP 28 COIN OR Linear Programming solver is an open source linear pro gramming solver written in C by John Forrest It can solve both linear program ming LP and quadratic programming QP problems It is primarily meant to be used as a callable library but a basic stand alone executable version exists as well It i
27. MU_VMIN Kuhn Tucker multiplier on lower voltage limit results gen MU_PMAX Kuhn Tucker multiplier on upper P limit results gen MU_PMIN Kuhn Tucker multiplier on lower Py limit results gen MU_QMAX Kuhn Tucker multiplier on upper Q limit results gen MU_QMIN Kuhn Tucker multiplier on lower Qg limit results branch MU_SF Kuhn Tucker multiplier on flow limit at from bus results branch MU_ST Kuhn Tucker multiplier on flow limit at to bus results mu shadow prices of constraints results g optional constraint values results dg optional constraint 1st derivatives results raw raw solver output in form returned by MINOS and more results var val final value of optimization variables by named subsett results var mu shadow prices on variable bounds by named subset results nln shadow prices on nonlinear constraints by named subset results lin shadow prices on linear constraints by named subset results cost final value of user defined costs by named subset See help for opf model for more details t See help for opf for more details Additional optional input arguments can be used to set options mpopt and provide file names for saving the pretty printed output fname or the solved case data solvedcase gt gt results runopf casedata mpopt fname solvedcase Some of the main options that control the optimal power flow simulation are listed in Tables 6 2 and 6 3 There are many
28. Ol RM hE HK doe SHS 21 21 21 23 23 23 24 24 28 28 30 30 32 6 5 Solvers 6 6 runopf 6 Optimal Power Flow OL Standard ALCOBE 2 2 esac eta moe eke be hee be eRe OES 62 Sipndard DO OPF cuca Oe a oe g a ee de be a 6 3 Extended OPF Formulation 0 0 000008 6 3 1 User defined Costs 2 0 0 6 3 2 User defined Constraints 0 0 0 02 00 0004 6 3 3 User defined Variables 0 0 2 00004 Standard EytensionsS lt lt a c s by eee ce ee eee eR ee YS 6 4 1 Piecewise Linear Costs 0 0 0 0 0 0 0 0000008 64 2 Dispatchable Loads gt gt s lt a sso sosterrana Ava SoS 6 4 3 Generator Capability Curves 6 4 4 Branch Angle Difference Limits Extending the OPF Ti Direct o AA T2 Callback FUNCIONE ceca a ead D oka ete de Tal 20 Calak a e geag a we Ba Roe Bs 7 2 2 formulation Callback laa imt2ext Callback e oe cu ep ad a e a A 248 printpf Gallback s cier ena aaa e e ee A moD pavecase Callback ecet oa p iui a a eke ea Registering the Callbacks a aoa a aa a eee ee ee o paid k a a eh ke Re ere 4 ere he Bes simple een ow ee ew Kee ac ae a ee SO 7 5 1 Fixed Zonal Reserves e 7 5 2 Interface Flow Limits 7 5 3 DC Transmission Lines 7 5 4 DC OPF Branch Flow Soft Limits Unit De commitment Algorithm Miscellaneous MATPOWER Functions
29. The matrix of second partial derivatives the Hessian of f is fe gen Of xx Ea OX ax ox t ef 011 0x1 r For a vector function F R R of a vector X where F X A X IX e fm X J A 16 the first derivatives form the Jacobian matrix where row 2 is the transpose of the gradient of fi Ofi Of OF 0x1 Orn Fy 3 o A 17 OX afm fm 0x1 OLn In these derivations the full 3 dimensional set of second partial derivatives of F will not be computed Instead a matrix of partial derivatives will be formed by computing the Jacobian of the vector function obtained by multiplying the transpose of the Jacobian of F by a vector A using the following notation o Fxx A A Bye A 18 Please note also that A is used to denote a diagonal matrix with vector A on the diagonal and e is a vector of all ones A 4 2 Problem Formulation and Lagrangian The primal dual interior point method used by MIPS solves a problem of the form min f X A 19 subject to G X 0 A 20 H X lt 0 A 21 where the linear constraints and variable bounds from A 4 and A 5 have been incorporated into G X and H X The approach taken involves converting the n 104 inequality constraints into equality constraints using a barrier function and vector of positive slack variables Z min 100 gt Y In Z n A 22 subject to G X 0 A 23 H X Z 0 A 24 Z gt 0 A 25 As the para
30. This works when specifying the overrides as a struct or function name as well For backward compatibility the first argument can be an old style options vector fol lowed by old style option name value pairs The available options and their default values are summarized in the following tables and can also be accessed via the command help mpoption Some of the options require separately installed optional packages available from the MATPOWER website 116 name model pf cpf opf verbose out mips clp cplex fmincon glpk gurobi ipopt knitro minopf mosek pdipm tralm default I AC see Table C 2 see Table C 3 see Tables C 4 C 5 1 see Table C 6 see Table C 7 see Table C 8 see Table C 9 see Table C 10 see Table C 11 see Table C 12 see Table C 13 see Table C 14 see Table C 15 see Table C 16 see Table C 17 see Table C 18 Table C 1 Top Level Options description AC vs DC modeling for power flow and OPF formulation AC use AC formulation and corresponding algs options DC use DC formulation and corresponding algs options power flow options continuation power flow options optimal power flow options amount of progress info printed 0 print no progress info 1 print a little progress info 2 print a lot of progress info 3 print all progress info pretty printed output options MIPS options CLP options CPLEX options fmincon options GLPK options Gurobi opti
31. and modify The MATPOWER home page can be found at http www pserc cornell edu matpower MATPOWER was initially developed by Ray D Zimmerman Carlos E Murillo S nchez and Deqiang Gan of PSERC at Cornell University under the direction of Robert J Thomas The initial need for MATLAB based power flow and optimal power flow code was born out of the computational requirements of the PowerWeb project Many others have contributed to MATPOWER over the years and it continues to be developed and maintained under the direction of Ray Zimmerman http www pserc cornell edu http www pserc cornell edu powerweb 1 2 License and Terms of Use Beginning with version 5 1 the code in MATPOWER is distributed under the 3 clause BSD license 1 The full text of the license can be found in the LICENSE file at the top level of the distribution or at http www pserc cornell edu matpower LICENSE txt and reads as follows Copyright c 1996 2015 Power System Engineering Research Center PSERC and individual contributors see AUTHORS file for details All rights reserved Redistribution and use in source and binary forms with or without modification are permitted provided that the following conditions are met 1 Redistributions of source code must retain the above copyright notice this list of conditions and the following disclaimer 2 Redistributions in binary form must reproduce the above copyright notice this list of c
32. case Let the m x 1 vector Byp be constructed similar to Yp where the th element is b and let Py shitt be the n x 1 vector whose i th element is equal to 0 urbi Then the nodal real power injections can be expressed as a linear function of O the nz x 1 vector of bus voltage angles Pous O BousO Ppus shift 3 27 where Poussnitt Cp Ce Pp shite 3 28 26 Similarly the branch flows at the from ends of each branch are linear functions of the bus voltage angles P O B 9 FP shift 3 29 and due to the lossless assumption the flows at the to ends are given by P Py The construction of the system B matrices is analogous to the system Y matrices for the AC model By Bsr Cp Ci 3 30 Br C O By 3 31 The DC nodal power balance equations for the system can be expressed in matrix form as gP 9 Po Bra Phus shift Py Gish Tr CP 0 3 32 2d 4 Power Flow The standard power flow or loadflow problem involves solving for the set of voltages and flows in a network corresponding to a specified pattern of load and generation MATPOWER includes solvers for both AC and DC power flow problems both of which involve solving a set of equations of the form g x 0 4 1 constructed by expressing a subset of the nodal power balance equations as functions of unknown voltage quantities All of MATPOWER s solvers exploit the sparsity of the problem and except for Gauss Seidel
33. fields listed in the table is actually a struct whose fields correspond to the named sets created by add_vars add_constraints and add_costs Table 7 2 Results for User Defined Variables Constraints and Costs name description results var val final value of user defined variables results var mu 1 shadow price on lower limit of user defined variables results var mu u shadow price on upper limit of user defined variables results lin mu 1 shadow price on lower left hand limit of linear constraints results lin mu u shadow price on upper right hand limit of linear constraints results cost final value of user defined costs In the example code below the callback function begins by converting the reserves input data in the resulting case qty cost and zones fields of results reserves back to external indexing via calls to i2e field See the help for i2e field and i2e data for more details on how they can be used Then the reserves results of interest are extracted from the appropriate sub fields Of results var results lin and results cost converted from per unit to per MW where necessary and stored with external indexing for the end user in the chosen fields of the results struct 66 function results userfcn_reserves_int2ext results args hh convert stuff back to external indexing convert all reserve parameters zones costs qty rgens results i2e_field results reserves qty gen results
34. function is function cb_state results cpf_user_callback k V_c lam_c V_p lam_p cb_data cb_state cb_args results and the input and output arguments are described in Table 5 3 and in the help for cpf_default_callback The CPF user callback functions are called in three different 39 Table 5 3 Continuation Power Flow Callback Arguments name description Inputs k continuation step iteration count vic vector of complex bus voltages after k th corrector step lam_c value of A after k th corrector step vp vector of complex bus voltages after k th predictor step lam_p value of A after k th predictor step cb_data struct containing potentially useful static data with the following fields all based on internal indexing mpc_base MATPOWER case struct of base state mpc_target MATPOWER case struct of target state Sxfr power transfer vector b from 5 4 Ybus bus admittance matrix Yf branch admittance matrix from end of branches Yt branch admittance matrix to end of branches pv list of indices of PV buses pq list of indices of PQ buses ref list of indices of reference buses mpopt MATPOWER options struct cb_state user defined struct containing any information the callback function would like to pass from one invokation to the next cb_args callback arguments struct specified in cpf user_callback_args results initial value of output struct to be assigned to cpf field of results struct returned b
35. m t_case9_dcline m t_case9_opf m t_case9_opfv2 m t_case9_pf m t_case9_pfv2 m t_case30_userfcns m t_psse_case raw t_psse_case2 m t_psse_case2 raw t_psse_case3 m t_psse_case3 raw pretty printed output of an example AC OPF run pretty printed output of an example DC OPF run solution data DC OPF of t_case9_opf solution data DC power flow of t_case9_pf solution data AC OPF of t_case9_opfv2 w only branch angle difference limits gen PQ capability constraints removed solution data AC OPF of t_case9_opf w extra cost constraints solution data AC OPF of t_case9_opf w opf flow_lim P solution data AC OPF of t_case9_opfv2 w only gen PQ capabil ity constraints branch angle diff limits removed solution data AC OPF of t_case9_opf solution data AC power flow of t_case9 pf case data used to test auction code case data used to test ext2int and int2ext external indexing example output from case_info used by t_islands case data used to test ext2int and int2ext internal indexing same as t_case9_opfv2 with additional DC line data sample case file with OPF data version 1 format sample case file with OPF data version 2 format includes addi tional branch angle diff limits amp gen PQ capability constraints sample case file with only power flow data version 1 format sample case file with only power flow data version 2 format sample case file with OPF reserves and interface flow limit data sample PSS E format RAW file used to
36. mpc It can optionally save the resulting case to a file fname convert loads only at specific buses idx and set the value of lost load voll to be used as the curtailment price default is 5 000 MWh 9 3 3 modcost newgencost modcost gencost alpha newgencost modcost gencost alpha modtype The modcost function can be used to modify generator cost functions by shifting or scaling them either horizontally or vertically The alpha argument specifies the numerical value of the modification and modtype defines the type of modification as a string that takes one of the following values SCALE_F default SCALE_X SHIFT_F or SHIFT_X 9 3 4 scale load bus scale_load load bus bus gen scale_load load bus gen load_zone opt bus gen gencost scale_load load bus gen load_zone opt gencost The scale_load function is used to scale active and optionally reactive loads in each zone by a zone specific ratio i e R k for zone k The amount of scaling for each zone either as a direct scale factor or as a target quantity is specified in load The load zones are defined by load_zone and opt specifies the type of scaling factor or target quantity and which loads are affected active reactive or both and fixed dispatchable or both The costs gencost associated with dispatchable loads can also be optionally scaled with the loads 89 9 4 Conversion between External and
37. no 3 pp 1185 1193 August 2007 6 4 1 6 5 A A 3 A 4 G 12 Optimization Toolbox 4 Users s Guide The MathWorks Inc 2008 On line Available http www mathworks com access helpdesk help pdf_ doc optim optim_tb pdf 6 5 BPMPD_MEX Online Available http www pserc cornell edu bpmpd 0 5 GI C M szaros The Efficient Implementation of Interior Point Methods for Linear Programming and their Applications Ph D thesis E tv s Lor nd University of Sciences Budapest Hungary 1996 6 5 G 1 166 22 23 24 25 26 27 28 29 30 31 32 MINOPF Online Available http www pserc cornell edu minopf 6 5 C 15 F G 8 B A Murtagh and M A Saunders MINOS 5 5 User s Guide Stanford Uni versity Systems Optimization Laboratory Technical Report SOL83 20R 6 5 G 8 R D Zimmerman AC Power Flows Generalized OPF Costs and their Deriva tives using Complex Matrix Notation MATPOWER Technical Note 2 Febru ary 2010 Online Available http www pserc cornell edu matpower TN2 OPF Derivatives pdf 6 5 H Wang On the Computation and Application of Multi period Security constrained Optimal Power Flow for Real time Electricity Market Operations Ph D thesis Electrical and Computer Engineering Cornell University May 2007 A A 4 G 12 S Fliscounakis P Panciatici F Capitanescu and L Wehenkel Contingency Ranking With Respect to Overloads in Very Large Po
38. of variables constraints or cost rows returns the value of a field of the object returns the initial values and bounds for optimimization vector builds and returns the full set of linear constraints A l u constructor for the opt_model class saves or returns values of user data stored in the model For all or alternatively only for a named and possibly indexed subset Table D 9 OPF Solver Functions name description dcopf_solver sets up and solves DC OPF problem fmincopf_solver sets up and solves OPF problem using fmincon MATLAB Opt Toolbox ipoptopf_solver sets up and solves OPF problem using Ipopt ktropf_solver sets up and solves OPF problem using KNITRO mipsopf_solver sets up and solves OPF problem using MIPS mopf_solver sets up and solves OPF problem using MINOPFt tspopf_solver sets up and solves OPF problem using PDIPM SC PDIPM or TRALM Requires the installation of an optional package See Appendix G for details on the corresponding package 137 name margcost makeAang makeApq makeAvl makeAy opf_args opf_setup opf_execute opf consfcn opf_costfcn opf _hessfcn totcost update _mupg Table D 10 Other OPF Functions description computes the marginal cost of generation as a function of generator output forms linear constraints for branch angle difference limits forms linear constraints for generator PQ capability curves forms linear constraints for dispatchable load constant power factor
39. other options that can be used to control the termination criteria and other behavior of the individual solvers See Appendix C or the mpoption help for details As with runpf the output printed to the screen can be controlled by the options in Table 4 3 but there are additional output options 55 for the OPF related to the display of binding constraints that are listed Table 6 4 along with an option that can be used to force the AC OPF to return information about the constraint values and Jacobian and the objective function gradient and Hessian By default runopf solves an AC optimal power flow problem using a primal dual interior point method To run a DC OPF the model option must be set to DC For convenience MATPOWER provides a function rundcopf which is simply a wrapper that sets the model to DC before calling runopf Internally the runopf function does a number of conversions to the problem data before calling the appropriate solver routine for the selected OPF algorithm This external to internal format conversion is performed by the ext2int function described in more detail in Section 7 2 1 and includes the elimination of out of service equipment the consecutive renumbering of buses and the reordering of generators by increasing bus number All computations are done using this internal indexing When the simulation has completed the data is converted back to external format by int2ext before the results are printed and returned
40. our PSERC associates at the University of Wisconsin for the technique for building the Jacobian matrix Our appreciation to Bruce Wollenberg for all of his suggestions for improvements to version 1 The enhanced output func tionality in version 2 0 is primarily due to his input Thanks also to Andrew Ward for code which helped us verify and test the ability of the OPF to optimize reactive power costs Thanks to Alberto Borghetti for contributing code for the Gauss Seidel power flow solver and to Mu Lin for contributions related to power flow reactive power limits Real power line limits were suggested by Pan Wei Thanks to Roman Korab for data for the Polish system Some state estimation code was contributed by James S Thorp and Rui Bo contributed additional code for state estimation and continuation power flow MATPOWER was improved in various ways in response to Doug Mitarotonda s contributions and suggestions Thanks also to many others who have contributed code testing time bug reports and suggestions over the years And last but not least thanks to all of the many users who by using MATPOWER in their own work have helped to extend the contribution of MATPOWER to the field of power systems far beyond what we could do on our own 95 Appendix A MIPS MATLAB Interior Point Solver Beginning with version 4 MATPOWER includes a new primal dual interior point solver called MIPS for MATLAB Interior Point Solver It is implemented in pur
41. power flow and VAr injections and loss pa rameters Also similar to the branch or gen matrices some of the columns are used for input values some for results and some such as PF can be either input or output depending on whether the problem is a simple power flow or an optimal power flow The idx_dcline function defines a set of constants for use as named column indices for the dcline matrix An optional dclinecost matrix in the same form as gencost can be used to specify a cost to be applied to py in the OPF If the dclinecost field is not present the cost is assumed to be zero MATPOWER s DC line handling is implemented in toggle_dcline and examples of using it can be found in t_dcline The case file t_case9 dcline includes some example DC line data See help toggle dcline for more information Running a case that includes DC lines is as simple as loading the case turning on the extension and running it Unlike with the reserves extension MATPOWER does not currently have a wrapper function to automate this mpc loadcase t_case9_dcline mpc toggle_dcline mpc on results runopf mpc 22A future version may make the handling of this second option automatic 78 7 5 4 DC OPF Branch Flow Soft Limits Beginning with version 5 0 MATPOWER includes an extension that replaces the branch flow limits on specified branches in a DC optimal power flow with soft limits that is limits that can be violated wi
42. r cost gt 1 fprintf fd Xt g r cost 2 end end fprintf fd t n if isfield r qty fprintf fd An h max reserve quantities for each gen n fprintf fd Asreserves qty tig prefix r qty 1 if length r qty gt 1 fprintf fd t g r qty 2 end end fprintf fd t n end hh Save output fields for solved case 71 7 3 Registering the Callbacks As seen in the fixed zonal reserve example adding a single extension to the standard OPF formulation is often best accomplished by a set of callback functions A typical use case might be to run a given case with and without the reserve requirements active so a simple method for enabling and disabling the whole set of callbacks as a single unit is needed The recommended method is to define all of the callbacks in a single file containing a toggle function that registers or removes all of the callbacks depending on whether the value of the second argument is on or off The state of the registration of any callbacks is stored directly in the mpc struct In our example the toggle_reserves m file contains the toggle_reserves function as well as the five callback functions 72 function mpc toggle_reserves mpc on_off TOGGLE_RESERVES Enable disable or check status of fixed reserve requirements MPC TOGGLE_RESERVES MPC on MPC TOGGLE_RESERVES MPC off T_F TOGGLE_RESERVES MPC status if strcmp upper on_o
43. robust memory efficient and easy to use software for solving large sparse symmetric and non symmetric linear systems of equations on shared memory and distributed memory multiprocessor sys tems 33 34 More information is available at http www pardiso project org When the MATLAB interface to PARDISO is installed PARDISO s solvers can be used to replace the built in operator for solving for the Newton update step in MATPOWER s default primal dual interior point solver MIPS by setting the mips linsolver option equal to PARDISO The mplinsolve function can also be called directly to solve Ax b problems via PARDISO or the built in solver de pending on the arguments supplied This interface also gives access to the full range of PARDISO s options For details see help mplinsolve and the PARDISO User s Manual at http www pardiso project org manual manual pdf When solving very large AC optimal power flow problems with MIPS selecting PARDISO as the linear solver can often dramtically improve both computation time and memory use G 11 SDP_PF Applications of a Semidefinite Programming Relaxation of the Power Flow Equations This package is contributed by Dan Molzahn and is currently included with MAT POWER in the MATPOWER extras sdp pf directory Complete documentation is avail able in MATPOWER extras sdp pf documentation directory and especially in the file sdp_pf_documentation pdf G 12 TSPOPF Three AC OPF
44. runduopf which is simply a wrapper that sets the model option to DC before calling runuopf MATPOWER uses an algorithm similar to dynamic programming to handle the de commitment It proceeds through a sequence of stages where stage N has N generators shut down starting with N 0 as follows Step 1 Begin at stage zero N 0 assuming all generators are on line with all limits in place Step 2 Ifthe sum of the minimum generation limits for all on line generators is less than the total system demand then go to Step 3 Otherwise go to the next stage N N 1 shut down the generator whose average per MW cost of operating at its minimum generation limit is greatest and repeat Step 2 Step 3 Solve a normal OPF Save the solution as the current best Step 4 Go to the next stage N N 1 Using the best solution from the previous stage as the base case for this stage form a candidate list of generators with minimum generation limits binding If there are no candidates skip to Step 6 Step 5 For each generator on the candidate list solve an OPF to find the total system cost with this generator shut down Replace the current best solu tion with this one if it has a lower cost If any of the candidate solutions produced an improvement return to Step 4 Step 6 Return the current best solution as the final solution 82 It should be noted that the method employed here is simply a heuristic It does not guarantee that the least
45. sc the step controlled version of this solver the mips step_control option must be set to 1 t For SC PDIPM the step controlled version of this solver the pdipm step_control option must be set to 1 57 Table 6 3 Other OPF Options name default description opf violation 5x 107 constraint violation tolerance opf flow_lim S quantity to limit for branch flow constraints opf ignore_ang lim 0 opf init_from_mpc 1 opf return_raw_der 0 S apparent power flow limit in MVA P active power flow limit in MW I current magnitude limit in MVA at 1 p u voltage ignore angle difference limits for branches 0 include angle difference limits if specified 1 ignore angle difference limits even if specified specify whether to use the current state in MATPOWER case to initialize OPF 1 MATPOWER decides based on solver algorithm 0 ignore current state when initializing OPF 1 use current state to initialize OPF for AC OPF return constraint and derivative info in results raw in fields g dg df d2f Currently supported only for IPOPT KNITRO and MIPS solvers Table 6 4 OPF Output Options name default out lim all 1 out lim v 1 out lim line 1 out lim pg I out lim qg 1 description controls constraint info output 1 individual flags control what is printed 0 do not print any constraint infot 1 print only binding constraint info 2 print all constraint info
46. solution The tangent vector zj dx da le at the current solution 17 17 is found by solving the linear system fe fr 0 pi pi Aj 11 5 8 36 The matrix on the left hand side is simply the standard power flow Jacobian with an additional column and row added The extra column f is simply the negative of the power transfer vector b and the extra row required to make the system non singular and define the magnitude of z is the derivative of the the parameterization function at the previous solution point p The resulting tangent vector is then normalized ei A 2 lille 5 9 and used to compute the predicted approximation 47 1 to the next solution zitt HD using gra a a do 5 o p where is the continuation step size 5 3 Corrector The corrector stage finds the next solution 27 1441 by correcting the approxi mation estimated by the predictor J Newton s method is used to find the next solution by solving the n 1 dimensional system in 5 11 where one of 5 5 5 7 has been added as an additional constraint to the parameterized power flow equations of 5 3 f _ ree 0 5 11 5 4 Step length control Step length control is a key element affecting the computational efficiency of a contin uation method It affects the continuation method with two issues 1 speed how fast the corrector converges to a specified accuracy and 2 robustness whether t
47. specified in columns PD 3 and QD 4 respectively of row i of the bus matrix Constant impedance and constant current loads are not implemented directly but the constant impedance portions can be modeled as a shunt element described below Dispatchable loads are modeled as negative generators and appear as negative values in Sy 3 5 Shunt Elements A shunt connected element such as a capacitor or inductor is modeled as a fixed impedance to ground at a bus The admittance of the shunt element at bus 1 is given as Ysh Gen JOsn 3 7 and Ysn Gsn 7 Bsn denotes the ny x 1 vector of shunt admittances at all buses The parameters gf and b are specified in columns GS 5 and BS 6 respectively of row i of the bus matrix as equivalent MW consumed and MVAr injected at a nominal voltage magnitude of 1 0 p u and angle of zero 23 3 6 Network Equations For a network with n buses all constant impedance elements of the model are incorporated into a complex np X np bus admittance matrix Yhus that relates the complex nodal current injections pus to the complex node voltages V Thus Yous V 3 8 Similarly for a network with n branches the n X na system branch admittance matrices Y and Y relate the bus voltages to the n x 1 vectors I and of branch currents at the from and to ends of all branches respectively I Y V 3 9 L Y V 3 10 If is used to denote an operator that takes an n x 1 vector and creat
48. test conversion code result of converting t_psse_case2 raw to MATPOWER format sample PSS E format RAW file used to test conversion code result of converting t_psse_case3 raw to MATPOWER format sample PSS E format RAW file used to test conversion code 145 Table D 20 Miscellaneous MATPOWER Tests name description t test_matpower t_auction_minopf t_auction_mips t_auction_tspopf_pdipm t_cpf t_dcline t_ext2int2ext t_get_losses t_hasPQcap t_hessian t_islands t_jacobian t_loadcase t_makeLODF t_makePTDF t_margcost t_mips t_miqps_matpower t_modcost t_mpoption t_nested_struct_copy t_off2case t_opf model t_printpf t_psse t_qps_matpower t_pf t_runmarket t_scale_load t_total_load t_totcost runs all MATPOWER tests runs tests for auction using MINOPF runs tests for auction using MIPS runs tests for auction using PDIPM runs tests for AC continuation power flow runs tests for DC line implementation in toggle_dcline runs tests for ext2int and int2ext runs tests for get_losses runs tests for hasPQcap runs tests for 2 derivative code runs test for find_islands and extract_islands runs test for partial derivative code runs tests for loadcase runs tests for makeLODF runs tests for makePTDF runs tests for margcost runs tests for MIPS NLP solver runs tests for miqps matpower runs tests for modcost runs tests for mpoption runs tests for nested_struct_copy runs tests for of f2case runs tests for op
49. the objective function has units u 110 Table B 2 Generator Data mpc gen name column description GEN_BUS 1 bus number PG 2 real power output MW QG 3 reactive power output MVAr QMAX 4 maximum reactive power output MVAr QMIN 5 minimum reactive power output MVAr VG 6 voltage magnitude setpoint p u MBASE 7 total MVA base of machine defaults to baseMVA GEN STATUS 8 machine status 7 Msciine in service gt lt 0 machine out of service PMAX 9 maximum real power output MW PMIN 10 minimum real power output MW pc1 11 lower real power output of PQ capability curve MW pc2 12 upper real power output of PQ capability curve MW QCiMIN 13 minimum reactive power output at PC1 MVAr QCIMAX 14 maximum reactive power output at PC1 MVAr QC2MIN 15 minimum reactive power output at PC2 MVAr QC2MAX 16 maximum reactive power output at PC2 MVAr RAMP_AGC 17 ramp rate for load following AGC MW min RAMP_10 18 ramp rate for 10 minute reserves MW RAMP _30 19 ramp rate for 30 minute reserves MW RAMP Q 20 ramp rate for reactive power 2 sec timescale MVAr min APF 21 area participation factor MU_PMAX 22 Kuhn Tucker multiplier on upper P limit u MW MU_PMINT 23 Kuhn Tucker multiplier on lower P limit u MW MU_QMAX 24 Kuhn Tucker multiplier on upper Q limit u MVAr MU_QMINT 25 Kuhn Tucker multiplier on lower Q limit u MVAr Not included in version 1 case format Y Included in OPF output typic
50. to mosek_user_options_ for backward compatibility with old MATPOWER option MOSEK_OPT For opf solver dc option set to MOSEK only Requires the installation of the optional MOSEK package See Default values in parenthesis refer to defaults assigned by MOSEK if called with option equal to 0 The values listed here correspond to those used by MOSEK version 7 x Version 6 x was different It is probably safer to write your code using the symbolic constants defined by mosek_symbcon rather than using explicit numerical values For details see help mosek_options and the Parameters reference in The MOSEK optimization toolbox for MATLAB manaul at http docs mosek com 7 1 toolbox Parameters html 128 name pdipm pdipm pdipm pdipm pdipm pdipm pdipm pdipm Table C 17 OPF Options for PDIPM default feastol 0 gradtol 107 comptol 1076 costtol 1076 max_it 150 step_control 0 sc red_it 20 sc smooth_ratio 0 04 description feasibiliy equality tolerance set to value of opf violation by default gradient tolerance complementarity condition inequality tolerance optimality tolerance maximum number of iterations set to 1 to enable step size control maximum number of step size reductions per iteration piecewise linear curve smoothing ratio Requires installation of the optional TSPOPF package 17 See Appendix G 12 for details Only relevant when pdipm step control is on Table C 18 OPF
51. to be more robust against potential future changes to the MATPOWER case data format 92 9 6 2 have_fcn TorF have_fcn tag TorF have_fcn tag toggle ver_str have_fcn tag vstr ver_num have_fcn tag vnum rdate have_fcn tag date info have_fcn tag all The have_fcn function provides a unified mechanism for testing for optional func tionality such as the presence of certain solvers or to detect whether the code is running under MATLAB or Octave Since its results are cached they allow for a very quick way to check frequently for functionality that may initially be a bit more costly to determine For installed functionality have_fcn also determines the installed ver sion and release date if possible The optional second argument when it is a string defines which value is returned as follows e empty 1 if optional functionality is available O if not available e vstr version number as a string e g 3 11 4 e vnum version number as numeric value e g 3 011004 e date release date as a string e g 20 Jan 2015 e all struct with fields named av for availability vstr vnum and date and values corresponding to each of the above respectively Alternatively the optional functionality specified by tag can be toggled OFF or ON by calling have_fcn with a numeric second argument toggle with one of the following values e 0 turn OFF the optional functi
52. to k and the second is equal to the corresponding branch index i multiplied by d to indicate the direction lims nif X 3 matrix of interface limits where nig is the number of interface limits to be enforced The first column is the index k of the interface and the second and third columns are F mig and Fp the lower and upper limits respectively on the DC model flow limits in MW for the interface Table 7 5 Output Data Structures for Interface Flow Limits name description results OPF results struct superset of mpc with additional fields for output data if additional field in results containing output parameters for interface flow limits in the following sub fields P nit x 1 vector of actual flow in MW across the corresponding interface as measured at the from end of associated branches mu l ni xX 1 vector of shadow prices on lower flow limits u MW mu u nig X 1 vector of shadow prices on upper flow limits u MW Here we assume the objective function has units u Running a case that includes the interface flow limits is as simple as loading the case turning on the extension and running it Unlike with the reserves extension MATPOWER does not currently have a wrapper function to automate this mpc loadcase t_case30_userfcns mpc toggle_iflims mpc on results runopf mpc 7 5 3 DC Transmission Lines Beginning with version 4 1 MATPOWER also includes a simple model for dispatchable D
53. us to access the real power demand column of the bus matrix using the name PD without having to remember that it is the 3 column Other top level simulation functions are available for running DC versions of power flow and OPF for running an OPF with the option for MATPOWER to shut down decommit expensive generators etc These functions are listed in Table D 2 in Appendix D 2 3 3 Accessing the Results By default the results of the simulation are pretty printed to the screen displaying a system summary bus data branch data and for the OPF binding constraint information The bus data includes the voltage angle and total generation and load at each bus It also includes nodal prices in the case of the OPF The branch data shows the flows and losses in each branch These pretty printed results can be saved to a file by providing a filename as the optional 3 argument to the simulation function The solution is also stored in a results struct available as an optional return value from the simulation functions This results struct is a superset of the MATPOWER case struct mpc with additional columns added to some of the existing data fields and additional fields The following example shows how simple it is after running a DC OPF on the 118 bus 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 gt gt define_constants gt gt results ru
54. what is printed 0 do not print anything 1 print everything out sys_sum 1 print system summary 0 or 1 out area_sum 0 print area summaries 0 or 1 out bus 1 print bus detail includes per bus gen info 0 or 1 out branch 1 print branch detail 0 or 1 out gen 0 print generator detail 0 or 1 out force 0 print results even if success flag 0 0 or 1 out suppress_detail 1 suppress all output but system summary 1 suppress details for large systems gt 500 buses 0 do not suppress any output specified by other flags 1 suppress all output except system summary section Overrides individual flags but in the case of out suppress_detail not out all 1 Internally the runpf function does a number of conversions to the problem data before calling the appropriate solver routine for the selected power flow algorithm This external to internal format conversion is performed by the ext2int function described in more detail in Section 7 2 1 and includes the elimination of out of service equipment the consecutive renumbering of buses and the reordering of generators by increasing bus number All computations are done using this internal indexing When the simulation has completed the data is converted back to external format by int2ext before the results are printed and returned 4 4 Linear Shift Factors The DC power flow model can also be used to compute the sensitivities of branch flows to changes in nodal re
55. 0 gt gt results runpf case300 mpopt See Appendix C or type gt gt help mpoption for more information on MATPOWER s options 2 4 Documentation There are two primary sources of documentation for MATPOWER The first is this manual which gives an overview of MATPOWER s capabilities and structure and describes the modeling and formulations behind the code It can be found in your MATPOWER distribution at MATPOWER docs manual pdf The second is the built in help command As with MATLAB s built in functions and toolbox routines you can type help followed by the name of a command or M file to get help on that particular function Nearly all of MATPOWER s M files have such documentation and this should be considered the main reference for the 18 calling options for each individual function See Appendix D for a list of MATPOWER functions As an example the help for runopf looks like 19 gt gt help runopf RUNOPF Runs an optimal power flow RESULTS SUCCESS RUNOPF CASEDATA MPOPT FNAME SOLVEDCASE Runs an optimal power flow AC OPF by default optionally returning a RESULTS struct and SUCCESS flag Inputs all are optional CASEDATA either a MATPOWER case struct or a string containing the name of the file with the case data default is case9 see also CASEFORMAT and LOADCASE MPOPT MATPOWER options struct to override default options can be used to specify the s
56. 00 or bounded on both sides 47 Figure 6 2 Relationship of w to r for d 2 quadratic option 48 6 3 3 User defined Variables The creation of additional user defined z variables is done implicitly based on the difference between the number of columns in A and the dimension of x The op tional vectors Zmin and Zmax are available to impose lower and upper bounds on z respectively 6 4 Standard Extensions In addition to making this extensible OPF structure available to end users MAT POWER also takes advantage of it internally to implement several additional capa bilities 6 4 1 Piecewise Linear Costs The standard OPF formulation in 6 1 6 4 does not directly handle the non smooth piecewise linear cost functions that typically arise from discrete bids and offers in electricity markets When such cost functions are convex however they can be modeled using a constrained cost variable CCV method The piecewise lin ear cost function c x is replaced by a helper variable y and a set of linear constraints that form a convex basin requiring the cost variable y to lie in the epigraph of the function c z Figure 6 3 illustrates a convex n segment piecewise linear cost function mi 1 21 C1 z lt T Mal Xo Co IIS c x a te 6 32 MA T En HF Cn Ln1 lt 2 defined by a sequence of points xj cj 7 0 n where m denotes the slope of the j th segment mj EL gsm 6 33 y AA and zo lt
57. 129183 0 00936418 0 117278 0 339269 3 7 0553031 0 10406 O 0 00174933 0 0196518 0 0490616 4 7 0686267 0 034574 O 0 00041301 0 0030084 0 00165402 5 7 0706104 0 0065191 O 1 53531e 05 0 000337971 0 000245844 6 7 0710134 0 00062152 O 1 22094e 07 3 41308e 05 4 99387e 05 7 7 0710623 5 7217e 05 O 9 84879e 10 3 41587e 06 6 05875e 06 8 7 0710673 5 6761e 06 O 9 73527e 12 3 41615e 07 6 15483e 07 Converged f 7 07107 exitflag 1 1 58114 2 23607 1 58114 lambda ineqnonlin 0 0 707107 More example problems for mips can be found in t mips m A 3 Quadratic Programming Solver A convenience wrapper function called qps mips is provided to make it trivial to set up and solve linear programming LP and quadratic programming QP problems of the following form 1 min xt He clz A 11 subject to lt Ar lt u A 12 Tmin lt x lt Tmax A 13 Instead of a function handle the objective function is specified in terms of the paramters H and c of quadratic cost coefficients Internally qps_mips passes mips 102 the handle of a function that uses these paramters to evaluate the objective function gradients and Hessian The calling syntax for qps_mips is similar to that used by quadprog from the MATLAB Optimization Toolbox x f exitflag output lambda qps_mips H c A 1 u xmin xmax x0 opt Alternatively the input arguments can be packaged as fields in a problem struct and passed in as a single a
58. 36 DE OPF Model Objects lt 65 4 lt 8 464 crs eed eh ee ee Ree 137 D 9 OPF Solver Fu un tions s s s se s soa ea dsa kaad Ea GrG ia 137 DAD Other OPF Functions sos 2 1 Koay AAA ACA 138 D 11 OPF User Callback Punctiong lt lt cio 22444 be eb eax 138 D 12 Power Flow Derivative Functions 22 004 139 D 13 NLP LP amp QP Solver Functions se ss 464 swari dea drii 140 D 14 Matrix Building Functions s sos c stss ces e ede ed Wade doe 4 141 DIS Utility Functions ss ce asr citada AE 141 D 16 Other Functions 220 ae ack A a ee a a a 142 D 17 Example Cases cocine irse de 143 D 18 Automated Test Utility Functions o 144 D 19 Test Data 145 D 20 Miscellaneous MATPOWER TestS 146 D 21 MATPOWER OPF Tests ee eee 147 ed Auction Types cw kd HEY oe HRS Bee A 150 F 2 Generator Offers a e e ee 152 ES Load Bids e ca 25 ea ees enserio risas 152 F 4 Generator Sales 0 a e a a 155 F 5 Load Purchases 2 2 0 0 00000 2 eee es 155 F 6 Smartmarket Files and Functions 2246 seb ee iaa 156 1 Introduction 1 1 Background MATPOWER is a package of MATLAB M files 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
59. 75 20 48 60 1 bids P qty 10 10 10 10 10 10 10 10 10 bids P prc 100 70 60 100 50 20 100 60 50 mpc_out co cb f dispatch success et runmarket mpc offers bids mkt 153 The resulting cleared offers and bids are gt gt co ans 12 12 12 12 12 12 gt gt CO ans 50 50 50 51 52 52 gt gt cb ans 10 10 10 gt gt cb ans 51 54 55 P qty 0000 0000 0000 0000 0000 0000 P prc 0000 2406 3368 0242 1697 9832 P qty 0000 0000 0000 P pre 8207 0312 6208 23 24 24 24 24 24 50 50 50 51 52 52 10 10 51 54 55 3156 0000 0000 0000 0000 0000 0000 2406 3368 0242 1697 9832 0000 0000 8207 0312 6208 50 50 50 51 52 52 10 51 54 55 TO OO O O 0000 2406 3368 0242 1697 9832 0000 8207 0312 6208 154 In other words the sales by generators and purchases by loads are as shown summarized in Tables F 4 and Tables F 5 respectively Table F 4 Generator Sales Generator Quantity Sold Selling Price MW MWh 1 35 3 50 00 2 36 0 50 24 3 36 0 50 34 4 36 0 51 02 5 36 0 52 17 6 36 0 52 98 Table F 5 Load Purchases Load Quantity Bought Purchase Price MW MWh 1 30 0 51 82 2 10 0 54 03 3 20 0 55 62 F 3 Smartmarket Files and Functions 155 Table F 6 Smartmarket F
60. 9 bus New England case IEEE 57 bus case IEEE 118 bus case IEEE 300 bus case Polish system winter 1999 2000 peak Polish system summer 2004 peak Polish system summer 2004 off peak Polish system winter 2003 04 off peak Polish system winter 2003 04 evening peak Polish system winter 2007 08 evening peak Polish system summer 2008 morning peak Polish system plus winter 2007 08 evening peak 89 bus portion of European transmission system from PEGASE project 1354 bus portion of European transmission system from PEGASE project 2869 bus portion of European transmission system from PEGASE project 9241 bus portion of European transmission system from PEGASE project Please cite reference 26 when publishing results based on this data 143 D 4 Automated Test Suite Table D 18 Automated Test Utility Functions name description t t_begin begin running tests t_end finish running tests and print statistics t_is tests if two matrices are identical to with a specified tolerance t_ok tests if a condition is true t_run_tests run a series of tests t_skip skips a number of tests with explanatory message 144 Table D 19 Test Data name description t pretty_print_acopf txt pretty_print_dcopf txt so1n9_dcop f mat soln9_dcpf mat soln9_opf_ang mat soln9_opf_extras1 mat so1n9_opf Plim mat soln9_opf_PQcap mat soln9_opf mat soln9_pf mat t_auction_case m t_case_ext m t_case_info_eg txt t_case_int
61. Ap 3 Convert generator allocations and nodal prices into set of cleared offers and bids 4 Print results For step 1 the offers and bids are supplied as two structs offers and bids each with fields P for real power and Q for reactive power optional Each of these is also a struct with matrix fields qty and prc where the element in the i th row and j th column of qty and prc are the quantity and price respectively of the j th block of capacity being offered bid by the i th generator These block offers bids are converted to the equivalent piecewise linear generator costs and generator capacity limits by the off2case function See help off2case for more information Offer blocks must be in non decreasing order of price and the offer must cor respond to a generator with 0 lt PMIN lt PMAX A set of price limits can be speci fied via the lim struct e g and offer price cap on real energy would be stored in lim P max_offer Capacity offered above this price is considered to be withheld from the auction and is not included in the cost function produced Bids must be in non increasing order of price and correspond to a generator with PMIN lt PMAX lt 0 see Section 6 4 2 on page 50 A lower limit can be set for bids in lim P min bid See help pricelimits for more information The data specified by a MATPOWER case file with the gen and gencost matrices modified according to step 1 are then used to run an OPF A decommitment mech a
62. C Line Data mpc dcline name column description F_BUS 1 from bus number T_BUS 2 to bus number BR_STATUS 3 initial branch status 1 in service 0 out of service PFI 4 real power flow at from bus end MW from to PTI 5 real power flow at to bus end MW from to QFT 6 reactive power injected into from bus MVAr qr 7 reactive power injected into to bus MVAr VF 8 voltage magnitude setpoint at from bus p u VT 9 voltage magnitude setpoint at to bus p u PMIN 10 if positive negative lower limit on PF PT PMAX 11 if positive negative upper limit on PF PT QMINF 12 lower limit on reactive power injection into from bus MVAr QMAXF 13 upper limit on reactive power injection into from bus MVAr QMINT 14 lower limit on reactive power injection into to bus MVAr QMAXT 15 upper limit on reactive power injection into to bus MVAr LOSSO 16 coefficient lo of constant term of linear loss function MW LOSS1 17 coefficient l of linear term of linear loss function MW MW Pioss lo lips where py is the flow at the from end MU_PMIN 18 Kuhn Tucker multiplier on lower flow limit at from bus u MW MU_PMAX 19 Kuhn Tucker multiplier on upper flow limit at from bus u MW MU_QMINF 20 Kuhn Tucker multiplier on lower VAr limit at from bus u MVAr MU_QMAXF 21 Kuhn Tucker multiplier on upper VAr limit at
63. C transmission lines While the implementation is based on the extensible OPF architecture described above it can be used for simple power flow problems as well 76 from bus Ploss lo iF lips Figure 7 2 DC Line Model f rom to bus bus Pf pe 1 l1 ps lo Figure 7 3 Equivalent Dummy Generators in which the case the OPF only formulation callback is skipped A DC line in MATPOWER is modeled as two linked dummy generators as shown in Figures 7 2 and 7 3 one with negative capacity extracting real power from the network at the from end of the line and another with positive capacity injecting power into the network at the to end These dummy generators are added by the ext2int callback and removed by the int2ext callback The real power flow py on the DC line at the from end is defined to be equal to the negative of the injection of corresponding dummy generator The flow at the to end p is defined to be equal to the injection of the corresponding generator MATPOWER links the values of py and p using the following relationship which includes a linear approximation of the real power loss in the line Pt Pf Ploss ps lo lips 1 l1 ps lo 7 8 Here the linear coefficient l is assumed to be a small lt lt 1 positive number Ob viously this is not applicable for bi directional lines where the flow could go either TT direction res
64. EX section of the CPLEX documentation at http pic dhe ibm com infocenter cosinfoc v12r6 124 Table C 10 OPF Options for fmincon name default description fmincon alg 4 algorithm used by fmincon in MATLAB Opt Toolbox gt 4 1 active set 2 interior point default bfgs Hessian approximation 3 interior point Ibfgs Hessian approximation 4 interior point exact user supplied Hessian 5 interior point Hessian via finite differences 6 sqp sequential quadratic programming ae P 2 fmincon tol_x 10 4 termination tolerance on x pe E 7 fmincon tol_f 10 4 termination tolerance on f fmincon max_it 0 maximum number of iterations 0 gt use solver s default value t Requires MATLAB s Optimization Toolbox available from The MathWorks Inc http www mathworks com t Does not use sparse matrices so not applicable for large scale systems i Display is set by verbose TolCon by opf violation TolX by fmincon tol_x TolFun by fmincon tol f and MaxIter and MaxFunEvals by fmincon max_it Table C 11 OPF Options for GLPKt name default description glpk opts empty struct of native GLPK options passed to glpk_options to over ride defaults applied after overrides from glpk opt_fname glpk opt_fname empty name of user supplied function passed as FNAME argument to glpk options to override defaults For opf solver dc option set to GLPK only Requires the install
65. E_A column 6 of the branch matrix The variable limits 6 4 include an equality constraint on any reference bus angle and upper and lower limits on all bus voltage magnitudes and real and reactive generator injections grt lt 0 lt ort i E Leet 6 10 y smin lt vi lt ge p 6 11 pimin lt pi lt pimax 1 my 6 12 gua lt di lt As a Ng 6 13 The voltage reference angle 67 and voltage magnitude bounds v4 and vi are specified in columns VA 9 VMAX 12 and VMIN 13 respectively of row i of the bus matrix Similarly the generator bounds qi qi por and pe are specfied in columns QMAX 4 QMIN 5 PMAX 9 and PMIN 10 respectively of row i of the gen matrix 6 2 Standard DC OPF When using DC network modeling assumptions and limiting polynomial costs to second order the standard OPF problem above can be simplified to a quadratic program with linear constraints and a quadratic cost function In this case the voltage magnitudes and reactive powers are eliminated from the problem completely and real power flows are modeled as linear functions of the voltage angles The optimization variable is g and the overall problem reduces to the following form el T an fp P5 6 15 45 subject to gP Q Ea Bie F Phus shift Pa Gsh CP 0 6 16 h a BrO Pr snitt Fmax lt 0 6 17 h O m B 0 a Pf shift Fmax lt 0 6 18 gre lt Os a gE 1 ret
66. Jacobian updated at each iteration Each Newton step involves computing the mismatch g x forming the Jacobian based on the sensitivities of these mismatches to changes in x and solving for an updated value of x by factorizing this Jacobian This method is described in detail in many textbooks Also included are solvers based on variations of the fast decoupled method 6 specifically the XB and BX methods described in 7 These solvers greatly reduce the amount of computation per iteration by updating the voltage magnitudes and angles separately based on constant approximate Jacobians which are factored only once at the beginning of the solution process These per iteration savings however come at the cost of more iterations The fourth algorithm is the standard Gauss Seidel method from Glimm and Stagg 8 It has numerous disadvantages relative to the Newton method and is included primarily for academic interest By default the AC power flow solvers simply solve the problem described above ignoring any generator limits branch flow limits voltage magnitude limits etc How ever there is an option pf enforce_q_lims that allows for the generator reactive power limits to be respected at the expense of the voltage setpoint This is done in a rather brute force fashion by adding an outer loop around the AC power flow 29 solution If any generator has a violated reactive power limit its reactive injection is fixed at the limit the corres
67. MATPOWER 5 1 User s Manual Ray D Zimmerman Carlos E Murillo S nchez March 20 2015 2010 2011 2012 2013 2014 2015 Power Systems Engineering Research Center PSERC All Rights Reserved Contents 1 Introduction LIL Background so pos dor he ee BO ma BOS SR ere BS 1 2 License and Terms of Use 0 0 0 0 200000048 La Citne MATPOWER nfs ee 2 eee eee se oe a oe oe eg ee Getting Started 2 1 System Requirements o e E DEAN s are a RA o a BE 29 Runnmg Ps E ao Prepara Case Input Dil css res a as Ke SY a 23 2 a AI 2 3 3 Accessing the Results ene 23 4 petting UNAS o a a a 24 Documentation sorsi s re eR ee a a ee i Modeling SL Data Formats gt 2454 6 ees ee erd erpa enaa 2 8 32 OOO gt ia a he ee ee Mee oe oe et aie ey ee eo ee oe ee Dat COMETE da apa caera oe a Aa ce g 34 Loads cos meridia da PA A 30 Ohut Elements o sires eA EROS AA A O 36G Network Equations s se sasea ee dG Bae he e eet DO Modeling s scr eb ac eed eee ee A Power Flow Mo AC Power FOW AA a DC Power Pl nerio k a AR OE ERAS o A A a p a eee wee ee AAA a 44 Linear Shift Factors o a saoao 20 ae ee ee eee Continuation Power Flow 5L Parameterization o es 6 das ess we ea ee sarta ee De PECOT si Sconce ots A aeaa he we a Da e n Da e A E A oud Corretor o ecos ca m ma do ees wae a eh e e a a Dad Diep length control scoe sica pa e a Eb Se ee a Do YUNEP e ee eS
68. Options for TRALM name default description tralm feastol 0 feasibiliy tolerance set to value of opf violation by default tralm primaltol 5x107 primal variable tolerance tralm dualtol 5x 107 4 dual variable tolerance tralm costtol 107 optimality tolerance tralm major_it 40 maximum number of major iterations tralm minor_it 100 maximum number of minor iterations tralm smooth ratio 0 04 piecewise linear curve smoothing ratio Requires installation of the optional TSPOPF package 17 See Appendix G 12 for details 129 C 1 Mapping of Old Style Options to New Style Options A MATPOWER options struct can be created from an old style options vector simply by passing it to mpoption The mapping of old style options into the fields in the option struct are summarized in Table C 19 An old style options vector can also be created from an options struct by calling mpoption with the struct and an empty second argument mpopt_struct mpoption mpopt_vector mpopt_vector mpoption mpopt_struct Table C 19 Old Style to New Style Option Mapping idx old option new option notes 1 PF_ALG pf alg new option has string values 1 gt NR 2 gt FDXB 3 gt FDBX 4 gt GS 2 PF_TOL pf tol 3 PF_MAX_IT pf nr max_it 4 PF_MAX_IT_FD pf fd max_it 5 PF_MAX_IT_GS pf gs max_it 6 ENFORCE_Q_LIMS pf enforce_q_lims 10 PFDC model new option has string values 0 gt AC 1 gt DC 11 OPF_ALG opf ac solver new option has
69. POWER core MATPOWER functions e MATPOWER t test scripts for MATPOWER e optional sub directories of MATPOWER extras additional function ality and contributed code see Appendix E for details Step 4 At the MATLAB prompt type test_matpower to run the test suite and verify that MATPOWER is properly installed and functioning The result should resemble the following possibly including extra tests depending on the availablility of optional packages solvers and extras 14 gt gt test_matpower t_nested_struct_copy ok t_mpoption ok t_loadcase ok t_ext2int2ext ok t_jacobian ok t_hessian ok t_margcost ok t_totcost ok t_modcost ok t_hasPQcap ok t_mplinsolve ok 2 of 4 skipped GMT PSs sen de Sh ew ida ok t_qps_matpower ok 288 of 360 skipped t_miqps_matpower ok 240 of 240 skipped DEP ia ae ok CDE ss ia ad ok t_islands ok toopi mode lia ok t_opf_mips ok 101 of 202 skipped t_opf_mips_sc ok 101 of 202 skipped t_opf_dc_mips ok t_opf_dc_mips_sc ok t_opf_userfcns ok t_opf_softlims ok t_runopf_w_res ok CEACLIMNG Mii oia ok t_get_losses ok t_makePTDF ok t_makeLODF ok Caprintps sci Bente os dw e ok t_total_load o
70. Solvers by H Wang TSPOPF 17 is a collection of three high performance AC optimal power flow solvers for use with MATPOWER The three solvers are e PDIPM primal dual interior point method 163 e SCPDIPM step controlled primal dual interior point method e TRALM trust region based augmented Lagrangian method The algorithms are described in 18 25 The first two are essentially C language implementations of the algorithms used by MIPS see Appendix A with the ex ception that the step controlled version in TSPOPF also includes a cost smoothing technique in place of the constrained cost variable CCV approach for handling piece wise linear costs The PDIPM in particular is significantly faster for large systems than any previ ous MATPOWER AC OPF solver including MINOPF When TSPOPF is installed the PDIPM solver becomes the default optimal power flow solver for MATPOWER Additional options for TSPOPF can be set using mpoption see help mpoption for details Builds are available for Linux 32 bit 64 bit Mac OS X PPC Intel 32 bit Intel 64 bit and Windows 32 bit 64 bit at http www pserc cornell edu tspopf 164 References 1 The BSD 3 Clause License Online Available http opensource org licenses BSD 3 Clause 1 2 GNU General Public License Online Available http www gnu org licenses 3 R D Zimmerman C E Murillo S nchez and R J Thomas MATPOWER Steady State Operations Pla
71. T choose default solver based on availability in the following order CPLEX GUROBI MOSEK BPMPD OT GLPK linear costs only MIPS MIPS MIPS MATLAB Interior Point Solver pri mal dual interior point method BPMPD BPMPD CLP CLP CPLEX CPLEX GLPK GLPK no quadratic costs GUROBI Gurobi IPOPT IPOPT MOSEK MOSEK OT MATLAB Opt Toolbox quadprog linprog Requires the installation of an optional package See Appendix G for details on the corresponding package t For MIPS sc the step controlled version of this solver the mips step_control option must be set to 1 t For SC PDIPM the step controlled version of this solver the pdipm step_control option must be set to 1 120 name Table C 5 General OPF Options default description opf violation opf flow lim opf ignore_ang lim opf init_from mpc opf return_raw_der 5 x 1078 gt 0 constraint violation tolerance quantity to limit for branch flow constraints S apparent power flow limit in MVA P active power flow limit in MW I current magnitude limit in MVA at 1 p u voltage ignore angle difference limits for branches 0 include angle difference limits if specified 1 ignore angle difference limits even if specified specify whether to use the current state in MATPOWER case to initialize OPF 1 MATPOWER decides based on solver algorit
72. al power injections sometimes called injection shift factors 32 ISF or generation shift factors 9 These n x n sensitivity matrices also called power transfer distribution factors or PTDFs carry an implicit assumption about the slack distribution If H is used to denote a PTDF matrix then the element in row and column j hij represents the change in the real power flow in branch i given a unit increase in the power injected at bus j with the assumption that the additional unit of power is extracted according to some specified slack distribution AP HAP ys 4 8 This slack distribution can be expressed as an n x 1 vector w of non negative weights whose elements sum to 1 Each element specifies the proportion of the slack taken up at each bus For the special case of a single slack bus k w is equal to the vector ex The corresponding PTDF matrix H can be constructed by first creating the n x na 1 matrix H By Bz 4 9 then inserting a column of zeros at column k Here B y and Bac are obtained from By and Bpus respectively by eliminating their reference bus columns and in the case of Bac removing row k corresponding to the slack bus The PTDF matrix Hu corresponding to a general slack distribution w can be obtained from any other PTDF such as Hg by subtracting H w from each column equivalent to the following simple matrix multiplication Ho Hf a1 4 10 These same linear shift factors may also be
73. ally not included or ignored in input matrix Here we assume the objective function has units u 111 Table B 3 Branch Data mpc branch name column description F_BUS 1 from bus number T_BUS 2 to bus number BRR 3 resistance p u BR_X 4 reactance p u BR_B 5 total line charging susceptance p u RATE_A 6 MVA rating A long term rating RATE_B 7 MVA rating B short term rating RATE_C 8 MVA rating C emergency rating TAP 9 transformer off nominal turns ratio taps at from bus impedance at to bus ie if r x 0 tap rah SHIFT 10 transformer phase shift angle degrees positive delay BR_STATUS 11 initial branch status 1 in service 0 out of service ANGMIN 12 minimum angle difference 0 6 degrees ANGMAX 13 maximum angle difference 0 0 degrees PFT 14 real power injected at from bus end MW QFt 15 reactive power injected at from bus end MVAr PT 16 real power injected at to bus end MW qr 17 reactive power injected at to bus end MVAr MU_SF 18 Kuhn Tucker multiplier on MVA limit at from bus u MVA MU_sT 19 Kuhn Tucker multiplier on MVA limit at to bus u MVA MU_ANGMIN 20 Kuhn Tucker multiplier lower angle difference limit u degree MU_ANGMAX 21 Kuhn Tucker multiplier upper angle difference limit u degree Not included in version 1 case format The voltage angle difference is taken to be unbounded below i
74. an be bounded above and below to act as a proxy for a transient stability limit for example If these limits are provided in columns ANGMIN 92 41 dmax DP gpin E min 41 p Pmin Pmax p2 Figure 6 6 Generator P Q Capability Curve 12 and ANGMAX 13 of the branch matrix MATPOWER creates the corresponding constraints on the voltage angle variables 6 5 Solvers Early versions of MATPOWER relied on MATLAB s Optimization Toolbox 19 to provide the NLP and QP solvers needed to solve the AC and DC OPF problems respectively While they worked reasonably well for very small systems they did not scale well to larger networks Eventually optional packages with additional solvers were added to improve performance typically relying on MATLAB extension MEX files implemented in Fortran or C and pre compiled for each machine architecture Some of these MEX files are distributed as optional packages due to differences in terms of use For DC optimal power flow there is a MEX build 20 of the high The voltage angle difference for branch k is taken to be unbounded below if branch k ANGMIN is less than 360 and unbounded above if branch k ANGMAX is greater than 360 If both param eters are zero the voltage angle difference is unconstrained 93 performance interior point BPMPD solver 21 for LP QP problems For the AC OPF problem the MINOPF 22 and TSPOPF 17 packages provide solvers suitable for much
75. an specify either polynomial or piecewise linear costs and need not be uniform 9 2 6 isload TorF isload gen The isload function returns a column vector of 1 s and 0 s The 1 s correspond to rows of the gen matrix which represent dispatchable loads The current test is Poin lt 0 and Pinax 0 9 2 7 printpf printpf results fd mpopt The printpf function prints power flow and optimal power flow results as re turned to fd a file identifier which defaults to STDOUT the screen The details of what gets printed are controlled by an optional MATPOWER options struct mpopt 87 9 2 8 total_load Pd total_load bus Pd total_load bus gen load_zone opt Pd Qd total_load The total_load function returns a vector of total load in each load zone The opt argument controls whether it includes fixed loads dispatchable loads or both and for dispatchable loads whether to use the nominal or realized load values The load_zone argument defines the load zones across which loads will be summed It uses the BUS_AREA column 7 of the bus matrix by default The string value a11 can be used to specify a single zone including the entire system The reactive demands are also optionally available as an output 9 2 9 totcost totalcost totcost gencost Pg The totcost function computes the total cost for generators given a matrix in gencost format and a column vector
76. and mips step_control MIPS and mips step_control OT IPOPT CPLEX MOSEK GUROBI verbose out all sys are out out out out out out out out out out out opf for ret Sum a_sum bug branch gen lim all lim v lim line lim pg lim qg ce urn_raw_der fmincon alg knitro ipopt o minopf minopf minopf minopf minopf minopf minopf opt pt feastol rowtol xtol majdamp mindamp penalty major_it continued on next page 131 idx 68 69 70 71 72 73 80 81 82 83 84 85 86 87 88 89 90 91 92 93 95 98 97 111 112 113 114 115 116 Table C 19 Old Style to New Style Option Mapping continued old option MNS_MINOR_IT MNS_MAX_IT MNS_VERBOSITY MNS_CORE MNS_SUPBASIC_LIM MNS_MULT_PRICE FORCE PC EQ PO PDIPM_FEASTOL PDIPM_GRADTOL PDIPM_COMPTOL PDIPM_COSTTOL PDIPM_MAX_IT SCPDIPM_RED_IT TRALM_FEASTOL TRALM_PRIMETOL TRALM_DUALTOL TRALM_COSTTOL TRALM_MAJOR_IT TRALM_MINOR_IT SMOOTHING_RATIO CPLEX_LPMETHOD CPLEX_QPMETHOD CPLEX_OPT MOSEK_LP_ALG MOSEK_MAX_IT MOSEK_GAP_TOL MOSEK_MAX_TIME MOSEK_NUM_THREADS MOSEK_OPT new option minopf minor_it minopf max_it minopf verbosity minopf core minopf supbasic_lim minopf mult_price sopf force_Pc_eq_P0 mips feastol pdipm feastol mips gradtol pdipm gradtol mips comptol pdipm comptol mips costtol pdipm costtol mips max_it pdipm max_it
77. ation of the optional GLPK package See Appendix G 4 for details t For details see help glpk options or the param section of the GLPK documentation at http www gnu org software octave doc interpreter Linear Programming html 125 Table C 12 OPF Options for Gurobi name default gurobi method 0 gurobi timelimit 00 gurobi threads 0 auto gurobi opts empty gurobi opt_fname empty gurobi opt 0 t For opf solver dc option set to Appendix G 5 for details description algorithm used by Gurobi for LP QP problems 0 primal simplex 1 dual simplex 2 barrier 3 concurrent LP only 4 deterministic concurrent LP only maximum time allowed for solver secs maximum number of threads to use struct of native Gurobi options passed to gurobi_options to override defaults applied after overrides from gurobi opt_fname name of user supplied function passed as FNAME argument to gurobi_options to override defaults if gurobi opt_fname is empty and gurobi opt is non zero the value of gurobi opt_fname is generated by appending gurobi opt to gurobi_user_options_ for backward compat ibility with old MATPOWER option GRB_OPT GUROBI only Requires the installation of the optional Gurobi package See Default values in parenthesis refer to defaults assigned by Gurobi if called with option equal to 0 t For details see help gurobi_options and the Parameters section of the Gurobi Optimizer Referen
78. ation of the optional MINOPF pack age 22 See Appendix G 8 for details t Default values in parenthesis refer to defaults assigned in MEX file if called with option equal to 0 127 name Table C 16 OPF Options for MOSEK default description mosek lp alg 0 mosek max_it 0 400 mosek gap_tol 0 1078 mosek max_time 0 1 mosek num_threads 0 1 mosek opts empty mosek opt_fname empty mosek opt 0 un Appendix G 9 for details solution algorithm used by MOSEK for continuous LP problems MSK_IPAR_OPTIMIZER 0 automatic let MOSEK choose 1 interior point 3 primal simplex 4 dual simplex 5 primal dual simplex 6 automatic simplex MOSEK chooses which simplex 7 network primal simplex 10 concurrent interior point maximum iterations MSK_IPAR_INTPNT_MAX_ITERATIONS interior point relative gap tolerance MSK_DPAR_INTPNT_TOL_REL_GAP maximum time allowed for solver negative means oo MSK_DPAR_OPTIMIZER_MAX_TIME maximum number of threads to use MSK_IPAR_INTPNT_NUM_THREADS struct of native MOSEK options param struct normally passed to mosekopt passed to mosek_options to override defaults ap plied after overrides from mosek opt_fname name of user supplied function passed as FNAME argument to mosek_options to override defaults if mosek opt_fname is empty and mosek opt is non zero the value of mosek opt_fname is generated by appending mosek opt
79. ccess flag 0 0 or 1 out suppress_detail 1 suppress all output but system summary 1 suppress details for large systems gt 500 buses 0 do not suppress any output specified by other flags 1 suppress all output except system summary section This setting is ignored for pretty printed output to files specified as FNAME argument in calls to runpf runopf etc Overrides individual flags but in the case of out suppress_detail not out all 1 Takes values of 0 1 or 2 as for out 1lim v 122 Table C 7 OPF Options for MIPS name default description mips linsolver ra linear system solver for update step or built in backslash operator PARDISO PARDISO solvert mips feastol 0 feasibiliy equality tolerance set to value of opf violation by default mips gradtol 107 gradient tolerance mips comptol 107 complementarity condition inequality tolerance mips costtol 107 optimality tolerance mips max_it 150 maximum number of iterations mips step_control 0 set to 1 to enable step size control mips sc red_it 20 maximum number of step size reductions per iteration Requires installation of the optional PARDISO package See Appendix G 10 for details Only relevant when mips step control is on Table C 8 OPF Options for CLP name default description clp opts empty struct of native CLP options passed to clp_options to override defaults applied after overrides from clp opt_fname cl
80. ce Manual at http www gurobi com documentation 5 6 reference manual parameters Table C 13 OPF Options for Ipoptt name default description ipopt opts empty ipopt opt_fname empty ipopt opt 0 struct of native IPOPT options options ipopt for ipopt passed to ipopt_options to override defaults applied after over rides from ipopt opt_fname name of user supplied function passed as FNAME argument to ipopt_options to override defaults if ipopt opt_fname is empty and ipopt opt is non zero the value of ipopt opt_fname is generated by appending ipopt opt to ipopt_user_options_ for backward compatibility with old MATPOWER option IPOPT_OPT For opf solver ac or opf solver dc option set to IPOPT only Requires the installation of the optional IPOPT package 32 See Appendix G 6 for details t For details see help ipopt_options and the options reference section of the IPOPT documentation at http wiw coin or org Ipopt documentation 126 Table C 14 OPF Options for KNITRO name default description knitro tol_x 10 4 termination tolerance on x knitro tol_f 10 4 termination tolerance on f knitro opt_fname empty name of user supplied native KNITRO options file that overrides other options knitro opt 0 if knitro opt_fname is empty and knitro opt is a posi tive integer n the value of knitro opt_fname is generated as knitro_user_options_n txt for backward compatibility with old MATPOWER option KNITRO_OPT
81. constraints checks for availability of optional functionality named column index definitions for branch matrix named column index definitions for bus matrix named column index definitions for gencost matrix named column index definitions for dcline matrix named column index definitions for gen matrix checks if generators are actually dispatchable loads converts fixed loads to dispatchable loads prints version information for MATPOWER and optional packages modifies gencost by horizontal or vertical scaling or shifting copies the contents of nested structs creates piecewise linear approximation to polynomial cost function evaluates polynomial generator cost and its derivatives splits gencost into real and reactive power costs scales fixed and or dispatchable loads by load zone returns vector of total load in each load zone 141 name connected_components mpoption_info_clp mpoption_info_cplex mpoption_info_fmincon mpoption_info_glpk mpoption_info_gurobi mpoption_info_intlinprog mpoption_info_ipopt mpoption_info_knitro mpoption_info_linprog mpoption_info_mips mpoption_info_mosek mpoption_info_quadprog psse_convert psse_convert_hvdc psse_convert_xfmr psse_parse psse_parse_line psse_parse_section psse_read Table D 16 Other Functions description returns the connected components of a graph option information for CLP option information for CPLEX option information for FMINCON option information for GLPK option i
82. cost commitment of generators will be found It is also rather computationally expensive for larger systems and was implemented as a simple way to allow an OPF based smart market such as described in Appendix F the option to reject expensive offers while respecting the minimum generation limits on generators 83 9 Miscellaneous MATPOWER Functions This section describes a number of additional MATPOWER functions that users may find useful The descriptions here are simply brief summaries so please use the MATLAB help function to get the full details on each function 9 1 Input Output Functions 9 1 1 loadcase mpc loadcase casefile The loadcase function provides the canonical way of loading a MATPOWER case from a file or struct It takes as input either a struct or the name of an M file or MAT file in the MATLAB path casefile and returns a standard MATPOWER case struct mpc It can also convert from the older version 1 case file format to the current format This function allows a case to be loaded and potentially modified before calling one of the main simulation functions such as runpf or runopf 9 1 2 savecase savecase fname mpc savecase fname mpc version savecase fname comment mpc savecase fname comment mpc version fname savecase fname The savecase function writes out a MATPOWER case file given a name for the file to be created or overwritten fname and a MATPOWER ca
83. costs for reactive power or just real power Full details of the MATPOWER case format are documented in Appendix B and can be accessed from the MATLAB command line by typing help caseformat 3 2 Branches All transmission lines transformers and phase shifters are modeled with a com mon branch model consisting of a standard 7 transmission line model with series impedance Zs Ts jx and total charging susceptance be in series with an ideal phase shifting transformer The transformer whose tap ratio has magnitude 7 and This does not include DC transmission lines For more information the handling of DC trans mission lines in MATPOWER see Section 7 5 3 21 phase shift angle Osni is located at the from end of the branch as shown in Fig ure 3 1 The parameters rs s be T and Oni are specified directly in columns BR_R 3 BRX 4 BR_B 5 TAP 9 and SHIFT 10 respectively of the corresponding row of the branch matrix The complex current injections i and i at the from and to ends of the branch respectively can be expressed in terms of the 2 x 2 branch admittance matrix Yp and the respective terminal voltages vy and v Hegel a With the series admittance element in the m model denoted by ys 1 z the branch admittance matrix can be written bey 1 1 Yor ys 1 72 Ys mean 3 2 Ys Toni Ys IZ Gi A N N re shitt Figure 3 1 Branch Model If the four elements of th
84. ction Types auction type name description 0 discriminative price of each cleared offer bid is equal to the offered bid price 1 LAO uniform price equal to the last accepted offer 2 FRO uniform price equal to the first rejected offer 3 LAB uniform price equal to the last accepted bid 4 FRB uniform price equal to the first rejected bid 5 first price uniform price equal to the offer bid price of the marginal unit 6 second price uniform price equal to min FRO LAB if the marginal unit is an offer or max FRB LAO if it is a bid 7 split the difference uniform price equal to the average of the LAO and LAB 8 dual LAOB uniform price for sellers equal to LAO for buyers equal to LAB Generalizing to a network with possible losses and congestion results in nodal prices Ap which vary according to location These Ap values can be used to normalize all bids and offers to a reference location by multiplying by a locational scale factor For bids and offers at bus i this scale factor is A Sf Ab where AS is the nodal price at the reference bus The desired uniform pricing rule can then be applied to the adjusted offers and bids to get the appropriate uniform price at the reference 150 bus This uniform price is then adjusted for location by dividing by the locational scale factor The appropriate locationally adjusted uniform price is then used for all cleared bids and offers The relationships between the OPF results and the pricing rules
85. cumentation web site and mailing lists for help in building and installing the IPOPT MATLAB interface This inter face uses callbacks to MATLAB functions to evaluate the objective function and its gradient the constraint values and Jacobian and the Hessian of the Lagrangian 32M ATPOWER version 4 1 supported Gurobi version 4 x which required a free third party MATLAB MEX interface 31 available at http www convexoptimization com wikimization index php Gurobi_mex 160 Precompiled MEX binaries for a high performance version of IPOPT using the PARDISO linear solver 33 34 are available from the PARDISO project At the time of this writing these are the highest performing solvers available to MATPOWER for very large scale AC OPF problems For Microsoft Windows users a pre compiled MEX version of IPOPT and numerous other solvers such as CLP and GLPK are easily installable as part of the OPTI Toolbox 29 When installed IPOPT can be used by MATPOWER to solve both AC and DC OPF problems by setting the opf solver ac or opf solver dc options respectively equal to IPOPT See Table C 13 for a summary of the IPOPT related MATPOWER options The many algorithm options can be set by creating an IPOPT user op tions function and specifying it via ipopt opt_fname to override the defaults set by ipopt_options See help ipopt_options and the options reference section of the IPOPT documentation at http www coin or org Ipopt d
86. d output data structures is summarized in Table 7 1 The code for implementing the callbacks can be found in toggle_reserves A wrapper around runopf that turns on this extension before running the OPF is 74 provided in runopf_w_res allowing you to run a case with an appropriate reserves field such as t_case30_userfcns as follows results runopf_w_res t_case30_userfcns See help runopf_w_res and help toggle_reserves for more information Exam ples of using this extension and a case file defining the necessary input data can be found in t_opf userfcns and t_case30 userfcns respectively Additional tests for runopf_w_res are included in t_runopf_w_res 7 5 2 Interface Flow Limits This extension adds interface flow limits based on flows computed from a DC network model It is implemented in toggle_iflims A flow interface k is defined as a set By of branch indices 7 and a direction for each branch If p represents the real power flow from bus gt to bus in branch and d is equal to 1 or 1 to indicate the direction then the interface flow fp for interface k is defined as f O dipi O 7 6 iC By where each branch flow p is an approximation calculated as a linear function of the bus voltage angles based on the DC power flow model from equation 3 29 This extension adds to the OPF problem a set of nig doubly bounded constraints on these flows Fp lt f 0 lt FS vke TZ 7 7
87. ds function returns the islands in a network The return value groups is a cell array of vectors of the bus indices for each island The second and optional return value isolated is a vector of indices of isolated buses that have no connecting branches 9 2 4 get_losses loss get_losses results loss get_losses baseMVA bus branch loss chg get_losses results loss fchg tchg get_losses results loss fchg tchg dloss_dv get_losses results loss fchg tchg dloss_dv dchg_dvm get_losses results The get_losses function computes branch series losses and optionally reactive injections from line charging as functions of bus voltages and branch parameters using the following formulae for a branch as described in Section 3 2 connecting bus f to bus t 86 2 ART me loss HA 2 9 1 Ts JTs A e fong 2 9 2 be teng lvl 3 9 3 It can also optionally compute the partial derivatives of the line losses and reactive charging injections with respect to voltage angles and magnitudes 9 2 5 margcost marginalcost margcost gencost Pg The margcost function computes the marginal cost for generators given a matrix in gencost format and a column vector or matrix of generation levels The return value has the same dimensions as Pg Each row of gencost is used to evaluate the cost at the output levels specified in the corresponding row of Pg The rows of gencost c
88. e MATLAB code derived from the MEX implementation of the algorithms described in 18 25 This solver has application outside of MATPOWER to general nonlinear optimiza tion problems of the following form min f x A 1 subject to giz 0 A 2 h x lt 0 A 3 lt Ax lt u A 4 Lmin L T lt Tmax A 5 where f R gt R g R gt R and h R gt R The solver is implemented by the mips function which can be called as follows x f exitflag output lambda mips f_fcn x0 A 1 u xmin xmax gh_fcn hess_fcn opt where the input and output arguments are described in Tables A 1 and A 2 respec tively Alternatively the input arguments can be packaged as fields in a problem struct and passed in as a single argument where all fields except f_fcn and x0 are optional x f exitflag output lambda mips problem The calling syntax is nearly identical to that used by fmincon from MATLAB s Optimization Toolbox The primary difference is that the linear constraints are specified in terms of a single doubly bounded linear function 1 lt Ax lt u as opposed to separate equality constrained A beq and upper bounded Ax lt b functions Internally equality constraints are handled explicitly and determined at run time based on the values of l and u The user defined functions for evaluating the objective function constraints and Hessian are id
89. e 30 bus system that has 9 generators where the last three have negative PMIN to model the dispatchable loads e Six generators with three blocks of capacity each offering as shown in Ta ble F 2 e Fixed load totaling 151 64 MW e Three dispatchable loads bidding three blocks each as shown in Table F 3 27In versions of MATPOWER prior to 4 0 the smart market code incorrectly shifted prices instead of scaling them resulting in prices that while falling within the offer bid gap and therefore acceptable to all participants did not necessarily correspond to the OPF solution 151 Table F 2 Generator Offers Generator Block 1 Block 2 Block 3 MW MWh MW MWh MW MWh 1 12 20 24 50 24 60 2 12 20 24 40 24 70 3 12 20 24 42 24 80 4 12 20 24 44 24 90 5 12 20 24 46 24 75 6 12 20 24 48 24 60 Table F 3 Load Bids Load Block 1 Block 2 Block 3 MW Q MWh MW MWh MW MWh 1 10 100 10 70 10 60 2 10 100 10 50 10 20 3 10 100 10 60 10 50 To solve this case using an AC optimal power flow and a last accepted offer LAO pricing rule we use mkt OPF AC mkt auction_type 1 152 and set up the problem as follows mpc loadcase t_auction_case offers P qty 12 24 24 12 24 24 12 24 24 12 24 24 12 24 24 12 24 24 offers P pre 20 50 60 20 40 70 20 42 80 20 44 90 20 46
90. e converted according to the ordering specified by the third argument described below If val is an n dimensional matrix or cell array then the optional fourth argument dim default 1 can be used to specify which dimension to reorder The return value in this case is the value passed in converted to internal indexing The third argument ordering is used to indicate whether the data corresponds to bus gen or branch ordered data It can be one of the following three strings bus gen or branch For data structures with multiple blocks of data ordered by bus gen or branch they can be converted with a single call by specifying ordering as a cell array of strings Any extra elements rows columns etc beyond those indicated in ordering are not disturbed 90 The function i2e_data performs the opposite conversion from internal back to external indexing It also assumes that mpc is using internal indexing and the only difference is that it also includes an oldval argument used to initialize the return value before converting val to external indexing In particular any data correspond ing to off line gens or branches or isolated buses or any connected gens or branches will be taken from oldval with val supplying the rest of the returned data 9 4 3 e2i field i2e field mpc e2i_field mpc field ordering mpc e2i_field mpc field ordering dim mpc i2e_field mpc field ordering mpc i2e_field mpc field orderin
91. e doc interpreter Linear Programming html for details See Table C 11 for a summary of the GLPK related MATPOWER options GLPK can also be used to solve general LP problems via MATPOWER s common QP solver interface qps matpower or MILP problems via miqps _matpower with the algorithm option set to GLPK or by calling qps_glpk or miqps_glpk directly G 5 Gurobi High performance LP and QP Solvers Gurobi is a collection of optimization tools that includes high performance solvers for large scale linear programming LP and quadratic programming QP problems 30The http glpkmex sourceforge net site and Davide Barcelli s page http www dii unisi it barcelli software php may be useful in obtaining the MEX source or pre compiled binaries for Mac or Linux platforms 31The OPTI Toolbox is available from http www i2c2 aut ac nz Wiki OPTI 159 among others The project was started by some former CPLEX developers More information is available at http www gurobi com Although Gurobi is a commercial package at the time of this writing their is a free academic license available See http www gurobi com html academic html for more details Beginning with version 5 0 0 Gurobi includes a native MATLAB interface which is supported in MATPOWER version 4 2 and above When Gurobi is installed it can be used to solve DC OPF problems by setting the opf solver dc option equal to GUROBI The solution algorithms can be con t
92. e eee 0 2 118 C 3 Continuation Power Flow Options 119 CA OPF Solver OpDHOnS s hs s oe oY eek ey ee ae oe Oe 120 C o General OPP Options ec ss e ao s sice ta soia orata ae 121 C 6 Power Flow and OPF Output Options 2 444 445 4445 54 122 CT OPF Options fof MIPS a ss osea a na eE Ta es e E A 123 ES OPF Opuons Or OLP e s seas a ana eee a A E A 123 Ce DPF Options for CPLEX socias idad 124 C 100OPF Options for fingom lt soeg ke eee eR eoi ie D a 125 Cell OPF Options for GLPK e e ee cete sea a CER RMS BRS a 125 C12 0OPF Options for gro e e saose e ee he ee 126 C 13 OPF Options for IPOPT s es cd coce ed ioe rn arar 126 C AOPF Options for KNITRO ek ee ee ne bee e e ERE A 127 C 150PF Options for MUNOPP a e eosi s ocara mabat u ead eae da 127 C 16 OPF Options for MOSER 4 4 cios rica woe e ERS 128 C 1I7T OPF Options for PDIPM o c scot eg he bad bucna d pe aehu 129 C 18 OPP Options fort TRALM a i eg ead ew P ea we CHL e a 129 C 19 Old Style to New Style Option Mapping 130 D 1 MATPOWER Documentation Files 2 004 134 D 2 Top Level Simulation Functions 004 135 D 3 Input Output Functions lc bee ha ho ee we eee 135 D 4 Data Conversion Functions o e 00002 eee 135 D 5 Power Plow Functions occ ee ee ee he tera 136 D 6 Continuation Power Flow Functions 2 62 6 bs ee be es 136 D 7 OPF and Wrapper Functions lt lt e lt 4 eae 1
93. eached FULL trace full nose curve Astop Stop upon reaching target A value Astop cpf step 0 05 continuation power flow step size cpf adapt_step 0 toggle adaptive step size feature 0 adaptive step size disabled 1 adaptive step size enabled cpf error_tol 10 3 tolerance for the adaptive step controller cpf step_min 107 minimun allowed step size cpf step_max 0 2 maximum allowed step size cpf plot level 0 control plotting of nose curve 0 do not plot nose curve 1 plot when completed 2 plot incrementally at each iteration 3 same as 2 with pause at each iteration cpf plot bus empty index of bus whose voltage is to be plotted cpf user_callback empty string or cell array of strings with names of user callback functions cpf user_callback args empty struct passed to user defined callback functions See help cpf default_callback for details Any user defined callback takes the same input and output arguments as those used by the cpf_default_callback function which is always called and is used to col lect the A and V results from each predictor and corrector iteration To register user callback function s so it they will be executed the function name s is are supplied as a string cell array of strings and assigned to the cpf user_callback option If your callback requires additional arguments they can be provided in the cpf user_callback_args option The prototype for a CPF user callback
94. ed constraint violation cost c See help toggle softlims for more information Examples of using this extension can be found in t_opf softlims Note that while this extension can be used for AC OPF problems the flow violations will not be actual AC flow violations since the computed violations are based on a DC flow model and it is those values that incur the penalty cost 80 Running a case that includes the interface flow limits is as simple as loading the case turning on the extension and running it Unlike with the reserves extension MATPOWER does not currently have a wrapper function to automate this mpc loadcase case2383wp mpc toggle_softlims mpc on results rundcopf mpc 81 8 Unit De commitment Algorithm The standard OPF formulation described in the previous section has no mechanism for completely shutting down generators which are very expensive to operate Instead they are simply dispatched at their minimum generation limits MATPOWER includes the capability to run an optimal power flow combined with a unit de commitment for a single time period which allows it to shut down these expensive units and find a least cost commitment and dispatch To run this for case30 for example type gt gt runuopf case30 By default runuopf is based on the AC optimal power flow problem To run a DC OPF the model option must be set to DC For convenience MATPOWER provides a function
95. een A and Ag and p p for prices below As This corresponds to a negative generator with the piecewise linear cost curve shown in Figure 6 5 Note that this approach assumes that the demand blocks can be partially dispatched or split Requiring blocks to be accepted or rejected in 50 MW A marginal benefit Figure 6 4 Marginal Benefit or Bid Function c total cost MW p injection Figure 6 5 Total Cost Function for Negative Injection 51 their entirety would pose a mixed integer problem that is beyond the scope of the current MATPOWER implementation With an AC network model there is also the question of reactive dispatch for such loads Typically the reactive injection for a generator is allowed to take on any value within its defined limits Since this is not normal load behavior the model used in MATPOWER assumes that dispatchable loads maintain a constant power factor When formulating the AC OPF problem MATPOWER will automatically generate an additional equality constraint to enforce a constant power factor for any negative generator being used to model a dispatchable load It should be noted that with this definition of dispatchable loads as negative generators if the negative cost corresponds to a benefit for consumption minimizing the cost f x of generation is equivalent to maximizing social welfare 6 4 3 Generator Capability Curves The typical AC OPF formulation include
96. entical to those required by fmincon with one exception described 96 Table A 1 Input Arguments for mips name description f fcn Handle to a function that evaluates the objective function its gradients and Hessian for a given value of x Calling syntax for this function df d2f f_fcn x x0 Starting value of optimization vector zx A l u Define the optional linear constraints l lt Ax lt u Default values for the elements of l and u are Inf and Inf respectively xmin xmax Optional lower and upper bounds on the x variables defaults are Inf and Inf respectively gh fcn Handle to function that evaluates the optional nonlinear constraints and their gra dients for a given value of x Calling syntax for this function is h g dh dg gh_fcn x hess_fcn Handle to function that computes the Hessian of the Lagrangian for given values of x A and u where and y are the multipliers on the equality and inequality constraints g and h respectively The calling syntax for this function is Lxx hess_fcn x lam cost mult where lam eqnonlin y lam ineqnonlin and cost_mult is a parameter used to scale the objective function opt Optional options structure with fields all of which are also optional described in Table A 3 problem Alternative single argument input struct with fields corresponding to arguments above t All inputs are optional except f_fcn and x0 t If gh_fcn is provided then hess_fcn is also
97. erators R name for new reserve variable block itt element is r Pg plus R name for new capacity limit constraint set 7 4 Rreq name for new reserve requirement constraint set 7 5 All isolated buses out of service generators and branches are removed along with any generators or branches connected to isolated buses The buses are renumbered consecutively beginning at 1 and the in service generators are sorted by increasing bus number All of the related indexing information and the original data matrices are stored in an order field in the case struct to be used later by int2ext to perform the reverse conversions when the simulation is complete The first stage callback is invoked from within the ext2int function immediately after the case data has been converted Inputs are a MATPOWER case struct mpc freshly converted to internal indexing and any optional args value supplied when the callback was registered via add_userfcn Output is the presumably updated mpc This is typically used to reorder any input arguments that may be needed in internal ordering by the formulation stage The example shows how e2i_field can also be used with a case struct that has already been converted to internal indexing to convert other data structures by passing in 2 or 3 extra parameters in addition to the case struct In this case it automatically converts the input data in the qty cost and zones fields of mpc reserves to be consistent with the internal ge
98. erbose rev mpc warnings psse2mpc rawfile_name The psse2mpc function converts a PSS E RAW data file into a MATPOWER case struct Given an optional file name mpc_name it can save the converted case to a MATPOWER case file Warnings generated during the conversion process can be optionally returned in the warnings argument By default psse2mpc attempts to determine the revision of the PSS E RAW file from the contents but the user can specify an explicit revision number to use in the optional rev argument 9 2 System Information 9 2 1 case_info case_info mpc case_info mpc fd groups isolated case_info mpc 85 The case_info function prints out detailed information about a MATPOWER case including connectivity information summarizing the generation load and other data by interconnected island It can optionally print the output to an open file whose file identifier as returned by fopen is specified in the optional second parameter fd Optional return arguments include groups and isolated buses as returned by the find_islands function 9 2 2 compare_case compare_case mpc1 mpc2 Compares the bus branch and gen matrices of two MATPOWER cases and prints a summary of the differences For each column of the matrix it prints the maximum of any non zero differences 9 2 3 find islands groups find_islands mpc groups isolated find_islands mpc The find islan
99. erior Point Optimizer asis ee dae SS ELSES G 7 KNITRO Non Linear Programming Solver G 8 MINOPF AC OPF Solver Based on MINOS G 9 MOSEK High performance LP and QP Solvers G 10 PARDISO Parallel Sparse Direct and Multi Recursive Iterative Lin eor DoVe 8 ee Sos A es a e E LA G 11 SDP_PF Applications of a Semidefinite Programming Relaxation of the Power Blow Equations lt a ccoo a eine de ee dae amp G 12 TSPOPF Three AC OPF Solvers by H Wang References 109 115 130 134 134 134 143 144 148 List 3 1 5 1 6 1 6 2 6 3 6 4 6 5 6 6 7 1 7 2 7 3 7 4 List 4 1 4 2 4 3 9 1 9 2 5 3 6 1 6 2 6 3 6 4 7 1 7 2 7 3 7 4 7 5 7 6 7 7 A 1 A 2 A 3 B 1 of Figures Branch AR Nose Curve of Voltage Magnitude at Bus9 Relationship of w to r for d 1 linear option Relationship of w to r for d 2 quadratic option Constrained Cost Variable 2 i045 6s eee eee ee ew Ye Os Marginal Benefit or Bid Function 008 Total Cost Function for Negative Injection Generator P Q Capability Curve Adding Constraints Across Subsets of Variables DO AE Model 2 gd Gd e Pe BOR Hw GS aS SE RG RS Equivalent Dummy Generators lt 4 644 be 4s cs Feasible Region for Branch Flow Violation Constraints of Tables Power Plow se lt lt
100. es the corresponding n x n diagonal matrix with the vector elements on the diagonal these system admittance matrices can be formed as follows Y Y yr Cf Y ye Ct 3 11 Y Yy Cf Yu Ct 3 12 Vine OF Y OF Y Yaa 3 13 The current injections of 3 8 3 10 can be used to compute the corresponding complex power injections as functions of the complex bus voltages V Spus V V fous V Yas V 3 14 SV CV 15 CV YF V 3 15 SV CV 17 CV YV 3 16 The nodal bus injections are then matched to the injections from loads and generators to form the AC nodal power balance equations expressed as a function of the complex bus voltages and generator injections in complex matrix form as gs V Sy Sbus V Sa CS 0 3 17 3 7 DC Modeling The DC formulation 9 is based on the same parameters but with the following three additional simplifying assumptions 24 e Branches can be considered lossless In particular branch resistances r and charging capacitances be are negligible 1 1 be 0 3 18 Ts EJTs Jts Ys e All bus voltage magnitudes are close to 1 p u vi x et 3 19 e Voltage angle differences across branches are small enough that sin 6 0 Osnitt X 0 0 Oshitt 3 20 Substituting the first set of assumptions regarding branch parameters from 3 18 the branch admittance matrix in 3 2 approximates to 1 es Vin amp Gee 3 21
101. f ANGMIN lt 360 and unbounded above if ANGMAX gt 360 If both parameters are zero the voltage angle difference is unconstrained Y Included in power flow and OPF output ignored on input Included in OPF output typically not included or ignored in input matrix Here we assume the objective function has units u 112 Table B 4 Generator Cost Data mpc gencost name column description MODEL 1 cost model 1 piecewise linear 2 polynomial STARTUP 2 startup cost in US dollars SHUTDOWN 3 shutdown cost in US dollars NCOST 4 number of cost coefficients for polynomial cost function or number of data points for piecewise linear COST 5 parameters defining total cost function f p begin in this column units of f and p are hr and MW or MVAr respectively MODEL 1 gt Po fo P1 fis Pn fn where po lt p lt lt Pn and the cost f p is defined by the coordinates po fo p1 f1 Pn Jn of the end break points of the piecewise linear cost MODEL 2 gt Cn C1 C0 n 1 coefficients of n th order polynomial cost starting with highest order where cost is f p cnp cp co t If gen has ng rows then the first ng rows of gencost contain the costs for active power produced by the corresponding generators If gencost has 2ng rows then rows ng 1 through 2ng contain the reactive power costs in the same format Not currently used by any MATPOWER functions 113 Table B 5 D
102. f model and opt_model objects runs tests for printpf runs tests for psse2mpc and related functions runs tests for qps_matpower runs tests for AC and DC power flow runs tests for runmarket runs tests for scale_load runs tests for total_load runs tests for totcost Deprecated Will be removed in a subsequent version Requires the installation of an optional package See Appendix G for details on the corresponding package 146 Table D 21 MATPOWER OPF Tests name description t t_opf_dc_bpmpd runs tests for DC OPF solver using BPMPD_MEXt t_opf_dc_clp runs tests for DC OPF solver using CLP t_opf _dc_cplex runs tests for DC OPF solver using CPLEX t_opf_dc_glpk runs tests for DC OPF solver using GLPKt t_opf_dc_gurobi runs tests for DC OPF solver using Gurobi t_opf_dc_ipopt runs tests for DC OPF solver using Ipoptt t_opf_dc_mosek runs tests for DC OPF solver using MOSEK t_opf_dc_ot runs tests for DC OPF solver using MATLAB Opt Toolbox t_opf_dc_mips runs tests for DC OPF solver using MIPS t_opf dc mips_sc runs tests for DC OPF solver using MIPS sc t_opf fmincon runs tests for AC OPF solver using fmincon t_opf_ipopt runs tests for AC OPF solver using Ipopt t_opf_knitro runs tests for AC OPF solver using KNITROt t_opf minopf runs tests for AC OPF solver using MINOPFt t_opf mips runs tests for AC OPF solver using MIPS t_opf mips_sc runs tests for AC OPF solver using MIPS sc t_opf_softlims runs tests for DC OPF with use
103. fast decoupled power flow 91 9 5 2 makeBdc Bbus Bf Pbusinj Pfinj makeBdc baseMVA bus branch The function builds the B matrices By Bbus and By Bf and phase shift in jections Py Pbusinj and Pr shitt P inj for the DC power flow model as described in 3 29 and 4 7 9 5 3 makeJac J makeJac mpc J makeJac mpc fullJac J Ybus Yf Yt makejac mpc The makeJac function forms the power flow Jacobian and optionally the system admittance matrices Bus numbers in the input case must be consecutive beginning at 1 i e internal indexing If the fullJac argument is present and true it returns the full Jacobian sensitivities of all bus injections with respect to all voltage angles and magnitudes as opposed to the reduced version used in the Newton power flow updates 9 5 4 makeYbus Ybus Yf Yt makeYbus mpc Ybus Yf Yt makeYbus baseMVA bus branch The makeYbus function builds the bus admittance matrix and branch admittance matrices from 3 11 3 13 Bus numbers in the input case must be consecutive beginning at 1 i e internal indexing 9 6 Miscellaneous 9 6 1 define constants define_constants The define constants is a convenience script that defines a set of constants to be used as named column indices into the bus branch gen and gencost data matrices The purpose is to avoid having to remember column numbers and to allow code
104. ff ON lt code to check for required reserves fields in mpc gt add callback functions mpc add_userfcn mpc ext2int userfcn_reserves_ext2int mpc add_userfcn mpc formulation Guserfcn_reserves_formulation mpc add_userfcn mpc int2ext userfcn_reserves_int2ext mpc add_userfcn mpc printpf userfcn_reserves_printpf mpc add_userfcn mpc savecase Guserfcn_reserves_savecase mpc userfcn status dcline 1 elseif strcmp upper on_off OFF mpc remove_userfcn mpc savecase Guserfcn_reserves_savecase mpc remove_userfcn mpc printpf userfcn_reserves_printpf mpc remove_userfcn mpc int2ext userfcn_reserves_int2ext mpc remove_userfcn mpc formulation Guserfcn_reserves_formulation mpc remove_userfcn mpc ext2int userfcn_reserves_ext2int mpc userfcn status dcline 0 elseif strcmp upper on_off STATUS if isfield mpc userfcn amp amp isfield mpc userfcn status amp amp isfield mpc userfcn status dcline mpc mpc userfcn status dcline else mpc 0 end else error toggle_dcline 2nd argument must be on off or status end Running a case that includes the fixed reserves requirements is as simple as loading the case turning on reserves and running it mpc loadcase t_case30_userfcns mpc toggle_reserves mpc on results runopf mpc 73 7 4 Summary The five callback sta
105. formed hist struct array with trajectories of the following feascond gradcond compcond costcond gamma stepsize obj alphap alphad message exit message lambda struct containing the Langrange and Kuhn Tucker multipliers on the con straints with fields eqnonlin nonlinear equality constraints ineqnonlin nonlinear inequality constraints mu_l lower left hand limit on linear constraints mu_u upper right hand limit on linear constraints lower lower bound on optimization variables upper upper bound on optimization variables The use of nargout in f_fcn and gh_fcn is recommended so that the gradients and Hessian are only computed when required A l Example 1 The following code shows a simple example of using mips to solve a 2 dimensional unconstrained optimization of Rosenbrock s banana function 23 f x 100 22 x 1 21 A 7 First create a MATLAB function that will evaluate the objective function its gradients and Hessian for a given value of x In this case the coefficient of the first term is defined as a paramter a 23http en wikipedia org wiki Rosenbrock_function 98 Table A 3 Options for mips name default description opt verbose 0 controls level of progress output displayed 0 print no progress info 1 print a little progress info 2 print a lot of progress info 3 print all progress info opt feastol 1076 termination tolerance for feasibility condition
106. from bus u MVAr MU_QMINT 22 Kuhn Tucker multiplier on lower VAr limit at to bus u MVAr MU_QMAXT 23 Kuhn Tucker multiplier on upper VAr limit at to bus u MVAr Requires explicit use of toggle_dcline Output column value updated by power flow or OPF except PF in case of simple power flow t Included in OPF output typically not included or ignored in input matrix Here we assume the objective function has units u 114 Appendix C MATPOWER Options Beginning with version 4 2 MATPOWER uses an options struct to control the many options available Earlier versions used an options vector with named elements MATPOWER s options are used to control things such as e power flow algorithm e power flow termination criterion e power flow options e g enforcing of reactive power generation limits e continuation power flow options e OPF algorithm e OPF termination criterion e OPF options e g active vs apparent power vs current for line limits e verbose level e printing of results e solver specific options As with the old style options vector the options struct should always be created and modified using the mpoption function to ensure compatibility across different versions of MATPOWER The default MATPOWER options struct is obtained by calling mpoption with no arguments gt gt mpopt mpoption Individual options can be overridden from their default values by calling mpoption wi
107. g dim These functions can be used to convert additional fields in mpc from external to internal indexing and vice versa When given a case struct that has already been converted to internal indexing e2i field can be used to convert other fields as well by passing in 2 or 3 extra parameters in addition to the case struct The second argument field is a string or cell array of strings specifying a field in the case struct whose value should be converted by a corresponding call to e2i_data The field can contain either a numeric or a cell array The converted value is stored back in the specified field the original value is saved for later use and the updated case struct is returned If field is a cell array of strings they specify nested fields The third and optional fourth arguments ordering and dim are simply passed along to the call to e2i_data Similarly i2e field performs the opposite conversion from internal back to ex ternal indexing It also assumes that mpc is using internal indexing and utilizes the original data stored by e2i_field calling i2e_data to do the conversion work 9 5 Forming Standard Power Systems Matrices 9 5 1 makeB Bp Bpp makeB baseMVA bus branch alg The makeB function builds the two matrices B and B used in the fast decoupled power flow The alg which can take values FDXB or FDBX determines whether the matrices returned correspond to the XB or BX version of the
108. ges currently defined by MATPOWER are summarized in Ta ble 7 3 Table 7 3 Callback Functions name invoked typical use ext2int from ext2int immediately after Check consistency of input data con case data is converted from external vert to internal indexing to internal indexing formulation from opf after OPF Model om Modify OPF formulation by adding object is initialized with standard user defined variables constraints OPF formulation costs int2ext from int2ext immediately before Convert data back to external index case data is converted from internal ing populate any additional fields in back to external indexing the results struct printpf from printpf after pretty printing Pretty print any results not included the standard OPF output in standard OPF savecase from savecase after printing all of Write non standard case struct fields the other case data to the file to the case file 7 5 Example Extensions MATPOWER includes three OPF extensions implementing via callbacks respectively the co optimization of energy and reserves interface flow limits and dispatchable DC transmission lines 7 5 1 Fixed Zonal Reserves This extension is a more complete version of the example of fixed zonal reserve requirements used for illustration above in Sections 7 2 and 7 3 The details of the extensions to the standard OPF problem are given in equations 7 2 7 5 and a description of the relevant input an
109. he MATLAB Optimization Toolbox 6 6 runopf In MATPOWER an optimal power flow is executed by calling runopf with a case struct or case file name as the first argument casedata In addition to printing output to the screen which it does by default runpf optionally returns the solution in a results struct gt gt results runopf casedata The results struct is a superset of the input MATPOWER case struct mpc with some additional fields as well as additional columns in some of the existing data 12 Available from http www coin or org projects Ipopt xml 13See https projects coin or org Ipopt wiki MatlabInterface l4See http www ibm com software integration optimization cplex optimizer See http www mosek com 16See http www ziena com See http www gurobi com 54 fields In addition to the solution values included in the results for a simple power flow shown in Table 4 1 in Section 4 3 the following additional optimal power flow solution values are stored as shown in Table 6 1 Table 6 1 Optimal Power Flow Results name description results f final objective function value results x final value of optimization variables internal order results om OPF model object results bus LAM_P Lagrange multiplier on real power mismatch results bus LAM_Q Lagrange multiplier on reactive power mismatch results bus MU_VMAX Kuhn Tucker multiplier on upper voltage limit results bus
110. he OPF is designed to recognize fields named A 1 u H Cw N fparm zO zl and zu as parameters used to directly extend the OPF formulation as described in Section 7 1 Other user defined fields may also be included such as the reserves field used in the example code throughout Section 7 2 The loadcase function will automatically load any extra fields from a case file and if the appropriate savecase callback function see Section 7 2 5 is added via add_userfcn savecase will also save them back to a case file Table B 1 Bus Data mpc bus name column description BUS_I 1 bus number positive integer BUS_TYPE 2 bus type 1 PQ 2 PV 3 ref 4 isolated PD 3 real power demand MW QD 4 reactive power demand MVAr GS 5 shunt conductance MW demanded at V 1 0 p u BS 6 shunt susceptance MVAr injected at V 1 0 p u BUS_AREA T area number positive integer VM 8 voltage magnitude p u VA 9 voltage angle degrees BASE_KV 10 base voltage kV ZONE ti loss zone positive integer VMAX 12 maximum voltage magnitude p u VMIN 13 minimum voltage magnitude p u LAM Pt 14 Lagrange multiplier on real power mismatch u MW LAM_Q 15 Lagrange multiplier on reactive power mismatch u MVAr MU_VMAX 16 Kuhn Tucker multiplier on upper voltage limit u p u MU_VMINT 17 Kuhn Tucker multiplier on lower voltage limit u p u Y Included in OPF output typically not included or ignored in input matrix Here we assume
111. he corrector converges to a true solution given a predicted point MATPOWER s continuation power flow can optionally use adaptive steps where the step is varied based on an error estimation between the predicted and corrected solutions as given in 5 12 grt g Ecpf Omin lt oT lt Omax 5 12 ai 1 2 a i 1 ie 37 5 5 runcpf In MATPOWER a continuation power flow is executed by calling runcpf with two MATPOWER cases case structs or case file names as the first two arguments basecasedata and targetcasedata respectively The first contains the base load ing generation profile while the second contains the target loading generation pro file In addition to printing output to the screen which it does by default runcpf optionally returns the solution in a results struct gt gt results runcpf basecasedata targetcasedata Additional optional input arguments can be used to set options mpopt and provide file names for saving the pretty printed output fname or the solved case data solvedcase gt gt results runcpf basecasedata targetcasedata mpopt fname solvedcase The results struct is a superset of the input MATPOWER case struct mpc with some additional fields as well as additional columns in some of the existing data fields In addition to the solution values included in the results for a simple power flow shown in Table 4 1 in Section 4 3 the following addi
112. he values of x A along the solution curve can parameterized in a number of ways 12 13 Parameterization is a mathematical way of identifying each solution so that the next solution or previous solution can be quantified MATPOWER includes three parameterization scheme options to quantify this relationship detailed below where g is the continuation step size parameter e Natural parameterization simply uses A directly as the parameter so the new A is simply the previous value plus the step size p z A A M 0 0 5 5 e Arc length parameterization results in the following relationship where the step size is equal to the 2 norm of the distance from one solution to the next p z X 2 ri A A o 0 5 6 i e Pseudo arc length parameterization 15 is MATPOWER s default pa rameterization scheme where the next point x A on the solution curve is constrained to lie in the hyperplane running through the predicted solution 2741 J orthogonal to the tangent line from the previous corrected solution 27 7 This relationship can be quantified by the function rr 1 0 0 5 7 where Z is the normalized tangent vector at xf A and o is the continuation step size parameter 5 2 Predictor The predictor is used to produce an estimate for the next solution The better the prediction the faster is the convergence to the solution point MATPOWER uses a tangent predictor for estimating the curve to the next
113. hm 0 ignore current state when initializing OPF 1 use current state to initialize OPF for AC OPF return constraint and derivative info in results raw in fields g dg df d2f t Currently supported only for IPOPT KNITRO and MIPS solvers 121 Table C 6 Power Flow and OPF Output Options name default description verbose 1 amount of progress info to be printed 0 print no progress info 1 print a little progress info 2 print a lot of progress info 3 print all progress info out all 1 controls pretty printing of results 1 individual flags control what is printed 0 do not print anything 1 print everything out sys_sum 1 print system summary 0 or 1 out area_sum 0 print area summaries 0 or 1 out bus 1 print bus detail includes per bus gen info 0 or 1 out branch 1 print branch detail 0 or 1 out gen 0 print generator detail 0 or 1 out lim all 1 controls constraint info output 1 individual flags control what is printed 0 do not print any constraint info 1 print only binding constraint info 2 print all constraint info out lim v 1 control output of voltage limit info 0 do not print 1 print binding constraints only 2 print all constraints out lim line 1 control output of line flow limit info out lim pg 1 control output of gen active power limit info out lim qg 1 control output of gen reactive power limit info out force 0 print results even if su
114. i2e_field results reserves cost gen results i2e_field results reserves zones gen 2 r results reserves ng size results gen 1 number of on line gens internal ng0 size results order ext gen 1 number of gens external Ah results post processing hh get the results per gen reserves multipliers with internal gen indexing and convert from p u to per MW units RO Rl Ru getv results om R R results var val R results baseMVA Rmin R1 results baseMVA Rmax Ru results baseMVA mu_l results var mu 1 R results baseMVA mu_u results var mu u R results baseMVA mu_Pmax results lin mu u Pg_plus_R results baseMVA store in results in results struct z zeros ng0 1 results reserves R i2e_data results R z gen results reserves Rmin i2e_data results Rmin z gen results reserves Rmax i2e_data results Rmax z gen results reserves mu l i2e_data results mu_l z gen results reserves mu u i2e_data results mu_u z gen results reserves mu Pmax i2e_data results mu_Pmax z gen results reserves prc Z for k 1 ng0 iz find r zones k results reserves prc k sum results lin mu 1 Rreq iz results baseMVA end results reserves totalcost results cost Rcost 7 2 4 printpf Callback The pretty printing of the standard OPF output is done via a call to printpf after the case has been con
115. iles and Functions name description extras smartmarket auction clears set of bids and offers based on pricing rules and OPF results case2off generates quantity price offers and bids from gen and gencost idx_disp named column index definitions for dispatch matrix off2case updates gen and gencost based on quantity price offers and bids pricelimits fills in a struct with default values for offer and bid limits printmkt prints the market output runmarket top level simulation function runs the OPF based smart market runmkt top level simulation function runs the OPF based smart market smartmkt implements the smart market solver SM_CHANGES change history for the smart market software Deprecated Will be removed in a subsequent version 156 Appendix G Optional Packages There are a number of optional packages not included in the MATPOWER distribu tion that MATPOWER can utilize if they are installed in your MATLAB path Each of them is based on one or more MEX files pre compiled for various platforms some distributed by PSERC others available from third parties and each with their own terms of use G 1 BPMPD MEX MEX interface for BPMPD BPMPD_MEX 20 21 is a MATLAB MEX interface to BPMPD an interior point solver for quadratic programming developed by Csaba M sz ros at the MTA SZ TAKI Computer and Automation Research Institute Hungarian Academy of Sci ences Budapest Hungary It can be used by MATPOWER s DC and
116. is matrix for branch 7 are labeled as follows yi Mr Yh 33 b Yy Yu om then four n x 1 vectors Y ff Y fe Yyy and Ya can be constructed where the i th element of each comes from the corresponding element of Y Furthermore the n x np sparse connection matrices C y and Cr used in building the system admittance matrices can be defined as follows The i j element of Cp and the i k element of C are equal to 1 for each branch i where branch 7 connects from bus j to bus k All other elements of Cf and C are zero 22 3 3 Generators A generator is modeled as a complex power injection at a specific bus For generator i the injection is Sy Py Id 3 4 Let Sy P jQ be the ng x 1 vector of these generator injections The MW and MVAr equivalents before conversion to p u of Py and a are specified in columns PG 2 and QG 3 respectively of row 7 of the gen matrix A sparse n X ng generator connection matrix C can be defined such that its i 7 element is 1 if generator j is located at bus and O otherwise The n x 1 vector of all bus injections from generators can then be expressed as Sa pus Cy Sy 3 5 3 4 Loads Constant power loads are modeled as a specified quantity of real and reactive power consumed at a bus For bus 7 the load is Sa Pat IM 3 6 and Sa Pa jQa denotes the np x 1 vector of complex loads at all buses The MW and MVAr equivalents before conversion to p u of p and qi are
117. k t_scale_load ok TPB ii rito lied ok A11 tests successful 2775 passed 732 skipped of 3507 Elapsed time 7 71 seconds 2 3 Running a Simulation The primary functionality of MATPOWER is to solve power flow and optimal power flow OPF problems This involves 1 preparing the input data defining the all of the relevant power system parameters 2 invoking the function to run the simulation and 3 viewing and accessing the results that are printed to the screen and or saved 15 in output data structures or files 2 3 1 Preparing Case Input Data The input data for the case to be simulated are specified in a set of data matrices packaged as the fields of a MATLAB struct referred to as a MATPOWER case struct and conventionally denoted by the variable mpc This struct is typically defined in a case file either a function M file whose return value is the mpc struct or a MAT file that defines a variable named mpc when loaded The main simulation routines whose names begin with run e g runpf runopf accept either a file name or a MATPOWER case struct as an input Use loadcase to load the data from a case file into a struct if you want to make modifications to the data before passing it to the simulation gt gt mpc loadcase casefilename See also savecase for writing a MATPOWER case struct to a case file The structure of the MATPOWER case data is described a bit further in Section 3 1
118. ki ui gt ki Here k specifies the size of the dead zone m is a simple scale factor and fa is a pre defined scalar function selected by the value of d Currently MATPOWER implements only linear and quadratic options Q if di 1 Oori a 6 31 as illustrated in Figure 6 1 and Figure 6 2 respectively This form for f provides the flexibility to handle a wide range of costs from simple linear functions of the optimization variables to scaled quadratic penalties on quantities such as voltages lying outside a desired range to functions of linear combinations of variables inspired by the requirements of price coordination terms found in the decomposition of large loosely coupled problems encountered in our own research Some limitations are imposed on the parameters in the case of the DC OPF since MATPOWER uses a generic quadratic programming QP solver for the optimization In particular k 0 and d 1 for all 7 so the dead zone is not considered and only the linear option is available for fq As a result for the DC case 6 30 simplifies to Wi Mij 6 3 2 User defined Constraints The user defined constraints 6 25 are general linear restrictions involving all of the optimization variables and are specified via matrix A and lower and upper bound vectors l and u These parameters can be used to create equality constraints l u or inequality constraints that are bounded below u 00 bounded above l
119. larger systems The former is based on MINOS 23 and the latter includes the primal dual interior point and trust region based augmented Lagrangian methods described in 18 MATPOWER version 4 and later also includes the option to use the open source IPOPT solver for solving both AC and DC OPFs based on the Matlab MEX interface to IPOPT It also includes the option to use CPLEX or MOSEK for DC OPFs MATPOWER 4 1 added the option to use KNITRO 35 for AC OPFs and the Gurobi Optimizer for DC OPFs and MATPOWER 5 added GLPK and 5 1 added CLP See Appendix G for more details on these optional packages Beginnning with version 4 MATPOWER also includes its own primal dual interior point method implemented in pure MATLAB code derived from the MEX imple mentation of the algorithms described in 18 This solver is called MIPS MATLAB Interior Point Solver and is described in more detail in Appendix A If no optional packages are installed MIPS will be used by default for both the AC OPF and as the QP solver used by the DC OPF The AC OPF solver also employs a unique technique for efficiently forming the required Hessians via a few simple matrix operations 24 This solver has application to general nonlinear optimization problems outside of MATPOWER and can be called directly as mips There is also a convenience wrapper function called gps_mips making it trivial to set up and solve LP and QP problems with an interface similar to quadprog from t
120. luate the constraints in this case inequalities only and their gradients function h g dh dg gh2 x h 1 1 1 111 x 72 2 10 dh 2 x 1 x 1 x 2 x 2 x 3 x 3 g O d and another to evaluate the Hessian of the Lagrangian function Lxx hess2 x lam cost_mult if nargin lt 3 cost_mult 1 end h allows to be used with fmincon mu lam ineqnonlin Lxx cost_mult O 1 0 1 0O 1 O 1 0 2x 1 1 mu O 0 O 2 1 1 mu 0 O O 2 1 1 mu Then create a problem struct with handles to these functions a starting value for x and an option to print the solver s progress Finally pass this struct to mips to solve the problem and print some of the return values to get the output below function example2 problem struct f_fcn x f 2 x gh_fcn Q x gh2 x hess_fcn x lam cost_mult hess2 x lam cost_mult x0 1 1 Ol opt struct verbose 2 x f exitflag output lambda mips problem fprintf nf g exitflag d n f exitflag fprintf nx n fprintf g n x fprintf nlambda ineqnonlin n fprintf g n lambda ineqnonlin 101 gt gt example2 MATLAB Interior Point Solver MIPS Version 1 2 20 Mar 2015 using built in linear solver it objective step size feascond gradcond compcond costcond 0 1 0 1 5 5 0 1 5 3250167 1 6875 0 0 894235 0 850653 2 16251 2 7 4708991 0 97413 0
121. me description mpc MATPOWER Case struct softlims additional field in mpc containing input parameters for DC OPF branch flow soft limits in the following sub fields idx ns X 1 vector of branch indices of the branches whose flow limits are to be converted to soft limits If empty it defaults to include all on line branches with non zero branch ratings cost Ns X 1 vector of cost coefficients cy This is a per MW cost applied to any flow overload in the corresponding branch Alternatively the cost can be specified as a scalar in which case it is used for each soft limit The default value if not specified is 1000 MW Table 7 7 Output Data Structures for DC OPF Branch Flow Soft Limits name description results OPF results struct superset of mpc with additional fields for out put data softlims additional field in results containing output parameters for DC OPF branch flow soft limits in the following sub fields overload n xX 1 vector of branch flow overloads in MW ovl_cost n x 1 vector of branch flow overload penalty costs in u MWt branch MU_SF for branches whose limits have been replaced with soft limits these branch MU_ST contain the Kuhn Tucker multipliers on the soft limit constraints T Here we assume the objective function has units u t When there is no violation of the soft limit this shadow price is the same as it would be for a hard limit When there is a violation it is equal to the corresponding user specifi
122. meter of perturbation y approaches zero the solution to this problem approaches that of the original problem For a given value of y the Lagrangian for this equality constrained problem is CURL ADE POS A ECO AEA Y In Zm 4 26 Taking the partial derivatives with respect to each of the variables yields LUX Z A fx NM Gx p Hx A 27 LHX Z 11 yt m yer 217 A 28 LUX Z u G X A 29 LI X Z u H X 2 A 30 And the Hessian of the Lagrangian with respect to X is given by Lyx X Z u fxx Gxx Hxx p A 31 A 4 3 First Order Optimality Conditions The first order optimality Karush Kuhn Tucker conditions for this problem are satisfied when the partial derivatives of the Lagrangian above are all set to zero F X Z u 0 A 32 Z gt 0 A 33 p gt 0 A 34 105 where ja HW Z ye _ G X A X Z F X Z 11 fx Gx A Hx p u Z ye G X H X Z A 35 A 4 4 Newton Step The first order optimality conditions are solved using Newton s method The Newton update step can be written as follows AX AZ Fx Fz Fy F Ay F X ZAK A 36 Au Liz 0 Gx Hx AX pa 0 0 Z AZ __ l 1Z ye Gx 0 0 0 Al GX i est Hy I 0 0 Au H X Z This set of equations can be simplified and reduced to a smaller set of equations by solving explicitly for Ay in terms of AZ and for AZ in terms of AX Taking the 29 row of A 37 and solving for Ay we get 1 AZ Z Ap
123. ming LP and quadratic programming QP problems among others More information is available at http www mosek com Although MOSEK is a commercial package at the time of this writing there is a free academic license available See http mosek com resources academic license for more details When the MATLAB interface to MOSEK is installed the MOSEK LP and QP solvers can be used to solve DC OPF problems by setting the opf solver dc op tion equal to MOSEK The solution algorithm for LP problems can be controlled by MATPOWER s mosek 1p_alg option See Table C 16 for other MOSEK related MATPOWER options A MOSEK user options function can also be specified via mosek opt_fname to override the defaults for any of the many MOSEK parame ters For details see help mosek_options and the Parameters reference in The MOSEK optimization toolbox for MATLAB manual at http docs mosek com 7 1 toolbox Parameters html You may also find it helpful to use the symbolic constants defined by mosek_symbcon 162 It can also be used to solve general LP and QP problems via MATPOWER s com mon QP solver interface qps natpower or MILP and MIQP problems via miqps_matpower with the algorithm option set to MOSEK or 600 for backward compatibility or by calling qps_mosek or miqps mosekdirectly G 10 PARDISO Parallel Sparse Direct and Multi Recursive Iterative Linear Solvers The PARDISO package is a thread safe high performance
124. ndcopf case118 gt gt final_objective results f gt gt gen6_output results gen 6 PG gt gt branch51_flow results branch 51 PF Full documentation for the content of the results struct can be found in Sec tions 4 3 and 6 6 17 2 3 4 Setting Options MATPOWER has many options for selecting among the available solution algorithms controlling the behavior of the algorithms and determining the details of the pretty printed output These options are passed to the simulation routines as a MATPOWER options struct The fields of the struct have names that can be used to set the corresponding value via the mpoption function Calling mpoption with no arguments returns the default options struct the struct used if none is explicitly supplied Calling it with a set of name and value pairs modifies the default vector For example the following code runs a power flow on the 300 bus example in case300 m using the fast decoupled XB version algorithm with verbose printing of the algorithm progress but suppressing all of the pretty printed output gt gt mpopt mpoption pf alg FDXB verbose 2 out all 0 gt gt results runpf case300 mpopt To modify an existing options struct for example to turn the verbose option off and re run with the remaining options unchanged simply pass the existing options as the first argument to mpoption gt gt mpopt mpoption mpopt verbose
125. nerator ordering where off line generators have been eliminated and the on line generators are sorted in order of increasing bus number Notice that it is the second dimension columns of mpc reserves zones that is being re ordered See the on line help for e2i_field and e2i_data for more details on what all they can do 62 function mpc userfcn_reserves_ext2int mpc args mpc e2i_field mpc reserves qty gen mpc e2i_field mpc reserves cost gen mpc e2i_field mpc reserves zones gen 2 This stage is also a good place to check the consistency of any additional input data required by the extension and throw an error if something is missing or not as expected 7 2 2 formulation Callback This stage is called from opf after the OPF Model om object has been initialized with the standard OPF formulation but before calling the solver This is the ideal place for modifying the problem formulation with additional variables constraints and costs using the add_vars add_constraints and add_costs methods of the OPF Model object Inputs are the om object and any optional args supplied when the callback was registered via add_userfcn Output is the updated om object The om object contains both the original MATPOWER case data as well as all of the indexing data for the variables and constraints of the standard OPF formulation See the on line help for opf_model for more details on the OPF m
126. nformation for Gurobi option information for INTLINPROG option information for IPOPT option information for KNITRO option information for LINPROG option information for MIPS option information for MOSEK option information for QUADPROG converts data read from PSS E RAW file to MATPOWER format called by psse_convert to handle HVDC data called by psse_convert to handle transformer data parses data from a PSS E RAW data file called by psse_parse to parse a single line called by psse_parse to parse an entire section reads data from a PSS E RAW data file 142 D 3 Example MATPOWER Cases name Table D 17 Example Cases description caseformat case_ieee30 case24_ieee_rts case4gs cased case6ww case9 case9Q case9target casel4 case30 case30pwl case30Q case39 case57 case118 case300 case2383wp case2736sp case2737sop case2746wop case2746wp case3012wp case3120sp case3375wp case89pegase case1354pegase case2869pegase case9241pegase help file documenting MATPOWER case format IEEE 30 bus case IEEE RTS 24 bus case 4 bus example case from Grainger amp Stevenson modified 5 bus PJM example case from Rui Bo 6 bus example case from Wood amp Wollenberg 9 bus example case from Chow case9 with reactive power costs modified case9 target for example continuation power flow IEEE 14 bus case 30 bus case based on IEEE 30 bus case case30 with piecewise linear costs case30 with reactive power costs 3
127. ng re laxation of the power flow equations Code contributed by Dan Molzahn See Appendix G 11 and the documenation in the MATPOWER extras sdp_pf documentation directory especially the file sdp_pf_documentation pdf for a full description of the func tions in this package se State estimation code contributed by Rui Bo Type test se test_se_14bus or test_se_14bus_err to run some examples See se_intro pdf for a brief introduction to this code smartmarket Code that implements a smart market auction clearing mech anism based on MATPOWER s optimal power flow solver See Appendix F for details state_estimator Older state estimation example based on code by James S Thorp 148 Appendix F Smart Market Code MATPOWER 3 and later includes in the extras smartmarket directory code that implements a smart market auction clearing mechanism The purpose of this code is to take a set of offers to sell and bids to buy and use MATPOWER s optimal power flow to compute the corresponding allocations and prices It has been used extensively by the authors with the optional MINOPF package 22 in the context of POWERWEB but has not been widely tested in other contexts The smart market algorithm consists of the following basic steps 1 Convert block offers and bids into corresponding generator capacities and costs 2 Run an optimal power flow with decommitment option uopf to find generator allocations and nodal prices
128. nism is used to shut down generators if doing so results in a smaller overall system cost see Section 8 26See http www pserc cornell edu powerweb 149 In step 3 the OPF solution is used to determine for each offer bid block how much was cleared and at what price These values are returned in co and cb which have the same structure as offers and bids The mkt parameter is a struct used to specify a number of things about the market including the type of auction to use type of OPF AC or DC to use and the price limits There are two basic types of pricing options available through mkt auction_type discriminative pricing and uniform pricing The various uniform pricing options are best explained in the context of an unconstrained lossless network In this context the allocation is identical to what one would get by creating bid and offer stacks and finding the intersection point The nodal prices Ap computed by the OPF and returned in bus LAM_P are all equal to the price of the marginal block This is either the last accepted offer LAO or the last accepted bid LAB depending which is the marginal block i e the one that is split by intersection of the offer and bid stacks There is often a gap between the last accepted bid and the last accepted offer Since any price within this range is acceptable to all buyers and sellers we end up with a number of options for how to set the price as listed in Table F 1 Table F 1 Au
129. nning and Analysis Tools for Power Systems Re search and Education Power Systems IEEE Transactions on vol 26 no 1 pp 12 19 Feb 2011 1 3 F Milano An Open Source Power System Analysis Toolbox Power Systems IEEE Transactions on vol 20 no 3 pp 1199 1206 Aug 2005 W F Tinney and C E Hart Power Flow Solution by Newton s Method IEEE Transactions on Power Apparatus and Systems vol PAS 86 no 11 pp 1449 1460 November 1967 4 1 B Stott and O Alsag Fast Decoupled Load Flow IEEE Transactions on Power Apparatus and Systems vol PAS 93 no 3 pp 859 869 May 1974 4 1 R A M van Amerongen A General Purpose Version of the Fast Decoupled Load Flow Power Systems IEEE Transactions on vol 4 no 2 pp 760 770 May 1989 4 1 A F Glimm and G W Stagg Automatic Calculation of Load Flows AIEE Transactions Power Apparatus and Systems vol 76 pp 817 828 October 1957 4 1 A J Wood and B F Wollenberg Power Generation Operation and Control 2nd ed New York J Wiley amp Sons 1996 3 7 4 2 4 4 T Guler G Gross and M Liu Generalized Line Outage Distribution Fac tors Power Systems IEEE Transactions on vol 22 no 2 pp 879 881 May 2007 4 4 V Ajjarapu C Christy The Continuation Power Flow A Tool for Steady State Voltage Stability Analysis Power Systems IEEE Transacations on vol 7 no 1 pp 416 423 Feb 1992 5 165 12
130. no charge through the IBM Academic Initia tive program for teaching and non commercial research See http www ibm com support docview wss uid swg21419058 for more details When the MATLAB interface to CPLEX is installed the CPLEX LP and QP solvers cplexlp and cplexqp can be used to solve DC OPF problems by setting the opf solver dc option equal to CPLEX The solution algorithms can be controlled by MATPOWER s cplex lpmethod and cplex qpmethod options See Table C 9 for a summary of the CPLEX related MATPOWER options A CPLEX user options function can also be specified via cplex opt_fname to override the defaults for any of the many CPLEX parameters See help cplex_options and the Parameters 28 According to David Gleich at http web stanford edu dgleich notebook 2009 03 coinor_clop_for_matlab html there was a Matlab MEX interface to CLP written by Johan Lofberg and available at some point in the past at http control ee ethz ch joloef mexclp zip Unfortunately at the time of this writing it seems it is no longer available there but Davide Barcelli makes some precompiled MEX files for some platforms available here http www dii unisi it barcelli software php and the ZIP file linked as Clp 1 14 3 con tains the MEX source as well as a clp m wrapper function with some rudimentary documentation 22The OPTI Toolbox is available from http www i2c2 aut ac nz Wiki OPTI 158 of CPLEX section of the CPLEX documenta
131. ocumentation for de tails It can also be used to solve general LP and QP problems via MATPOWER s common QP solver interface qgps_matpower with the algorithm option set to IPOPT or 400 for backward compatibility or by calling qps ipopt directly G 7 KNITRO Non Linear Programming Solver KNITRO 35 is a general purpose optimization solver specializing in nonlinear problems available from Ziena Optimization LLC As of version 9 KNITRO in cludes a native Matlab interface knitromatlab More information is available at http www ziena com and http www ziena com knitromatlab htm Although KNITRO is a commercial package at the time of this writing there is a free academic license available with details on their download page When installed KNITRO s MATLAB interface function knitromatlab or ktrlink can be used by MATPOWER to solve AC OPF problems by simply setting the opf solver ac option to KNITRO See Table C 14 for a summary of KNITRO related MATPOWER options The knitromatlab function uses callbacks to MATLAB func tions to evaluate the objective function and its gradient the constraint values and Jacobian and the Hessian of the Lagrangian KNITRO options can be controlled directly by creating a standard KNITRO op 33See http www pardiso project org index php p manual for the download links 34The OPTI Toolbox is available from http www i2c2 aut ac nz Wiki OPTI 35Earlier versions required the MATLAB O
132. odel object and the methods available for manipulating and accessing it In the example code a new variable block named R with n elements and the limits from 7 2 is added to the model via the add vars method Similarly two linear constraint blocks named Pg_plus_R and Rreq implementing 7 4 and 7 5 respectively are added via the add_constraints method And finally the add_costs method is used to add to the model a user defined cost block corresponding to 7 3 Notice that the last argument to add_constraints and add_costs allows the con straints and costs to be defined only in terms of the relevant parts of the optimiza tion variable x For example the A matrix for the Pg_plus_R constraint contains only columns corresponding to real power generation Pg and reserves R and need not bother with voltages reactive power injections etc As illustrated in Figure 7 1 this allows the same code to be used with both the AC OPF where x includes Vm and and the DC OPF where it does not This code is also independent of any 19Tt is perfectly legitimate to register more than one callback per stage such as when enabling multiple independent OPF extensions In this case the callbacks are executed in the order they were registered with add_userfcn E g when the second and subsequent formulation callbacks are invoked the om object will reflect any modifications performed by earlier formulation callbacks 63 additional variables that ma
133. of the various uniform price auctions are described in detail in 27 There are certain circumstances under which the price of a cleared offer deter mined by the above procedures can be less than the original offer price such as when a generator is dispatched at its minimum generation limit or greater than the price cap lim P max_cleared_offer For this reason all cleared offer prices are clipped to be greater than or equal to the offer price but less than or equal to lim P max_cleared_offer Likewise cleared bid prices are less than or equal to the bid price but greater than or equal to lim P min_cleared_bid F 1 Handling Supply Shortfall In single sided markets in order to handle situations where the offered capacity is insufficient to meet the demand under all of the other constraints resulting in an infeasible OPF we introduce the concept of emergency imports We model an import as a fixed injection together with an equally sized dispatchable load which is bid in at a high price Under normal circumstances the two cancel each other and have no effect on the solution Under supply shortage situations the dispatchable load is not fully dispatched resulting in a net injection at the bus mimicking an import When used in conjunction with the LAO pricing rule the marginal load bid will not set the price if all offered capacity can be used F 2 Example The case file t t_auction_case m used for this example is a modified version of th
134. olution algorithm output options termination tolerances and more see also MPOPTION FNAME name of a file to which the pretty printed output will be appended SOLVEDCASE name of file to which the solved case will be saved in MATPOWER case format M file will be assumed unless the specified name ends with mat Outputs all are optional RESULTS results struct with the following fields all fields from the input MATPOWER case i e bus branch gen etc but with solved voltages power flows etc order info used in external lt gt internal data conversion et elapsed time in seconds success success flag 1 succeeded O failed additional OPF fields see OPF for details SUCCESS the success flag can additionally be returned as a second output argument Calling syntax options results runopf results runopf casedata results runopf casedata mpopt results runopf casedata mpopt fname results runopf casedata mpopt fname solvedcase results success runopf Alternatively for compatibility with previous versions of MATPOWER some of the results can be returned as individual output arguments baseMVA bus gen gencost branch f success et runopf Example results runopf case30 See also RUNDCOPF RUNUOPF 20 3 Modeling MATPOWER employs all of the standard steady state models typically used for power flow analysis The AC models are described fir
135. onality e 1 turn ON the optional functionality if available e 1 toggle the ON OFF state of the optional functionality 9 6 3 mpver mpver v mpver v mpver all 93 The mpver function returns the current MATPOWER version number With the optional all argument it returns a struct with the fields Name Version Release and Date all strings Calling mpver without assigning the return value prints the version and release date of the current installation of MATPOWER MAT LAB or Octave the Optimization Toolbox MIPS and any optional MATPOWER packages 9 6 4 nested_struct_copy ds ds nested_struct_copy d s opt nested_struct_copy d s The nested_struct_copy function copies values from a source struct s to a desti nation struct d in a nested recursive manner That is the value of each field in s is copied directly to the corresponding field in d unless that value is itself a struct in which case the copy is done via a recursive call to nested struct_copy Certain aspects of the copy behavior can be controled via the optional options struct opt including the possible checking of valid field names 94 10 Acknowledgments The authors would like to acknowledge contributions from others who have helped make MATPOWER what it is today First we would like to acknowledge the input and support of Bob Thomas throughout the development of MATPOWER Thanks to Chris DeMarco one of
136. onditions and the following disclaimer in the documentation and or other materials provided with the distribution 3 Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE DATA OR PROFITS OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 3Versions 4 0 through 5 0 of MATPOWER were distributed under version 3 0 of the GNU General Public License GPL 2 with an exception added to clarify our intention to allow MATPOWER to interface with MATLAB as well as any other MATLAB code or MEX files a user may have installed regardless of their licensing terms The full text of the GPL can be found at http www gnu org licenses gp1 3 0 tx
137. ons IPOPT options KNITRO options MINOPF options MOSEK options PDIPM options TRALM options Requires the installation of an optional package See Appendix G for details on the corresponding package Requires MATLAB s Optimization Toolbox available from The MathWorks Inc http www mathworks com 117 Table C 2 Power Flow Options name default description pf alg NR AC power flow algorithm NR Newtons s method FDXB Fast Decoupled XB version FDBX Fast Decouple BX version GS Gauss Seidel pf tol 1078 termination tolerance on per unit P and Q dispatch pf nr max_it 10 maximum number of iterations for Newton s method pf fd max_it 30 maximum number of iterations for fast decoupled method pf gs max_it 1000 maximum number of iterations for Gauss Seidel method pf enforce_q_lims 0 enforce gen reactive power limits at expense of Vm 0 do not enforce limits 1 enforce limits simultaneous bus type conversion 2 enforce limits one at a time bus type conversion 118 Table C 3 Continuation Power Flow Options name default cpf parameterization 3 cpf stop_at NOSE cpf step 0 05 cpf adapt_step 0 cpf error_tol 1073 cpf step_min 1074 cpf step_max 0 2 cpf plot level 0 cpf plot bus empty cpf user_callback empty cpf user_callback_args empty description choice of parameterization 1 natural 2 arc length 3 pseudo arc length determines st
138. ons that are regis tered via add_userfcn for MATPOWER to call automatically at one of the five stages Each stage has a name and by convention the name of a user defined callback func tion ends with the name of the corresponding stage For example a callback for the formulation stage that modifies the OPF problem formulation to add reserve requirements could be registered with the following line of code mpc add_userfcn mpc formulation Guserfcn_reserves_formulation 60 The sections below will describe each stage and the input and output arguments for the corresponding callback function which vary depending on the stage An example that employs additional variables constraints and costs will be used for illustration Consider the problem of jointly optimizing the allocation of both energy and reserves where the reserve requirements are defined as a set of n fixed zonal MW quantities Let Z be the set of generators in zone k and R be the MW reserve requirement for zone k A new set of variables r are introduced representing the reserves provided by each generator The value r for generator i must be non negative and is limited above by a user provided upper bound r e g a reserve offer quantity as well as the physical ramp rate Aj max 2 0 lt r lt mmr A GH Lon 7 2 If the vector c contains the marginal cost of reserves for each generator the user defined cost term from 6 21 is simply falx z
139. opping criterion NOSE stop when nose point is reached FULL trace full nose curve Astop Stop upon reaching target A value Astop continuation power flow step size toggle adaptive step size feature 0 adaptive step size disabled 1 adaptive step size enabled tolerance for the adaptive step controller minimum allowed step size maximum allowed step size control plotting of nose curve 0 do not plot nose curve 1 plot when completed 2 plot incrementally at each iteration 3 same as 2 with pause at each iteration index of bus whose voltage is to be plotted string or cell array of strings with names of user callback functions struct passed to user defined callback functions See help cpf_default_callback for details 119 Table C 4 OPF Solver Options name default description opf ac solver DEFAULT AC optimal power flow solver DEFAULT choose default solver based on availability in the following order PDIPM MIPS MIPS MIPS MATLAB Interior Point Solver pri mal dual interior point method FMINCON MATLAB Optimization Toolbox fmincon IPOPT IPOPT KNITRO KNITRO MINOPF MINOPF MINOS based solver PDIPM PDIPM primal dual interior point method SDPOPF SDPOPF solver based on semidefinite relax ation TRALM TRALM trust region based augmented Lan grangian method opf dc solver DEFAULT DC optimal power flow solver DEFAUL
140. or matrix of generation levels The return value has the same dimensions as Pg Each row of gencost is used to evaluate the cost at the output levels specified in the corresponding row of Pg The rows of gencost can specify either polynomial or piecewise linear costs and need not be uniform 9 3 Modifying a Case 9 3 1 extract_islands mpc_array extract_islands mpc mpc_array extract_islands mpc groups mpc_k extract_islands mpc k mpc_k extract_islands mpc groups k mpc_k extract_islands mpc k custom mpc_k extract_islands mpc groups k custom The extract_islands function extracts individual islands in a network that is not fully connected The original network is specified as a MATPOWER case struct mpc and the result is returned as a cell array of case structs or as a single case struct Supplying the optional group avoids the need to traverse the network again saving time on large systems A final optional argument custom is a struct that can be used to indicate custom fields of mpc from which to extract data corresponding to buses generators branches or DC lines 88 9 3 2 load2disp mpc load2disp mpc0 mpc load2disp mpcO fname mpc load2disp mpcO fname idx mpc load2disp mpcO fname idx voll The load2disp function takes a MATPOWER case mpcO converts fixed loads to dispatchable loads curtailable at a specific price and returns the resulting case struct
141. orithm NR Newtons s method FDXB Fast Decoupled XB version FDBX Fast Decouple BX version GS Gauss Seidel pf tol 1078 termination tolerance on per unit P and Q dispatch pf nr max_it 10 maximum number of iterations for Newton s method pf fd max_it 30 maximum number of iterations for fast decoupled method pf gs max_it 1000 maximum number of iterations for Gauss Seidel method pf enforce_q_lims 0 enforce gen reactive power limits at expense of V 0 do not enforce limits 1 enforce limits simultaneous bus type conversion 2 enforce limits one at a time bus type conversion gt gt results runpf casedata mpopt fname solvedcase The options that control the power flow simulation are listed in Table 4 2 and those controlling the output printed to the screen in Table 4 3 31 By default runpf solves an AC power flow problem using a standard Newton s method solver To run a DC power flow the model option must be set to DC For convenience MATPOWER provides a function rundcpf which is simply a wrapper that sets the model option to DC before calling runpf Table 4 3 Power Flow Output Options name default description verbose 1 amount of progress info to be printed 0 print no progress info 1 print a little progress info 2 print a lot of progress info 3 print all progress info out all 1 controls pretty printing of results 1 individual flags control
142. p opt_fname empty name of user supplied function passed as FNAME argument to clp_options to override defaults For opf solver dc option set to CLP only Requires the installation of the optional CLP package See Appendix G 2 for details t For details see help clp_options or help clp 123 Table C 9 OPF Options for CPLEX name default description cplex 1lpmethod 0 algorithm used by CPLEX for LP problems 0 automatic let CPLEX choose 1 primal simplex 2 dual simplex 3 network simplex 4 barrier 5 sifting 6 concurrent dual barrier and primal cplex qpmethod 0 algorithm used by CPLEX for QP problems 0 automatic let CPLEX choose 1 primal simplex 2 dual simplex 3 network simplex 4 barrier cplex opts empty struct of native CPLEX options for cplexoptimset passed to cplex_options to override defaults applied after overrides from cplex opt_fname cplex opt_fname empty name of user supplied function passed as FNAME argument to cplex_options to override defaults cplex opt 0 if cplex opt_fname is empty and cplex opt is non zero the value of cplex opt_fname is generated by appending cplex opt to cplex_user_options_ for backward compatibility with old MATPOWER option CPLEX_OPT For opf solver dc option set to CPLEX only Requires the installation of the optional CPLEX package See Appendix G 3 for details t For details see help cplex_options and the Parameters of CPL
143. ponding bus is converted to a PQ bus and the power flow is solved again This procedure is repeated until there are no more violations Note that this option is based solely on the QMAX and QMIN parameters for the generator from columns 4 and 5 of the gen matrix and does not take into account the trape zoidal generator capability curves described in Section 6 4 3 and specifed in columns PC1 QC2MAX 11 16 4 2 DC Power Flow For the DC power flow problem 9 the vector x consists of the set of voltage angles at non reference buses Tt laiz Vi Tres 4 6 and 4 1 takes the form Back Pic 0 4 7 where Bae is the np 1 x n 1 matrix obtained by simply eliminating from Bpus the row and column corresponding to the slack bus and reference angle respectively Given that the generator injections P are specified at all but the slack bus Py can be formed directly from the non slack rows of the last four terms of 3 32 The voltage angles in x are computed by a direct solution of the set of linear equations The branch flows and slack bus generator injection are then calculated directly from the bus voltage angles via 3 29 and the appropriate row in 3 32 respectively 4 3 runpf In MATPOWER a power flow is executed by calling runpf with a case struct or case file name as the first argument casedata In addition to printing output to the screen which it does by default runpf optionally returns the solution in a
144. ptimization Toolbox from The MathWorks which includes an interface to the KNITRO libraries called ktrlink but the libraries themselves still had to be acquired directly from Ziena Optimization LLC 161 tions file in your working directory and specifying it via the knitro opt_fname or for backward compatibility naming it knitro_user_options_n txt and setting MAT POWER s knitro opt option to n where n is some positive integer value See the KNITRO user manuals at http www ziena com documentation htm for details on the available options G 8 MINOPF AC OPF Solver Based on MINOS MINOPF 22 is a MINOS based optimal power flow solver for use with MATPOWER It is for educational and research use only MINOS 23 is a legacy Fortran based software package developed at the Systems Optimization Laboratory at Stanford University for solving large scale optimization problems While MINOPF is often MATPOWER s fastest AC OPF solver on small problems as of MATPOWER 4 it no longer becomes the default AC OPF solver when it is in stalled It can be selected manually by setting the opf solver ac option to MINOPF see help mpoption for details Builds are available for Linux 32 bit Mac OS X PPC Intel 32 bit and Win dows 32 bit at http www pserc cornell edu minopf G 9 MOSEK High performance LP and QP Solvers MOSEK is a collection of optimization tools that includes high performance solvers for large scale linear program
145. r callback functions for branch flow soft limits t_opf tspopf pdipm runs tests for AC OPF solver using PDIPM t_opf_tspopf_scpdipm runs tests for AC OPF solver using SC PDIPM t_opf_tspopf_tralm runs tests for AC OPF solver using TRALM t_opf userfcns runs tests for AC OPF with user callback functions for reserves and interface flow limits t_runopf_w_res runs tests for AC OPF with fixed reserve requirements Requires the installation of an optional package See Appendix G for details on the corresponding package 147 Appendix E Extras Directory For a MATPOWER installation in MATPOWER the contents of MATPOWER extras con tains additional MATPOWER related code some contributed by others Some of these could be moved into the main MATPOWER distribution in the future with a bit of polishing and additional documentation Please contact the developers if you are interested in helping make this happen misc A number of potentially useful functions that are either not yet fully implemented tested and or documented See the help and the code in each individual file to understand what it does reduction A network reduction toolbox that performs a modifed Ward reduction and can be used to produce a smaller approximate equivalent from a larger original system Code contributed by Yujia Zhu and Daniel Tylavsky For more details please see the Network Reduction Toolbox pdf file sdp_pf Applications of a semidefinite programming programmi
146. required Specifically if there are nonlinear constraints the Hessian information must provided by the hess_fcn function and it need not be computed in f_fcn below for the Hessian evaluation function Specifically _fcn should return f as the scalar objective function value f x df as an n x 1 vector equal to Vf and unless gh fcn is provided and the Hessian is computed by hess_fcn d2f as an n x n matrix equal to the Hessian rf Similarly the constraint evaluation function gh fcn must return the m x 1 vector of nonlinear equality constraint violations g x the p x 1 vector of nonlinear inequality constraint violations h x along with their gradients in dg and dh Here dg is an n x m matrix whose j column is Vg and dh is n x p with jt column equal to Vh Finally for cases with nonlinear constraints hess _fcn returns the n x n Hessian oe of the Lagrangian function L z A 0 of x r g x w h a A 6 for given values of the multipliers A and u where is the cost_mult scale factor for the objective function Unlike fmincon mips passes this scale factor to the Hessian evaluation function in the 3 argument 97 Table A 2 Output Arguments for mips name description x solution vector f final objective function value exitflag exit flag 1 first order optimality conditions satisfied 0 maximum number of iterations reached 1 numerically failed output output struct with fields iterations number of iterations per
147. results struct gt gt results runpf casedata The results struct is a superset of the input MATPOWER case struct mpc with some additional fields as well as additional columns in some of the existing data fields The solution values are stored as shown in Table 4 1 Additional optional input arguments can be used to set options mpopt and provide file names for saving the pretty printed output fname or the solved case data solvedcase 30 Table 4 1 Power Flow Results name description results success success flag 1 succeeded 0 failed results et computation time required for solution results order see ext2int help for details on this field results bus VM t bus voltage magnitudes results bus VA bus voltage angles results gen PG generator real power injections results gen qt generator reactive power injections results branch PF real power injected into from end of branch results branch PT real power injected into to end of branch results branch QF reactive power injected into from end of branch results branch QT reactive power injected into to end of branch AC power flow only Table 4 2 Power Flow Options name default description model AC AC vs DC modeling for power flow and OPF formulation AC use AC formulation and corresponding alg options DC use DC formulation and corresponding alg options pf alg NR AC power flow alg
148. rgument where all fields except H c A and 1 are optional x f exitflag output lambda qps_mips problem Aside from H and c all input and output arguments correspond exactly to the same arguments for mips as described in Tables A 1 and A 2 As with mips and fmincon the primary difference between the calling syntax for qps mips and quadprog is that the linear constraints are specified in terms of a single doubly bounded linear function l lt Ax lt u as opposed to separate equality constrained 4 1 bey and upper bounded Az lt b functions MATPOWER also includes another wrapper function gps_matpower that provides a consistent interface for all of the QP and LP solvers it has available This interface is identical to that used by gps_mips with the exception of the structure of the opt input argument The solver is chosen according to the value of opt alg See the help for qps matpower for details Several examples of using qps_matpower to solve LP and QP problems can be found in t_qps_matpower m A 4 Primal Dual Interior Point Algorithm This section provides some details on the primal dual interior point algorithm used by MIPS and described in 18 25 A 4 1 Notation For a scalar function f R R of a real vector X Li Ta Ly J we use the following notation for the first derivatives transpose of the gradient _ Of _f at af af fx E Ox 0x1 x2 Orn g A 14 103
149. rolled by MATPOWER s gurobi method option See Table C 12 for a summary of the Gurobi related MATPOWER options A Gurobi user options function can also be specified via gurobi opt_fname to override the defaults for any of the many Gurobi pa rameters See help gurobi_options and the Parameters section of the Gurobi Op timizer Reference Manual at http www gurobi com documentation 5 6 reference manual parameters for details It can also be used to solve general LP and QP problems via MATPOWER s com mon QP solver interface qps_matpower or MILP and MIQP problems via miqps_matpower with the algorithm option set to GUROBI or 700 for backward compatibility or by calling qps_gurobi or miqps gurobi directly G 6 IPOPT Interior Point Optimizer IpopT 32 Interior Point OPTimizer pronounced I P Opt is a software package for large scale nonlinear optimization It is is written in C and is released as open source code under the Common Public License CPL It is available from the COIN OR initiative at http www coin or org projects Ipopt xml The code has been written by Carl Laird and Andreas Wachter who is the COIN project leader for IPOPT MATPOWER requires the MATLAB MEX interface to IPOPT which is included in the IPOPT source distribution but must be built separately Additional information on the MEX interface is available at https projects coin or org Ipopt wiki MatlabInterface Please consult the IPOPT do
150. s a zero matrix and the default for fparm is such that d and m are all ones and 7 and k are all zeros resulting in simple linear cost with no shift or dead zone N and H should be specified as sparse matrices For additional constraints the A l and u parameters of 6 25 are specified as fields or arguments of the same names A 1 and u respectively where A is sparse Additional variables are created implicitly based on the difference between the number of columns in A and the number n of standard OPF variables If A has more columns than x has elements the extra columns are assumed to correspond to a new z variable The initial value and lower and upper bounds for z can also be specified in the optional fields or arguments z0 z1 and zu respectively For a simple formulation extension to be used for a small number of OPF cases this method has the advantage of being direct and straightforward While MAT POWER does include code to eliminate the columns of A and N corresponding to Vm and Q when running a DC OPF as well as code to reorder and eliminate columns appropriately when converting from external to internal data formats this mecha nism still requires the user to take special care in preparing the A and N matrices 18Only if they contain all zeros 59 to ensure that the columns match the ordering of the elements of the opimization vectors x and z All extra constraints and variables must be incorporated into a single
151. s available from the COIN OR initiative at http www coin or org projects Clp xml 157 To use CLP with MATPOWER a MEX interface is required For Microsoft Windows users a pre compiled MEX version of CLP and numerous other solvers such as GLPK and IPOPT are easily installable as part of the OPTI Toolbox 29 With the MATLAB interface to CLP installed it can be used to solve DC OPF problems by setting the opf solver dc option equal to CLP The solution algo rithms and other CLP parameters can be set directly via MATPOWER s clp opts option A CLP user options function can also be specified via clp opt_fname to override the defaults for any of the many CLP parameters See help clp for details See Table C 8 for a summary of the CLP related MATPOWER options CLP can also be used to solve general LP and QP problems via MATPOWER s common QP solver interface qps_matpower with the algorithm option set to CLP or by calling qps_clp directly G 3 CPLEX High performance LP and QP Solvers The IBM ILOG CPLEX Optimizer or simply CPLEX is a collection of optimiza tion tools that includes high performance solvers for large scale linear programming LP and quadratic programming QP problems among others More informa tion is available at http www ibm com software integration optimization cplex optimizer Although CPLEX is a commercial package at the time of this writing the full version is available to academics at
152. s box constraints on a generator s real and reactive injections specified as simple lower and upper bounds on p pmin and Pmax and q dmin and dmax On the other hand the true P Q capability curves of phys ical generators usually involve some tradeoff between real and reactive capability so that it is not possible to produce the maximum real output and the maximum or minimum reactive output simultaneously To approximate this tradeoff MAT POWER includes the ability to add an upper and lower sloped portion to the standard box constraints as illustrated in Figure 6 6 where the shaded portion represents the feasible operating region for the unit The two sloped portions are constructed from the lines passing through the two pairs of points defined by the six parameters p G qP po qu and q If these six parameters are specified for a given generator in columns PC1 QC2MAX 11 16 MATPOWER automatically constructs the corresponding additional linear inequality constraints on p and q for that unit If one of the sloped portions of the capability constraints is binding for genera tor k the corresponding shadow price is decomposed into the corresponding up and UQnin OT HQmax Components and added to the respective column MU_PMAX MU_QMIN or MU_QMAX in the k row of gen max 2 6 4 4 Branch Angle Difference Limits The difference between the bus voltage angle 0 at the from end of a branch and the angle 0 at the to end c
153. scale well to very large systems Currently none of them include any automatic updating of transformer taps or other techniques to attempt to satisfy typical optimal power flow constraints such as generator voltage or branch flow limits 4 1 AC Power Flow In MATPOWER by convention a single generator bus is typically chosen as a refer ence bus to serve the roles of both a voltage angle reference and a real power slack The voltage angle at the reference bus has a known value but the real power gen eration at the slack bus is taken as unknown to avoid overspecifying the problem The remaining generator buses are typically classified as PV buses with the values of voltage magnitude and generator real power injection given These are specified in the VG 6 and PG 3 columns of the gen matrix respectively Since the loads Py and Qa are also given all non generator buses are classified as PQ buses with real and reactive injections fully specified taken from the PD 3 and QD 4 columns of the bus matrix Let Zef Zpy and Zpq denote the sets of bus indices of the reference bus PV buses and PQ buses respectively The bus type classification is specified in the MATPOWER case file in the BUS_TYPE column 2 of the bus matrix Any isolated buses must be identified as such in this column as well In the traditional formulation of the AC power flow problem the power balance equation in 3 17 is split into its real and reactive components expres
154. se struct mpc If fname ends with mat it saves the case as a MAT file otherwise it saves it as an M file Optionally returns the filename with extension added if necessary The optional comment argument is either string single line comment or a cell array of strings which are inserted as comments in the help section of the file If the optional version argument is 1 it will modify the data matrices to version 1 format before saving 84 9 1 3 cdf2mpc mpc cdf2mpc cdf_file_name mpc cdf2mpc cdf_file_name verbose mpc cdf2mpc cdf_file_name mpc_name mpc cdf2mpc cdf_file_name mpc_name verbose mpc warnings cdf2mpc cdf_file_name The cdf2mpc function converts an IEEE Common Data Format CDF data file intoa MATPOWER case struct Given an optional file name mpc_name it can save the converted case to a MATPOWER case file Warnings generated during the conversion process can be optionally returned in the warnings argument Since the IEEE CDF format does not contain all of the data needed to run an optimal power flow some data such as voltage limits generator limits and generator costs are created by cdf2mpc See help cdf2mpc for details 9 1 4 psse2mpc mpc psse2mpc rawfile_name mpc psse2mpc rawfile_name verbose mpc psse2mpc rawfile_name verbose rev mpc psse2mpc rawfile_name mpc_name mpc psse2mpc rawfile_name mpc_name verbose mpc psse2mpc rawfile_name mpc_name v
155. sed as functions of the voltage angles and magnitudes Vm and generator injections P and Qg where the load injections are assumed constant and given gP Q Vm Pa Pousl Vm Pa E CP 0 4 2 gQ 9 Vm Q Qbus O Vm Qa Cas 0 4 3 28 For the AC power flow problem the function g x from 4 1 is formed by taking the left hand side of the real power balance equations 4 2 for all non slack buses and the reactive power balance equations 4 3 for all PQ buses and plugging in the reference angle the loads and the known generator injections and voltage magnitudes oO Vm P 95 0 Vm Qg Vi Tpy U Tpo Vi e Teg 4 4 g x The vector x consists of the remaining unknown voltage quantities namely the volt age angles at all non reference buses and the voltage magnitudes at PQ buses Ori Vi Leet 4 j y Vj Ipo eo This yields a system of nonlinear equations with np 2rpq equations and un knowns where np and npg are the number of PV and PQ buses respectively After solving for x the remaining real power balance equation can be used to compute the generator real power injection at the slack bus Similarly the remaining n 1 reactive power balance equations yield the generator reactive power injections MATPOWER includes four different algorithms for solving the AC power flow problem The default solver is based on a standard Newton s method 5 using a polar form and a full
156. set of parameters that are constructed before calling the OPF The bookkeep ing needed to access the resulting variables and shadow prices on constraints and variable bounds must be handled manually by the user outside of the OPF along with any processing of additional input data and processing printing or saving of the additional result data Making further modifications to a formulation that al ready includes user supplied costs constraints or variables requires that both sets be incorporated into a new single consistent set of parameters 7 2 Callback Functions The second method based on defining a set of callback functions offers several distinct advantages especially for more complex scenarios or for adding a feature for others to use such as the zonal reserve requirement or the interface flow limits mentioned previously This approach makes it possible to e define and access variable constraint sets as individual named blocks e define constraints costs only in terms of variables directly involved e pre process input data and or post process result data print and save new result data simultaneously use multiple independently developed extensions e g zonal reserve requirements and interface flow limits MATPOWER defines five stages in the execution of a simulation where custom code can be inserted to alter the behavior or data before proceeding to the next stage This custom code is defined as a set of callback functi
157. st then the simplified DC models In ternally the magnitudes of all values are expressed in per unit and angles of complex quantities are expressed in radians Internally all off line generators and branches are removed before forming the models used to solve the power flow or optimal power flow problem All buses are numbered consecutively beginning at 1 and generators are reordered by bus number Conversions to and from this internal indexing is done by the functions ext2int and int2ext The notation in this section as well as Sec tions 4 and 6 is based on this internal numbering with all generators and branches assumed to be in service Due to the strengths of the MATLAB programming lan guage in handling matrices and vectors the models and equations are presented here in matrix and vector form 3 1 Data Formats The data files used by MATPOWER are MATLAB M files or MAT files which define and return a single MATLAB struct The M file format is plain text that can be edited using any standard text editor The fields of the struct are baseMVA bus branch gen and optionally gencost where baseMVA is a scalar and the rest are matrices In the matrices each row corresponds to a single bus branch or generator The columns are similar to the columns in the standard IEEE CDF and PTI formats The number of rows in bus branch and gen are np m and ny respectively If present gencost has either ng or 2n rows depending on whether it includes
158. string values 0 gt DEFAULT 500 gt MINOPF 520 FMINCON 540 PDIPM and pdipm step control 0 545 PDIPM and pdipm step control 1 550 TRALM 560 gt MIPS and mips step_control 0 565 gt MIPS and mips step_control 1 580 gt IPOPT 600 KNITRO 16 OPF_VIOLATION opf violation 17 CONSTR_TOL_X fmincon tol_x support for constr has been removed knitro tol_x 18 CONSTR_TOL_F fmincon tol_f support for constr has been removed knitro tol_f 19 CONSTR_MAX_IT fmincon max_it support for constr has been removed continued on next page 130 idx 24 25 26 31 32 33 34 35 36 37 38 39 40 41 42 44 52 55 58 60 61 62 63 64 65 66 67 Table C 19 Old Style to New Style Option Mapping continued old option OPF_FLOW_LIM 0 gt 1 gt 2 gt OPF_IGNORE_ANG_LIM OPF_ALG_DC 0 gt 100 gt 200 gt 250 gt 300 gt 400 gt 500 gt 600 gt 700 gt VERBOSE DUT_ALL DUT_SYS_SUM DUT_AREA_SUM DUT_BUS DUT_BRANCH DUT_GEN OUT_ALL_LIM OUT_V_LIM OUT_LINE_LIM DUT_PG_LIM OUT_QG_LIM DUT_FORCE RETURN_RAW_DER FMC_ALG KNITRO_OPT IPOPT_OPT MNS_FEASTOL MNS_ROWTOL MNS_XTOL MNS_MAJDAMP MNS_MINDAMP MNS_PENALTY_PARM MNS_MAJOR_IT new option opf flo Ss Pp 1I opf ign opf dc notes w_lim new option has string values ore_angle_lim solver new option has string values DEFAULT BPMPD MIPS
159. t prints version information for Gurobi Gurobi MEX default options for IPOPT solvert MATLAB Interior Point Solver primal dual interior point solver for NLP prints version information for MIPS default options for MOSEK solvert symbolic constants to use for MOSEK solver options Mixed Integer Quadratic Program Solver for MATPOWER wrapper function provides a common MIQP solver interface for various MIQP MILP solvers common MIQP MILP solver interface to CPLEX cplexmiqp and cplexmilp common MILP solver interface to GLPK common MIQP MILP solver interface to Gurobi common MIQP MILP solver interface to MOSEK mosekopt common QP MILP solver interface to MATLAB Opt Toolbox s intlinprog quadprog linprog Quadratic Program Solver for MATPOWER wrapper function provides a common QP solver interface for various QP LP solvers common QP LP solver interface to BPMPD_MEXt common QP LP solver interface to CLP common QP LP solver interface to CPLEX cplexgp and cplex1p common QP LP solver interface to GLPK common QP LP solver interface to Gurobi common QP LP solver interface to IPOPT based solvert common QP LP solver interface to MIPS based solver common QP LP solver interface to MOSEK mosekopt common QP LP solver interface to MATLAB Opt Toolbox s quadprog linprog Requires the installation of an optional package See Appendix G for details on the corresponding package 140 Table D 14 Matrix Building F
160. t MATPOWER versions prior to version 4 had their own license 10 Please note that the MATPOWER case files distributed with MATPOWER are not covered by the BSD license In most cases the data has either been included with permission or has been converted from data available from a public source 1 3 Citing MATPOWER 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 reference 3 R D Zimmerman C E Murillo S nchez and R J Thomas MATPOWER Steady State Operations Planning and Analysis Tools for Power Systems Research and Ed ucation Power Systems IEEE Transactions on vol 26 no 1 pp 12 19 Feb 2011 11 2 Getting Started 2 1 System Requirements To use MATPOWER 5 1 you will need e MATLAB version 7 R14 or later or e GNU Octave version 3 4 or later 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 For the hardware requirements please refer to the system requirements for the version of MATLAB or Octave that you are using If the MATLAB Optimization Toolbox is installed as well MATPOWER enables an option to use it to solve optimal power flow problems though this option is not recommended for most applications In this manual references to MATLAB
161. tep 2 lambda 0 359 2 corrector Newton steps step 3 lambda 0 530 2 corrector Newton steps step 4 lambda 0 693 3 corrector Newton steps step 5 lambda 0 839 3 corrector Newton steps step 6 lambda 0 952 3 corrector Newton steps step 7 lambda 0 988 3 corrector Newton steps step 8 lambda 0 899 3 corrector Newton steps step 9 lambda 0 776 3 corrector Newton steps step 10 lambda 0 654 3 corrector Newton steps step 11 lambda 0 533 2 corrector Newton steps step 12 lambda 0 413 2 corrector Newton steps step 13 lambda 0 294 2 corrector Newton steps step 14 lambda 0 176 2 corrector Newton steps step 15 lambda 0 000 3 corrector Newton steps Traced full continuation curve in 15 continuation steps The results of the continuation power flow are then found in the cpf field of the returned results struct 41 Voltage Magnitude Voltage at Bus 9 T T 0 9 0 8 0 7 2 D ad a 2 P 0 3 0 2 0 1 4 Figure 5 1 Nose Curve of Voltage Magnitude at Bus 9 42 gt gt results cpf ans V_p lam_p V_c lam_c iterations max_lam 9x16 double 1x16 double 9x16 double 1x16 double 15 0 9876 43 6 Optimal Power Flow MATPOWER includes code to solve both AC and DC versions of the optimal power flow problem The standard version of each takes the following form min f x 6 1 subject to g x 0 6 2 h x lt 0 6
162. th a set of name value pairs as input arguments For example the following runs a fast decoupled power flow of case30 with very verbose progress output gt gt mpopt mpoption pf alg FDXB verbose 3 gt gt runpf case30 mpopt For backward compatibility old style option names values can also be used gt gt mpopt mpoption PF_ALG 2 VERBOSE 3 115 Another way to specify option overrides is via a struct Using the example above the code would be as follows gt gt overrides struct pf struct alg FDXB verbose 3 gt gt mpopt mpoption overrides Finally a string containing the name of a function that returns such a struct can be passed to mpoption instead of the struct itself gt gt mpopt mpoption verbose_fast_decoupled_pf_opts where the function verbose_fast_decoupled_pf_opts is defined as follows function ov verbose_fast_decoupled_pf_opts ov struct pf struct alg FDXB verbose 3 To make changes to an existing options struct as opposed to the default options struct simply include it as the first argument For example to modify the previous run to enforce reactive power limts suppress the pretty printing of the output and save the results to a struct instead gt gt mpopt mpoption mpopt pf enforce_q_lims 1 out all 0 gt gt results runpf case30 mpopt
163. th some linear penalty cost This can be useful in identifying the cause of infeasibility in some DC optimal power flow problems The extension is implemented in toggle_softlims A new variable ff is defined to represent the flow limit violation on branch i This variable is constrained to be positive and the sum of ff and the flow limit must be greater than both the flow and the negative of the flow on the branch both of which are expressed as functions of the bus voltage angles from 3 29 The three constraints on the new flow violation variable can be written as Ran 7 9 E ag gt py BO ud sui 7 10 i pp 2 p Bye D s ahitts 7 11 where the feasible area is illustrated in Figure 7 4 Furthermore a simple linear cost coefficient c is applied to each flow violation variable so that the additional user defined cost term from 6 21 looks like fulz 2 ey fu 7 12 Figure 7 4 Feasible Region for Branch Flow Violation Constraints The data for the problem is specifed in an additional softlims field in the MAT POWER case struct mpc This field is itself a struct with two optional sub fields 79 idx and cost for input and two others overload and ovl_cost used for output data Flow constraint shadow prices are reported in the usual columns of the branch matrix in the results The format for this data is detailed in Tables 7 6 and 7 7 Table 7 6 Input Data Structures for DC OPF Branch Flow Soft Limits na
164. the columns are similar to the columns in the standard IEEE and PTI formats The mpc struct also has a version field whose value is a string set to the current MATPOWER case version currently 2 by default The version 1 case format defines the data matrices as individual variables rather than fields of a struct and some do not include all of the columns defined in version 2 Numerous examples can be found in the case files listed in Table D 17 in Ap pendix D The case files created by savecase use a tab delimited format for the data matrices to make it simple to transfer data seamlessly back and forth between a text editor and a spreadsheet via simple copy and paste The details of the MATPOWER case format are given in the tables below and can also be accessed by typing help caseformat at the MATLAB prompt First the baseMVA field is a simple scalar value specifying the system MVA base used for converting power into per unit quantities For convenience and code portability idx_bus defines a set of constants to be used as named indices into the columns of the bus matrix Similarly idx_brch idx_gen and idx_cost define names for the columns of branch gen and gencost respectively The script define constants provides a simple way to define all the usual constants at one shot These are the names that appear in the first column of the tables below 109 The MATPOWER case format also allows for additional fields to be included in the structure T
165. tion at http pic dhe ibm com infocenter cosinfoc v12r6 for details It can also be used to solve general LP and QP problems via MATPOWER s com mon QP solver interface qps_matpower or MILP and MIQP problems via migps matpower with the algorithm option set to CPLEX or 500 for backward compatibility or by calling qps_cplex or miqps_cplex directly G 4 GLPK GNU Linear Programming Kit The GLPK 30 GNU Linear Programming Kit package is intended for solving large scale linear programming LP mixed integer programming MIP and other related problems It is a set of routines written in ANSI C and organized in the form of a callable library To use GLPK with MATPOWER a MEX interface is required For Microsoft Windows users a pre compiled MEX version of GLPK and numerous other solvers such as CLP and IPOPT are easily installable as part of the OPTI Toolbox 29 When GLPK is installed either as part of Octave or with a MEX interface for MATLAB it can be used to solve DC OPF problems that do not include any quadratic costs by setting the opf solver dc option equal to GLPK The solution algorithms and other GLPK parameters can be set directly via MATPOWER s g1pk opts option A GLPK user options function can also be specified via glpk opt_fname to override the defaults for any of the many GLPK parameters See help glpk_options and the parameters section the GLPK documentation at http www gnu org software octav
166. tional continuation power flow solution values are stored in the cpf field as shown in Table 5 1 Table 5 1 Continuation Power Flow Results name description results cpf iterations Nsteps number of continuation steps performed results cpf lam_c 1 x n vector of A values from correction steps results cpf lam_p 1 x n vector of A values from prediction steps results cpf max_lam maximum value of found in results cpf lam_c results cpf V_c np X n matrix of complex bus voltages from correction steps results cpf V_p np X n matrix of complex bus voltages from prediction steps Y n is one more than the number of continuation steps i e Nsteps 1 The options that control the continuation power flow simulation are listed in Table 5 2 All the power flow options for Newton s method tolerance maximum iterations and for controlling the output on the screen see Tables 4 2 and 4 3 are also available with the continuation power flow MATPOWER s continuation power flow also provides a callback mechanism to give the user access to the iteration process for executing custom code at each iter ation for example to implement custom incremental plotting of a PV nose curve 38 Table 5 2 Continuation Power Flow Options name default description cpf parameterization 3 choice of parameterization 1 natural 2 arc length 3 pseudo arc length cpf stop_at NOSE determines stopping criterion NOSE stop when nose point is r
167. uates the V dSbr_dV evaluates the partial derivatives of Si evaluates the V dSbus_dV evaluates the partial derivatives of Shus evaluates the V dAbr_dV evaluates the partial derivatives of Fy with respect to V d2Tbr_dV2 evaluates the 2 derivatives of I fit evaluates the V d2Sbr_dV2 evaluates the 2 derivatives of S fle evaluates the V d2ATbr_dV2 evaluates the 2 derivatives of 1 p evaluates the V d2ASbr_dV2 evaluates the 2 derivatives of S p evaluates the V d2Sbus_dv2 evaluates the 2 4 derivatives of Shus evaluates the V V represents complex bus voltages I fy complex branch current injections Sf complex branch power injec tions Ihus complex bus current injections Sbus complex bus power injections and Fpjs refers to branch flows either Ip or Spie depending on the inputs The second derivatives are all actually partial derivatives of the product of a first derivative matrix and a vector X 139 name Table D 13 NLP LP QP Solver Functions description default options for CLP solvert clp_options cplex_options glpk_options gurobi_options gurobiver ipopt_options mips mipsver mosek_options mosek_symbcon miqps matpower miqps_cplex miqps_glpk miqps gurobi miqps mosek miqps ot qps matpower qps_bpmpd qps_clp qps cplex qps glpk qps gurobi qps ipopt qps mips qps mosek qps ot default options for CPLEX solver default options for GLPK solvert default options for Gurobi solver
168. ulting in decreasing losses for increasing flow in the to from di rection There are currently two options for handling bi directional lines The first is to use a constant loss model by setting l 0 The second option is to create two separate but identical lines oriented in opposite directions In this case it is important that the lower limit on the flow and the constant term of the loss model lo be set to zero to ensure that only one of the two lines has non zero flow at a time Upper and lower bounds on the value of the flow can be specified for each DC line along with an optional operating cost It is also assumed that the terminals of the line have a range of reactive power capability that can be used to maintain a voltage setpoint Just as with a normal generator the voltage setpoint is only used for simple power flow the OPF dispatches the voltage anywhere between the lower and upper bounds specified for the bus Similarly in a simple power flow the input value for pr and the corresponding value for p computed from 7 8 are used to specify the flow in the line Most of the data for DC lines is stored in a decline field in the MATPOWER case struct mpc This field is a matrix similar to the branch matrix where each row corresponds to a particular DC line The columns of the matrix are defined in Table B 5 and include connection bus indices line status flows terminal reactive injections voltage setpoints limits on
169. unction run directly from the command line It provides more calling options than runopf primarly for backward compatibility with previous versions of mopf from MINOPF but does not offer the option to save the output or the solved case t Wrapper with same calling conventions as opf Requires the installation of an optional package See Appendix G for details on the corresponding package 136 name Copf_model display get_mpc opf_model opt_model add_constraints add_costs add_vars build_cost_params compute_cost describe_idx display get_cost_params get_idx getN get getv linear_constraints opt_model userdata Table D 8 OPF Model Objects description OPF model object used to encapsulate the OPF problem formulation called to display object when statement not terminated by semicolon returns the MATPOWER case struct constructor for the opf_model class optimization model object Copf_model base class adds a named subset of constraints to the model adds a named subset of user defined costs to the model adds a named subset of optimization variables to the model builds and stores the full generalized cost parameters in the model computes a user defined cost identifies variable constraint or cost row indices called to display object when statement not terminated by semicolon returns the cost parameter struct created by build_cost_params returns the idx struct for vars lin nln constraints costs returns the number
170. unctions name description makeB forms the fast decoupled power flow matrices B and B makeBdc forms the system matrices Bpus and By and vectors Py shift and Pous shitt for the DC power flow model makeJac makeLODF makePTDF makeSbus makeYbus name bustypes case_info compare_case define_constants extract_islands fairmax find islands get_losses hasPQcap have_fcn idx_brch idx_bus idx_cost idx_dcline idx_gen isload load2disp mpver modcost nested_struct_copy poly2pwl polycost pqcost scale_load total_load forms the power flow Jacobian matrix forms the line outage distribution factor matrix forms the DC PTDF matrix for a given choice of slack forms the vector of complex bus power injections forms the complex bus and branch admittance matrices Ypus Yy and Y Table D 15 Utility Functions description creates vectors of bus indices for reference bus PV buses PQ buses checks a MATPOWER case for connectivity and prints a system summary prints summary of differences between two MATPOWER cases convenience script defines constants for named column indices to data matrices calls idx_bus idx_brch idx_gen and idx_cost extracts islands in a network into their own MATPOWER case struct same as MATLAB s max function except it breaks ties randomly finds islands and isolated buses in a network compute branch losses and derivatives as functions of bus voltage checks for generator P Q capability curve
171. used to compute sensitivities of branch flows to branch outages known as line outage distribution factors or LODFs 10 Given a PTDF matrix Hw the corresponding n x n LODF matrix L can be con structed as follows where l is the element in row and column j representing the change in flow in branch 7 as a fraction of the initial flow in branch j for an outage of branch 7 First let H represent the matrix of sensitivities of branch flows to branch endpoint injections found by multplying the PTDF matrix by the node branch incidence matrix H H C C 4 11 Here the individual elements h represent the sensitivity of flow in branch 7 with respect to injections at branch 7 endpoints corresponding to a simulated increase in flow in branch j Then l can be expressed as ij r A lij 1 2 hjj 7 4 12 1 isj 33 MATPOWER includes functions for computing both the DC PTDF matrix and the corresponding LODF matrix for either a single slack bus k or a general slack distribution vector w See the help for makePTDF and makeLODF for details 34 5 Continuation Power Flow Continuation methods or branch tracing methods are used to trace a curve given an initial point on the curve These are also called predictor corrector methods since they involve the prediction of the next solution point and correcting the prediction to get the next point on the curve Consider a system of n nonlinear equations g x 0 2 R
172. usually apply to Octave as well At the time of writing none of the optional MEX based MATPOWER packages have been built for Octave but Octave does typically include GLPK 2 2 Installation Installation and use of MATPOWER requires familiarity with the basic operation of MATLAB including setting up your MATLAB path Step 1 Follow the download instructions on the MATPOWER home page You should end up with a file named matpowerXXX zip where XXX depends on the version of MATPOWER Step 2 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 1MATLAB is available from The MathWorks Inc http www mathworks com MAT POWER 4 required MATLAB 6 5 R13 MATPOWER 3 2 required MATLAB 6 R12 MATPOWER 3 0 required MATLAB 5 and MATPOWER 2 0 and earlier required only MATLAB 4 MATLAB is a regis tered trademark of The MathWorks Inc 5GNU Octave is free software available online at http www gnu org software octave Some parts of MATPOWER 5 1 may work on earlier versions of Octave but it has not been tested on versions prior to 3 4 Shttp www mathworks com support sysreq previous_releases html http www pserc cornell edu matpower 12 recommended that they be kept separate from your own code We will use MATPOWER to denote the path to this directory 13 Step 3 Add the following directories to your MATLAB path e MAT
173. ve data if it is loaded via loadcase possibly run then saved via savecase will not lose the data in the reserves field This callback could also include the saving of the output fields if present The contributed serialize function can be very useful for this purpose 0nttp www mathworks com matlabcentral fileexchange 1206 70 function mpc userfcn_reserves_savecase mpc fd prefix args mpc userfcn_reserves_savecase mpc fd mpopt args This is the savecase stage userfcn callback that prints the M file code to save the reserves field in the case file It expects a MATPOWER case struct mpc a file descriptor and variable prefix usually mpc The optional args are not currently used r mpc reserves fprintf fd nhhhh Reserve Data AAA fprintf fd f h reserve zones element i j is 1 iff gen j is in zone i n fprintf fd sreserves zones n prefix template for i 1l size r zones 2 template template tid end template template n fprintf fd template r zones fprintf fd n fprintf fd An 4 reserve requirements for each zone in MW n fprintf fd sreserves req thg prefix r req 1 if length r req gt 1 fprintf fd t g r req 2 end end fprintf fd t n fprintf fd n 4 reserve costs in MW for each gen n fprintf fd sreserves cost t g prefix r cost 1 if length
174. verted back to external indexing This callback is invoked from within printpf after the pretty printing of the standard OPF output Inputs are 67 the results struct the file descriptor to write to a MATPOWER options struct and any optional args supplied via add userfcn Output is the results struct This is typically used for any additional pretty printing of results In this example the out a11 flag in the options struct is checked before printing anything If it is non zero the reserve quantities and prices for each unit are printed first followed by the per zone summaries An additional table with reserve limit shadow prices might also be included 68 function results userfcn_reserves_printpf results fd mpopt args define named indices into data matrices GEN_BUS PG QG QMAX QMIN VG MBASE GEN_STATUS PMAX PMIN MU_PMAX MU_PMIN MU_QMAX MU_QMIN PC1 PC2 QC1MIN QC1MAX QC2MIN QC2MAX RAMP_AGC RAMP_10 RAMP_30 RAMP_Q APF idx_gen hh 777 print results r results reserves ng length r R nrz size r req 1 if mpopt out all 0 fprintf fd Mn fprintf fd n Reserves IO fprintf fd Mn fprintf fd n Gen Bus Status Reserves Price fprintf fd n MW MW fprintf fd n js for k 1 ng fprintf fd n
175. wer Systems Taking Into Account Uncertainty Preventive and Corrective Actions Power Systems IEEE Transactions on vol 28 no 4 pp 4909 4917 Nov 2013 D 17 R D Zimmerman Uniform Price Auctions and Optimal Power Flow MAT POWER Technical Note 1 February 2010 Online Available http www pserc cornell edu matpower TN1 OPF Auctions pdf F COIN OR Linear Programming CLP Solver Online Available http www coin or org projects Clp xml G 2 J Currie and D I Wilson OPTI Lowering the Barrier Between Open Source Optimizers and the Industrial MATLAB User Foundations of Computer Aided Process Operations Georgia USA 2012 G 2 G 4 G 6 GLPK Online Available http www gnu org software glpk G 4 Wotao Yin Gurobi Mex A MATLAB interface for Gurobi URL http convexoptimization com wikimization index php gurobi_mex 2009 2011 32 A W chter and L T Biegler On the implementation of a primal dual inte rior point filter line search algorithm for large scale nonlinear programming Mathematical Programming 106 1 2557 2006 C 13 G 6 167 33 34 35 O Shenk and K Gartner Solving unsymmetric sparse systems of linear equations with PARDISO Journal of Future Generation Computer Systems 20 3 475 487 2004 G 6 G 10 A Kuzmin M Luisier and O Shenk Fast methods for computing selected elements of the Greens function in massively parallel nanoelectronic device sim
176. xt converts case from internal to external indexing i2e_data converts arbitrary data from internal to external indexing i2e_field converts fields in mpc from internal to external indexing get_reorder set_reorder returns A with one of its dimensions indexed assigns B to A with one of the dimensions of A indexed 135 Table D 5 Power Flow Functions name description dcpf implementation of DC power flow solver fdpf implementation of fast decoupled power flow solver gausspf implementation of Gauss Seidel power flow solver newtonpf implementation of Newton method power flow solver pfsoln computes branch flows generator reactive power and real power for slack bus updates bus gen branch matrices with solved values Table D 6 Continuation Power Flow Functions name description cpf_corrector computes Newton method corrector steps cpf_default_callback callback function that accumulates results from each iteration cpf_predictor computes tangent predictor steps cpf_user_callback_1 example user callback function that plots a nose curve Table D 7 OPF and Wrapper Functions name description opf the main OPF function called by runopf dcopf calls opf with options set to solve DC OPF fmincopf calls opf with options set to use fmincon to solve AC OPF mopf calls opf with options set to use MINOPF to solve AC OPF uopf implements unit decommitment heuristic called by runuopf Can also be used as a top level f
177. y 526 ed wa dee ew deed A ee eR 94 10 Acknowledgments 95 Appendix A MIPS MATLAB Interior Point Solver 96 AL Te Lo eec eara RH RR ah aa EH HG ROE OE Ee Be 98 AS IS a See Soe e a whe Ew eee e SDD 100 A 3 Quadratic Programming Solver 102 A 4 Primal Dual Interior Point Algorithm 103 AAT Notati n iaa Eh ER ewe dR Pee GES 103 A 4 2 Problem Formulation and Lagrangian A 4 3 First Order Optimality Conditions AAA Newton Step 44 024 4b ee eS ee Se ee ee Appendix B Data File Format Appendix C MATPOWER Options C 1 Mapping of Old Style Options to New Style Options Appendix D MATPOWER Files and Functions DI Documentation Piles o cr eu bate oe Sew A he ea we e e D 2 MATPOWER Functions sa aas e D 3 Example MATPOWER Gases cc Gwe pero w konie ee D 4 Automated Test Suite es Appendix E Extras Directory Appendix F Smart Market Code Pl Handling Supply Shortfall 22 244 sda iones de ER Example o ee cs eeo e e a o ee hee kop DRS F 3 Smartmarket Files and Functions Appendix G Optional Packages G 1 BPMPD_MEX MEX interface for BPMPD G2 CLP COIN OR Linear Programming lt i caa oc ec c hee na G 3 CPLEX High performance LP and QP Solvers GA GLPK GNU Linear Programming Kit 2 2 2 4 26 ee bees G 5 Gurobi High performance LP and QP Solvers G6 IPOPT Int
178. y have been added by MATPOWER e g y variables from MATPOWER s CCV handling of piece wise linear costs or by the user via previous formulation callbacks MATPOWER will place the constraint matrix blocks in the appropriate place when it constructs the overall A matrix at run time This is an im portant feature that enables independently developed MATPOWER OPF extensions to work together Va Vm Pg Qg y R a bricks aes pays ains bles la eee A AC OPF vo 3 A 0 Aal o A2 DC OPF Va Pg y R Figure 7 1 Adding Constraints Across Subsets of Variables 64 function om hh initialize some things define_constants mpc get_mpc om r mpc reserves ng size mpc gen 1 hh variable bounds Rmin zeros ng 1 Rmax r qty Ah Ah k find mpc gen RAMP_10 gt O amp mpc userfcn_reserves_formulation om args number of on line gens bound below by 0 bound above by stated max reserve qty gen RAMP_10 lt Rmax Rmax k mpc gen k RAMP_10 hh and ramp rate Rmax Rmax mpc baseMVA constraints I speye ng hh identity matrix Ar I I Pmax mpc gen PMAX mpc baseMVA lreq r req mpc baseMVA hh cost Cw r cost mpc baseMVA per unit cost coefficients 4 add them to the model om add_vars om R ng Rmin Rmax om add_constraints om Pg_plus_R Ar Pmax Pg R
179. y runcpf Ouputs cb_state updated version of cb_state input argument results updated version of results input argument contexts distinguished as follows 1 initial called without results output arg with input argument k 0 after base power flow before first CPF step 2 iterations called without results output arg with input argument k gt 0 at each iteration after predictor corrector step 3 final called with results output arg after exiting predictor corrector loop inputs identical to last iteration call 40 Example The following is an example of running a continuation power flow using a version of the 9 bus system looking at increasing all loads by a factor of 2 5 This example plots the nose curve shown in Figure 5 1 define_constants mpopt mpoption out all 0 verbose 2 mpopt mpoption mpopt cpf stop_at FULL cpf step 0 2 mpopt mpoption mpopt cpf plot level 2 mpcb loadcase t_case9_pfv2 load base case mpct mpcb set up target case with mpct gen PG QG mpcb gen PG QG 2 5 increased generation mpct bus PD QD mpcb bus PD QD 2 5 and increased load results runcpf mpcb mpct mpopt This should result in something like the following output to the screen MATPOWER Version 5 1 20 Mar 2015 AC Continuation Power Flow step 0 lambda 0 000 4 Newton steps step 1 lambda 0 181 2 corrector Newton steps s
Download Pdf Manuals
Related Search
Related Contents
DVG-5004S VoIP Gateway User`s Manual - D-Link Cables Direct 2m 3.5mm, M - F MF240-en-fr-sp-ge-it(new LCD)-v1.0.ai Manuel d`utilisation Nokia E55 - File Delivery Service T。SHーBA 東芝電球ベンダン ト取扱説明書 保管用 POWER INVERTERS User`s Manual NOTE DE PRÉSENTATION GLOBALE Model DRC-91C - Lake Shore Cryotronics, Inc. GE T2100 Treadmill - Frank`s Hospital Workshop Les boules Chinoises Copyright © All rights reserved.
Failed to retrieve file