First step: What is the constraint you want to implement, expressed in terms of Pg and Qg?
-- Ray Zimmerman Senior Research Associate B30 Warren Hall, Cornell University, Ithaca, NY 14853 phone: (607) 255-9645 On Jan 9, 2014, at 9:34 AM, Dailan Xu <[email protected]> wrote: > I tried the following code but the results are the same compared to previous > one. > > > nb = size(mpc.bus, 1); > ng = size(mpc.gen, 1); > pf = 0.8; > QPratio = sqrt(1/pf^2 -1); > %% add constraint that QPratio * Pg(i) - Qg(i) = 0, for i = 2 .. ng > mpc.A = sparse([1:ng 1:ng]', [2*nb+(1:ng) 2*nb+ng+(1:ng)]', > [QPratio*ones(ng,1); -ones(ng,1)], ng, 2*nb+2*ng); > % mpc.A = mpc.A(3:12, :); > % mpc.l = zeros(ng-1-31, 1); > mpc.A = mpc.A(2:16, :); > mpc.l = -0.8*ones(ng-29-1, 1); > mpc.u = -mpc.l; > > Best regards, > > > > I found one of your posts below but I don't know how can I implement A,l,u. > > ---------- Forwarded message ---------- > From: Ray Zimmerman <[email protected]> > Date: Wed, Mar 16, 2011 at 3:36 PM > Subject: Re: PF > To: MATPOWER discussion forum <[email protected]> > > > sparse is a built-in Matlab function, see the Matlab documentation for more > details. MATPOWER really does assume a basic knowledge of Matlab and there > are other forums for asking Matlab questions. So please make sure you > understand all of the Matlab commands involved before posting questions here > about MATPOWER. > > The A matrix is from equation (5.25) in the User's Manual, where x is defined > in (5.5). So as it says in the example code I provided you, the constraint we > want to implement is ... > > 0 <= QPratio * Pg(i) - Qg(i) <= 0 > > This is an equality constraint that forces a constant ratio between Qg(i) and > Pg(i), in other words, a constant power factor. So we need to define A such > that A * x = QPratio * Pg(i) - Qg(i), which means that A needs to have > QPratio in the column corresponding to Pg(i) and -1 in the column > corresponding to Qg(i). If you look at equation (5.5), you'll see that Pg(i) > is found in element (2*nb + i) of x and Qg(i) in element (2*nb+ng+i). The > sparse statement constructs this A matrix, and l and u from (5.25) are set to > zero. > > Hope this finally makes everything clear. > > -- > Ray Zimmerman > Senior Research Associate > 211 Warren Hall, Cornell University, Ithaca, NY 14853 > phone: (607) 255-9645 > > > On Mar 15, 2011, at 10:46 AM, Carlos Gonzalez Almeida wrote: > >> Thank you very much dear Prof. Zimmerman >> >> My problem is that I don't understand the sparse() function used to >> construct the A matrix especially don't understand how the A matrix defined >> in the example implements a constant power factor constraint. The latter is >> very important for me. I will be greatly appreciated you if you explain me >> further. >> >> Best Regards >> >> Carlos >> >> On Tue, Mar 15, 2011 at 15:41, Ray Zimmerman <[email protected]> wrote: >> In order to help you further, you're going to have to be more specific about >> what it is that you are having trouble with. Is it that you don't understand >> the sparse() function used to construct the A matrix? Or that you don't >> understand how the A matrix is used? Or you don't understand how the A >> matrix defined in the example implements a constant power factor constraint? >> >> Btw, if anyone else on the list can see something I'm missing in my attempts >> to help Carlos get up to speed ... jump in, don't be shy. >> >> -- >> Ray Zimmerman >> Senior Research Associate >> 211 Warren Hall, Cornell University, Ithaca, NY 14853 >> phone: (607) 255-9645 >> >> >> >> On Mar 15, 2011, at 9:31 AM, Carlos Gonzalez Almeida wrote: >> >>> Dear Prof. Zimmerman >>> >>> Once again I appreciate you for the file that you sent me. Where can I find >>> more information about the way of definition of A matrix. I have read the >>> manual but I didn't understand well, for example in the case you sent me >>> yesterday. If it is possible either please introduce me a book or explain a >>> little bit more about A matrix in general. >>> >>> Best Wishes >>> >>> C. Gonzalez Almeida >>> >>> >>> On Mon, Mar 14, 2011 at 19:05, Carlos Gonzalez Almeida >>> <[email protected]> wrote: >>> Thank you very very much. >>> >>> On Mon, Mar 14, 2011 at 18:59, Ray Zimmerman <[email protected]> wrote: >>> Did you understand the previous example? If so, it's a trivial modification >>> (attached). If not, please go back and familiarize yourself with the >>> extended OPF formulation in the manual, the paper, the slides for the >>> paper, etc. This is about the most trivial example can think of for adding >>> a user-defined constraint to the OPF. >>> >>> >>> >>> -- >>> Ray Zimmerman >>> Senior Research Associate >>> 211 Warren Hall, Cornell University, Ithaca, NY 14853 >>> phone: (607) 255-9645 >>> >>> >>> >>> On Mar 14, 2011, at 12:16 PM, Carlos Gonzalez Almeida wrote: >>> >>>> With more details I want to do runmarket and I want to have PF=0.85 for >>>> example in case9 for generators 2, 3. How can I do it? >>>> >>>> Best Wishes >>>> >>>> C. Gonzalez Almeida >>>> >>>> >>>> On Mon, Mar 14, 2011 at 17:10, Carlos Gonzalez Almeida >>>> <[email protected]> wrote: >>>> Thank you. >>>> >>>> I also have the Roberto's problem as well as in the case of runmarket to >>>> set an specified power factor for generators except slack bus. >>>> >>>> If it is possible please give an example. Because it can be useful for >>>> other people who will use in the future MATPOWER. >>>> >>>> Best Wishes >>>> >>>> C. Gonzalez Almeida >>>> >>>> >>>> On Mon, Mar 14, 2011 at 16:59, Ray Zimmerman <[email protected]> wrote: >>>> 1. You can constrain a generator to have a zero power factor by setting >>>> PMIN = PMAX = 1. The generator reactive power is one of the optimization >>>> variables in x, so it's value is determined by whatever solver you happen >>>> to be using, MIPS by default. So I suppose if you need to know which >>>> m-file computes its value, it would be mips.m. If you want to set the >>>> reactive power of generator 2 to zero, simply set both the QMIN and QMAX >>>> column in the corresponding row of the gen matrix to zero (by the way, >>>> that is a power factor of 1, not 0). >>>> >>>> Without more details I have no idea. Are you passing in any reactive power >>>> offers? >>>> >>>> -- >>>> Ray Zimmerman >>>> Senior Research Associate >>>> 211 Warren Hall, Cornell University, Ithaca, NY 14853 >>>> phone: (607) 255-9645 >>>> >>>> >>>> >>>> On Mar 14, 2011, at 6:17 AM, Carlos Gonzalez Almeida wrote: >>>> >>>>> Dear Prof. Zimmerman >>>>> >>>>> 1.I studied the your response to Roberto Carvalini but I don't know how >>>>> can I define the PF for other generators to zero or other values when I >>>>> do runmarket and it doesn't work the code when I do runmarket. By which >>>>> formula you have computed the generator reactive power (in which m.file, >>>>> please address the m.file because I couldn't find it). For example, if I >>>>> want to set reactive power of generator 2 to zero, what should I do? >>>>> >>>>> 2. Why I cannot do runmarket for case30Q and case9Q? what is the reason? >>>>> >>>>> >>>>> Best Wishes >>>>> >>>>> C. Gonzalez Almeida >>>>> >>>>> >>>>> On Fri, Mar 11, 2011 at 16:29, Ray Zimmerman <[email protected]> wrote: >>>>> See my response to Roberto Carvalini, posted only seconds ago. Am I fast >>>>> or what? ;-) >>>>> >>>>> -- >>>>> Ray Zimmerman >>>>> Senior Research Associate >>>>> 211 Warren Hall, Cornell University, Ithaca, NY 14853 >>>>> phone: (607) 255-9645 >>>>> >>>>> >>>>> >>>>> On Mar 11, 2011, at 10:16 AM, Carlos Gonzalez Almeida wrote: >>>>> >>>>>> Thank you very much. >>>>>> >>>>>> Could you please give me an example about defining power factor for >>>>>> generators? >>>>>> >>>>>> I cannot set it. >>>>>> >>>>>> On Fri, Mar 11, 2011 at 16:09, Ray Zimmerman <[email protected]> wrote: >>>>>> Carlos, >>>>>> >>>>>> If you want the loads to have a power factor of 0.95, you need to set QD >>>>>> such that PD/sqrt(PD^2 + QD^2) = 0.95, i.e. QD has to equal 0.108 * PD. >>>>>> About the voltage constraint of 1.5 p.u., I don't see that anywhere, so >>>>>> I'm not sure what you are referring to. The different lambdas at the two >>>>>> buses are due to losses. The power factor of the generators is >>>>>> determined by the solution algorithm within the bounds set for them. >>>>>> That is, each generator has a feasible "box" defined by PMIN, PMAX, QMIN >>>>>> and QMAX. You don't normally "set" the power factor of a generator as >>>>>> input to the OPF. I suppose, if for some reason you have a strict power >>>>>> factor constraint on a generator you could use some additional linear >>>>>> constraints to the OPF to enforce it, but that would be unusual I think. >>>>>> >>>>>> -- >>>>>> Ray Zimmerman >>>>>> Senior Research Associate >>>>>> 211 Warren Hall, Cornell University, Ithaca, NY 14853 >>>>>> phone: (607) 255-9645 >>>>>> >>>>>> >>>>>> >>>>>> On Mar 10, 2011, at 8:10 AM, Carlos Gonzalez Almeida wrote: >>>>>> >>>>>>> Another question is this: when I have not fixed loads only I have >>>>>>> dispatchable loads how can I define power factor for generators and >>>>>>> loads separately? >>>>>>> >>>>>>> Best Wishes >>>>>>> >>>>>>> Carlos >>>>>>> >>>>>>> On Thu, Mar 10, 2011 at 13:53, Carlos Gonzalez Almeida >>>>>>> <[email protected]> wrote: >>>>>>> Dear Prof. Zimmerman >>>>>>> >>>>>>> Thanks a lot for your useful guidance. >>>>>>> >>>>>>> For example, in the attached file for a simple case study with 2 loads >>>>>>> and generators I want to have a power factor 0.95. I have problem with >>>>>>> adjusting power factor in MATPOWER. How can I do it in the attached >>>>>>> file? Also I don't know why I have voltage constraint 1.5 pu. I think >>>>>>> because of these constraints I have a little bit difference in the >>>>>>> value of lambda >>>>>>> I have done runmarket with the following offers and bids. >>>>>>> Could you please tell me why? >>>>>>> >>>>>>> +++++++++++++++++++++ >>>>>>> mpc0 = loadcase('case4gs1'); >>>>>>> mpc = load2disp(mpc0); >>>>>>> mkt.OPF = 'AC'; >>>>>>> offers.P.qty = [100;70]; >>>>>>> offers.P.prc = [50;100]; >>>>>>> bids.P.qty = [50 ;70 ]; >>>>>>> bids.P.prc = [150 ;130 ]; >>>>>>> [r, co, cb] = runmarket(mpc, offers, bids, mkt); >>>>>>> co.P.qty >>>>>>> co.P.prc >>>>>>> cb.P.qty >>>>>>> cb.P.prc >>>>>>> ++++++++++++++++++++++++ >>>>>>> >>>>>>> Best Wishes >>>>>>> >>>>>>> C. Gonzalez Almeida >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Wed, Mar 9, 2011 at 19:47, Ray Zimmerman <[email protected]> wrote: >>>>>>> Carlos, >>>>>>> >>>>>>> I'm not sure what you mean by "test the example ... regarding zero >>>>>>> power factor". If you are going to change some of the existing >>>>>>> dispatchable loads to have a zero power factor, then the existing >>>>>>> market structure for the example, which includes only $/MW bids for >>>>>>> active power, will not be applicable. So you need to decide how you >>>>>>> want to handle these reactive-only loads. I suppose you'll need to >>>>>>> specify reactive power bids for them. >>>>>>> >>>>>>> On your second question, the offers and bids are used to construct a >>>>>>> gencost matrix with negative costs for the negative generators that >>>>>>> represent dispatchable loads. The objective function is then to >>>>>>> minimize this "cost" of generation, which is computed in opf_costfcn.m. >>>>>>> You are correct that this is equivalent to maximizing social welfare. >>>>>>> >>>>>>> -- >>>>>>> Ray Zimmerman >>>>>>> Senior Research Associate >>>>>>> 211 Warren Hall, Cornell University, Ithaca, NY 14853 >>>>>>> phone: (607) 255-9645 >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Mar 8, 2011, at 5:04 PM, Carlos Gonzalez Almeida wrote: >>>>>>> >>>>>>>> Dear Dr. Zimmerman >>>>>>>> >>>>>>>> -Could you please test the example provided in the manual >>>>>>>> (t_auction_case) regarding zero power factor. What changes should be >>>>>>>> carried out? >>>>>>>> >>>>>>>> -Moreover, as you know, the objective function obtained in the >>>>>>>> runmarket is Social welfare. Could you please address me the file that >>>>>>>> you calculated objective function because I couldn't find it. I want >>>>>>>> to know in which file (the m file) you have calculated that? >>>>>>>> >>>>>>>> Best Regards >>>>>>>> >>>>>>>> Carlos >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Tue, Mar 8, 2011 at 22:34, Ray Zimmerman <[email protected]> wrote: >>>>>>>> I'm not really sure without seeing the details of your example. I'm >>>>>>>> not sure I've ever tested the runmarket code with pure reactive power >>>>>>>> loads. It would require reactive power bids for those loads, but I'll >>>>>>>> need the details to be able to help you further. >>>>>>>> >>>>>>>> -- >>>>>>>> Ray Zimmerman >>>>>>>> Senior Research Associate >>>>>>>> 211 Warren Hall, Cornell University, Ithaca, NY 14853 >>>>>>>> phone: (607) 255-9645 >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Mar 7, 2011, at 10:42 AM, Carlos Gonzalez Almeida wrote: >>>>>>>> >>>>>>>>> Hi >>>>>>>>> >>>>>>>>> I am new in MATPOWER abd I want to have zero power factor for example >>>>>>>>> in example case of manual in runmarket, but several error are >>>>>>>>> occured. please tell me why >>>>>>>>> >>>>>>>>> >>>>>>>>> Best Wishes >>>>>>>>> >>>>>>>>> C. Gonzalez Almeida >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Best Wishes >>>>>>>> >>>>>>>> C. Gonzalez Almeida >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> Best Wishes >>>>>> >>>>>> C. Gonzalez Almeida >>>>> >>>>> >>>>> >>>> >>>> >>>> >>> >>> >>> >>> >>> >>> Best Wishes >>> >>> C. Gonzalez Almeida >>> >> >> >> >> >> Best Wishes >> >> C. Gonzalez Almeida > > > >
