Info

This question is closed. Reopen it to edit or answer.

I am trying for weeks to solve this error can somebody help me, I am stuck in this problem for weeks and nobody here seems to understand the probelm

1 view (last 30 days)
format long; clear all; close all; clc; %*****************************************************************% %**********************%Parameters Definition*********************% %*****************************************************************% % A is the vector for Load information in a week, and the samples %are in an hour. the values are in kW. A=[]; %The B is the vector for wind turbines generation in a week % and the samples are in an hour B1=[]; B2=[]; W=176; W1=176; Bm=0.1*(W/W1)*B1; %disp('A='); %disp(A); %disp('B='); %disp(B); H2=4000; %H2 Tank capacity that is 20000kWh %Elec=560; %Electrolyser capacity that is 600kW %FC=280; %FC capacity that is 500kW %There are 176 units of 25kW wind turbines PV=0; % There are 6250 units of 120W PV panels. Diesel_R=1200; %Diesel generator rating W_C=5000; %25kW wind turbine is 100,000$, and 20 years life time, 100000/20 FC_C=100; %FC stacks are 20000$ for 20 years lifetime %and Stacks are 3kW, so 20000/20/3 = 333 Elec_C=100; %Electrolysers are 20000$ for 20 years lifetime %and units are 3kW, so 20000/20/3 = 333 PV_C=50; %120W units of PV are 1000$ per unit, and their lifetime is 20 years %their efficiency are 16%, we have 120kW PV panels in the system, so total cost %of the %system is 1000/0.16=6250 panels, 6250*1000=6,250,000$, and the annual cost %is 6,250,000/20=312,500$, so the annual cost is 50$/Unit Diesel_C=1.5; %120 L/hour is fuel burn of diesels for a 400kW unit %, so 120/400 L/kWh, so 0.3 L/kWh, and any litre offuel is 0.5$, so % 0.15 $/kWh is electricity price of diesels, I putthe price more for % better results CO2_C=0.010485; %Carbon tax is 15 $/tonne, and co2 emissions for diesel unit is % 0.699 kg/kWh. So the CO2_C = 0.699*15*0.001 = 0.010485 $/kWh CO2_E=0.699; %Co2 emission is 0.669 kg/kwh Dump_C=1; %Dump load cost is 1 $/kW Dump_E_C=0.1; %Electricity price in the area is 0.1 $/kWh H2_C=1.5; %Hydrogen tank price is supposed 30 $/kWh, so 600000/20 $/year, % so 30000/20000 = 1.5$ %*****************************************************************% %**********************%ECONOMICAL PARAMETERS*********************% %*****************************************************************% %***********************Annual Capital Cost**********************% i_loan=0.05; %loan rate f=0.02; %inflation rate i=(i_loan-f)/(1+f); %annual interest rate n1=20; %lifetime of the project CRF1=(i*(1+i)^n1)/((1+i)^n1-1); %Capital recovery factor n2=5; %lifetime of the project CRF2=(i*(1+i)^n2)/((1+i)^n2-1); %Capital recovery factor ACC_wind=4000*CRF1; %100,000/25kW=4000 $/kW ACC_FC=(20000/3)*CRF2; %Each 3kW unit of FC is 20000$ ACC_Elec=(20000/3)*CRF2; %Each 3kW unit of Elec is 20000$ ACC_H2=30*CRF1; %H2 tank is 30 $/kWh and 20 yrs lifetime %************************Annual replacement cost********************% SFF=i/((1+i)^n2-1); %sinking fund factor ARC_FC=(1400/3)*SFF; %Annual replacement cost of FC units, 1400 for 3kW units ARC_Elec=(1400/3)*SFF; %Annual replacement cost of Elec units, 1400 for 3kW units %***********************Annual fuel cost*****************************% % AFC=T_fc*CRF1; %Annual fuel cost %T-fc is total fuel consumption for lifetime of theproject %T_fc is 20*6*Diesel_E(59) %**********************Annual operation and maintenance cost**********% AOC_wind=(100/25)*(1+f)^n1; %for 25kW Wind units the operation cost for a yearsis 100$ AOC_FC=(15/3)*(1+f)^n1; %for 3kW FC units the operation cost for a years is15$ AOC_Elec=(15/3)*(1+f)^n1; %for 3kW Elec units the operation cost for a years is 15$ AOC_Diesel=6*(1+f)^n1; %**********************************************************************% [x,y]=meshgrid(1:1:20,1:1:20); % x is presenting number of Electrolyser Units, andy is presenting number of FC units
z=x^2-y^2; surf(x,y,z'); r=20*1; %Elec Units q=20*1; %FC Units j=q; %The units are composed of 100kW units u=1; while(u<=10) while(j<=10*q) p=r; while(p<=10*r) FC=j; Elec=p; B=u*Bm; Excess=B-A; Extra=A-B; %Extra demand power is (Demand - Wind Power), but negative values should put zero F=[0 0]; %Summation of Extra load, and its total extra demand in the period of %time, and since time period is one hour so it doesnt need any scaling %difference of stored power in any time in H2 tank,there is 20000kWh save %energy in H2 before start to work i=0; while(i<=719) i=i+1; if(Excess(i)>=0) if(F(i)<=H2-Elec) if(Excess(i)<=Elec) Excess(i)=Excess(i); else Excess(i)=Elec; end else Excess(i)=0; end else Excess(i)=0; end if(Excess(i)>=0) if(Excess(i)<=Elec) if(F(i)<=H2) Excess(i)=Excess(i); else Excess(i)=0; end elseif(F(i)<=H2) Excess(i)=Elec; else Excess(i)=0; end else Excess(i)=0; end if(Extra(i)>=0) if(Extra(i)<=FC) if(F(i)>=Extra(i)) Extra(i)=Extra(i); else Extra(i)=0; end elseif(F(i)>=Extra(i)) Extra(i)=FC; else Extra(i)=0; end else Extra(i)=0; end if(Excess(i)>0) F(i+1)=F(i)+Excess(i); elseif(Extra(i)>0) F(i+1)=F(i)-Extra(i); else F(i+1)=F(i); end end %If excess power is more than capacity of Electrolyser, it should be put %equal to Electrolyser rated power %If extra demand is more than capacity of FC, it should be put %equal to FC rated power %figure,plot(Extra); Dump=B-A; % we just make this vector to get dumped power i=0; while(i<=719) i=i+1; if(Dump(i)>=0) Dump(i)=Dump(i)-Excess(i); %dumped power in any time period is ((B-A)-Excess) else Dump(i)=0; end end %figure,plot(Dump); %disp('Dump='); %disp(Dump); Max_Dump=max(Dump.'); %disp('Max_Dump='); %disp(Max_Dump); Dump_E=cumsum(Dump); %Summation of dumoped power in the scale of time isdumped energy, 52 weeks %in a year Diesel=A-B; % we just make this vector to get extra demand i=0; while(i<=719) i=i+1; if(Diesel(i)>=0) Diesel(i)=Diesel(i)-Extra(i); %Extra demand in any time period is ((A-B)-Extra) else Diesel(i)=0; end end %disp('Diesel='); %disp(Diesel); %figure,plot(Diesel); Diesel_E=cumsum(Diesel); %Summation of extra demand in the scale of time is extra energy in the %system that should be supplied by diesel generators, 52 weeks in a year n=j/q; m=p/r; % n change from 1,2,3,..,20 ACC_T=W*25*ACC_wind+Elec*ACC_Elec+FC*ACC_FC+H2*ACC_H2; %Total ACC: W number of wind turbiens 25kW, Elect number of elec units r %kW, FC number of Fc units with q kW, H2 capacity of tank in kWh ARC_T=Elec*ARC_Elec+FC*ARC_FC; %Elec number of elec units r kW, FC number of Fc units with q kW ACO2_C=CO2_C*20*6*(Diesel_E(720)+400*720)*CRF1; %CO2 Annual cost AFC_T=Diesel_C*20*6*(Diesel_E(720)+400*720)*CRF1+ACO2_C; %fuel consumption in 59 days so 6 cause a year is 12 month, and 20 is %lifetime of project; AOC_T=W*25*AOC_wind+Elec*AOC_Elec+FC*AOC_FC+Diesel_R*AOC_Diesel; %Total AOC: W number of wind turbiens 25kW, Elect number of elec units r %kW, FC number of Fc units with q kW, H2 capacity of tank in kWh Cost(u,n,m)=ACC_T+ARC_T+AFC_T+AOC_T; %Cost(n,m)=W*W_C+Elec*Elec_C+FC*FC_C+PV*PV_C+Diesel_E(48)*Diesel_C+Diesel_E(48)*CO2_C+Max_Dump*Dump_C+H2*H2_C; Load_E=cumsum(A); %Energy Consumed as Load in 2 months Wind_E=cumsum(B1); %Energy produced by wind in 2 months Total_Dump_Energy=6*Dump_E(720);
%Total dumped energy in a year Total_Dump=20*6*Dump_E(720)*Dump_E_C*CRF1; %Total dump cost in a year Total_Load=6*Load_E(720); %Energy cosumed in a year Total_Wind=6*Wind_E(720); %Wind energy produced in a year Hybrid_Electricity_cost=Cost/Total_Load; %Electricity cost in the case of optimum design Only_D_Cost=Diesel_C*20*Total_Load*CRF1; %Annual Cost of system if it operates in diesel mode only Only_D_Electricity_Cost=Only_D_Cost/Total_Load; %Cost of electtricity in diesel only cost CO2_only_Diesel=CO2_E*Total_Load; %CO2 emissions in a year for only diesel case (kg) CO2_Hybrid=6*CO2_E*(Diesel_E(720)+400*720); %CO2 emissions in a year for hybrid system (kg) %Cost includes wind turbines capital cots %Electrolyser capital cost %FC stacks capital cost %energy supplied by diesel units %Dump energy cost % and H2 tank capital cost p=p+r; end j=j+q; end u=u+1; end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!