Here is an example of how to do it for case30. The first run is a
loss-minimization solution, the second minimizes the voltage deviations from 1
p.u. using the objective you specified.
define_constants;
mpopt = mpoption('opf.ac.solver', 'MIPS', 'verbose', 2);
mpc = loadcase('case30');
nb = size(mpc.bus, 1);
ng = size(mpc.gen, 1);
mpc.gencost = ones(ng, 1) * [2 0 0 2 1 0];
r1 = runopf(mpc, mpopt);
mpc.gencost(:, 5) = 0;
mpc.N = [sparse(nb, nb) speye(nb, nb) sparse(nb, 2*ng)];
mpc.fparm = ones(nb, 1) * [2 1 0 1];
mpc.Cw = 1000 * ones(nb, 1);
r2 = runopf(mpc, mpopt);
norm(r1.bus(:, VM) - 1)
norm(r2.bus(:, VM) - 1)
Notice the reduction in voltage deviations from the first run.
Ray
> On Nov 24, 2016, at 10:46 AM, Robin Weckx <[email protected]>
> wrote:
>
> Dear,
>
> I have implemented the two area kundur topology in the matpower software. I
> can successfully run a PF and OPF. My next goal is the change the objective
> of the OPF so that the voltages on the busses are as close to unity as
> possible independently from the cost of the generators. For this i modified
> my gencost matrix so that all the generators have the same cost. the next
> step is to add my objective while the constrains stay the same. Because i
> don't need to add any values because Vm is already in the x matrix this
> process should be quite straightforward but i keep failing.
> My objective function is fmin=(Vm-1)^2 for all the voltages of the busses.
> How do i implement this?
> i looked at the "add_costs" function but don't really know where i should use
> this function.
> i tried the direct implementation method of cheaper 7. should i just but the
> values of the H,N,Cw,... in de Kundur file that I use to perform
> runopf('Kundur')?
> or could i just modify the gencost matrix to make a "buscost" matrix where
> all the polynomial cost functions are as defined above?
>
> Could you please give me some more directions on how to solve this problem?
>
> thanks in advance
> kind regards
> Weckx Robin