filename = 'book1.xls';
sheetname = 'data';
I_L=xlsread(filename, sheetname,'D2:D8761');
T= xlsread(filename, sheetname, 'A2:A8761');
S= xlsread(filename, sheetname, 'B2:B8761');
NOCT=43.6;
Alpha=0.068;
IPV_M=6.89;
T_cell=T+S*(NOCT-20)/800;
I_PV=S/1000+Alpha*(T_cell-25);
I_PV(I_PV<0)=0;
PV_eff=0.16;
Wire_eff=0.98;
INV_eff=0.95;
V_sys=230;
PSH=(mean(S)*12)/1000;
V_B=12;
DCharge_eff=0.8;
DOD=0.8;
Alpha=0.068;
PV_WP=120;
P_L=I_L*230;
A_PV=1.408*0.56;
E_L=sum(P_L)/length(I_L)*24;
N_PV = ceil(E_L/(PV_eff*INV_eff*Wire_eff*PSH*1000*A_PV));
N_PVmin=ceil(N_PV/3);
N_PVmax=5*N_PV;
nh=2;
C_battery=(E_L*nh)/(DOD*DCharge_eff);
C_batterymin=C_battery/3;
C_batterymax=5*C_battery;
SOC=zeros(1,length(I_L));
I_Load=zeros(1,length(I_L));
I_Charge=zeros(1,length(I_L));
I_Discharge=zeros(1,length(I_L));
I_Deficit=zeros(1,length(I_L));
I_Damp=zeros(1,length(I_L));
I_Battery=zeros(1,length(I_L));
xxx=N_PVmin:N_PVmax;
yyy=C_batterymin:500:C_batterymax;
C_batteryf=zeros(length(xxx),length(yyy));
C_PVf=zeros(length(xxx),length(yyy));
LLP_calculated=zeros(length(xxx),length(yyy));
t=1;
Vmp=17.4;
NOCT=43.6;
K=0.8;
D=1e-5;
ns=6;
SOC1=1;
SOC2=SOC1;
SOC3=0.2;
x=1;
I_net=I_PV-I_L;
for m=xxx
y=1;
for n=yyy
SOCmax=n;
SOCmin=SOCmax.*(1-DOD);
w=0;
for k=1:length(I_L)
if SOCmax>0
if I_net(k)==0
I_Load(k)=I_PV(k);
if k==1
SOC(k)=SOC1;
elseif w==0
SOC(k)=SOC1;
elseif w==1
SOC(k)=SOC(k-1);
end
elseif I_net(k)>0
I_Load(k)=I_L(k);
if k==1
SOC(k)=SOC1;
I_Damp(k)=I_net(k);
elseif k>1
if w==0
SOC(k)=SOC1;
I_Damp(k)=I_net(k);
elseif w==1
if SOC(k-1)>=SOC1
SOC(k)=SOC(k-1);
I_Damp(k)=I_net(k);
elseif SOC(k-1)<SOC1
I_Charge(k)=I_net(k);
B=SOC2;
V1=(2+0.148*B)*ns;
R1=((0.758+(0.1309/(1.06-B)))*ns)/SOCmax;
ee=K*V1*I_net(k)-D*SOC2*SOCmax;
SOCx=SOC1+ee/SOCmax;
SOC2=SOCx;
SOC(k)=SOC(k-1)+abs(SOC1-SOC2);
end
end
end
elseif I_net(k)<0
if w==0
I_Discharge(k)=I_L(k)-I_PV(k);
I_Battery(k)=I_Discharge(k);
I_Load(k)=I_PV(k)+I_Battery(k);
B=SOC2;
V1=(1.926+0.124*B)*ns;
R1=(0.19+(0.1037/(B-0.14)))*(ns/SOCmax);
ee=K*V1*I_net(k)-D*SOC2*SOCmax;
SOCx=SOC1+ee/SOCmax;
SOC2=SOCx;
SOC(k)=SOC2;
w=w+1;
elseif w==1
if SOC(k-1)>SOC3
I_Discharge(k)=I_L(k)-I_PV(k);
I_Battery(k)=I_Discharge(k);
I_Load(k)=I_L(k);
B=SOC2;
V1=(1.926+0.124*B)*ns;
R1=(0.19+(0.1037/(B-0.14)))*(ns/SOCmax);
ee=K.*V1.*I_net(k)-D*SOC2*SOCmax;
SOCx=SOC1+ee/SOCmax;
SOC2=SOCx;
SOC(k)=SOC(k-1)-abs(SOC1-SOC2);
elseif SOC(k-1)<=SOC3
SOC2=SOC3;
SOC(k)=SOC3;
I_Deficit(k)=I_net(k);
end
end
end
else
if I_net(n)==0
SOC(k)=SOC1;
I_Load(n)=I_PV(n);
I_Damp(n)=0;
I_Charge(n)=0;
I_Deficit(n)=0;
I_Discharge(n)=0;
I_Battery(n)=0;
elseif I_net(n)>0
SOC(k)=SOC1;
I_Load(n)=I_L(n);
I_Damp(n)=I_net(n);
I_Charge(n)=0;
I_Deficit(n)=0;
I_Discharge(n)=0;
I_Battery(n)=0;
elseif I_net(n)<0
SOC(k)=SOC1;
I_Damp(n)=0;
I_Charge(n)=0;
I_Deficit(n)=I_L(n)-I_PV(n);
I_Discharge(n)=0;
I_Battery(n)=0;
I_Load(n)=I_PV(n);
end
end
end
E_Excess=sum(I_Damp.*230);
SOC_per=SOC./SOCmax;
C_batteryf(x,y)=n;
C_PVf(x,y)=m;
LLP_calculated(x,y)=abs(sum(I_Deficit)/sum(I_L));
y=y+1;
end
x=x+1;
end
cc=1;
LLP_ff=zeros(1,size(LLP_calculated,1)*size(LLP_calculated,1));
C_PV_ff=zeros(1,size(LLP_calculated,1)*size(LLP_calculated,1));
C_battery_ff=zeros(1,size(LLP_calculated,1)*size(LLP_calculated,1));
for ii=1:size(LLP_calculated,1)
for jj=1:size(LLP_calculated,1)
if LLP_calculated(ii,jj)>=0.0095 && LLP_calculated(ii,jj)<=0.0105
LLP_ff(cc)=LLP_calculated(ii,jj);
C_PV_ff(cc)=C_PVf(ii,jj);
C_battery_ff(cc)=C_batteryf(ii,jj);
cc=cc+1;
end
end
end
CC_PV=456;
MC_PV=6.5;
Ls=25;
L_PV=25;
Ca_battery=1200;
CC_batwh=4.8;
CC_bat=CC_batwh*Ca_battery;
MC_bat=3.4;
L_bat=5;
Y_bat=(Ls/L_bat)-1;
B_rep=50;
CC_B_rep=Y_bat*B_rep;
CC_cc=400;
MC_cc=0;
L_cc=25;
Y_cc=(Ls/L_cc)-1;
N_cc=1;
CC_inv=800;
MC_inv=0;
L_inv=25;
Y_inv=(Ls/L_inv)-1;
N_inv=1;
N_CB=4;
C_CB=25;
CC_CB=N_CB*C_CB;
CC_SS=200;
CC_CW=400;
CC_OC=CC_CB+CC_SS+CC_CW+CC_B_rep;
ir=0.035;
fr=0.015;
ndr=((1+ir)/(1+fr))-1;
LCCx=zeros(1,length(C_PV_ff));
CC_D=zeros(1,length(C_PV_ff));
LCC=zeros(1,length(C_PV_ff));
for kk=1:length(C_PV_ff)
LCCx(kk)=(CC_OC/((((1+ndr)^Ls)-1)/((ndr*((1+ndr)^Ls)))))+((C_PV_ff(kk)*(CC_PV+Ls*MC_PV))/L_PV)+(((ceil(C_battery_ff(kk)/Ca_battery)*CC_bat*(1+Y_bat))+(MC_bat*(LsY_bat)))/L_bat)+(((N_cc*CC_cc*(1+Y_cc))+(MC_cc*(Ls-Y_cc)))/L_cc)+(((N_inv*CC_inv*(1+Y_inv))+(MC_inv*(Ls-Y_inv))/L_inv));
CC_D(kk)=(C_PV_ff(kk)*(CC_PV))+((ceil(C_battery_ff( kk ) / Ca_battery ) * CC_bat * ( 1 + Y_rbat ) ) ) +(N_cc*CC_cc*(1+Y_cc))+(N_inv*CC_inv*(1+Y_inv))+CC_CB+CC_SS;
LCC(kk) = LCCx(kk)-(((0.13*(CC_D(kk))))/((((1+ndr)^Ls)-1)/((ndr*((1+nd)^Ls)))));
end
[MM,II]=min(LCC);
MM;
C_PV_best= C_PV_ff(II);
C_battery_best= C_battery_ff(II);
fprintf('Best PV Moduls Number is: %d\n',C_PV_best);
fprintf('Best Battery Capacity is: %d\n',C_battery_best);
Best Answer