can someone help me with the BUSDATA and LINEDATA (with the code i have here) using decoupled method please
Show older comments
i have to use Decoupled Method to solve for the load flow. but what i am having problem with is that i need to make sure that it solves for any size system and thats where i am having trouble with. can some one guide me to how to write this portion of code. thank you
function[Vm, delta,maxerror,Jacobian] = function_name(busdata,linedata,convergence_criterion, max_num_of_iteration)
nbus = number of buses %length(busdata(:,1));
% The 10 columns of busdata file is assumed to be:
% bus_#, bus_type(1 for slack, 0 for load, 2 for generator),V, angle,
%P_load, Q_load, P_gen, Q_gen.
%All the Ps and the Qs are assumed to be MW and MVAR.
bus_kind=busdata(:,2); Vm=busdata(:,3);delta=busdata(:, 4);
% Vm is the vector of the voltage magnitudes, it contains specified
%voltages, initial estimate or best available estimate.
P_load=busdata(:,5); Q_load=busdata(:,6); P_generated=busdata(:,7); Q_generated = busdata(:,8);
delta = 0*pi/180*delta; %Initializing delta to flat start
basemva=100;
P_net_pu=(P_generated-P_load)/basemva;
Q_net_pu=(Q_generated-Q_load)/basemva;
S_net_pu = P_net_pu + j*Q_net_pu;
[Y]= ybus(linedata); %dimension of Y is nb x nb
maxerror = 1;
iter = 0;
% Start of iterations
while maxerror >= crit & iter <= max_iter % Test for max. power mismatch
% the delta vector must be in radians.
[pcal,qcal] = pqcal(Y,Vm,delta) %
[Jacobian, DIM] = jacobian2(Y, Vm, delta, qcal, pcal, nbus,ngen)
det(Jacobian);
[mismatch]=DPDQ(P_net_pu,Q_net_pu,pcal,qcal,nbus,ngen);
correction=Jacobian\mismatch; %mismatch must be a row vector. This is equivalent to inv(Jacobian)*mismatch'
[Vm,delta]=update(Vm, delta, correction, nbus, ngen);
maxerror=max(abs(mismatch));
iter = iter+1;
end
if iter >= max_iter & maxerror > crit
fprintf('\nWARNING: Iterative solution did not converge after ')
fprintf('%g', iter), fprintf(' iterations.\n\n')
elseif maxerror <=crit
fprintf('\nIterative solution converged after ')
fprintf('%g', iter), fprintf(' iterations.\n\n')
else
end
delta=delta*180/pi;
[Y]= ybus(linedata);
function[pcal,qcal] = pqcalNoQ(Y,v,delta,iter)
% delta must be in radians
%pcal and qcal have nbus elements each. pcal(1) is the slack bus power
-_____________________
function[Jacobian, DIM] = jacobian(Ycomp, Vm, delta, qcal, pcal,
nbus,ngen,busdata)
_______________________
function [mismatch]=DPDQ(p_net,q_net,pcal,qcal,nbus,ngen)
%This returns the mismatch vector whose dimension is the same as the number
%of unknowns, i.e, 2*nbus -2 -ngen. The size of qcal and pcal is nbus.
DIM=2*nbus-2-ngen;
delta_p=p_net - pcal; %the size of p_net and q_net is nbus
delta_q = q_net - qcal;
_________________-
function [Vm,delta]=update(Vm, delta, correction, nbus, ngen);
n_load_nodes = nbus-1-ngen;
end
Answers (0)
Categories
Find more on Antennas, Microphones, and Sonar Transducers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!