The A matrix is from equation (5.25) in the User's Manual. As I mentioned, the coefficients need to go in the columns corresponding to Pg(1) and Qg(1). So, Pg(1) is in the first column following the voltage angles (1st nb columns) and magnitudes (next nb columns), so it's in column 2*nb+1. For Qg(1) it's the first column after the Pg columns, so 2*nb (for the voltage angles and magnitudes) plus ng columns for Pg.
Yes, if you wanted to do this for all generators, you need to include a row in A for each. Be careful though, this will likely over-constrain the problem and make it infeasible. If all generators have a fixed power factor, then balancing the real power output to match the load will mean a specific reactive power output as well, which will not necessarily match the reactive power load. -- Ray Zimmerman Senior Research Associate 211 Warren Hall, Cornell University, Ithaca, NY 14853 phone: (607) 255-9645 On Mar 11, 2011, at 11:40 AM, Roberto Carvalini wrote: > Thank you very much. > > I have read the manual but I didn't understand by which formula you computed > this matrix (highlighted) > > mpc.A = sparse([1; 1], [2*nb+1; 2*nb+ng+1], [QPratio; -1], 1, 2*nb+2*ng); > > and if want to define the same PF for all generators, must I repeat this for > all or it depends on the type buses (PV or Slack)? > > Regards > > R. Carvalini > > On Fri, Mar 11, 2011 at 16:27, Ray Zimmerman <[email protected]> wrote: > Dirk's suggestion is fine for a simple power flow. But if you want to run an > OPF, where the generator dispatch is to be determined by the optimization, > but subject to a constant power factor constraint, then you will need to > supply an additional user-defined linear constraint. For example, if you want > to run case9 with a constant power factor constraint of 0.95 on the first > generator, you could do it like this ... > > define_constants; > mpc = loadcase('case9'); > nb = size(mpc.bus, 1); > ng = size(mpc.gen, 1); > pf = 0.95; > QPratio = sqrt(1/pf^2 -1); > %% add constraint that QPratio * Pg(1) - Qg(1) = 0 > mpc.A = sparse([1; 1], [2*nb+1; 2*nb+ng+1], [QPratio; -1], 1, 2*nb+2*ng); > mpc.l = 0; > mpc.u = 0; > r = runopf(mpc); > resulting_pf = r.gen(1, PG) / sqrt(r.gen(1, PG)^2 + r.gen(1, QG)^2) > > The important part here is defining the A matrix properly, where the columns > correspond to voltage angles, voltage magnitudes, generator real injections, > and generator reactive injections (2*nb + 2*ng columns in all). So the > coefficients for our constraint co in the columns corresponding to Pg(1) and > Qg(1). > > -- > Ray Zimmerman > Senior Research Associate > 211 Warren Hall, Cornell University, Ithaca, NY 14853 > phone: (607) 255-9645 > > > > On Mar 11, 2011, at 9:50 AM, Dirk Van Hertem wrote: > >> You model your generator as a load, so it is not represented in your gen >> matrix. Of course, if you want model your generator in a unit commitment, >> this may not be trivial... >> >> Dirk >> >> On 03/11/2011 12:32 PM, Roberto Carvalini wrote: >>> >>> Thank you >>> >>> How can I add? my problem is this >>> >>> Best Wishes >>> >>> Roberto >>> >>> >>> On Fri, Mar 11, 2011 at 12:22, Dirk Van Hertem <[email protected]> >>> wrote: >>> You can just define them as a PQ bus with negative power... (negative load) >>> >>> Dirk >>> >>> >>> On 03/11/2011 12:11 PM, Roberto Carvalini wrote: >>> Hi >>> >>> How can I define constant power factor in MAPOWER for example, for >>> generators PF=0.9? >>> >>> Please help me >>> >>> Regards >>> >>> Roberto >>> >>> >>> >>> >>> -- >>> Dirk Van Hertem [email protected] >>> Electrical Engineering Department http://www.esat.kuleuven.be/electa >>> K.U. Leuven, ESAT-ELECTA GSM: +32-(O)498-61.74.98 >>> 10, Kasteelpark Arenberg, B-3001 Heverlee fax: +32-16-32.19.85 >>> >>> >>> >> >> >> -- >> Dirk Van Hertem [email protected] >> Electrical Engineering Department http://www.esat.kuleuven.be/electa >> K.U. Leuven, ESAT-ELECTA GSM: +32-(O)498-61.74.98 >> 10, Kasteelpark Arenberg, B-3001 Heverlee fax: +32-16-32.19.85 > > > > > > Best Wishes > > Roberto
