Info
此问题已关闭。 请重新打开它进行编辑或回答。
I ran a test simulation in MOPSO for four variables, first four 24 hrs (intend to add more variables and do 1yr analysis). But I got "Unable to perform assignment because the left and right sides have a different number of elements." plz help
1 次查看(过去 30 天)
显示 更早的评论
function z=costdailymop8(K)
id=[0 0 0 0 0 0 0 178 422 648 852 961 1000 942 827 638 398 137 0 0 0 0 0 0]; % Daily solar insolation data [w/m2]
Grid1 = [121 116 116 111 111 111 110 108 108 108 109 110 111 115 116 115 115 120 120 121 121 121 121 121]; Pgrid1=Grid1.*1000; % Total Grid power [kW] Pgrid = Pgrid1;
Load=[394 338 340 330 322 350 396 444 527 573 601 643 639 566 568 634 648 675 662 674 579 532 480 419]; Pl=Load.*1000; % Daily Load Demand [kW]
Vron=[7 6 4 4 6 7 8 7 7 11 12 10 10 8 4 7 6 4 7 7 6 7 7 4];
Vroff=[9 7 5 5 7 9 11 9 9 14 16 12 12 11 5 9 7 5 9 9 7 9 9 5];
% Input Data %K(1)=Apv; %Total area occupied by PV panels %K(2)=Awon; % Total area occupied by onshore wind turbines %K(3)=Awoff; % Total area occupied by offshore wind turbines %K(4)=Nbat; % Total number of batteries
%%%%%%%%%%%%% Parameters used in this study %%%%%%%%%%%%%%%%%%
i=0.1; % interest rate N=20; % project lifetime [years] delta=0.04; % Inflation rate mew=0.075; % Escalation rate effI=1; % Inverter efficiency
%%%%%%%%%%%%%%% battery parameters %%%%%%%%%%%%%%%%%%%%%%
dh=0.002; % Hourly self discharge rate ebc=0.95; % battery charging efficiency ebd=0.95; % battery discharging effciency ibat=200; % cost of 960 V and 1200 Ah battery [$/kWh] %dod=0.75; % maximum depth of discharge Lb=5; % Battery lifetime [years] Cb=1200; % nominal capacity of battery [kWh]
%%%%%%%%%%%%%%%%% PV array parameters %%%%%%%%%%%%%%%%%%%%
ipv=519.7; % initial cost [$/m2] Ompv=0.01*ipv; % yearly operating and maintenance cost [$/m2/year] spv=0.25*ipv; % reselling price [$/m2] effpv=0.14; % efficiency Lpv=20; % Lifetime
%%%%%%%%%%%%%%%% Wind onshore generator parameters %%%%%%%%%%%%%%%%%
iwon=544.2; % initial cost[$/m2] Omwon=0.02*iwon; % yearly operating and maintenance cost [$/m2/year] swon=0.3*iwon; % reselling price [$/m2] Lwon=20; % Lifetime effwon=0.85; % efficiency Cpon=0.59; % power coefficient rhoon=1.225; % air density [kg/m3]
% Turbine power curve coefficents SInon = 1.5; % cut-in speed (m/s) SRon=13; % rated output speed (m/s) SOuton = 27; % cut-out speed (m/s) PRatedon = 5000; % wind turbine rated power (kW)
%%%%%%%%%%%%%%%% Wind offshore generator parameters %%%%%%%%%%%%%%%%%
iwoff=700; % initial cost[$/m2] Omwoff=0.015*iwoff; % yearly operating and maintenance cost [$/m2/year] swoff=0.35*iwoff; % reselling price [$/m2] Lwoff=20; % Lifetime effwoff=0.85; % efficiency Cpoff=0.59; % power coefficient rhooff=1.225; % air density [kg/m3]
% Turbine power curve coefficents SInoff = 2; % cut-in speed (m/s) SRoff = 14; % rated output speed (m/s) SOutoff = 27.5; % cut-out speed (m/s) PRatedoff = 5000; % wind turbine rated power (kW)
%%%%%%%%%%%%%%%% Model for PV %%%%%%%%%%%%%%%%%%
for t=1:24
Ppv(t)=effpv.*K(1).*id(t)./1000; % power supplied by PV panels [kW]
end
Cpv=ipv.*K(1); % capital cost of the investment [$]
for j=1:N
OMpv1(j)= Ompv.*K(1).*(((1+mew)./(1+i)).^j);
end
OMpv=sum(OMpv1); % Total operation and maintainence cost [$]
Rpv=0; % Replacement cost [$]
Spv=spv*K(1).*(((1+delta)./(1+i)).^N); % resale price [$]
%%%%%%%%%% Model for onshore wind generator %%%%%%%%%%%%%%%
for t=1:24
Pwon(t)=0.5*Cpon.*rhoon.*effwon.*K(2).*(Vron(t).^3)./1000; % Rated power of wind generator [kW]
if Vron(t) <= SInon
Pwon = 0;
if Vron(t) > SOuton
Pwon = 0;
if Vron(t) >= SRon && Vron(t) <= SOuton
Vron(t)= SRon;
end
end
end
end
Cwon=iwon*K(2); % capital cost of the investment [$]
for j=1:N
OMw1(j)=Omwon.*K(2).*(((1+mew)./(1+i)).^j);
end
OMwon=sum(OMw1); % Total operation and maintainence cost [$]
Rwon=0; % Replacement cost [$]
Swon=swon.*K(2).*(((1+delta)./(1+i)).^N); % resale price [$]
%%%%%%%%%% Model for OffshoreWind generator %%%%%%%%%%%%%%%
for t=1:24
Pwoff(t)=0.5*Cpoff.*rhooff.*effwoff.*K(3).*(Vroff(t).^3)./1000; % Rated power of wind generator [kW]
if Vroff(t) <= SInoff
Pwoff = 0;
if Vroff(t) > SOutoff
Pwoff = 0;
if Vroff(t) >= SRoff && Vroff(t) <= SOutoff
Vroff(t)=SRoff;
end
end
end
end
Cwoff=iwoff*K(3); % capital cost of the investment [$]
for j=1:N
OMw2(j)=Omwoff*K(3)*(((1+mew)/(1+i)).^j);
end
OMwoff=sum(OMw2); % Total operation and maintainence cost [$]
Rwoff=0; % Replacement cost [$]
Swoff=swoff.*K(3).*(((1+delta)/(1+i)).^N); % resale price [$]
% SOCmax=K(4)*Cb; % Maximum state of charge [kWh]
% SOCmin=K(4)*0.5*Cb;
%%%%%%%%%%%% MOdel of battery %%%%%%%%%%%%%%%%%%
for t=1
Pg(1)= Ppv(1)+Pwon(1)+Pwoff(1)+Pgrid(1); % Total Power generated by PV,Wind and Grid
SOCmax=K(4)*0.8*Cb; % Maximum state of charge [kWh]
SOCmin=K(4)*0.2*Cb; % Minimum state of chage [kWh]
if Pg(1) >= Pl(1)/effI %%Battery Charging
SOC(1)=(SOCmin*(1-dh))+((Pg(1)-(Pl(1)./effI))*ebc);
DPS(1)=0;
if SOC(1)>=SOCmax % SOC(1)>=SOCmax
SOC(1)=SOCmax;
EPG(1)=Pg(1)-((Pl(1)/effI)+(((SOCmax-SOCmin))/ebc));
end
end
if Pg(1)<Pl(1)/effI % Battery discharge
SOC(1)=(SOCmin*(1-dh))-(((Pl(1)./effI)-Pg(1))./ebd);
EPG(1)=0;
if SOC(1)<SOCmin
DPS(1)=(Pl(1)./effI)-Pg(1);
SOC(1)=SOCmin;
end
end
end
for t=2:24
Pg(t)= Ppv(t)+Pwon(t)+Pwoff(t)+Pgrid(t);
if Pg(t)>=Pl(t)/effI % %%Battery Charging
SOC(t)=(SOC(t-1)*(1-dh))+((Pg(t)-(Pl(t)./effI))*ebc);
DPS(t)=0;
if SOC(t)>=SOCmax
SOC(t)=SOCmax;
EPG(t)=Pg(t)-((Pl(t)./effI)+(SOCmax-SOC(t-1))/ebc);
end
end
if Pg(t)<Pl(t)/effI % Battery discharge
SOC(t)=SOC(t-1)*(1-dh)-(((Pl(t)./effI)-Pg(t))./ebd);
EPG(t)=0;
if SOC(t)<SOCmin
DPS(t)=Pl(t)-((Pg(t)+SOC(t-1)-SOCmin))*effI;
SOC(t)=SOCmin;
end
end
Cbat=K(4)*ibat*Cb; % capital cost of the investment [$]
for j=5
Rbat1=K(4)*ibat*Cb*(((1+mew)/(1+i)).^j);
end
for j=10
Rbat2=K(4)*ibat*Cb*(((1+mew)/(1+i)).^j);
end
for j=15
Rbat3=K(4)*ibat*Cb*(((1+mew)/(1+i)).^j);
end
Rbat=Rbat1+Rbat2+Rbat3; % Total Replacement cost [$]
OMbat=0.0003; % Operating and maintenance cost [$]
Sbat=0; % resale cost [$]
end
a=sum(DPS);
b=sum(Pl);
DPSP=a/b;
z=sum(EPG);
REPG=z/b;
for i=1
Pg(i)= Ppv(i)+Pwon(i)+Pwoff(i)+Pgrid(i);
Pgu(i)=Pg(i)-(SOC(i)-SOCmin);
end
for i=2:24
Pg(i)= Ppv(i)+Pwon(i)+Pwoff(i)+Pgrid(i);
Pgu(i)=Pg(i)-(SOC(i)-SOC(i-1));
end
z1=Cpv+OMpv+Rpv-Spv+Cwon+OMwon+Rwon-Swon+Cwoff+OMwoff+Rwoff-Swoff+Cbat+OMbat+Rbat-Sbat;
z2=DPSP+REPG;
z=[z1 z2]';
end
0 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!