The UFZ services GitLab and Mattermost will be unavailable on Monday, July 4 from 06:00 AM to 08:00 AM due to maintenance work.

Commit 1d734eb8 authored by Markus Millinger's avatar Markus Millinger
Browse files

Updater vrePower, removed redundant code

parent d935a361
......@@ -27,9 +27,9 @@ close all;
%% Data Import
% Conversion options, biomass crops and residues and other data
% techData = ...
% importdata('../data/BENOPT_inputData_200409.xls'); %Save to variable - comment out if the .mat-file is up to date
% save('../data/techData.mat','techData'); %Save to .mat-file - comment out if the .mat-file is up to date
techData = ...
importdata('../data/BENOPT_inputData_200409.xls'); %Save to variable - comment out if the .mat-file is up to date
save('../data/techData.mat','techData'); %Save to .mat-file - comment out if the .mat-file is up to date
techData = ...
importdata('../data/techData.mat'); %reads data from .mat file
......@@ -37,9 +37,6 @@ techData = ...
techData.data.techInputData(isnan(techData.data.techInputData)) = 0;
techData.data.feedstockInputData(isnan(techData.data.feedstockInputData)) = 0;
%Read power system data for each region in 60 min resolution
% powerData = readtable('../data/time_series_60min_singleindex.csv');
%% Scenario parameter calculation and optimisation in GAMS
noScenarios = 1;
......@@ -68,7 +65,7 @@ for scenario = 1:noScenarios
f.wheatPriceStart = 189;% %/tFM
f.rapeSeedPriceStart = 381;% %/tFM
s.erePriceShare = 1; %Excess electricity price (share of power mix price) 0-1 (same price as power mix)
s.erePriceShare = 0.7; %Excess electricity price (share of power mix price) [0,1] (1=same price as power mix)
s.runTime = 2051-2020;
......@@ -77,15 +74,21 @@ for scenario = 1:noScenarios
%Set country specific data
countryID = 'SE';
s.weatherYear = {'2018'};
% powerDataCountry = ...
% powerData(contains(powerData.cet_cest_timestamp,s.weatherYear),...
% contains(powerData.Properties.VariableNames,countryID));
% save(['../data/powerData' countryID '.mat'],'powerDataCountry'); %Save to .mat-file - comment out if the .mat-file is up to date
s.weatherYear = {'2017'};
fileID = strjoin([countryID s.weatherYear],'_');
if isfile(['../data/powerData' fileID '.mat'])
powerDataCountry = ... %reads data from .mat file
importdata(['../data/powerData' fileID '.mat']);
else
%Read power system data for each region in 60 min resolution
powerData = readtable('../data/time_series_60min_singleindex.csv');
powerDataCountry = ... %Save to .mat-file
powerData(contains(powerData.cet_cest_timestamp,s.weatherYear),...
contains(powerData.Properties.VariableNames,countryID));
save(['../data/powerData' fileID '.mat'],'powerDataCountry');
end
powerDataCountry = ...
importdata(['../data/powerData' countryID '.mat']); %reads data from .mat file
[f,g,s] = ...
setCountryData(techData,countryID,powerDataCountry,s,f,g); %Set country specific data
......
......@@ -958,8 +958,8 @@ residualTotYear = round(sum(s.posResLoad(:,[2020 2030 2040 2050]-2019,1)))
% title('Residual load curves for selected years')
xlabel('Hour')
ylabel('Residual load curves (GW)')
legend(['2020, ERE = ' num2str(surplusTotYear(1)) ' TWh, residual = ' num2str(residualTotYear(1)) ' TWh'],...
['2030, ERE = ' num2str(surplusTotYear(2)) ' TWh, residual = ' num2str(residualTotYear(2)) ' TWh'],...
legend(['2020, ERE = ' num2str(surplusTotYear(1)) ' TWh, residual = ' num2str(residualTotYear(1)) ' TWh'],...
['2030, ERE = ' num2str(surplusTotYear(2)) ' TWh, residual = ' num2str(residualTotYear(2)) ' TWh'],...
['2040, ERE = ' num2str(surplusTotYear(3)) ' TWh, residual = ' num2str(residualTotYear(3)) ' TWh'],...
['2050, ERE = ' num2str(surplusTotYear(4)) ' TWh, residual = ' num2str(residualTotYear(4)) ' TWh'],'Location','SouthEast')
picName='../fig/resLoadCurve';
......
......@@ -90,17 +90,17 @@ s.ghgEFPowerData = techData.data.countryData(210:213,indexCountry)'
s.powerLoad = powerDataCountry{:,contains(powerDataCountry.Properties.VariableNames,join([countryID,'_load_actual_entsoe_power_statistics']))};
s.PVcap = powerDataCountry{:,contains(powerDataCountry.Properties.VariableNames,join([countryID,'_solar_cap']))};
if isempty(s.PVcap)==1 %if the data does not exist for the country/year, use the given initial capacity as approximation (the set weather year should not be too far off the capacity year for this to work properly)
s.PVcap = s.solarPVInit.*ones(8760,1);
s.PVcap = s.solarPVInit.*ones(8760,1)*1000; %GW->MW
end
s.PVgen = powerDataCountry{:,contains(powerDataCountry.Properties.VariableNames,join([countryID,'_solar_gen']))};
s.WindOnCap = powerDataCountry{:,contains(powerDataCountry.Properties.VariableNames,join([countryID,'_wind_onshore_cap']))};
if isempty(s.WindOnCap)==1
s.WindOnCap = s.windOnShoreInit.*ones(8760,1);
s.WindOnCap = s.windOnShoreInit.*ones(8760,1)*1000; %GW->MW
end
s.WindOnGen = powerDataCountry{:,contains(powerDataCountry.Properties.VariableNames,join([countryID,'_wind_onshore_gen']))};
s.WindOffCap = powerDataCountry{:,contains(powerDataCountry.Properties.VariableNames,join([countryID,'_wind_offshore_cap']))};
if isempty(s.WindOffCap)==1
s.WindOffCap = s.windOffShoreInit.*ones(8760,1);
s.WindOffCap = s.windOffShoreInit.*ones(8760,1)*1000; %GW->MW
end
s.WindOffGen = powerDataCountry{:,contains(powerDataCountry.Properties.VariableNames,join([countryID,'_wind_offshore_gen']))};
if isempty(s.WindOffGen)==1
......
......@@ -52,16 +52,16 @@ s.dayYear = linspace(1,365,365);
%% Set parameters for power sector
%Onshore wind capacity [GW] from start year to end year in 5-year steps
s.onShore = round(linspace(s.windOnShoreInit,s.windOnShoreEnd,7));
s.onShore = linspace(s.windOnShoreInit,s.windOnShoreEnd,7);
%Offshore
s.offShore = round(linspace(s.windOffShoreInit,s.windOffShoreEnd,7)); %GW
s.offShore = linspace(s.windOffShoreInit,s.windOffShoreEnd,7); %GW
%Photovoltaics
s.photoV = round(linspace(s.solarPVInit,s.solarPVEnd,7)); %GW
s.photoV = linspace(s.solarPVInit,s.solarPVEnd,7); %GW
%Power demand total for a year
s.demandPower = round(linspace(s.demandPowerInit,s.demandPowerEnd,7)); %GW
s.demandPower = linspace(s.demandPowerInit,s.demandPowerEnd,7); %GW
%Power storage effect
s.powerStorage = linspace(s.powerStorageInit,s.powerStorageEnd,7); %GW
......
......@@ -29,25 +29,13 @@ for i=1:7
Demand = powerLoad'*(totLoadPower(i)/totLoadPower(1));
S15_S = PVcapFacInst(i,:);
S15_E = powerLoad';
S15_W = powerLoad';
W15_B = WindOncapFacInst(i,:);
W15_A = powerLoad';
W15_O = WindOffcapFacInst(i,:);
S_S= S15_S(:);
S_E= S15_E(:);
S_W= S15_W(:);
W_B= W15_B(:);
W_A= W15_A(:);
W_O= W15_O(:);
RENshareexport = [ ];
RENsharestorageexport = [ ];
RENsharedynstorageexport = [ ];
S_S = PVcapFacInst(i,:)';
S_E = powerLoad*0;
S_W = powerLoad*0;
W_B = WindOncapFacInst(i,:)';
W_A = powerLoad*0;
W_O = WindOffcapFacInst(i,:)';
%check for Demand - MustRun < 0
% if Demand in any time is already served by Mustrun, RENshare
% calculations are not correct
......@@ -86,9 +74,6 @@ for i=1:7
w_B= CAPFAC.*(w_B_loop-1);%[CAPFAC * (w_B_loop-1) ];
w_A= CAPFAC.*(w_A_loop-1);%[CAPFAC * (w_A_loop-1) ];
w_O= CAPFAC.*(w_O_loop-1);%[CAPFAC * (w_O_loop-1) ];
%x_s= [8.31281780492601 ; 5.55040489988835]
%x_s = [4.20451047966732 ; 1.72446329872413]
%resulting feed-in
S_S_scaled = S_S.*s_S;
......@@ -98,26 +83,20 @@ for i=1:7
W_A_scaled = W_A.*w_A;
W_O_scaled = W_O.*w_O;
% [size(Demand);size(S_S_scaled);size(S_E_scaled);size(S_W_scaled);size(W_B_scaled);size(W_A_scaled);size(W_O_scaled);size(MustRun);size(RENMustRun)]
%resulting RL
RL= Demand' - S_S_scaled - S_E_scaled - S_W_scaled - W_B_scaled - W_A_scaled - W_O_scaled - MustRun - RENMustRun;
% 3 year balances of 1h values [MWh/a]
SumDemand = sum(Demand)/(1);
SumS = ( sum(S_S_scaled) + sum(S_E_scaled) + sum(S_W_scaled) ) /(1);
SumW = ( sum(W_B_scaled) + sum(W_A_scaled) + sum(W_O_scaled) ) /(1);
SumDemand = sum(Demand);
SumS = ( sum(S_S_scaled) + sum(S_E_scaled) + sum(S_W_scaled) );
SumW = ( sum(W_B_scaled) + sum(W_A_scaled) + sum(W_O_scaled) );
%SumRL = sum(RL)/(3)
% calculation sum for all elements RL < 0
% or alternatively "sum (RL (RL<=0)) / 1"
SumnegRL = 0;
%SumposRL = 0;
% [size(S_S_scaled);size(S_E_scaled);size(S_W_scaled);size(W_B_scaled);size(W_A_scaled);size(W_O_scaled);size(MustRun);size(RENMustRun)]
for k=1:length(powerLoad)
if ( Demand(k) - (S_S_scaled(k) + S_E_scaled(k) + S_W_scaled(k) + W_B_scaled(k) + W_A_scaled(k) + W_O_scaled(k)+ MustRun + RENMustRun ) ) < 0
......@@ -125,10 +104,8 @@ for i=1:7
% elseif Demand(k) - (Sscaled(k) + Wscaled(k)) > 0
% SumposRL = SumposRL + ( Demand(k) - ( Sscaled(k) + Wscaled(k) ) / (3) );
end
end
%%
% Storage model parametrization
......@@ -265,35 +242,7 @@ for i=1:7
RENshare(i) = 1 - ((SumposRL + (length(powerLoad) * MustRun)/ 1 ) / SumDemand ) ;
% disp('REN share without storage '); disp(RENshare);
% disp('SumnegRL'); disp(SumnegRL);
% disp('SumposRL'); disp(SumposRL);
% disp('SumnegMustRun'); disp(SumnegMustRun);
%disp(s_S-loop * w_B_loop)
%G = SumnegRL + SumDemand;
%disp('G'); disp(G);
%RLexport = RLexport(:);
RENshareexport = [RENshareexport RENshare(i)];
RENsharestorageexport = [RENsharestorageexport RENsharestorage];
RENsharedynstorageexport = [RENsharedynstorageexport RENsharedynstorage];
RENsharematrix (s_S_loop,w_B_loop) = RENshare(i);
RENsharestoragematrix (s_S_loop,w_B_loop) = RENsharestorage(i);
RENsharedynstoragematrix (s_S_loop,w_B_loop) = RENsharedynstorage(i);
SumnegRLmatrix (s_S_loop,w_B_loop) = SumnegRL;
RENsharedifferencestorageexport = RENsharedynstoragematrix - RENsharematrix;
residualLoad(:,i) = RLafterstorage;
end
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment