Thank you very much for your help. I got it.
1) Is it possible to add a transformer and control the voltage of it?

2) I want to minimize power losses instead of cost function. How can I do
it?


Best Regards

D. Xu



On Tue, Jun 21, 2011 at 17:32, Ray Zimmerman <[email protected]> wrote:

> In an OPF there is no slack bus, only a reference bus to serve as a
> reference for the voltage angles. The voltages at all buses are already
> optimization variables. You don't need to add it. And you can constrain it
> as you like, either with fixed limits using the VMIN and VMAX columns in the
> bus matrix, or by adding linear constraints that tie it to any of your other
> optimization variables, (Pg, Qg, Vm, Va or any user-specified variables).
>
>  --
> Ray Zimmerman
> Senior Research Associate
> 211 Warren Hall, Cornell University, Ithaca, NY 14853
> phone: (607) 255-9645
>
>
>
> On Jun 21, 2011, at 6:52 AM, Dailan Xu wrote:
>
> Dear Prof. Zimmerman
>
> Another question: I want to use an OLTC (on load tap changer) to control
> the voltage of slack bus. Is it possible to do it in MATPOWER by adding an
> optimization variable(voltage of slack bus)?
>
>
> Best Regards
>
> D. Xu
>
>
>
> On Tue, Jun 21, 2011 at 01:14, Dailan Xu <[email protected]> wrote:
>
>> Dear Prof. Zimmerman
>>
>> Thank you very much for your guidance. I have written a code as
>> follow(also I have attached in a m.file) that I need for both power factor
>> constraint and variable constraints.
>>
>> But when I run runopf I encounter with an error. Could you please let me
>> know what is the error?
>>
>> *+++++++++++++++++++++++++++++++++++++++++++++++++++
>> define_constants;
>> mpc = loadcase( 't_case30_userfcns');
>>
>> om=opf_setup(mpc,mpopt);
>> r = mpc.reserves;
>> ng = size(mpc.gen, 1); %% number of on-line gens
>>
>> Rmin = zeros(ng, 1); %% bound below by 0
>> Rmax = r.qty; %% bound above by stated max reserve qty ...
>> k = find(mpc.gen(:, RAMP_10) > 0 & mpc.gen(:, RAMP_10) < Rmax);
>> Rmax(k) = mpc.gen(k, RAMP_10); %% ... and ramp rate
>> Rmax = Rmax / mpc.baseMVA;
>>
>> I = speye(ng); %% identity matrix
>> Ar = [I I];
>> Pmax = mpc.gen(:, PMAX) / mpc.baseMVA;
>> lreq = r.req / mpc.baseMVA;
>>
>> Cw = r.cost * mpc.baseMVA; %% per unit cost coefficients
>>
>> om = add_vars(om, 'R', ng, [], Rmin, Rmax);
>> om = add_constraints(om, 'Pg_plus_R', Ar, [], Pmax, {'Pg', 'R'});
>> om = add_constraints(om, 'Rreq', r.zones, lreq, [], {'R'});
>> om = add_costs(om, 'Rcost', struct('N', I, 'Cw', Cw), {'R'});
>>
>>
>> nb = size(mpc.bus, 1);
>> ng = size(mpc.gen, 1);
>> pf = 0.95;
>> 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(2:end, :);
>> mpc.l = zeros(ng-1, 1);
>> mpc.u = mpc.l;
>> opf_execute(om,mpopt);
>>
>> +++++++++++++++++++++++++++++++++++++++++++++
>> *
>> Best Regards
>>
>> D. Xu
>>
>>
>>
>> On Mon, Jun 20, 2011 at 21:47, Ray Zimmerman <[email protected]> wrote:
>>
>>> You simply need to build an A matrix that has all of your constraints in
>>> it. In other words, in addition to the rows for the power factor
>>> constraints, you will be adding additional rows for the constraints that
>>> include your new variables. But new variables mean new columns in A as well.
>>> These must be added to all rows, including those for the power factor
>>> constraints.
>>>
>>> When you have multiple sets of constraints like this that you are adding,
>>> it is often best to use the callback mechanism described in Chapter 6. You
>>> can then treat them separately, using the add_vars and 
>>> add_constraintsfunctions and MATPOWER will then form the overall matrix at 
>>> runtime. It
>>> allows you to implement and then enable/disable multiple OPF extensions
>>> independently.
>>>
>>>  --
>>> Ray Zimmerman
>>> Senior Research Associate
>>> 211 Warren Hall, Cornell University, Ithaca, NY 14853
>>> phone: (607) 255-9645
>>>
>>>
>>>
>>> On Jun 20, 2011, at 10:21 AM, Dailan Xu wrote:
>>>
>>> I have used the following code to impose power factor constraint for
>>> generators (as you have written for one of the users). How can I
>>> differenciate these two problems, i.e. adding a variable z and specified
>>> power factor as follows: because we will have 2 matix of A
>>> mpc = loadcase('t_auction_case');
>>> nb = size(mpc.bus, 1);
>>> ng = size(mpc.gen, 1);
>>> pf = 0.95;
>>> 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(2:end, :);
>>> mpc.l = zeros(ng-1, 1);
>>> mpc.u = mpc.l;
>>> Best Regards
>>>
>>> D. Xu
>>>
>>>
>>>
>>> On Mon, Jun 20, 2011 at 16:08, Ray Zimmerman <[email protected]> wrote:
>>>
>>>> Section 6.4 references two examples included in MATPOWER. These both use
>>>> the callback mechanism. There is another very basic example at about line
>>>> 184 of t/t_opf_mips.m  that defines the A, l, u and N, fparm, H and 
>>>> Cwparameters to be passed directly to
>>>> opf. As described in the first paragraph of chapter 6, these parameters
>>>> can also be specified as additional fields in the case struct, which is how
>>>> you would need to do it when calling runmarket.
>>>>
>>>>  --
>>>> Ray Zimmerman
>>>> Senior Research Associate
>>>> 211 Warren Hall, Cornell University, Ithaca, NY 14853
>>>> phone: (607) 255-9645
>>>>
>>>>
>>>>
>>>> On Jun 20, 2011, at 9:41 AM, Dailan Xu wrote:
>>>>
>>>> Thank U. Where can I find an example? or could you please give me an
>>>> example?
>>>>
>>>> Best Regards
>>>>
>>>> D. Xu
>>>>
>>>>
>>>> On Mon, Jun 20, 2011 at 15:28, Ray Zimmerman <[email protected]> wrote:
>>>>
>>>>> The runmarket code is simply a wrapper around the OPF solver, so it's
>>>>> the same as adding variables to extend the OPF. The bus voltages are 
>>>>> already
>>>>> control variables, but please see section 5.3 and chapter 6 of the manual
>>>>> for details on how to extend the OPF with other variables, constraints and
>>>>> costs.
>>>>>
>>>>> --
>>>>> Ray Zimmerman
>>>>> Senior Research Associate
>>>>> 211 Warren Hall, Cornell University, Ithaca, NY 14853
>>>>> phone: (607) 255-9645
>>>>>
>>>>>
>>>>>
>>>>> On Jun 20, 2011, at 9:15 AM, Dailan Xu wrote:
>>>>>
>>>>> > Dear Prof. Zimmerman
>>>>> >
>>>>> > How can I add an optimization variable to runmarket, for example,
>>>>> adding voltage of buses as control variable? Is it possible?
>>>>> >
>>>>> > Best Regards
>>>>> >
>>>>> > D. Xu
>>>>> >
>>>>> >
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>
>

Reply via email to