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 a3f2ebc5 authored by Markus Millinger's avatar Markus Millinger
Browse files

Adapted monteCarlo to work with GAMS in parallel mode. Still need to add a...

Adapted monteCarlo to work with GAMS in parallel mode. Still need to add a check for some faulty runs. Also added an automatic latex version of gams code
parent 7b05a0ea
......@@ -13,8 +13,15 @@
*.spl
*.gpr
*.lxi
*.gdx
*.~gm
Efuels
225*
benopt.gdx
*.json
benopt.pdf
*.ref
src/benopt.txt
interconnectors*
201401_BEniVer_UFZ.pptx
BEniVerProjektFile.dat
......
......@@ -46,6 +46,8 @@
%% \begin{linenumbers}, end it with \end{linenumbers}. Or switch it on
%% for the whole article with \linenumbers.
\usepackage{lineno}
\usepackage{tabularx}
\usepackage{ltablex}
\usepackage[nocomma]{optidef}
\usepackage{lmodern,textcomp}
\usepackage{enumitem}
......@@ -591,22 +593,20 @@ Parameters and decision variables are summarised in Tables \ref{tab:nomenclature
\begin{table*}[!htb]\centering
\begin{footnotesize}
\caption{\footnotesize{Parameters in the modelling. Values are given if they are constant across all dimensions (I=fuel option; F=Feedstock; S=sector; T=time) and scenarios. If the values differ between dimensions and/or scenarios, "Diff" is stated. Decision variables are "Free".}}
\begin{tabular}{l l c l}
\begin{tabular}{l l l l}
\hline
\textbf{Parameters} & \textbf{Symbol} & \textbf{Value} & \textbf{Unit} \\ \hline
Pathway emissions & $\varepsilon_{i,t}$ & Diff & ktCO$_{2}$eq PJ$^{-1}$ \\
Fossil substitute emission & $\varepsilon_{sub,t}$ & 94.1 & ktCO$_{2}$eq PJ$^{-1}$ \\
Ramp minimum & $r_{min}$ & 0.1 & PJ a$^{-1}$ \\
Ramp factor & $r_f$ & 0.5 & - \\
Ramp maximum & $r_{max}$ & 25 & PJ a$^{-1}$ \\
Initial capacity & $\kappa_0$ & Diff & PJ \\
Yield & $Y_{i,t}$ & Diff & PJ$_{feed}$ Mha$^{-1}$ \\
Conversion efficiency & $\eta_{i,t}$ & Diff & PJ$_{fuel}$ PJ$_{feed}^{-1}$ \\
Land use & $\Lambda_{t}$ & Diff & Mha \\
Energy service demand & & & \\
& & & \\
& & & \\
\end{tabular}
\textbf{Parameters} & \textbf{Symbol} & \textbf{Value} & \textbf{Unit} \\ \hline
Pathway emissions & $\varepsilon_{i,t}$ & Diff & ktCO$_{2}$eq PJ$^{-1}$ \\
Fossil substitute emission & $\varepsilon_{sub,t}$ & 94.1 & ktCO$_{2}$eq PJ$^{-1}$ \\
Ramp minimum & $r_{min}$ & 0.1 & PJ a$^{-1}$ \\
Ramp factor & $r_f$ & 0.5 & - \\
Ramp maximum & $r_{max}$ & 25 & PJ a$^{-1}$ \\
Initial capacity & $\kappa_0$ & Diff & PJ \\
Yield & $Y_{i,t}$ & Diff & PJ$_{feed}$ Mha$^{-1}$ \\
Conversion efficiency & $\eta_{i,t}$ & Diff & PJ$_{fuel}$ PJ$_{feed}^{-1}$ \\
Land use & $\Lambda_{t}$ & Diff & Mha \\
Energy service demand & & & \\
\end{tabular}
\label{tab:nomenclatureParams}
\end{footnotesize}
\end{table*}
......@@ -656,6 +656,125 @@ Parameters and decision variables are summarised in Tables \ref{tab:nomenclature
\end{footnotesize}
\end{table*}
%\subsection*{Parameters}
\begin{footnotesize}
\begin{tabularx}{\textwidth}{ l l X }
\hline
\textbf{Name} & \textbf{Domains} & \textbf{Description} \\ \hline
\endhead
market & * & energy markets \\
marketCONV & market & \\
passenger & market & \\
CH4market & market & \\
H2market & market & \\
fuel & * & fuel type options \\
tech & * & technology options \\
techDiesel & tech & tech options diesel \\
techEtOH & tech & tech options ethanol \\
techCH4fuel & tech & tech options methane fuel \\
techLNG & tech & tech options LNG fuel \\
techH2 & tech & tech options H2 fuel \\
techEV & tech & tech options battery electric vehicle \\
techCONVth & tech & technlogies in the sector CONVth \\
techCH4in & tech & technologies that require methane \\
techInter & tech & technologies that require intermediate CH4 or H2 \\
biomass & * & biomass options \\
biomassResidue & biomass & biomass options residues \\
biomassCrop & biomass & biomass options crop based \\
powerMix & biomass & feedstock power mix \\
powerRes & biomass & feedstock power residue options \\
cat & * & feedstock price categories \\
year & * & global year time \\
t & year & model year time points \\
d & * & model time steps intra year \\ \hline
\end{tabularx}
\begin{tabularx}{\textwidth}{ l l X }
\hline
\textbf{Name} & \textbf{Domains} & \textbf{Description} \\ \hline
\endhead
rampF & $r_f$ & capacity expansion ramp per year \\
rampMinGW & & minimum capacity expansion ramp per year [GW] \\
rampMin & & minimum capacity expansion ramp per year [PJ] \\
rampMinVehicles & & minimum vehicle expansion ramp per year [PJ] \\
landF & & land use expansion ramp per year \\
rampFvehicles & & vehicle fuel type expansion per year \\
landMin & & minimum land use expansion per year [ha] \\
lifeTvehicles & & Vehicle life time \\
ghgTarget & & GHG target \\
dMax & & number of time steps intra year \\
ghgRefCO2 & & GHG reference for input CO2 (ktCO2eq per MtCO2 - 1000 or zero) \\
pwrMixMax & & Maximum power usage from mix for EVs and H2 production (PJ) \\
landMax & year & arable land limit [ha] \\
demand & year, market & demand matrix [PJ] \\
costInvLevel & year, tech & investment cost levelized [MioEuro per GW] \\
costMarg & year, tech & marginal cost [Mio\texteuro per PJ] \\
capF & year, tech & capacity factor development [frac] \\
cap0 & year, tech & initial capacity (continuously decommissioned) [GW] \\
landDmdPJ & year, biomassCrop & Land demand (ha per PJ fuel\_Power\_Heat) \\
feedLandUseInit & biomassCrop & Feed land use initial [ha] \\
convEta & year, tech & Energetic conversion efficiency crop to main energy carrier (PJ\_energy per PJ\_crop) \\
convEtaBiomSpec & year, biomass, tech & Energetic conversion efficiency crop to main energy carrier (PJ\_energy per PJ\_crop) for each biomass type \\
bioResPot & year, biomassResidue & Biomass residue potential (PJ feed) \\
bioResPotImport & year, biomass & Biomass residue potential (PJ feed) \\
resImportMax & year & Maximal residual biomass import (PJ) \\
biomassPrice & year, biomass, cat & Biomass price (MioEuro per PJ feed) \\
biomassPriceImport & year, biomass & Biomass price import (MioEuro per PJ feed) \\
heatByprod & year, tech & Heat byproduct per unit of main product (PJ per PJ) \\
lifeT & tech & capacity lifetime for each technology \\
powerPrice & year, tech & power price for each sector (Mio \texteuro per MWh) \\
heatPrice & year & heat price development (Mio \texteuro per MWh) \\
powerInput & tech & power input (MWh per PJ) \\
heatInput & tech & heat input (MWh per PJ) \\
CO2input & tech & CO2 feedstock input (Mt per PJ) \\
CO2price & year & CO2 feedstock price (Mio \texteuro per Mt) \\
H2input & year, tech & H2 feedstock input (PJ per PJ) \\
H2Max & year, market & Maximal H2 share development in each sector \\
CH4Max & year, market & Maximal CH4 share development in each sector \\
LCH4Max & year, market & Maximal LCH4 (LNG) share development in each sector \\
CO2source & year & CO2 feedstock maximum source (Mt) \\
ghgEmisFeed & year, biomassCrop & ktCO2eq per PJ \\
ghgEmisT1 & year & ktCO2eq per PJ \\
ghgEmisGateWheel & year, tech & ktCO2eq per PJ \\
powerMixEmis & year & ktCO2eq per PJ \\
ghgRef & year, market & ktCO2eq per PJ \\
historicFuelDemand & year, fuel & MATLAB data from GDXMRW \\
newVehicSharePass & year & share of new vehicles yearly in the passenger road sector \\
residualLoad & d, year & residualLoad \\
posResLoad & d, year & positive residual load = demand for dispatchable power \\
vehicleKMroadTot & * & total vehicle km in passenger road sector \\
MJperKMavgICEV & * & fuel economy baseline passenger road sector \\
relativeFuelEconomy & tech, market & relative fuel economy between fuels in passenger road sector \\ \hline
\end{tabularx}
%\subsection*{Variables}
\begin{tabularx}{\textwidth}{ l l X }
\hline
\textbf{Name} & \textbf{Domains} & \textbf{Description} \\ \hline
\endhead
cost & & Total system cost (M\texteuro) \\
costAnnual & * & Total system cost (M\texteuro annually) \\
ghgAbatement & & Total GHG abatement (ktCO2eq per PJ) \\
ghgAbateTech & year, tech & technology GHG abatement (ktCO2eq per year) \\
inst & year, tech & new installed capacity [GW] \\
deco & year, tech & capacity decommission [GW] \\
cap & year, tech & capacity [GW] \\
capNew & year, tech & endogenously installed standing capacity [GW] \\
prd & year, tech, market & production (PJ) \\
prdDaily & year, d, tech, market & dispatchable power production (PJ) \\
biomassUse & year, tech, biomass, cat & biomass used (PJ) \\
residualLoadUse & d, year & residualLoad use \\
dispatchPrd & d, year & dispatchable power production \\
CO2use & year & CO2 used (Mton) \\
powerUseDaily & year, d, tech, biomass & power used daily (PJ) \\
biomassUseImport & year, tech, biomass & biomass import used (PJ) \\
newVehicles & year, market, fuel & new vehicle fuel demand development \\
vehiclePark & year, market, fuel & vehicle park demand per fuel (PJ) \\
decomVehicles & year, market, fuel & vehicle fuel type decommission (PJ) \\
costTech & year, tech & technology cost incl CAPEX and OPEX (M\texteuro per year) \\ \hline
\end{tabularx}
\end{footnotesize}
\end{document}
\endinput
%%
......
This diff is collapsed.
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*% BENOPT (BioENergy OPTimisation model)
*% Copyright (C) 2012-2020 Markus Millinger, Matthias Jordan
*%
*%
*% This program is free software: you can redistribute it and/or modify
*% it under the terms of the GNU General Public License as published by
*% the Free Software Foundation, either version 3 of the License, or
*% (at your option) any later version.
*%
*%
*% This program is distributed in the hope that it will be useful,
*% but WITHOUT ANY WARRANTY; without even the implied warranty of
*% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*% GNU General Public License for more details.
*%
*%
*% You should have received a copy of the GNU General Public License
*% along with this program. If not, see <https://www.gnu.org/licenses/>.
*%
*%
*% Contact: markus.millinger@ufz.de
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
$set matout "'matsol.gdx', prd, cost, costAnnual, inst, biomassUse, biomassUseImport, TS, cap, ghgAbatement, residualLoadUse, CO2use, costTech, ghgAbateTech, prdDaily, dispatchPrd, returnstat";
*$set matout "'matsol.gdx', prd, cost, costAnnual, inst, biomassUse, biomassUseImport, TS, cap, ghgAbatement, residualLoadUse, CO2use, costTech, ghgAbateTech, prdDaily, dispatchPrd, returnstat";
$gdxin matdata.gdx
......@@ -138,7 +138,7 @@ landMax(year) arable land limit [ha]
demand(year,market) demand matrix [PJ]
costInv(year,tech) investment cost [MioEuro per GW]
costInvLevel(year,tech) investment cost levelized [MioEuro per GW]
costMarg(year,tech) marginal cost [Mio per PJ]
costMarg(year,tech) marginal cost [Mio EUR per PJ]
capF(year,tech) capacity factor development [frac]
cap0(year,tech) initial capacity (continuously decommissioned) [GW]
landDmdPJ(year,biomassCrop) Land demand (ha per PJ fuel_Power_Heat)
......@@ -149,15 +149,15 @@ bioResPot(year,biomassResidue) Biomass residue potential (PJ f
bioResPotImport(year,biomass) Biomass residue potential (PJ feed)
resImportMax(year) Maximal residual biomass import (PJ)
biomassPrice(year,biomass,cat) Biomass price (MioEuro per PJ feed)
biomassPriceImport(year,biomass) Biomass price import (MioEuro per PJ feed)
biomassPriceImport(year,biomass) Biomass price import (Mio EUR per PJ feed)
heatByprod(year,tech) Heat byproduct per unit of main product (PJ per PJ)
lifeT(tech) capacity lifetime for each technology
powerPrice(year,tech) power price for each sector (Mio per MWh)
heatPrice(year) heat price development (Mio per MWh)
powerPrice(year,tech) power price for each sector (Mio EUR per MWh)
heatPrice(year) heat price development (Mio EUR per MWh)
powerInput(tech) power input (MWh per PJ)
heatInput(tech) heat input (MWh per PJ)
CO2input(tech) CO2 feedstock input (Mt per PJ)
CO2price(year) CO2 feedstock price (Mio per Mt)
CO2price(year) CO2 feedstock price (Mio EUR per Mt)
H2input(year,tech) H2 feedstock input (PJ per PJ)
H2Max(year,market) Maximal H2 share development in each sector
CH4Max(year,market) Maximal CH4 share development in each sector
......@@ -187,9 +187,11 @@ $loadR residualLoad, CO2input, H2input, CO2source, CO2price, ghgTarget, dMax, H2
$loadR newVehicSharePass, pwrMixMax, vehicleKMroadTot, MJperKMavgICEV, relativeFuelEconomy, posResLoad, solveOption
*newICEVPJ, vehicleCostPerGJfuel,
$gdxin
FREE VARIABLES
cost Total system cost (M)
costAnnual Total system cost (M annually)
cost Total system cost (M EUR)
costAnnual Total system cost (M EUR annually)
costImportAnnual Total system cost import fuel and power (annual)
prodMinusImportAnnual Total production minus imports (annual)
ghgAbatement Total GHG abatement (ktCO2eq per PJ)
......@@ -212,7 +214,7 @@ transportFuelDemand(year,market,fuel) total transport fuel demand dev
newVehicles(year,market,fuel) new vehicle fuel demand development
vehiclePark(year,market,fuel) vehicle park demand per fuel (PJ)
decomVehicles(year,market,fuel) vehicle fuel type decommission (PJ)
costTech(year,tech) technology cost incl CAPEX and OPEX (M per year)
costTech(year,tech) technology cost incl CAPEX and OPEX (M EUR per year)
capFout(year,tech) capacity factor resulting from prd per cap
;
......@@ -307,7 +309,7 @@ vehicleExpRampAllCH4
vehicleExpRampAllLNG
vehicleExpRampAllH2
costTechEq technology cost incl. biomass and levelized investment yearly (M)
costTechEq technology cost incl. biomass and levelized investment yearly (M EUR)
GHGabateTechEq technology GHG abatement yearly (ktCO2eq)
totCost total cost
......@@ -474,7 +476,8 @@ elseif solveOption=0,
*returnStat('solvestat') = benopt.solvestat;
returnStat('modelstat') = benopt.modelstat;
Display prd.l,inst.l,deco.l,cap.l,cost.l,biomassUse.l,deco.l,biomassUseImport.l,
newVehicles.l,vehiclePark.l,CO2use.l,powerUseDaily.l,residualLoadUse.l,prdDaily.l,dispatchPrd.l;
newVehicles.l,vehiclePark.l,CO2use.l,powerUseDaily.l,residualLoadUse.l,prdDaily.l,dispatchPrd.l,returnStat;
execute_unload %matout%;
*execute_unload %matout%;
This diff is collapsed.
......@@ -25,12 +25,13 @@ tic
if contains(version,'ghgMax')
gamsTemp.ghgTarget.val = 1;
gamsTemp.solveOption.val = 0;
solName = ['matsol' num2str(scenario) '1'];
elseif contains(version,'costMin')
gamsTemp.solveOption.val = 1;
solName = ['matsol' num2str(scenario) '1'];
end
gams('benopt',...
g.d,g.C,g.I,g.J,g.F,g.B,g.BR,g.BF,g.tb,g.ts,g.fuelType,g.PwrSrc,g.PwrMix,g.PwrRes,...
wgdx('matdata.gdx',g.d,g.C,g.I,g.J,g.F,g.B,g.BR,g.BF,g.tb,g.ts,g.fuelType,g.PwrSrc,g.PwrMix,g.PwrRes,...
g.tDiesel,g.tEtOH,g.tCH4,g.tLNG,g.tH2,g.tEV,g.tAviationFuel,...
gamsTemp.costMarg,...
gamsTemp.costInv,...
......@@ -77,17 +78,24 @@ end
gamsTemp.MJperKMavgICEV,...
gamsTemp.relativeFuelEconomy,... gamsTemp.vehicleCostPerGJfuel,...
gamsTemp.posResLoad,...
gamsTemp.solveOption);%#ok<*SAGROW>
gamsTemp.solveOption);
system(['gams benopt.gms gdx=' solName]); %lo=3
% gams('benopt',...
% );%#ok<*SAGROW>
toc
% Test if problem is infeasible
% statstr.name = 'returnstat';
% gamsOut.stat = rgdx('matsol', statstr);
% if gamsOut.stat.val(1,2)~=1
% %if stat.val(1,1)~=1 || stat.val(2,1)~=1
% % Test if problem is infeasible
statstr.name = 'returnstat';
gamsOut.stat = rgdx(solName, statstr);
sdfdf = gamsOut.stat.val
% size(sdfdf)
% % if gamsOut.stat.val(1,1)~=1
% if stat.val(1,1)~=1 || stat.val(1,2)~=1
% error('Problem infeasible!')
% %end
% end
% end
% Import results from GAMS
......@@ -95,7 +103,7 @@ end
TS2str.uels = {s.techNames, s.sectorNames};
TS2str.name = 'TS';
TS2str.form = 'full';
TS2data = rgdx('matsol', TS2str);
TS2data = rgdx(solName, TS2str);
g.TS2=cell(1,10);
for j=1:s.numSectors
......@@ -105,84 +113,84 @@ end
prdstr.uels = {strsplit(num2str(s.year)), s.techNames, s.sectorNames};
prdstr.name = 'prd';
prdstr.form = 'full';
prd = rgdx('matsol', prdstr);
prd = rgdx(solName, prdstr);
gamsOut.prd=prd.val;
inststr.uels = {strsplit(num2str(s.year)), s.techNames};
inststr.name = 'inst';
inststr.form = 'full';
instCap = rgdx('matsol', inststr);
instCap = rgdx(solName, inststr);
gamsOut.instCap=instCap.val;
coststr.name = 'cost';
coststr.form = 'full';
cost = rgdx('matsol', coststr);
cost = rgdx(solName, coststr);
gamsOut.cost=cost.val;
costAnnualstr.uels = {strsplit(num2str(s.year))};
costAnnualstr.name = 'costAnnual';
costAnnualstr.form = 'full';
costAnnual = rgdx('matsol', costAnnualstr);
costAnnual = rgdx(solName, costAnnualstr);
gamsOut.costAnnual=costAnnual.val;
biomassstr.uels = {strsplit(num2str(s.year)), s.techNames, f.biomassNames,g.cats};
biomassstr.name = 'biomassUse';
biomassstr.form = 'full';
biomassUse = rgdx('matsol', biomassstr);
biomassUse = rgdx(solName, biomassstr);
gamsOut.biomassUse=biomassUse.val;
biomassImportstr.uels = {strsplit(num2str(s.year)), s.techNames, f.biomassNames};
biomassImportstr.name = 'biomassUseImport';
biomassImportstr.form = 'full';
biomassUseImport = rgdx('matsol', biomassImportstr);
biomassUseImport = rgdx(solName, biomassImportstr);
gamsOut.biomassUseImport=biomassUseImport.val;
capstr.uels = {strsplit(num2str(s.year)), s.techNames};
capstr.name = 'cap';
capstr.form = 'full';
capCAP = rgdx('matsol', capstr);
capCAP = rgdx(solName, capstr);
gamsOut.capCAP=capCAP.val;
costTechstr.uels = {strsplit(num2str(s.year)), s.techNames};
costTechstr.name = 'costTech';
costTechstr.form = 'full';
costTech = rgdx('matsol', costTechstr);
costTech = rgdx(solName, costTechstr);
gamsOut.techCost = costTech.val; %unit: M /year
ghgAbateTechstr.uels = {strsplit(num2str(s.year)), s.techNames};
ghgAbateTechstr.name = 'ghgAbateTech';
ghgAbateTechstr.form = 'full';
ghgAbateTech = rgdx('matsol', ghgAbateTechstr);
ghgAbateTech = rgdx(solName, ghgAbateTechstr);
gamsOut.ghgAbateTech = ghgAbateTech.val; %unit: ktCO2eq
%
% capFoutstr.uels = {strsplit(num2str(s.year)), s.techNames};
% capFoutstr.name = 'capFout';
% capFoutstr.form = 'full';
% capFout = rgdx('matsol', capFoutstr);
% capFout = rgdx(solName, capFoutstr);
% gamsOut.capFout = capFout.val;
powerResUsestr.uels = {strsplit(num2str(1:1:max(g.timeStepsIntraYear))), strsplit(num2str(s.year))};
powerResUsestr.name = 'residualLoadUse';
powerResUsestr.form = 'full';
powerResUse = rgdx('matsol', powerResUsestr);
powerResUse = rgdx(solName, powerResUsestr);
gamsOut.powerResUse = powerResUse.val;
dispatchPrdstr.uels = {strsplit(num2str(s.year)), strsplit(num2str(1:1:max(g.timeStepsIntraYear))), s.techNames, s.sectorNames};
dispatchPrdstr.name = 'prdDaily';
dispatchPrdstr.form = 'full';
dispatchPrd = rgdx('matsol', dispatchPrdstr);
dispatchPrd = rgdx(solName, dispatchPrdstr);
gamsOut.dispatchPrd = dispatchPrd.val;
CO2Usestr.uels = {strsplit(num2str(s.year))};
CO2Usestr.name = 'CO2use';
CO2Usestr.form = 'full';
CO2Use = rgdx('matsol', CO2Usestr);
CO2Use = rgdx(solName, CO2Usestr);
gamsOut.CO2Use=CO2Use.val;
if contains(version,'ghgMax')
ghgAbatementstr.name = 'ghgAbatement';
ghgAbatementstr.form = 'full';
ghgTarget = rgdx('matsol', ghgAbatementstr);
ghgTarget = rgdx(solName, ghgAbatementstr);
gamsOut.ghgTarget=ghgTarget.val;
end
......
......@@ -63,10 +63,10 @@ for scenario = 1:noScenarios
% save(['../data/powerData' countryID '.mat'],'powerDataCountry'); %Save to .mat-file - comment out if the .mat-file is up to date
powerDataCountry = importdata(['../data/powerData' countryID '.mat']); %reads data from .mat file
[f,g,s] = setCountryData(techData,countryID,powerDataCountry,s,f);
[f,g,s] = setCountryData(techData,countryID,powerDataCountry,s,f); %Set country specific data
%Set variables
[f,g,s] = setData2(techData,f,g,s);
[f,g,s] = setData(techData,f,g,s);
%Calculate GHG emissions
[s,f] = ghgEmissions(s,f);
......@@ -75,7 +75,6 @@ for scenario = 1:noScenarios
% [monteCarloOut,weatherYear,H2,runTimeGAMS,timeSteps,EVfactor,dRate,CO2source,H2max,landMax,CO2Use]...
% =
monteCarlo(100,s,f,g,techData);
%% Scenario loop
switch scenario
case 1 %Base scenario
......
......@@ -24,10 +24,11 @@
function monteCarlo(iter,s,f,g,techDataIn)
% [mcVar,weatherYear,H2,runTimeGAMS,timeSteps,EVfactor,dRate,CO2source,H2max,landMax,CO2Use]
% delete(gcp)
% parpool('local',2)
delete(gcp('nocreate'))
parpool('local',2)
%%Monte Carlo Simulation
% par
for simNum=1:iter
parfor simNum=1:iter
%First, create sliced variables, which can run in parallel. All input
%variables need new variable names. Only first order brackets work
......@@ -39,11 +40,11 @@ for simNum=1:iter
%Set variables
[b,c,a] = setData2(techData,b,c,a);
[b,c,a] = setData(techData,b,c,a);
c.timeStepsIntraYear = 1:50;%(1+randi(49));
timeS = c.timeStepsIntraYear(end);
simNum
% timeS = c.timeStepsIntraYear(end);
% simNum
a.EVfactor = 0.8+0.2*rand;
a.discountRateInvest = 0 + 0.1*rand;
a.co2source = a.co2source.*linspace(0,(0.1+0.2*rand),s.runTime);
......@@ -91,14 +92,16 @@ for simNum=1:iter
% Define GAMS parameters
[gamsTemp,c] = gamsVar(a,b,d,e,simNum,c,techData);
% Run GAMS GHG abatement maximization
[gamsOutGHG,g] = gamsRun(a,b,c,simNum,iter,gamsTemp,'ghgMax');
% Run GAMS GHG abatement maximization (the GAMS call has to be
% modified to work in parallel as currently only one .gdx file per
% GAMS-file is allowed)
[gamsOutGHG,c] = gamsRun(a,b,c,simNum,iter,gamsTemp,'ghgMax');
%Set GHG budget for cost minimization
gamsTemp.ghgTarget.val = 0.9*gamsOutGHG.ghgTarget;
% Run GAMS cost minimization
[gamsOutCost,g] = gamsRun(a,b,c,simNum,iter,gamsTemp,'costMin');
[gamsOutCost,c] = gamsRun(a,b,c,simNum,iter,gamsTemp,'costMin');
% runTimeGAMS(simNum) = toc;
mcVar(simNum) = gamsOutCost;
......
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BENOPT (BioENergy OPTimisation model)
% Copyright (C) 2012-2020 Markus Millinger
%
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <https://www.gnu.org/licenses/>.
%
%
% Contact: markus.millinger@ufz.de
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% Function for setting the data
%
function [f,g,s] = setData(techData)
function [f,g,s] = setData(techData,f,g,s)
s.numTech = size(techData.data.techInputData(1,:),2);
s.techNames = techData.textdata.techInputData(2,3:s.numTech+2);
s.techNamesLegend = s.techNames;
s.numSectors = 11;
s.sectorNames = techData.textdata.techInputData(125:135,2)';
s.sectorNamesLegend = s.sectorNames;
s.fuelNames = techData.textdata.techInputData(136:142,2)';
f.numResidue = 12;
f.residueNames = techData.textdata.biomassResPot(2:f.numResidue+1,1)';
f.numFeed = size(techData.data.feedstockInputData(1,1:end),2);
f.feedNames = techData.textdata.feedstockInputData(1,3:f.numFeed+2);
......@@ -44,12 +43,10 @@ f.biomassNames = [f.feedNames f.residueNames f.powerNames];
%% Definition of Input Data s= Technology specific f=feedstock specific
%Discount rate
s.discountRateInvest = 0.05;
s.inflation = 0;
s.plantPayBackTime = 20;
s.dieselCostStart = 0.9; %/l
s.labourCostStart = 15; %/h
s.referenceGHGemission = 94.1; %kgCO2/GJ
f.wheatPriceStart = 189;% %/tFM
......@@ -62,52 +59,61 @@ s.hourYear = linspace(1,8760,8760);
s.dayYear = linspace(1,365,365);
%Set parameters for power sector
s.RENMustRun = 2483; %Hydro average over year
s.MustRun = 0; %Must-run electriticy generation capacity
g.timeStepsIntraYear = 1:50; %up to 8760 possible (heavy on run-time)
s.onShore = round(linspace(54,170,7)); %GW capacity from start year to end year in 5-year steps
s.offShore = round(linspace(7.5,54,7)); %GW
s.photoV = round(linspace(49,200,7)); %GW
s.demandPower = round(linspace(513,700,7)); %GW
s.powerStorage = linspace(9000,30000,7); %GW
s.powerStorageMax = linspace(66000,100000,7); %GWh
%Set parameters for crops
s.priceDevFactor = 0.04; % frac/a
g.landMax = 10^6.*linspace(1,1,s.runTime); %ha
%Set restrictions for fuel types in sectors
%--Hydrogen
g.H2maxShipping = linspace(0,0.1,s.runTime); %Share of market
g.H2maxGoods = linspace(0,0.3,s.runTime); %Share of market
g.H2maxAviation = linspace(0,0.1,s.runTime); %Share of market
%--Methane
g.CH4maxLand = linspace(0,0,s.runTime); %Share of market
g.CH4maxShipping = linspace(0,0,s.runTime); %Share of market
g.CH4maxGoods = linspace(0,0.3,s.runTime); %Share of market
%--Liquefied Methane