MATLAB Answers

## Error to run PSO code in hydrothermal Economic and emission dispatch Problem. Please help me out

Asked by Mary Lusenie

### Mary Lusenie (view profile)

on 8 Dec 2018
In the PSO code, i want to get hydro output, thermal output , Fuel cost, emission, power loss and total Fuel cost. But i got the following errors while running the code.
These are the errors.
Undefined function or variable 'P11'.
Error in ELD_mobjective (line 15)
P1=sum(P11')';
Error in pso_Trelea_vectorized (line 266)
out = feval(functname,pos); % returns column of cost values (1 for each particle)
Error in hydrothermalEconimicEmissionDispatch (line 72)
[OUT]=pso_Trelea_vectorized('ELD_mobjective',n,1,ran,0,Pdef);
clear
clc
global elddata Pd emidata B w
propmt='Enter the power demand value (in MW)= ';
PD = input(propmt);
%% HYDRO POWER GENERATION
%P=W*Q*H*n*g Watts where w=water density, q=discharge in m^3/s, n=efficiency, %g=gravitational acceleration
propmt='\n Enter the water dicharge value=';
Q=input(propmt);
W=1000; % Water density
H=70; % The water head of the Plant
g=9.81;% gravitational acceleration
n=0.7; % the operating efficiency of the plant
if Q<10
pOUT=0;
elseif Q>40
pOUT=0;
else
pOUT=W.*Q'*H*n*g;
end
power=pOUT/(10^6);
fprintf('========================== =================================== =');
fprintf ('\n The Average Hydro Power Generated is = %8.3f MW/hour\n',power);
fprintf('========================== =================================== =\n');
% the elddata matrix should have 5 columns of fuel cost coefficients and plant limits.
% 1.a (\$/MW^2) 2. b \$/MW 3. c (\$) 4.lower lomit(MW) 5.Upper limit(MW)
%no of rows denote the no of plants(n)
elddata=[0.1 1.5 1 0.05 8.25 %Warsilla thermal plant 1
0.1 1.5 1.2 0.05 8.26 %Warsilla thermal plant 2
0.2 1.8 0.4 0.05 5 %Nigatta thermal plant 1
0.1 1 0.6 0.05 6 %Nigatta thermal plant 2
0.2 1.8 0.4 10 22.5 %CAT thermal plant 1
0.1 2 1 10 20 %CAT thermal plant 2
];
% the emidata matrix should have 3 columns of fuel cost coefficients and plant limits.
% 1.a (Kg/MW^2) 2. b Kg/MW 3. c (Kg)
emidata=[0.0613 -0.0555 0.0515
0.0254 -0.0605 0.0564
0.0426 -0.005 0.0459
0.0532 -0.0355 0.0338
0.0426 -0.051 0.0456
0.041 -0.0556 0.65];
% Loss coefficients it should be squarematrix of size nXn where n is the no
% of plants
B=1e-4*[1.4 .17 .15 .19 .26 .22
.17 .6 .13 .16 .15 .2
.15 .13 .65 .17 .24 .19
.19 .16 .17 .71 .3 .25
.26 .15 .24 .3 .69 .32
.22 .2 .19 .25 .32 .85];
% w1 and w2 are the weightage factor for economy and emission
w=1;
% Demand (MW)
Pd = PD;
n=length(elddata(:,1));
l=elddata(:,4)';
u=elddata(:,5)';
ran=[l' u'];
% P1=[100 10000 100 2 2 .9 .4 1500 1e-25 200 1e50 0 0];
Pdef = [100 100000 100 2 2 0.9 0.4 1500 1e-10 5000 NaN 0 0];
[OUT]=pso_Trelea_vectorized('ELD_mobjective',n,1,ran,0,Pdef);
out=abs(OUT);
P=out(1:6);
[Fcost, Emi, P1, Ft]=ELD_mobjective(P');
%ELD_mobjective
function[Fcost Emi P1 Ft]=ELD_mobjective(in)
in=abs(in);
global elddata emidata B Pd w;
a=elddata(:,1);
b=elddata(:,2);
c=elddata(:,3);
e=emidata(:,1);
f=emidata(:,2);
g=emidata(:,3);
y1=in.*in*diag(a)+in*diag(b);
y2=in.*in*diag(e)+in*diag(f);
Pl1=(in*B).*in;
P1=sum(P11')';
lam=abs(Pd+Pl-sum(in'))';
Fcost=sum(y1')+sum(c)+100*lam;
Emi=sum(y2')+sum(g);
Ft=(sum(w*Fcost'))+(sum(1-w)*Emi')+100*lam;%Total Fuel Cost

#### 0 Comments

Sign in to comment.