CPF_CORRECTVOLTAGE Do correction for predicted voltage in cpf. [INPUT PARAMETERS] loadvarloc: (in internal bus numbering) created by Rui Bo on 2007/11/12
0001 function [V, lambda, success, iterNum] = cpf_correctVoltage(baseMVA, bus, gen, Ybus, V_predicted, lambda_predicted, initQPratio, loadvarloc) 0002 %CPF_CORRECTVOLTAGE Do correction for predicted voltage in cpf. 0003 % [INPUT PARAMETERS] 0004 % loadvarloc: (in internal bus numbering) 0005 % created by Rui Bo on 2007/11/12 0006 0007 % MATPOWER 0008 % $Id: cpf_correctVoltage.m,v 1.4 2010/04/26 19:45:26 ray Exp $ 0009 % by Rui Bo 0010 % Copyright (c) 2009-2010 by Rui Bo 0011 % 0012 % This file is part of MATPOWER. 0013 % See http://www.pserc.cornell.edu/matpower/ for more info. 0014 % 0015 % MATPOWER is free software: you can redistribute it and/or modify 0016 % it under the terms of the GNU General Public License as published 0017 % by the Free Software Foundation, either version 3 of the License, 0018 % or (at your option) any later version. 0019 % 0020 % MATPOWER is distributed in the hope that it will be useful, 0021 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0022 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0023 % GNU General Public License for more details. 0024 % 0025 % You should have received a copy of the GNU General Public License 0026 % along with MATPOWER. If not, see <http://www.gnu.org/licenses/>. 0027 % 0028 % Additional permission under GNU GPL version 3 section 7 0029 % 0030 % If you modify MATPOWER, or any covered work, to interface with 0031 % other modules (such as MATLAB code and MEX-files) available in a 0032 % MATLAB(R) or comparable environment containing parts covered 0033 % under other licensing terms, the licensors of MATPOWER grant 0034 % you additional permission to convey the resulting work. 0035 0036 %% define named indices into bus, gen, branch matrices 0037 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ... 0038 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus; 0039 0040 %% get bus index lists of each type of bus 0041 [ref, pv, pq] = bustypes(bus, gen); 0042 0043 %% set load as lambda indicates 0044 lambda = lambda_predicted; 0045 bus(loadvarloc, PD) = lambda*baseMVA; 0046 bus(loadvarloc, QD) = lambda*baseMVA*initQPratio; 0047 0048 %% compute complex bus power injections (generation - load) 0049 SbusInj = makeSbus(baseMVA, bus, gen); 0050 0051 %% prepare initial guess 0052 V0 = V_predicted; % use predicted voltage to set the initial guess 0053 0054 %% run power flow to get solution of the current point 0055 mpopt = mpoption('VERBOSE', 0); 0056 [V, success, iterNum] = newtonpf(Ybus, SbusInj, V0, ref, pv, pq, mpopt); %% run NR's power flow solver