GETV0 Get initial voltage profile for power flow calculation. Note: The pv bus voltage will remain at the given value even for flat start. type_initialguess: 1 - initial guess from case data 2 - flat start 3 - from input
0001 function V0 = getV0(bus, gen, type_initialguess, V0) 0002 %GETV0 Get initial voltage profile for power flow calculation. 0003 % Note: The pv bus voltage will remain at the given value even for 0004 % flat start. 0005 % type_initialguess: 1 - initial guess from case data 0006 % 2 - flat start 0007 % 3 - from input 0008 0009 % MATPOWER 0010 % Copyright (c) 2009-2016, Power Systems Engineering Research Center (PSERC) 0011 % by Rui Bo 0012 % 0013 % This file is part of MATPOWER. 0014 % Covered by the 3-clause BSD License (see LICENSE file for details). 0015 % See http://www.pserc.cornell.edu/matpower/ for more info. 0016 0017 %% define named indices into bus, gen, branch matrices 0018 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ... 0019 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus; 0020 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, ... 0021 RATE_C, TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST] = idx_brch; 0022 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, ... 0023 GEN_STATUS, PMAX, PMIN, MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN] = idx_gen; 0024 0025 %% generator info 0026 on = find(gen(:, GEN_STATUS) > 0); %% which generators are on? 0027 gbus = gen(on, GEN_BUS); %% what buses are they at? 0028 if type_initialguess == 1 % using previous value in case data 0029 % NOTE: angle is in degree in case data, but in radians in pf solver, 0030 % so conversion from degree to radians is needed here 0031 V0 = bus(:, VM) .* exp(sqrt(-1) * pi/180 * bus(:, VA)); 0032 elseif type_initialguess == 2 % using flat start 0033 V0 = ones(size(bus, 1), 1); 0034 elseif type_initialguess == 3 % using given initial voltage 0035 V0 = V0; 0036 else 0037 fprintf('Error: unknow ''type_initialguess''.\n'); 0038 pause 0039 end 0040 % set the voltages of PV bus and reference bus into the initial guess 0041 V0(gbus) = gen(on, VG) ./ abs(V0(gbus)).* V0(gbus);