4b_outputInvariant.gms 29.1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ontext
This file is part of Backbone.

Backbone is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Backbone 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with Backbone.  If not, see <http://www.gnu.org/licenses/>.
$offtext

18
* =============================================================================
19
* --- Time Step Dependent Results ---------------------------------------------
20
* =============================================================================
21

22
23
// Need to loop over the model dimension, as this file is no longer contained in the modelSolves loop...
loop(m,
24

Topi Rasku's avatar
Topi Rasku committed
25
26
27
* --- Realized Individual Costs ----------------------------------------------

    // Variable O&M costs
28
    r_gnuVOMCost(gnu(grid, node, unit), ft_realizedNoReset(f,t))$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]
Topi Rasku's avatar
Topi Rasku committed
29
30
        = 1e-6 // Scaling to MEUR
            * p_stepLengthNoReset(m, f, t)
31
            * abs(r_gen(grid, node, unit, f, t))
32
            * p_gnu(grid, node, unit, 'vomCosts');
Topi Rasku's avatar
Topi Rasku committed
33
34

    // Fuel and emission costs during normal operation
35
    r_uFuelEmissionCost(commodity, unit_commodity(unit), ft_realizedNoReset(f,t))${ un_commodity(unit, commodity) and [ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]}
Topi Rasku's avatar
Topi Rasku committed
36
37
        = 1e-6 // Scaling to MEUR
            * p_stepLengthNoReset(m, f, t)
38
            * r_fuelUse(commodity, unit, f, t)
39
40
41
42
43
44
            * [ // Fuel price when input
                + p_price(commodity, 'price')${p_price(commodity, 'useConstant') and un_commodity_in(unit, commodity)}
                + ts_price(commodity, t)${p_price(commodity, 'useTimeSeries')  and un_commodity_in(unit, commodity)}
                // Fuel price when output
                - p_price(commodity, 'price')${p_price(commodity, 'useConstant') and un_commodity_out(unit, commodity)}
                - ts_price(commodity, t)${p_price(commodity, 'useTimeSeries')  and un_commodity_out(unit, commodity)}
Topi Rasku's avatar
Topi Rasku committed
45
                // Emission costs
46
47
                + sum(emission, p_unitEmissionCost(unit, commodity, emission))
              ];
Topi Rasku's avatar
Topi Rasku committed
48
49

    // Unit startup costs
50
    r_uStartupCost(unit, ft_realizedNoReset(f,t))${sum(starttype, unitStarttype(unit, starttype)) and [ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]}
Topi Rasku's avatar
Topi Rasku committed
51
52
53
        = 1e-6 // Scaling to MEUR
            * sum(unitStarttype(unit, starttype),
                + r_startup(unit, starttype, f, t)
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
                    * [
                        + p_uStartup(unit, starttype, 'cost') // CUR/start-up
                        // Start-up fuel and emission costs
                        + sum(nu(node,unit)$p_unStartup(unit, node, starttype),
                            + p_unStartup(unit, node, starttype) // MWh/start-up
                              * [
                                  + p_price(node, 'price')$p_price(node, 'useConstant') // CUR/MWh
                                  + ts_price(node, t)$p_price(node, 'useTimeseries') // CUR/MWh
                                ] // END * p_uStartup
                          ) // END sum(node)
                        + sum((nu(node, unit), emission)$p_unitEmissionCost(unit, node, emission),
                            + p_unStartup(unit, node, starttype) // MWh/start-up
                              * p_unitEmissionCost(unit, node, emission) // CUR/MWh
                          ) // END sum(nu, emission)
                      ] // END * r_startup
69
              ); // END sum(starttype)
Topi Rasku's avatar
Topi Rasku committed
70
71

    // Node state slack costs
72
    r_gnStateSlackCost(gn_stateSlack(grid, node), ft_realizedNoReset(f,t))$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]
Topi Rasku's avatar
Topi Rasku committed
73
74
75
76
77
78
79
80
        = 1e-6 // Scaling to MEUR
            * p_stepLengthNoReset(m, f, t)
            * sum(slack${ p_gnBoundaryPropertiesForStates(grid, node, slack, 'slackCost') },
                + r_stateSlack(grid, node, slack, f, t)
                    * p_gnBoundaryPropertiesForStates(grid, node, slack, 'slackCost')
                ); // END sum(slack)

    // Storage Value Change
81
    r_gnStorageValueChange(gn_state(grid, node))${ active(m, 'storageValue') }
Topi Rasku's avatar
Topi Rasku committed
82
83
84
        = 1e-6
            * [
                + sum(ft_realizedNoReset(f,t)${ ord(t) = mSettings(m, 't_end') + 1 },
85
                    + [
Topi Rasku's avatar
Topi Rasku committed
86
                        + p_storageValue(grid, node)${ not p_gn(grid, node, 'storageValueUseTimeSeries') }
87
88
                        + ts_storageValue(grid, node, f, t)${ p_gn(grid, node, 'storageValueUseTimeSeries') }
                      ]
Topi Rasku's avatar
Topi Rasku committed
89
90
                        * r_state(grid, node, f, t)
                    ) // END sum(ft_realizedNoReset)
91
                - sum(ft_realizedNoReset(f,t)${ ord(t) = mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod') }, // INITIAL v_state NOW INCLUDED IN THE RESULTS
92
                    + [
Topi Rasku's avatar
Topi Rasku committed
93
                        + p_storageValue(grid, node)${ not p_gn(grid, node, 'storageValueUseTimeSeries') }
94
95
                        + ts_storageValue(grid, node, f, t)${ p_gn(grid, node, 'storageValueUseTimeSeries') }
                      ]
Topi Rasku's avatar
Topi Rasku committed
96
97
98
99
                        * r_state(grid, node, f, t)
                    ) // END sum(ft_realizedNoReset)
                ]; // END * 1e-6

100
* --- Total Cost Components (discounted) --------------------------------------
Topi Rasku's avatar
Topi Rasku committed
101
102
103

    // Total VOM costs
    r_gnuTotalVOMCost(gnu_output(grid, node, unit))
104
        = sum(ft_realizedNoReset(f,t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
Topi Rasku's avatar
Topi Rasku committed
105
            + r_gnuVOMCost(grid, node, unit, f, t)
106
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s) * p_s_discountFactor(s))
Topi Rasku's avatar
Topi Rasku committed
107
108
109
            );

    // Total fuel & emission costs
110
    r_uTotalFuelEmissionCost(commodity, unit)$un_commodity(unit, commodity)
111
        = sum(ft_realizedNoReset(f,t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
112
            + r_uFuelEmissionCost(commodity, unit, f, t)
113
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s) * p_s_discountFactor(s))
Topi Rasku's avatar
Topi Rasku committed
114
115
116
117
            );

    // Total unit startup costs
    r_uTotalStartupCost(unit)${ sum(starttype, unitStarttype(unit, starttype)) }
118
        = sum(ft_realizedNoReset(f,t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
Topi Rasku's avatar
Topi Rasku committed
119
            + r_uStartupCost(unit, f, t)
120
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s) * p_s_discountFactor(s))
Topi Rasku's avatar
Topi Rasku committed
121
122
123
124
            );

    // Total state variable slack costs
    r_gnTotalStateSlackCost(gn_stateSlack(grid, node))
125
        = sum(ft_realizedNoReset(f,t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
Topi Rasku's avatar
Topi Rasku committed
126
            + r_gnStateSlackCost(grid, node, f, t)
127
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s) * p_s_discountFactor(s))
Topi Rasku's avatar
Topi Rasku committed
128
129
            );

Niina Helistö's avatar
Niina Helistö committed
130
131
132
    // Fixed O&M costs
    r_gnuFOMCost(gnu(grid, node, unit))
        = 1e-6 // Scaling to MEUR
133
134
            * sum(ms(m, s)${ sum(msft_realizedNoReset(m, s, f, t_), 1) }, // consider ms only if it has active msft_realizedNoReset
                + [
135
                    + p_gnu(grid, node, unit, 'capacity')$sum(msft_realizedNoReset(m, s, f, t_), uft(unit, f, t_)) // Not in v_obj; only units active in msft_realizedNoReset
136
                    + r_invest(unit)$sum(msft_realizedNoReset(m, s, f, t_), uft(unit, f, t_)) // only units active in msft_realizedNoReset
137
                        * p_gnu(grid, node, unit, 'unitSize')
138
139
                    ]
                    * p_msAnnuityWeight(m, s) // Sample weighting to calculate annual costs
140
                    * p_s_discountFactor(s) // Discount costs
141
                ) // END * sum(ms)
Niina Helistö's avatar
Niina Helistö committed
142
143
144
145
146
            * p_gnu(grid, node, unit, 'fomCosts');

    // Unit investment costs
    r_gnuUnitInvestmentCost(gnu(grid, node, unit))
        = 1e-6 // Scaling to MEUR
147
            * sum(ms(m, s)${ sum(msft_realizedNoReset(m, s, f, t_), 1) }, // consider ms only if it has active msft_realizedNoReset
148
                + r_invest(unit)$sum(msft_realizedNoReset(m, s, f, t_), uft(unit, f, t_)) // only units active in msft_realizedNoReset
149
                    * p_msAnnuityWeight(m, s) // Sample weighting to calculate annual costs
150
                    * p_s_discountFactor(s) // Discount costs
151
                ) // END * sum(ms)
152
            * p_gnu(grid, node, unit, 'unitSize')
Niina Helistö's avatar
Niina Helistö committed
153
154
155
156
            * p_gnu(grid, node, unit, 'invCosts')
            * p_gnu(grid, node, unit, 'annuity');

    // Transfer link investment costs
157
    r_gnnLinkInvestmentCost(gn2n_directional(grid, from_node, to_node)) // gn2n_directional only, as in q_obj
Niina Helistö's avatar
Niina Helistö committed
158
        = 1e-6 // Scaling to MEUR
159
160
161
162
163
            * sum(ms(m, s)${ sum(msft_realizedNoReset(m, s, f, t_), 1) }, // consider ms only if it has active msft_realizedNoReset
                + sum(t_invest(t)${ord(t) <= msEnd(m, s)}, // only if investment was made before or during the sample
                    + r_investTransfer(grid, from_node, to_node, t)
                    )
                    * p_msAnnuityWeight(m, s) // Sample weighting to calculate annual costs
164
                    * p_s_discountFactor(s) // Discount costs
165
                ) // END * sum(ms)
Niina Helistö's avatar
Niina Helistö committed
166
167
168
169
170
171
172
            * [
                + p_gnn(grid, from_node, to_node, 'invCost')
                    * p_gnn(grid, from_node, to_node, 'annuity')
                + p_gnn(grid, to_node, from_node, 'invCost')
                    * p_gnn(grid, to_node, from_node, 'annuity')
                ]; // END * r_investTransfer;

173
174
* --- Realized Nodal System Costs ---------------------------------------------

Niina Helistö's avatar
Niina Helistö committed
175
    // Total realized gn operating costs
176
    r_gnRealizedOperatingCost(gn(grid, node), ft_realizedNoReset(f, t))$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
        = + sum(gnu(grid, node, unit),
              // VOM costs
              + r_gnuVOMCost(grid, node, unit, f, t)
            )
          // Allocate fuel and startup costs on energy basis, but for output nodes only
          + sum(unit$gnu(grid, node, unit),
              + sum(gnu(grid, node, unit)$(gnu_output(grid, node, unit) and r_gen[grid, node, unit, f, t]),
                  + abs{r_gen[grid, node, unit, f, t]}  // abs is due to potential negative outputs like energy from a cooling unit. It's the energy contribution that matters, not direction.
                    /
                    sum(gnu_output(grid_output, node_output, unit)$r_gen[grid_output, node_output, unit, f, t], abs{r_gen[grid_output, node_output, unit, f, t]})
                )
                *
                {
                  + sum(un_commodity(unit, commodity), r_uFuelEmissionCost(commodity, unit, f, t))
                  + r_uStartupCost(unit, f, t)
                }
            )
          // Node state slack costs
          + r_gnStateSlackCost(grid, node, f, t);
196
197
198
199

* --- Realized Nodal Energy Consumption ---------------------------------------
// !!! NOTE !!! This is a bit of an approximation at the moment !!!!!!!!!!!!!!!

200
    r_gnConsumption(gn(grid, node), ft_realizedNoReset(f, t))$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]
201
202
203
204
205
206
207
208
        = p_stepLengthNoReset(m, f, t)
            * [
                + min(ts_influx(grid, node, f, t), 0) // Not necessarily a good idea, as ts_influx contains energy gains as well...
                + sum(gnu_input(grid, node, unit),
                    + r_gen(grid, node, unit, f, t)
                    ) // END sum(gnu_input)
                ];

209
210
211
* --- Total Energy Generation -------------------------------------------------

    // Total energy generation
212
    r_gnuTotalGen(gnu_output(grid, node, unit))
213
        = sum(ft_realizedNoReset(f, t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
214
215
            + r_gen(grid, node, unit, f, t)
                * p_stepLengthNoReset(m, f, t)
216
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
217
            ); // END sum(ft_realizedNoReset)
218

219
220
221
222
223
224
225
226
227
    r_gen_gnUnittype(gn(grid, node), unittype)$sum(unit$unitUnittype(unit, unittype), 1)
      = sum(gnu(grid,node,unit)$unitUnittype(unit, unittype),
            sum(ft_realizedNoReset(f, t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
              + r_gen(grid, node, unit, f, t)
                  * p_stepLengthNoReset(m, f, t)
                  * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
            ) // END sum(ft_realizedNoReset)
        );

228
    // Energy generation by fuels
229
230
231
    r_genFuel(gn(grid, node), commodity, ft_realizedNoReset(f, t))$[    sum(gnu_input(grid_, node_, unit)$gnu_output(grid, node, unit), r_gen(grid_, node_, unit, f, t))
                                                                    and ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]
        = sum(gnu_output(grid, node, unit)$sum(gnu_input(grid_, commodity, unit), 1),
232
            + r_gen(grid, node, unit, f, t)
233
234
235
236
237
238
239
240
241
          );
// The calculation with multiple inputs needs to be fixed below (right share for different commodities - now units with multiple input commodities will get the same amount allocated which will then be too big
//          * sum((grid_, unit)$gnu_output(grid, node, unit),
//                r_gen(grid_, commodity, unit, f, t))
//                  / sum(gnu_input(grid__, node_, unit), r_gen(grid__, node_, unit, f, t));

    r_genFuel(gn(grid, node), flow, ft_realizedNoReset(f, t))$flowNode(flow, node)
        = sum(gnu_output(grid, node, unit)$flowUnit(flow, unit),
            + r_gen(grid, node, unit, f, t));
242

Juha Kiviluoma's avatar
Juha Kiviluoma committed
243
    // Energy generation by fuels
244
245
246
247
    r_genUnittype(gn(grid, node), unittype, ft_realizedNoReset(f,t))
        ${  sum(unit,gnu_output(grid, node, unit))
            and [ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]
            }
Juha Kiviluoma's avatar
Juha Kiviluoma committed
248
        = sum(unit${unitUnittype(unit, unittype) and gnu_output(grid, node, unit)},
249
            + r_gen(grid, node, unit, f, t)
Juha Kiviluoma's avatar
Juha Kiviluoma committed
250
251
            ); // END sum(unit)

252
    // Total generation on each node by fuels
253
    r_gnTotalGenFuel(gn(grid, node), commodity)
254
        = sum(ft_realizedNoReset(f, t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
255
            + r_genFuel(grid, node, commodity, f, t)
256
                * p_stepLengthNoReset(m, f, t)
257
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
258
            ); // END sum(ft_realizedNoReset)
259

260
261
    // Total dummy generation/consumption
    r_gnTotalqGen(inc_dec, gn(grid, node))
262
        = sum(ft_realizedNoReset(f,t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
263
264
            + r_qGen(inc_dec, grid, node, f, t)
                * p_stepLengthNoReset(m, f, t)
265
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
266
267
            ); // END sum(ft_realizedNoReset)

268
* --- Total Unit Online Results -----------------------------------------------
269

270
271
    // Total sub-unit-hours for units over the simulation
    r_uTotalOnline(unit)
272
        = sum(ft_realizedNoReset(f, t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
273
            + r_online(unit, f, t)
274
                * p_stepLengthNoReset(m, f, t)
275
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
276
            ); // END sum(ft_realizedNoReset)
277

278
    // Approximate utilization rates for gnus over the simulation
279
    r_gnuUtilizationRate(gnu_output(grid, node, unit))${ r_gnuTotalGen(grid, node, unit)
280
                                                         and ( p_gnu(grid, node, unit, 'capacity')
281
                                                               or r_invest(unit)
282
283
                                                               )
                                                         }
284
285
        = r_gnuTotalGen(grid, node, unit)
            / [
286
                + (p_gnu(grid, node, unit, 'capacity') + r_invest(unit)*p_gnu(grid, node, unit, 'unitSize'))
287
                    * (mSettings(m, 't_end') - (mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')) + 1)
288
                    * mSettings(m, 'stepLengthInHours')
289
290
291
292
                ]; // END division

* --- Total Reserve Provision -------------------------------------------------

293
    // Total reserve provisions over the simulation
294
    r_gnuTotalReserve(gnuRescapable(restype, up_down, grid, node, unit))
295
        = sum(ft_realizedNoReset(f, t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
296
            + r_reserve(restype, up_down, grid, node, unit, f, t)
297
                * p_stepLengthNoReset(m, f, t)
298
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
299
300
            ); // END sum(ft_realizedNoReset)

301
    // Total dummy reserve provisions over the simulation
302
    r_groupTotalqResDemand(restypeDirectionGroup(restype, up_down, group))
303
        = sum(ft_realizedNoReset(f, t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
304
            + r_qResDemand(restype, up_down, group, f, t)
305
                * p_stepLengthNoReset(m, f, t)
306
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
307
308
            ); // END sum(ft_realizedNoReset)

309
310
311
312
* --- Total Transfer and Spill ------------------------------------------------

    // Total transfer of energy between nodes
    r_gnnTotalTransfer(gn2n(grid, from_node, to_node))
313
        = sum(ft_realizedNoReset(f, t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
314
            + r_transfer(grid, from_node, to_node, f, t)
315
                * p_stepLengthNoReset(m, f, t)
316
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
317
318
            ); // END sum(ft_realizedNoReset)

319
320
    // Total energy spill from nodes
    r_gnTotalSpill(grid, node_spill(node))
321
        = sum(ft_realizedNoReset(f, t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
322
323
            + r_spill(grid, node, f, t)
                * p_stepLengthNoReset(m, f, t)
324
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
325
            ); // END sum(ft_realizedNoReset)
326

327
328
329
330
* =============================================================================
* --- Futher Time Step Independent Results ------------------------------------
* =============================================================================

331
* --- Scaling Marginal Values to EUR/MWh from MEUR/MWh ------------------------
332
333

// Energy balance
334
r_balanceMarginal(gn(grid, node), ft_realizedNoReset(f, t))$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]
335
336
337
    = 1e6 * r_balanceMarginal(grid, node, f, t);

// Reserve balance
338
339
r_resDemandMarginal(restypeDirectionGroup(restype, up_down, group), ft_realizedNoReset(f, t))$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]
    = 1e6 * r_resDemandMarginal(restype, up_down, group, f, t);
340

341
342
* --- Total Generation Results ------------------------------------------------

343
344
// Total generation in gn
r_gnTotalGen(gn(grid, node))
345
346
    = sum(gnu_output(grid, node, unit), r_gnuTotalGen(grid, node, unit));

347
348
349
// Total generation in g
r_gTotalGen(grid)
    = sum(gn(grid, node), r_gnTotalGen(grid, node));
350

351
// Total generation gnu/gn shares
352
r_gnuTotalGenShare(gnu_output(grid, node, unit))${ r_gnTotalGen(grid, node) > 0 }
353
354
355
356
    = r_gnuTotalGen(grid, node, unit)
        / r_gnTotalGen(grid, node);

// Total generation gn/g shares
357
r_gnTotalGenShare(gn(grid, node))${ r_gTotalGen(grid) > 0 }
358
359
360
    = r_gnTotalGen(grid, node)
        / r_gTotalGen(grid);

361
362
363
364
365
366
* --- Total Dummy Generation Results ------------------------------------------

// Total dummy generaion in g
r_gTotalqGen(inc_dec, grid)
    = sum(gn(grid, node), r_gnTotalqGen(inc_dec, grid, node));

367
368
* --- Total Energy Consumption Results ----------------------------------------

369
370
// Total consumption on each gn over the simulation
r_gnTotalConsumption(gn(grid, node))
371
    = sum(ft_realizedNoReset(f, t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
Niina Helistö's avatar
Niina Helistö committed
372
        + r_gnConsumption(grid, node, f ,t)
373
            * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
Niina Helistö's avatar
Niina Helistö committed
374
        );
375

376
377
378
// Total consumption in each grid over the simulation
r_gTotalConsumption(grid)
    = sum(gn(grid, node), r_gnTotalConsumption(grid, node));
379

380
// Total consumption gn/g share
381
r_gnTotalConsumptionShare(gn(grid, node))${ r_gTotalConsumption(grid) > 0 }
382
383
384
385
386
    = r_gnTotalConsumption(grid, node)
        / r_gTotalConsumption(grid);

* --- Total Fuel Consumption Results ------------------------------------------

387
// Total fuel consumption in grids over the simulation
388
389
r_gTotalGenFuel(grid, commodity)
    = sum(gn(grid, node), r_gnTotalGenFuel(grid, node, commodity));
390

391
// Total fuel consumption over the simulation
392
393
r_totalGenFuel(commodity)
    = sum(gn(grid, node), r_gnTotalGenFuel(grid, node, commodity));
394

395
// Total fuel consumption gn/g shares
396
397
r_gnTotalGenFuelShare(gn(grid, node), commodity)${ r_gnTotalGen(grid, node) }
    = r_gnTotalGenFuel(grid, node, commodity)
398
        / r_gnTotalGen(grid, node);
399
400
401

* --- Total Spilled Energy Results --------------------------------------------

402
403
404
// Total spilled energy in each grid over the simulation
r_gTotalSpill(grid)
    = sum(gn(grid, node_spill(node)), r_gnTotalSpill(grid, node));
405

406
// Total spilled energy gn/g share
407
r_gnTotalSpillShare(gn(grid, node_spill))${ r_gTotalSpill(grid) > 0 }
408
409
410
    = r_gnTotalSpill(grid, node_spill)
        / r_gTotalSpill(grid);

411
* --- Total Costs Results (discounted) ----------------------------------------
412

Niina Helistö's avatar
Niina Helistö committed
413
414
// Total realized operating costs on each gn over the simulation
r_gnTotalRealizedOperatingCost(gn(grid, node))
415
    = sum(ft_realizedNoReset(f, t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
Niina Helistö's avatar
Niina Helistö committed
416
        + r_gnRealizedOperatingCost(grid, node, f ,t)
417
            * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s) * p_s_discountFactor(s))
Niina Helistö's avatar
Niina Helistö committed
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
        );

// Total realized net operating costs on each gn over the simulation
r_gnTotalRealizedNetOperatingCost(gn(grid, node))
    = r_gnTotalRealizedOperatingCost(grid, node) - r_gnStorageValueChange(grid, node);

// Total realized operating costs on each grid over the simulation
r_gTotalRealizedOperatingCost(grid)
    = sum(gn(grid, node), r_gnTotalRealizedOperatingCost(grid, node));

// Total realized net operating costs on each grid over the simulation
r_gTotalRealizedNetOperatingCost(grid)
    = sum(gn(grid, node), r_gnTotalRealizedNetOperatingCost(grid, node));

// Total realized operating costs gn/g share
433
r_gnTotalRealizedOperatingCostShare(gn(grid, node))${ r_gTotalRealizedOperatingCost(grid) > 0 }
Niina Helistö's avatar
Niina Helistö committed
434
435
436
437
438
439
440
441
442
443
444
    = r_gnTotalRealizedOperatingCost(grid, node)
        / r_gTotalRealizedOperatingCost(grid);

// Total realized operating costs over the simulation
r_totalRealizedOperatingCost
    = sum(gn(grid, node), r_gnTotalRealizedOperatingCost(grid, node));

// Total realized net operating costs over the simulation
r_totalRealizedNetOperatingCost
    = sum(gn(grid, node), r_gnTotalRealizedNetOperatingCost(grid, node));

445
446
// Total realized costs on each gn over the simulation
r_gnTotalRealizedCost(gn(grid, node))
Niina Helistö's avatar
Niina Helistö committed
447
448
449
450
451
452
453
    = r_gnTotalRealizedOperatingCost(grid, node)
        + sum(gnu(grid, node, unit),
            + r_gnuFOMCost(grid, node, unit)
            + r_gnuUnitInvestmentCost(grid, node, unit)
            )
        + sum(gn2n_directional(grid, from_node, node),
            + r_gnnLinkInvestmentCost(grid, from_node, node)
454
                / 2 // Half of the link costs are allocated to the receiving end
Niina Helistö's avatar
Niina Helistö committed
455
456
457
            )
        + sum(gn2n_directional(grid, node, to_node),
            + r_gnnLinkInvestmentCost(grid, node, to_node)
458
                / 2 // Half of the link costs are allocated to the sending end
Niina Helistö's avatar
Niina Helistö committed
459
            );
460

461
462
463
464
// Total realized net costs on each gn over the simulation
r_gnTotalRealizedNetCost(gn(grid, node))
    = r_gnTotalRealizedCost(grid, node) - r_gnStorageValueChange(grid, node);

465
466
467
// Total realized costs on each grid over the simulation
r_gTotalRealizedCost(grid)
    = sum(gn(grid, node), r_gnTotalRealizedCost(grid, node));
468

469
470
471
472
// Total realized net costs on each grid over the simulation
r_gTotalRealizedNetCost(grid)
    = sum(gn(grid, node), r_gnTotalRealizedNetCost(grid, node));

473
// Total realized costs gn/g share
474
r_gnTotalRealizedCostShare(gn(grid, node))${ r_gTotalRealizedCost(grid) > 0 }
475
476
477
    = r_gnTotalRealizedCost(grid, node)
        / r_gTotalRealizedCost(grid);

478
479
// Total realized costs over the simulation
r_totalRealizedCost
480
    = sum(gn(grid, node), r_gnTotalRealizedCost(grid, node));
481

Niina Helistö's avatar
Niina Helistö committed
482
// Total realized net operating costs over the simulation
483
484
485
r_totalRealizedNetCost
    = sum(gn(grid, node), r_gnTotalRealizedNetCost(grid, node));

486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
// Total realized fixed costs on each gn over the simulation
r_gnTotalRealizedFixedCost(gn(grid, node))
    = r_gnTotalRealizedCost(grid, node)
        - r_gnTotalRealizedOperatingCost(grid, node);

// Total realized fixed costs on each grid over the simulation
r_gTotalRealizedFixedCost(grid)
    = r_gTotalRealizedCost(grid)
        - r_gTotalRealizedOperatingCost(grid);

// Total realized fixed costs gn/g share
r_gnTotalRealizedFixedCostShare(gn(grid, node))${ r_gTotalRealizedFixedCost(grid) > 0 }
    = r_gnTotalRealizedFixedCost(grid, node)
        / r_gTotalRealizedFixedCost(grid);

// Total realized fixed costs over the simulation
r_totalRealizedFixedCost
    = r_totalRealizedCost
        - r_totalRealizedOperatingCost;

506
507
508
* --- Reserve Provision Overlap Results ---------------------------------------

// Calculate the overlapping reserve provisions
509
510
511
512
r_reserve2Reserve(gnuRescapable(restype, up_down, grid, node, unit), restype_, ft_realizedNoReset(f, t))
    ${ p_gnuRes2Res(grid, node, unit, restype, up_down, restype_) }
    = r_reserve(restype, up_down, grid, node, unit, f, t)
        * p_gnuRes2Res(grid, node, unit, restype, up_down, restype_);
513

514
515
* --- Total Reserve Provision Results -----------------------------------------

516
517
518
519
520
// Total reserve provision in groups over the simulation
r_groupTotalReserve(restypeDirectionGroup(restype, up_down, group))
    = sum(gnuRescapable(restype, up_down, grid, node, unit)${gnGroup(grid, node, group)},
        + r_gnuTotalReserve(restype, up_down, grid, node, unit)
    ); // END sum(gnuRescapable)
521

522
523
524
525
r_gnuTotalReserveShare(gnuRescapable(restype, up_down, grid, node, unit))
    ${ sum(gnGroup(grid, node, group), r_groupTotalReserve(restype, up_down, group)) > 0 }
    = r_gnuTotalReserve(restype, up_down, grid, node, unit)
        / sum(gnGroup(grid, node, group), r_groupTotalReserve(restype, up_down, group));
526
527
528

* --- Total Unit Online State Results -----------------------------------------

529
// Total unit online hours per sub-unit over the simulation
530
r_uTotalOnlinePerUnit(unit)${ p_unit(unit, 'unitCount') > 0 }
531
532
533
    = r_uTotalOnline(unit)
        / p_unit(unit, 'unitCount');

534
535
// Total sub-unit startups over the simulation
r_uTotalStartup(unit, starttype)
536
    = sum(ft_realizedNoReset(f, t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
537
        + r_startup(unit, starttype, f, t)
538
            * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
539
540
541
542
        ); // END sum(ft_realizedNoReset)

// Total sub-unit shutdowns over the simulation
r_uTotalShutdown(unit)
543
    = sum(ft_realizedNoReset(f, t)$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')],
544
        + r_shutdown(unit, f, t)
545
            * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
546
547
        ); // END sum(ft_realizedNoReset)

548
549
* --- Diagnostic Results ------------------------------------------------------

550
// Only include these if '--diag=yes' given as a command line argument
551
$iftheni.diag '%diag%' == yes
552
// Estimated coefficients of performance
553
554
555
d_cop(unit, ft_realizedNoReset(f, t))${  [ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]
                                         and sum(gnu_input(grid, node, unit), 1)
                                         }
556
557
558
559
560
561
562
    = sum(gnu_output(grid, node, unit),
        + r_gen(grid, node, unit, f, t)
        ) // END sum(gnu_output)
        / [ sum(gnu_input(grid_, node_, unit),
                -r_gen(grid_, node_, unit, f, t)
                ) // END sum(gnu_input)
            + 1${not sum(gnu_input(grid_, node_, unit), -r_gen(grid_, node_, unit, f, t))}
563
564
            ]
        + Eps; // Eps to correct GAMS plotting (zeroes are not skipped)
565
566

// Estimated efficiency
567
d_eff(unit_commodity(unit), ft_realizedNoReset(f, t))$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]
568
569
570
571
572
573
574
    = sum(gnu_output(grid, node, unit),
        + r_gen(grid, node, unit, f, t)
        ) // END sum(gnu_output)
        / [ sum(uFuel(unit, 'main', fuel),
                + r_fuelUse(fuel, unit, f, t)
                ) // END sum(uFuel)
            + 1${not sum(uFuel(unit, 'main', fuel), r_fuelUse(fuel, unit, f, t))}
575
576
            ]
        + Eps; // Eps to correct GAMS plotting (zeroes are not skipped)
577
$endif.diag
578

579
); // END loop(m)
580