Home > matpower4.0 > extras > cpf > drawPVcurves.m

drawPVcurves

PURPOSE ^

DRAWPVCURVES Draw PV curves for specified buses.

SYNOPSIS ^

function drawPVcurves(casedata, loadvarloc, corrected_list, combined_list, flag_combinedCurve, busesToDraw)

DESCRIPTION ^

DRAWPVCURVES  Draw PV curves for specified buses.
   [INPUT PARAMETERS]
   corrected_list, combined_list: data points obtained from CPF solver
   loadvarloc: load variation location(in external bus numbering). Single bus supported so far.
   flag_combinedCurve: flag indicating if the prediction-correction curve will be drawn
   busesToDraw: bus indices whose PV curve will be be drawn
   created by Rui Bo on 2008/01/13

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function drawPVcurves(casedata, loadvarloc, corrected_list, combined_list, flag_combinedCurve, busesToDraw)
0002 %DRAWPVCURVES  Draw PV curves for specified buses.
0003 %   [INPUT PARAMETERS]
0004 %   corrected_list, combined_list: data points obtained from CPF solver
0005 %   loadvarloc: load variation location(in external bus numbering). Single bus supported so far.
0006 %   flag_combinedCurve: flag indicating if the prediction-correction curve will be drawn
0007 %   busesToDraw: bus indices whose PV curve will be be drawn
0008 %   created by Rui Bo on 2008/01/13
0009 
0010 %   MATPOWER
0011 %   $Id: drawPVcurves.m,v 1.6 2010/04/26 19:45:26 ray Exp $
0012 %   by Rui Bo
0013 %   Copyright (c) 2009-2010 by Rui Bo
0014 %
0015 %   This file is part of MATPOWER.
0016 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0017 %
0018 %   MATPOWER is free software: you can redistribute it and/or modify
0019 %   it under the terms of the GNU General Public License as published
0020 %   by the Free Software Foundation, either version 3 of the License,
0021 %   or (at your option) any later version.
0022 %
0023 %   MATPOWER is distributed in the hope that it will be useful,
0024 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0025 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0026 %   GNU General Public License for more details.
0027 %
0028 %   You should have received a copy of the GNU General Public License
0029 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0030 %
0031 %   Additional permission under GNU GPL version 3 section 7
0032 %
0033 %   If you modify MATPOWER, or any covered work, to interface with
0034 %   other modules (such as MATLAB code and MEX-files) available in a
0035 %   MATLAB(R) or comparable environment containing parts covered
0036 %   under other licensing terms, the licensors of MATPOWER grant
0037 %   you additional permission to convey the resulting work.
0038 
0039 %% assign default parameters
0040 if nargin < 6
0041     busesToDraw = loadvarloc;   % draw the curve for the load changing bus
0042 end
0043 if isempty(busesToDraw)
0044     busesToDraw = loadvarloc;   % draw the curve for the load changing bus
0045 end
0046 
0047 %% load the case & convert to internal bus numbering
0048 [baseMVA, bus, gen, branch] = loadcase(casedata);
0049 nb = size(bus, 1);
0050 
0051 correctedDataNum = size(corrected_list, 2) - 1;
0052 combinedDataNum  = size(combined_list, 2) - 1;
0053 
0054 %% prepare data for drawing
0055 lambda_corrected = corrected_list(nb+1, [2:correctedDataNum+1]);
0056 lambda_combined  = combined_list(nb+1, [2:combinedDataNum+1]);
0057 
0058 fprintf('Start plotting CPF curve(s)...\n');
0059 for j = 1:length(busesToDraw)%for i = 1+npv+1:1+npv+npq
0060     i = find(corrected_list(:, 1) == busesToDraw(j)); % find row index
0061     
0062     %% get voltage magnitudes
0063     Vm_corrected = abs(corrected_list(i, [2:correctedDataNum+1]));
0064     Vm_combined  = abs(combined_list(i, [2:combinedDataNum+1]));
0065     
0066     %% create a new figure
0067     figure;
0068     hold on;
0069     
0070     %% plot PV curve
0071     plot(lambda_corrected, Vm_corrected, 'bx-');
0072     
0073     %% plot CPF prediction-correction curve
0074     if flag_combinedCurve == true
0075         plot(lambda_combined, Vm_combined, 'r.-');
0076         legend('CPF Curve', 'Prediction-Correction Curve');
0077         legend('Location', 'Best');
0078     end
0079     
0080     %% add plot title
0081     title(['Vm at bus ' int2str(busesToDraw(j)) ' w.r.t. load (p.u.) at ' int2str(loadvarloc)]);
0082 end
0083 fprintf('Plotting is done.\n');

Generated on Mon 26-Jan-2015 14:56:45 by m2html © 2005