/
EOLES_elecRES_compact.gms
311 lines (302 loc) · 15.5 KB
/
EOLES_elecRES_compact.gms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
*-------------------------------------------------------------------------------
* Defining the sets
*-------------------------------------------------------------------------------
sets
h 'all hours' /0*166439/
step 'variable time step TO BE MODIFIED' /0*28026/
first(step) 'first hour'
last(step) 'last hour'
m 'month' /1*228/
tec 'technology' /offshore, onshore, pv, river, lake, biogas, gas, phs, battery, methanation/
gen(tec) 'power plants' /offshore, onshore, pv, river, lake, biogas, gas/
vre(tec) 'variable tecs' /offshore, onshore, pv, river/
ncomb(tec) 'non-combustible generation' /offshore, onshore, pv, river, lake, phs, battery/
comb(tec) 'combustible generation techs' /biogas, methanation/
str(tec) 'storage technologies' /phs, battery, methanation/
frr(tec) 'technologies for upward FRR' /lake, phs, battery, gas/
;
first(step) = ord(step)=1;
last(step) = ord(step)= card(step);
*-------------------------------------------------------------------------------
* Inputs
*-------------------------------------------------------------------------------
$Offlisting
$ondelim
parameter first_hour(step) 'the first hour of each timestep (included in the timestep)'
/
$include inputs/first_hour.csv
/;
parameter last_hour(step) 'the last hour of each timestep (not included in the timestep)'
/
$include inputs/last_hour.csv
/;
parameter load_factor(vre,step) 'cumulative load factor of vre during the timestep'
/
$include inputs/load_factor_step.csv
/;
parameter demand(step) 'cumulative demand during the timestep in GWh'
/
$include inputs/demand_step.csv
/;
parameter month(step) 'gives the month of each timestep'
/
$include inputs/month_step.csv
/;
Parameter lake_inflows(m) 'monthly lake inflows in GWh'
/
$include inputs/lake19.csv
/ ;
parameter epsilon(vre) 'additional FRR requirement for variable renewable energies because of forecast errors'
/
$include inputs/reserve_requirements.csv
/ ;
parameter capa_ex(tec) 'existing capacities of the technologies by December 2017 in GW'
/
$include inputs/existing_capasn.csv
/ ;
parameter capa_max(tec) 'maximum capacities of the technologies in GW'
/
$include inputs/max_capasn.csv
/ ;
parameter capex(tec) 'annualized power capex cost in M€/GW/year'
/
$include inputs/annuities_19.csv
/ ;
parameter capex_en(str) 'annualized energy capex cost of storage technologies in M€/GWh/year'
/
$include inputs/str_annuities_19.csv
/ ;
parameter fOM(tec) 'annualized fixed operation and maintenance costs M€/GW/year'
/
$include inputs/fO&M_19.csv
/ ;
Parameter vOM(tec) 'Variable operation and maintenance costs in M€/GWh'
/
$include inputs/vO&M.csv
/ ;
$offdelim
$Onlisting
parameter s_capex(str) 'charging related annuity of storage in M€/GW/year' /PHS 0, battery 0, methanation 1671.01395/;
parameter s_opex(str) 'charging related fOM of storage in M€/GW/year' /PHS 0, battery 0, methanation 1125.75/;
parameter eta_in(str) 'charging efifciency of storage technologies' /PHS 0.95, battery 0.9, methanation 0.59/;
parameter eta_out(str) 'discharging efficiency of storage technolgoies' /PHS 0.9, battery 0.95, methanation 0.45/;
scalar pump_capa 'pumping capacity in GW' /9.3/;
scalar max_phs 'maximum volume of energy can be stored in PHS reservoir in TWh' /0.18/;
scalar max_biogas 'maxium yearly energy can be generated by biogas in TWh' /15/;
scalar max_methanation 'maximum energy storable in methanation to not fonction as inter-annual storage in TWh' /16/
scalar load_uncertainty 'uncertainty coefficient for hourly demand' /0.01/;
scalar delta 'load variation factor' /0.1/;
parameter length(step);
length(step) = last_hour(step) - first_hour(step);
parameter lambda(tec) 'asymptotic decrease of capacity for long-term steps' ;
lambda('phs')=0.2;
lambda('lake')=0.2;
*-------------------------------------------------------------------------------
* Model
*-------------------------------------------------------------------------------
variables GENE(tec,step) 'step energy generation in GWh'
CAPA(tec) 'overal yearly installed capacity in GW'
STORAGE(str,step) 'step electricity input of battery storage GW'
S(str) 'charging power capacity of each storage technology'
STORED(str,step) 'energy stored in each storage technology in GWh'
CAPACITY(str) 'energy volume of storage technologies in GWh'
RSV(frr,step) 'required upward frequency restoration reserve in GW'
COST 'final investment cost in b€'
positive variables GENE(tec,step),CAPA(tec),STORAGE(str,step), S(str),STORED(str,step),CAPACITY(str),RSV(frr,step);
equations gene_vre 'variables renewable profiles generation'
gene_capa 'capacity and genration relation for technologies'
combustion 'the relationship of combustible technologies'
capa_frr 'capacity needed for the secondary reserve requirements'
storing 'the definition of stored energy in the storage options'
storage_const 'storage in the first hour is equal to the storage in the last hour'
storage_con 'hourly storage can not be more than storage capacity'
storage_capa 'hourly storage should be less than charging capacity of storage technology'
lake_res 'constraint on water for lake reservoirs'
stored_cap 'maximum energy that is stored in storage units'
biogas_const 'maximum energy can be produced by biogas'
reserves 'FRR requirement'
adequacy 'supply/demand relation'
obj 'the final objective function which is COST';
gene_vre(vre,step).. GENE(vre,step) =e= CAPA(vre)*load_factor(vre,step);
gene_capa(tec,step).. GENE(tec,step) =l= CAPA(tec)*length(step);
combustion(step).. GENE('gas',step) =e= GENE('biogas',step)+ GENE('methanation',step);
capa_frr(frr,step).. GENE(frr,step) + RSV(frr,step)=l= CAPA(frr)*length(step)*(1.001*lambda(frr)/(length(step)+0.001)+1-lambda(frr));
storing(step,step+1,str).. STORED(str,step+1) =e= STORED(str,step) + STORAGE(str,step)*eta_in(str) - GENE(str,step)/eta_out(str);
storage_const(str,first,last).. STORED(str,first) =l= STORED(str,last) + STORAGE(str,last)*eta_in(str) - GENE(str,last)/eta_out(str);
lake_res(m).. lake_inflows(m) =g= sum(step$(month(step) = ord(m)),GENE('lake',step))/1000;
stored_cap(str,step).. STORED(str,step) =l= CAPACITY(str);
storage_capa(str,step).. STORAGE(str,step) =l= S(str)*length(step)*(1.001*lambda(str)/(length(step)+0.001)+1-lambda(str));
*storage_battery.. S('battery') =e= CAPA('battery');
biogas_const.. sum(step,GENE('biogas',step)) =l= max_biogas*1000*19;
reserves(step).. sum(frr, RSV(frr,step)) =e= sum(vre,epsilon(vre)*CAPA(vre)*length(step))+ demand(step)*load_uncertainty*(1+delta);
adequacy(step).. sum(tec,GENE(tec,step))-GENE('gas',step) =g= demand(step) + sum(str,STORAGE(str,step));
storage_con(str).. S(str) =l= CAPA(str);
obj.. COST =e= (sum(tec,(CAPA(tec)-capa_ex(tec))*capex(tec))+ sum(str,CAPACITY(str)*capex_en(str))+sum(tec,(CAPA(tec)*fOM(tec)))+sum(str, S(str)*(s_opex(str)+s_capex(str))) +sum((tec,step),GENE(tec,step)*vOM(tec)))/1000;
*-------------------------------------------------------------------------------
* Initial and fixed values
*-------------------------------------------------------------------------------
CAPA.fx('phs') = pump_capa;
*CAPA.fx('river')= capa_ex('river');
CAPA.fx('lake') = 10.1;
S.fx('phs') = pump_capa;
CAPACITY.fx('phs') = max_phs*1000;
CAPACITY.up('methanation') = max_methanation*1000;
CAPA.up(vre) = capa_max(vre);
*initial values
CAPA.l('offshore') = 13;
CAPA.l('onshore') = 80;
CAPA.l('pv') = 122;
CAPA.l('battery') = 20;
CAPA.l('methanation') = 33;
CAPA.l('biogas') = 33;
CAPA.l('gas') = 33;
CAPACITY.l('battery') = 70;
CAPACITY.l('methanation') = 16000;
*----------------------------------------------------
*-------------------------------------------------------------------------------
* Model options
*-------------------------------------------------------------------------------
model RES_long /all/;
option solvelink=0;
option RESLIM = 1000000;
option lp=CPLEX;
option Savepoint=1;
option solveopt = replace;
option limcol = 0;
option limrow = 0;
option SOLPRINT = OFF;
*-------------------------------------------------------------------------------
* Solve statement
*-------------------------------------------------------------------------------
$If exist RES_long_p.gdx execute_loadpoint 'RES_long_p';
Solve RES_long using lp minimizing COST;
*-------------------------------------------------------------------------------
* Display statement
*-------------------------------------------------------------------------------
parameter sumdemand 'the whole demand per period in TWh';
sumdemand = sum(step,demand(step))/1000;
parameter gene_tec(tec) 'the whole generation of each technology in TWh' ;
gene_tec(tec) = sum(step,GENE.l(tec,step))/1000;
parameter sumgene 'the whole generation per year in TWh';
sumgene = sum((gen,step),GENE.l(gen,step))/1000 - gene_tec('gas');
parameter sum_FRR 'the whole yearly energy budgeted for reserves in TWh';
sum_FRR = sum((step,frr),RSV.l(frr,step))/1000;
parameter reserve(frr) 'capacity allocated for reserve from each FRR tech in GW';
reserve(frr) = smax(step,RSV.l(frr,step)/length(step));
Parameter lcoe(gen);
lcoe(gen) = (CAPA.l(gen)*(fOM(gen)+capex(gen))+ gene_tec(gen)*vOM(gen)*1000)/gene_tec(gen);
parameter lcos(str);
lcos(str) = ((CAPA.l(str)*(fOM(str)+capex(str)))+(sum(step,GENE.l(str,step))*vOM(str))+CAPACITY.l(str)*capex_en(str))/gene_tec(str);
parameter cf(gen) 'load factor of generation technologies';
cf(gen) = gene_tec(gen)*1000/(166440*CAPA.l(gen));
parameter str_loss 'storage losses in % of power production';
str_loss = (sum((str,step),STORAGE.l(str,step))-sum(str,gene_tec(str)*1000))/(sumgene*10);
parameter lc 'load curtailment in %';
lc = ((sumgene-sumdemand)*100/sumgene) - str_loss;
parameter lcoe_sys1 'the overall MWh cost of electricity in €';
lcoe_sys1 = COST.l*1000/sumgene;
parameter lcoe_sys2 'the overall MWh cost of electricity in €';
lcoe_sys2 = COST.l*1000/sumdemand;
parameter spot_price(step) 'marginal cost' ;
spot_price(step) = 1000000*adequacy.m(step);
parameter marginal_cost 'average value over the year of spot price in €/MWh';
marginal_cost = sum(step,spot_price(step))/166440;
*-------------------------------------------------------------------------------
display cost.l;
display capa.l;
display gene_tec;
display sumdemand;
display sumgene;
display sum_FRR;
display lcoe;
display lcos;
display CAPACITY.l;
display cf;
display str_loss;
display lc;
display lcoe_sys1;
display lcoe_sys2;
display marginal_cost;
*-------------------------------------------------------------------------------
* Output
*-------------------------------------------------------------------------------
file results /'outputs/2000-2018n.txt'/ ;
put results;
put ' the main results' //
//
'I)Overall investment cost is' cost.l 'b€' //
//
'II)the Renewable capacity ' //
'Offshore 'CAPA.l('offshore')' GW'//
'onsore 'CAPA.l('onshore')' GW' //
'PV 'CAPA.l('PV')' GW'//
'run of river 'CAPA.l('river') 'GW' //
'lake 'CAPA.l('lake') 'GW' //
'biogas 'CAPA.l('biogas')' GW'//
'gas 'CAPA.l('gas')' GW'//
'Battery 'CAPA.l('battery')' GW'//
'PHS 'CAPA.l('phs')' GW'//
'methanation 'CAPA.l('methanation')' GW'//
//
//
'III)Needed storage volume' //
'Battery Storage 'CAPACITY.l('battery')' GWh' //
'PHS Storage 'CAPACITY.l('phs')' GWh'//
'methane storage 'CAPACITY.l('methanation')' GWh'//
//
'IV)Secondary reserve requirements'//
'lake 'reserve('lake') 'GW'//
'gas 'reserve('gas') 'GW'//
'Pumped Storage 'reserve('phs') 'GW'//
'Battery 'reserve('battery') 'GW'//
//
'V)Overall yearly energy generation of each technology'//
'Offshore 'gene_tec('offshore')' TWh'//
'onsore 'gene_tec('onshore')' TWh' //
'PV 'gene_tec('PV')' TWh'//
'run of river 'gene_tec('river') 'TWh' //
'lake 'gene_tec('lake') 'TWh' //
'biogas 'gene_tec('biogas')' TWh'//
'gas 'gene_tec('gas')' TWh'//
'battery 'gene_tec('battery')' TWh'//
'phs 'gene_tec('phs')' TWh'//
'Methanation 'gene_tec('methanation')'TWh'//
//
'VI)more details'//
'LCOE for Offshore ' lcoe('offshore')' €/MWh'//
'LCOE for Onshore ' lcoe('onshore')' €/MWh'//
'LCOE for PV ' lcoe('pv')' €/MWh'//
'LCOE for Run-of-river ' lcoe('river')' €/MWh'//
'LCOE for Lake ' lcoe('lake')' €/MWh'//
'LCOE for Biogas ' lcoe('biogas')' €/MWh'//
'LCOE for Gas ' lcoe('gas')' €/MWh'//
'LCOS for battery ' lcos('battery')' €/MWh'//
'LCOS for pumped storage ' lcos('phs')' €/MWh'//
'LCOS for methanation ' lcos('methanation')' €/MWh'//
//
'Load Curtailment' lc'% and storage loss is 'str_loss'% of the produced power'//
'system LCOE is ' lcoe_sys1 ' €/MWh or ' lcoe_sys2 ' €/MWh'//
'and average spot price 'marginal_cost' €/MWh' //
//
'capacity factors'//
'Offshore 'cf('offshore')//
'onsore 'cf('onshore')//
'PV 'cf('PV')//
'run of river 'cf('river')//
'lake 'cf('lake')//
'biogas 'cf('biogas')//
'gas 'cf('gas')//
;
*-------------------------------------------------------------------------------
file hourly_generation /'outputs/2000-2018n.csv' / ;
parameter nSTORAGE(str,step);
nSTORAGE(str,step) = 0 - STORAGE.l(str,step);
put hourly_generation;
hourly_generation.pc=5;
put 'step', 'first hour', 'last hour'; loop(tec, put tec.tl;); put 'demand' ;put 'ElecStr' ;put 'Pump' ; put 'CH4' ; put 'price' / ;
loop (step,
put step.tl, first_hour(step), last_hour(step); loop(tec, put gene.l(tec,step);) ;put demand(step); put nSTORAGE('PHS',step) ; put nSTORAGE('battery',step) ; put nSTORAGE('methanation',step) ; put spot_price(step)/
;);
*-------------------------------------------------------------------------------
* The End :D
*-------------------------------------------------------------------------------