forked from NREL/ReEDS-2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
d_solveprep.gms
253 lines (195 loc) · 10.6 KB
/
d_solveprep.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
$setglobal ds \
$ifthen.unix %system.filesys% == UNIX
$setglobal ds /
$endif.unix
Model ReEDSmodel /all/ ;
*=================================
* -- MODEL AND SOLVER OPTIONS --
*=================================
OPTION lp = %solver% ;
ReEDSmodel.optfile = %GSw_gopt% ;
*treat fixed variables as parameters
ReEDSmodel.holdfixed = 1 ;
$ifthen %solver%==CBC
* adjust the GAMS infeasibility tolerance to handle empty rows when using CBC
ReEDSmodel.tolinfeas = 1e-15 ;
$endif
$if not set loadgdx $setglobal loadgdx 0
$ifthen.gdxin %loadgdx% == 1
execute_loadpoint "gdxfiles%ds%%gdxfin%.gdx" ;
Option BRatio = 0.0 ;
$endif.gdxin
*================================================
* --- Parameters only used when loading data ---
*================================================
set tload(t) "years in which data is loaded" ;
tload(t) = no ;
parameter
cc_old_load(i,r,ccreg,ccseason,t) "--MW-- cc_old loading in from the cc_out gdx file"
sdbin_size_load(ccreg,ccseason,sdbin,t) "--MW-- bin_size loading in from the cc_out gdx file"
cc_mar_load(i,r,ccreg,ccseason,t) "--fraction-- cc_mar loading in from the cc_out gdx file"
cc_dr_load(i,r,ccseason,t) "--fraction-- cc_dr loading in from the cc_out gdx file"
;
*============================
* --- Round parameters ---
*============================
* As a general rule, costs or prices should be rounded to two decimal places
* and all other parameter should be rounded to no more than 3 decimal places
* Some exceptions might exist due to number scaling (e.g., emission rates)
acp_price(st,t)$acp_price(st,t) = round(acp_price(st,t),2) ;
avail_retire_exog_rsc(i,v,r,t)$valcap(i,v,r,t) = round(avail_retire_exog_rsc(i,v,r,t),3) ;
batterymandate(st,t)$batterymandate(st,t) = round(batterymandate(st,t),2) ;
bcr(i)$bcr(i) = round(bcr(i),4) ;
biosupply(usda_region,bioclass,"price") = round(biosupply(usda_region,bioclass,"price"),2) ;
biosupply(usda_region,bioclass,"cap") = round(biosupply(usda_region,bioclass,"cap"),3) ;
cc_storage(i,sdbin)$cc_storage(i,sdbin) = round(cc_storage(i,sdbin),3) ;
cendiv_weights(r,cendiv)$cendiv_weights(r,cendiv) = round(cendiv_weights(r,cendiv), 3) ;
cost_cap(i,t)$cost_cap(i,t) = round(cost_cap(i,t),2) ;
cost_co2_pipeline_fom(r,rr,t) =round(cost_co2_pipeline_fom(r,rr,t),2) ;
cost_co2_pipeline_cap(r,rr,t) =round(cost_co2_pipeline_cap(r,rr,t),2) ;
cost_co2_spurline_fom(r,cs,t) = round(cost_co2_spurline_fom(r,cs,t),2) ;
cost_co2_spurline_cap(r,cs,t) = round(cost_co2_spurline_cap(r,cs,t),2) ;
cost_co2_stor_bec(cs,t) = round(cost_co2_stor_bec(cs,t),2) ;
cost_fom(i,v,r,t)$cost_fom(i,v,r,t) = round(cost_fom(i,v,r,t),2) ;
cost_h2_storage_cap(h2_st,t) = round(cost_h2_storage_cap(h2_st,t), 2) ;
cost_h2_transport_cap(r,rr,t)$cost_h2_transport_cap(r,rr,t) = round(cost_h2_transport_cap(r,rr,t),2) ;
cost_h2_transport_fom(r,rr,t)$cost_h2_transport_fom(r,rr,t) = round(cost_h2_transport_fom(r,rr,t),2) ;
cost_opres(i,ortype,t)$cost_opres(i,ortype,t) = round(cost_opres(i,ortype,t),2) ;
cost_prod(i,v,r,t)$cost_prod(i,v,r,t) = round(cost_prod(i,v,r,t), 2) ;
cost_upgrade(i,v,r,t)$cost_upgrade(i,v,r,t) = round(cost_upgrade(i,v,r,t),2) ;
cost_vom(i,v,r,t)$cost_vom(i,v,r,t) = round(cost_vom(i,v,r,t),2) ;
cost_vom_pvb_b(i,v,r,t)$cost_vom_pvb_b(i,v,r,t) = round(cost_vom_pvb_b(i,v,r,t),2) ;
cost_vom_pvb_p(i,v,r,t)$cost_vom_pvb_p(i,v,r,t) = round(cost_vom_pvb_p(i,v,r,t),2) ;
degrade(i,tt,t)$degrade(i,tt,t) = round(degrade(i,tt,t),3) ;
derate_geo_vintage(i,v)$derate_geo_vintage(i,v) = round(derate_geo_vintage(i,v),3) ;
distance(r,rr,trtype)$distance(r,rr,trtype) = round(distance(r,rr,trtype),3) ;
* non-CO2 emission/capture rates get small, here making sure accounting stays correct
emit_rate(e,i,v,r,t)$valgen(i,v,r,t) = round(emit_rate(e,i,v,r,t),6) ;
capture_rate(e,i,v,r,t)$valgen(i,v,r,t) = round(capture_rate(e,i,v,r,t),6) ;
fuel_price(i,r,t)$fuel_price(i,r,t) = round(fuel_price(i,r,t),2) ;
gasmultterm(cendiv,t)$gasmultterm(cendiv,t) = round(gasmultterm(cendiv,t),3) ;
heat_rate(i,v,r,t)$heat_rate(i,v,r,t) = round(heat_rate(i,v,r,t),2) ;
m_capacity_exog(i,v,r,t)$[valcap(i,v,r,t)$(not sameas(i,"smr"))] = round(m_capacity_exog(i,v,r,t),3) ;
m_rsc_dat(r,i,rscbin,"cap")$m_rsc_dat(r,i,rscbin,"cap") = round(m_rsc_dat(r,i,rscbin,"cap"),3) ;
m_rsc_dat(r,i,rscbin,"cost")$m_rsc_dat(r,i,rscbin,"cost") = round(m_rsc_dat(r,i,rscbin,"cost"),2) ;
m_rsc_dat(r,i,rscbin,"cost_trans")$m_rsc_dat(r,i,rscbin,"cost_trans") = round(m_rsc_dat(r,i,rscbin,"cost_trans"),2) ;
prm(r,t)$prm(r,t) = round(prm(r,t),3) ;
prod_conversion_rate(i,v,r,t)$prod_conversion_rate(i,v,r,t) = round(prod_conversion_rate(i,v,r,t),6) ;
ptc_value_scaled(i,v,t)$ptc_value_scaled(i,v,t) = round(ptc_value_scaled(i,v,t),2) ;
recperc(rpscat,st,t)$recperc(rpscat,st,t) = round(recperc(rpscat,st,t),3) ;
rggi_cap(t)$rggi_cap(t) = round(rggi_cap(t),0) ;
state_cap(st,t)$state_cap(st,t) = round(state_cap(st,t),0) ;
storage_eff_pvb_g(i,t)$storage_eff_pvb_g(i,t) = round(storage_eff_pvb_g(i,t),3) ;
storage_eff_pvb_p(i,t)$storage_eff_pvb_p(i,t) = round(storage_eff_pvb_p(i,t),3) ;
tranloss(r,rr,trtype)$tranloss(r,rr,trtype) = round(tranloss(r,rr,trtype),3) ;
transmission_line_capcost(r,rr,trtype)$transmission_line_capcost(r,rr,trtype) = round(transmission_line_capcost(r,rr,trtype),2) ;
transmission_line_fom(r,rr,trtype)$transmission_line_fom(r,rr,trtype) = round(transmission_line_fom(r,rr,trtype),3) ;
trans_cost_cap_fin_mult(t) = round(trans_cost_cap_fin_mult(t),3) ;
trans_cost_cap_fin_mult_noITC(t) = round(trans_cost_cap_fin_mult_noITC(t),3) ;
upgrade_derate(i,v,r,t)$upgrade_derate(i,v,r,t) = round(upgrade_derate(i,v,r,t),3) ;
winter_cap_frac_delta(i,v,r)$winter_cap_frac_delta(i,v,r) = round(winter_cap_frac_delta(i,v,r),3) ;
*================================================
* --- SEQUENTIAL SETUP ---
*================================================
$ifthen.seq %timetype%=="seq"
* Parameter tracking
parameter
m_capacity_exog0(i,v,r,t) "--MW-- original value of m_capacity_exog used in d_solveoneyear to make sure upgraded capacity isnt forced into retirement"
z_rep(t) "--$-- objective function value by year"
z_rep_inv(t) "--$-- investment component of objective function by year"
z_rep_op(t) "--$-- operation component of objective function by year"
;
* -- upgrade capacity tracking --
m_capacity_exog0(i,v,r,t) = m_capacity_exog(i,v,r,t) ;
* remove cc_int as it is only used in the intertemporal setting
cc_int(i,v,r,ccseason,t) = 0 ;
*for the sequential solve, what matters is the relative ratio of the pvf for capital and the pvf for onm
*therefore, we set the pvf capital to one, and then pvf_onm to the relative 20 year present value by using the crf
pvf_capital(t) = 1 ;
pvf_onm(t)$tmodel_new(t) = round(1 / crf(t),6) ;
$endif.seq
*================================================
* --- INTERTEMPORAL AND WINDOW SETUP ---
*================================================
$ifthen.intwin ((%timetype%=="int") or (%timetype%=="win"))
set
loadset "set used for loading in merged gdx files" / ReEDS_Augur_2010*ReEDS_Augur_%endyear% /
;
parameter
cc_dr_load2(loadset,i,r,ccseason,t) "--fraction-- cc_dr loading in from the cc_out gdx file"
cc_iter(i,v,r,ccseason,t,cciter) "--fraction-- Actual capacity value in iteration cciter"
cc_mar_load2(loadset,i,r,ccseason,t) "--fraction-- cc_mar loading in from the cc_out gdx file"
cc_old_load2(loadset,i,r,ccseason,t) "--MW-- cc_old loading in from the cc_out gdx file"
cc_scale(i,r,ccseason,t) "--unitless-- scaling of marginal capacity value levels in intertemporal runs to equal total capacity value"
cc_totmarg(i,r,ccseason,t) "--MW-- original estimate of total capacity value for intertemporal, based on marginals"
sdbin_size_load2(loadset,ccreg,ccseason,sdbin,t) "--MW-- bin_size loading in from the cc_out gdx file"
;
cc_scale(i,r,ccseason,t) = 0 ;
cc_totmarg(i,r,ccseason,t) = 0 ;
$endif.intwin
*================================================
* --- INTERTEMPORAL SETUP ---
*================================================
$ifthen.int %timetype%=="int"
* Iteration tracking
set cciter "placeholder for iteration number for tracking CC" /0*20/ ;
parameter cap_iter(i,v,r,t,cciter) "--MW-- Capacity by iteration"
gen_iter(i,v,r,t,cciter) "--MWh-- Annual uncurtailed generation by iteration"
cap_firm_iter(i,v,r,ccseason,t,cciter) "--MW-- VRE Firm capacity by iteration"
;
cap_iter(i,v,r,t,cciter) = 0 ;
gen_iter(i,v,r,t,cciter) = 0 ;
*Assign csp3 and csp4 to use the same initial values as csp2_1
cc_int(i,v,r,ccseason,t)$[csp3(i) or csp4(i)] = cc_int('csp2_1',v,r,ccseason,t) ;
tmodel(t) = no ;
tmodel(t)$[tmodel_new(t)$(yeart(t)<=%endyear%)] = yes ;
*Cap the maximum CC in the first solve iteration
cc_int(i,v,r,ccseason,t)$[rsc_i(i)$(cc_int(i,v,r,ccseason,t)>0.4)$wind(i)] = 0.4 ;
cc_int(i,v,r,ccseason,t)$[rsc_i(i)$(cc_int(i,v,r,ccseason,t)>0.6)$pv(i)] = 0.6 ;
*set objective function to millions of dollars
cost_scale = 1 ;
*marginal capacity value not used in intertemporal case
m_cc_mar(i,r,ccseason,t) = 0 ;
*static capacity value for existing capacity not used in intertemporal case
cc_old(i,r,ccseason,t) = 0 ;
*sets needed for the demand side
*following sets are needed for linear interpolation of price
*that determine the year before the non-solved year and the year after
set t_before, t_after ;
alias(t,ttt) ;
t_before(t,tt)$[tprev(t,tt)$(ord(tt) = smax{ttt, ord(ttt)$tprev(t,ttt) })] = yes ;
t_after(t,tt)$tprev(tt,t) = yes ;
* intentionally not declaring all indices to make these flexibile
* rep only used when running the demand side
parameter rep "reporting for all sectors/timeslices/regions"
repannual(t,*,*) "national and annual reporting"
;
$endif.int
*=======================
* --- WINDOW SETUP ---
*=======================
$ifthen.win %timetype%=="win"
parameter pvf_capital0(t) "original pvf_capital used for calculating pvf_capital in window solve",
pvf_onm0(t) "original pvf_onm used for calculating pvf_capital in window solve";
pvf_capital0(t) = pvf_capital(t) ;
pvf_onm0(t) = pvf_onm(t) ;
cost_scale = 1e-3 ;
*Assign csp3 and csp4 to use the same initial values as csp2_1
cc_int(i,v,r,ccseason,t)$[csp3(i) or csp4(i)] = cc_int('csp2_1',v,r,ccseason,t) ;
*marginal capacity value not used in intertemporal case
m_cc_mar(i,r,ccseason,t) = 0 ;
*static capacity value for existing capacity not used in intertemporal case
cc_old(i,r,ccseason,t) = 0 ;
tmodel(t) = no ;
set windows /1*40/ ;
set blocks /start,stop/ ;
table solvewindows(windows,blocks)
$ondelim
$include inputs_case%ds%windows.csv
$offdelim
;
$endif.win
*======================
* --- Unload all inputs ---
*======================
execute_unload 'inputs_case%ds%inputs.gdx' ;