4b_outputInvariant.gms 34 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
// for performance, get rid of any zeros in r_gen and r_reserve. Many zero values missing anyway.
20
r_gen(gnu, f, t)$((r_gen(gnu, f, t)=0)$r_gen(gnu, f, t))=0;
21
r_reserve(restype, up_down, gnu, f, t)$((r_reserve(restype, up_down, gnu, f, t)=0)$r_reserve(restype, up_down, gnu, f, t))=0;
22

23
* =============================================================================
24
* --- Time Step Dependent Results ---------------------------------------------
25
* =============================================================================
26

27
28
// Need to loop over the model dimension, as this file is no longer contained in the modelSolves loop...
loop(m,
29

30
    option clear=startp; startp(t)$(ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod'))=yes;
Topi Rasku's avatar
Topi Rasku committed
31
32
33
* --- Realized Individual Costs ----------------------------------------------

    // Variable O&M costs
34
    r_gnuVOMCost(gnu(grid, node, unit), ft_realizedNoReset(f,startp(t)))
Topi Rasku's avatar
Topi Rasku committed
35
36
        = 1e-6 // Scaling to MEUR
            * p_stepLengthNoReset(m, f, t)
37
            * abs(r_gen(grid, node, unit, f, t))
38
            * p_gnu(grid, node, unit, 'vomCosts');
Topi Rasku's avatar
Topi Rasku committed
39
40

    // Fuel and emission costs during normal operation
41
42
43
44
    // Note that this result calculation uses ts_price directly while the
    // objective function uses ts_price average over the interval. There can
    // be differences if realized intervals contain several time steps.
    r_uFuelEmissionCost(gnu(grid, node, unit), ft_realizedNoReset(f,startp(t)))
Topi Rasku's avatar
Topi Rasku committed
45
46
        = 1e-6 // Scaling to MEUR
            * p_stepLengthNoReset(m, f, t)
47
48
49
50
51
            * abs(r_gen(grid, node, unit, f, t))
            * [ + p_price(node, 'price')${p_price(node, 'useConstant') and gnu_input(grid, node, unit)}
                + ts_price(node, t)${p_price(node, 'useTimeSeries') and gnu_input(grid, node, unit)}
                - p_price(node, 'price')${p_price(node, 'useConstant') and gnu_output(grid, node, unit)}
                - ts_price(node, t)${p_price(node, 'useTimeSeries') and gnu_output(grid, node, unit)}
Topi Rasku's avatar
Topi Rasku committed
52
                // Emission costs
53
                + sum(emission, p_unitEmissionCost(unit, node, emission))
54
              ];
Topi Rasku's avatar
Topi Rasku committed
55
56

    // Unit startup costs
57
    r_uStartupCost(unit, ft_realizedNoReset(f,startp(t)))$sum(starttype, unitStarttype(unit, starttype))
Topi Rasku's avatar
Topi Rasku committed
58
59
60
        = 1e-6 // Scaling to MEUR
            * sum(unitStarttype(unit, starttype),
                + r_startup(unit, starttype, f, t)
61
                    * [
62
                        // Fuel costs
63
64
                        + p_uStartup(unit, starttype, 'cost') // CUR/start-up
                        // Start-up fuel and emission costs
65
                        + sum(nu_startup(node,unit),
66
67
68
69
                            + 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
70
71
                                  // Emission costs
                                  + sum(emission$p_nEmission(node, emission),
72
                                       + p_nEmission(node, emission) // kg/MWh
73
74
75
76
77
78
79
                                          / 1e3 // NOTE!!! Conversion to t/MWh from kg/MWh in data
                                          * sum(gnGroup(grid, node, group),
                                              + p_groupPolicyEmission(group, 'emissionTax', emission) // CUR/t
                                              ) // END sum(gnGroup)
                                      ) // END sum(emission)
                                ] // END * p_unStartup
                            ) // END sum(nu_startup)
80
                      ] // END * r_startup
81
              ); // END sum(starttype)
Topi Rasku's avatar
Topi Rasku committed
82

83
    //Variable Trnasfer Costs
84
    r_gnnVariableTransCost(gn2n_directional(grid, node_, node), ft_realizedNoReset(f,startp(t)))
85
86
        = 1e-6 // Scaling to MEUR
            * p_stepLengthNoReset(m, f, t)
87
                    *[+ p_gnn(grid, node, node_, 'variableTransCost')
88
                    * r_transferLeftward(grid, node_, node, f, t)
89
                    + p_gnn(grid, node_, node, 'variableTransCost')
90
91
                    * r_transferRightward(grid, node_, node, f, t)];

92
   // Transfer marginal value (Me) calculated from r_transfer * balanceMarginal * transferLosses
93
   r_gnnTransferValue(gn2n_directional(grid, node_, node), ft_realizedNoReset(f,startp(t)))
94
95
96
97
98
99
100
101
102
        = p_stepLengthNoReset(m, f, t)
            * [ r_transferRightward(grid, node_, node, f, t)
                * r_balanceMarginal(grid, node, f, t)
                - r_transferLeftward(grid, node_, node, f, t)
                * r_balanceMarginal(grid, node_, f, t)
              ]
            * [ 1 - p_gnn(grid, node_, node, 'transferLoss')${not gn2n_timeseries(grid, node_, node, 'transferLoss')}
                - ts_gnn_(grid, node_, node, 'transferLoss', f, t)${gn2n_timeseries(grid, node_, node, 'transferLoss')}
              ]
103
104
    ;

Topi Rasku's avatar
Topi Rasku committed
105
    // Node state slack costs
106
    r_gnStateSlackCost(gn_stateSlack(grid, node), ft_realizedNoReset(f,startp(t)))
Topi Rasku's avatar
Topi Rasku committed
107
108
109
110
111
112
113
114
        = 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
115
    r_gnStorageValueChange(gn_state(grid, node))${ active(m, 'storageValue') }
Topi Rasku's avatar
Topi Rasku committed
116
117
118
        = 1e-6
            * [
                + sum(ft_realizedNoReset(f,t)${ ord(t) = mSettings(m, 't_end') + 1 },
119
                    + [
Topi Rasku's avatar
Topi Rasku committed
120
                        + p_storageValue(grid, node)${ not p_gn(grid, node, 'storageValueUseTimeSeries') }
121
122
                        + ts_storageValue(grid, node, f, t)${ p_gn(grid, node, 'storageValueUseTimeSeries') }
                      ]
Topi Rasku's avatar
Topi Rasku committed
123
124
                        * r_state(grid, node, f, t)
                    ) // END sum(ft_realizedNoReset)
125
                - sum(ft_realizedNoReset(f,t)${ ord(t) = mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod') }, // INITIAL v_state NOW INCLUDED IN THE RESULTS
126
                    + [
Topi Rasku's avatar
Topi Rasku committed
127
                        + p_storageValue(grid, node)${ not p_gn(grid, node, 'storageValueUseTimeSeries') }
128
129
                        + ts_storageValue(grid, node, f, t)${ p_gn(grid, node, 'storageValueUseTimeSeries') }
                      ]
Topi Rasku's avatar
Topi Rasku committed
130
131
132
133
                        * r_state(grid, node, f, t)
                    ) // END sum(ft_realizedNoReset)
                ]; // END * 1e-6

134
    // Diffusion from node to node_
135
136
137
    // Note that this result paramater does not necessarily consider the
    // implicit node state variable dynamics properly if energyStoredPerUnitOfState
    // is not equal to 0
138
139
140
141
142
143
    r_gnnDiffusion(gn_state(grid, node), node_, ft_realizedNoReset(f,startp(t)))
        ${gnn_state(grid, node, node_) or gnn_state(grid, node_, node)}
        = p_gnn(grid, node, node_, 'diffCoeff') * r_state(grid, node, f, t)
            - p_gnn(grid, node_, node, 'diffCoeff') * r_state(grid, node_, f, t)
            ;

144
* --- Total Cost Components (discounted) --------------------------------------
Topi Rasku's avatar
Topi Rasku committed
145
146
147

    // Total VOM costs
    r_gnuTotalVOMCost(gnu_output(grid, node, unit))
148
        = sum(ft_realizedNoReset(f,startp(t)),
Topi Rasku's avatar
Topi Rasku committed
149
            + r_gnuVOMCost(grid, node, unit, f, t)
150
                * 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
151
152
            );

153
154
    // Total Variable Transfer costs
    r_gnnTotalVariableTransCost(gn2n_directional(grid, node_, node))
155
        = sum(ft_realizedNoReset(f,startp(t)),
156
            + r_gnnVariableTransCost(grid, node_, node, f, t)
157
158
159
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s) * p_s_discountFactor(s))
            );

160
    // Total transfer marginal value over the simulation
161
    r_gnnTotalTransferValue(gn2n_directional(grid, node_, node))
162
        = sum(ft_realizedNoReset(f,startp(t)),
163
            + r_gnnTransferValue(grid, node_, node, f, t)
164
165
166
167
                * 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
168
    // Total fuel & emission costs
169
    r_uTotalFuelEmissionCost(gnu(grid, node, unit))
170
        = sum(ft_realizedNoReset(f,startp(t)),
171
            + r_uFuelEmissionCost(grid, node, unit, f, t)
172
                * 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
173
174
175
            );

    // Total unit startup costs
176
177
    r_uTotalStartupCost(unit)$sum(starttype, unitStarttype(unit, starttype))
        = sum(ft_realizedNoReset(f,startp(t)),
Topi Rasku's avatar
Topi Rasku committed
178
            + r_uStartupCost(unit, f, t)
179
                * 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
180
181
182
183
            );

    // Total state variable slack costs
    r_gnTotalStateSlackCost(gn_stateSlack(grid, node))
184
        = sum(ft_realizedNoReset(f,startp(t)),
Topi Rasku's avatar
Topi Rasku committed
185
            + r_gnStateSlackCost(grid, node, f, t)
186
                * 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
187
188
            );

Niina Helistö's avatar
Niina Helistö committed
189
190
191
    // Fixed O&M costs
    r_gnuFOMCost(gnu(grid, node, unit))
        = 1e-6 // Scaling to MEUR
192
193
            * sum(ms(m, s)${ sum(msft_realizedNoReset(m, s, f, t_), 1) }, // consider ms only if it has active msft_realizedNoReset
                + [
194
                    + 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
195
                    + r_invest(unit)$sum(msft_realizedNoReset(m, s, f, t_), uft(unit, f, t_)) // only units active in msft_realizedNoReset
196
                        * p_gnu(grid, node, unit, 'unitSize')
197
198
                    ]
                    * p_msAnnuityWeight(m, s) // Sample weighting to calculate annual costs
199
                    * p_s_discountFactor(s) // Discount costs
200
                ) // END * sum(ms)
Niina Helistö's avatar
Niina Helistö committed
201
202
203
204
205
            * p_gnu(grid, node, unit, 'fomCosts');

    // Unit investment costs
    r_gnuUnitInvestmentCost(gnu(grid, node, unit))
        = 1e-6 // Scaling to MEUR
206
            * sum(ms(m, s)${ sum(msft_realizedNoReset(m, s, f, t_), 1) }, // consider ms only if it has active msft_realizedNoReset
207
                + r_invest(unit)$sum(msft_realizedNoReset(m, s, f, t_), uft(unit, f, t_)) // only units active in msft_realizedNoReset
208
                    * p_msAnnuityWeight(m, s) // Sample weighting to calculate annual costs
209
                    * p_s_discountFactor(s) // Discount costs
210
                ) // END * sum(ms)
211
            * p_gnu(grid, node, unit, 'unitSize')
Niina Helistö's avatar
Niina Helistö committed
212
213
214
215
            * p_gnu(grid, node, unit, 'invCosts')
            * p_gnu(grid, node, unit, 'annuity');

    // Transfer link investment costs
216
    r_gnnLinkInvestmentCost(gn2n_directional(grid, from_node, to_node)) // gn2n_directional only, as in q_obj
Niina Helistö's avatar
Niina Helistö committed
217
        = 1e-6 // Scaling to MEUR
218
219
220
221
222
            * 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
223
                    * p_s_discountFactor(s) // Discount costs
224
                ) // END * sum(ms)
Niina Helistö's avatar
Niina Helistö committed
225
226
227
228
229
230
231
            * [
                + 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;

232
233
* --- Realized Nodal System Costs ---------------------------------------------

Niina Helistö's avatar
Niina Helistö committed
234
    // Total realized gn operating costs
235
    r_gnRealizedOperatingCost(gn(grid, node), ft_realizedNoReset(f, startp(t)))
236
237
238
        = + sum(gnu(grid, node, unit),
              // VOM costs
              + r_gnuVOMCost(grid, node, unit, f, t)
239
              + r_uFuelEmissionCost(grid, node, unit, f, t)
240
            )
241
242

          // Allocate startup costs on energy basis, but for output nodes only
243
244
245
246
247
          + sum(unit$(r_gen(grid, node, unit, f, t)$gnu_output(grid, node, unit)),
              + 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),
                       + abs{r_gen(grid_output, node_output, unit, f, t)}
                     ) // END sum(gnu_output)
248
                * r_uStartupCost(unit, f, t)
249
            )
250
          + sum(gn2n_directional(grid, node_, node),
251
252
              // Variable Transfer costs
              + r_gnnVariableTransCost(grid, node_, node, f, t)
253
            )
254
255
          // Node state slack costs
          + r_gnStateSlackCost(grid, node, f, t);
256
257
258
259

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

260
    r_gnConsumption(gn(grid, node), ft_realizedNoReset(f, startp(t)))
261
262
263
264
265
266
267
268
        = 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)
                ];

269
270
271
* --- Total Energy Generation -------------------------------------------------

    // Total energy generation
272
    r_gnuTotalGen(gnu_output(grid, node, unit))
273
        = sum(ft_realizedNoReset(f, startp(t)),
274
275
            + r_gen(grid, node, unit, f, t)
                * p_stepLengthNoReset(m, f, t)
276
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
277
            ); // END sum(ft_realizedNoReset)
278

279
280
    r_gen_gnUnittype(gn(grid, node), unittype)$sum(unit$unitUnittype(unit, unittype), 1)
      = sum(gnu(grid,node,unit)$unitUnittype(unit, unittype),
281
            sum(ft_realizedNoReset(f, startp(t)),
282
283
284
285
286
287
              + 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)
        );

288
    // Energy output to a node based on inputs from another node or flows
289
290
    r_genFuel(gn(grid, node), node_, ft_realizedNoReset(f, startp(t)))$sum(gnu_input(grid_, node_, unit)$gnu_output(grid, node, unit),r_gen(grid_, node_, unit, f, t))
        = sum(gnu_output(grid, node, unit)$sum(gnu_input(grid_, node_, unit), 1),
291
            + r_gen(grid, node, unit, f, t)
292
293
294
295
296
297
298
299
300
          );
// 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));
301

302
    // Energy generation for each unittype
303
304
    r_genUnittype(gn(grid, node), unittype, ft_realizedNoReset(f,startp(t)))
        = sum(gnu_output(grid, node, unit)$unitUnittype(unit, unittype),
305
            + r_gen(grid, node, unit, f, t)
Juha Kiviluoma's avatar
Juha Kiviluoma committed
306
307
            ); // END sum(unit)

308
    // Total energy generation in gn per input type over the simulation
309
    r_gnTotalGenFuel(gn(grid, node), node_)
310
        = sum(ft_realizedNoReset(f, startp(t)),
311
            + r_genFuel(grid, node, node_, f, t)
312
                * p_stepLengthNoReset(m, f, t)
313
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
314
            ); // END sum(ft_realizedNoReset)
315

316
317
    // Total dummy generation/consumption
    r_gnTotalqGen(inc_dec, gn(grid, node))
318
        = sum(ft_realizedNoReset(f,startp(t)),
319
320
            + r_qGen(inc_dec, grid, node, f, t)
                * p_stepLengthNoReset(m, f, t)
321
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
322
323
            ); // END sum(ft_realizedNoReset)

324
325
326
327
328
329
330
331
    // Unit start-up consumption
    r_nuStartupConsumption(nu_startup(node, unit), ft_realizedNoReset(f,startp(t)))
        ${sum(starttype, unitStarttype(unit, starttype))}
        = sum(unitStarttype(unit, starttype),
            + r_startup(unit, starttype, f, t)
                * p_unStartup(unit, node, starttype) // MWh/start-up
            ); // END sum(unitStarttype)

332
333
* --- Emission Results --------------------------------------------------------

334
335
336
337
338
    // Emissions of units (not including start-up fuels)
    // Only taking into account emissions from input because emissions from output
    // do not cause costs and are not considered in emission cap
    r_emissions(grid, node, emission, unit, ft_realizedNoReset(f,startp(t)))
       $gnu_input(grid, node, unit)
339
        =   + p_stepLengthNoReset(m, f, t)
340
341
342
343
344
345
346
347
348
349
350
            * abs(r_gen(grid, node, unit, f, t))
            * p_nEmission(node, emission)
            / 1e3 // NOTE!!! Conversion to t/MWh from kg/MWh in data
    ;

    // Emissions from unit outputs
    r_emissionsFromOutput(grid, node, emission, unit, ft_realizedNoReset(f,startp(t)))
        $gnu_output(grid, node, unit)
        =   + p_stepLengthNoReset(m, f, t)
            * r_gen(grid, node, unit, f, t)
            * p_nEmission(node, emission)
351
352
353
            / 1e3 // NOTE!!! Conversion to t/MWh from kg/MWh in data
    ;

354
355
    // Emissions from unit start-ups
    r_emissionsStartup(node, emission, unit, ft_realizedNoReset(f,startp(t)))
356
        ${sum(starttype, p_unStartup(unit, node, starttype))
357
358
359
360
361
362
363
364
          and p_nEmission(node, emission)}
        = sum(unitStarttype(unit, starttype),
            + r_startup(unit, starttype, f, t)
                * p_unStartup(unit, node, starttype) // MWh/start-up
                * p_nEmission(node, emission) // kg/MWh
                / 1e3 // NOTE!!! Conversion to t/MWh from kg/MWh in data
            ); // END sum(starttype)

365
    // Emission sums from normal operation input
366
    r_nuTotalEmissionsOperation(nu(node, unit), emission)
367
368
369
370
371
372
373
        = sum(ft_realizedNoReset(f, startp(t)),
            + sum(gn(grid, node), r_emissions(grid, node, emission, unit, f, t))
                 * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
            )
    ;

    // Emission sums from unit outputs
374
    r_nuTotalEmissionsFromOutput(nu(node, unit), emission)
375
376
377
378
379
        = sum(ft_realizedNoReset(f, startp(t)),
            + sum(gn(grid, node), r_emissionsFromOutput(grid, node, emission, unit, f, t))
                 * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
            )
    ;
380

381
    // Emission sums from start-ups
382
    r_nuTotalEmissionsStartup(nu_startup(node, unit), emission)
383
        = sum(ft_realizedNoReset(f, startp(t)),
384
            + r_emissionsStartup(node, emission, unit, f, t)
385
386
387
388
                 * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
            )
    ;

389
390
391
392
393
394
395
396
    // Emission sums (normal operation input and start-ups)
    r_nuTotalEmissions(node, unit, emission)
        = r_nuTotalEmissionsOperation(node, unit, emission)
            + r_nuTotalEmissionsStartup(node, unit, emission)
    ;

    r_nTotalEmissions(node, emission)
        = sum(unit, r_nuTotalEmissions (node, unit, emission))
397
398
399
    ;

    r_uTotalEmissions(unit, emission)
400
        = sum(node, r_nuTotalEmissions (node, unit, emission))
401
402
403
    ;

    r_totalEmissions (emission)
404
        = sum(node, r_nTotalEmissions(node, emission))
405
406
    ;

407
* --- Total Unit Online Results -----------------------------------------------
408

409
410
    // Total sub-unit-hours for units over the simulation
    r_uTotalOnline(unit)
411
        = sum(ft_realizedNoReset(f, startp(t)),
412
            + r_online(unit, f, t)
413
                * p_stepLengthNoReset(m, f, t)
414
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
415
            ); // END sum(ft_realizedNoReset)
416

417
    // Approximate utilization rates for gnus over the simulation
418
    r_gnuUtilizationRate(gnu_output(grid, node, unit))${ r_gnuTotalGen(grid, node, unit)
419
                                                         and ( p_gnu(grid, node, unit, 'capacity')
420
                                                               or r_invest(unit)
421
422
                                                               )
                                                         }
423
424
        = r_gnuTotalGen(grid, node, unit)
            / [
425
                + (p_gnu(grid, node, unit, 'capacity') + r_invest(unit)*p_gnu(grid, node, unit, 'unitSize'))
426
                    * (mSettings(m, 't_end') - (mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')) + 1)
427
                    * mSettings(m, 'stepLengthInHours')
428
429
430
431
                ]; // END division

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

432
    // Total reserve provisions over the simulation
433
    r_gnuTotalReserve(gnuRescapable(restype, up_down, grid, node, unit))
434
        = sum(ft_realizedNoReset(f, startp(t)),
435
            + r_reserve(restype, up_down, grid, node, unit, f, t)
436
                * p_stepLengthNoReset(m, f, t)
437
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
438
439
            ); // END sum(ft_realizedNoReset)

440
    // Total dummy reserve provisions over the simulation
441
    r_groupTotalqResDemand(restypeDirectionGroup(restype, up_down, group))
442
        = sum(ft_realizedNoReset(f, startp(t)),
443
            + r_qResDemand(restype, up_down, group, f, t)
444
                * p_stepLengthNoReset(m, f, t)
445
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
446
447
            ); // END sum(ft_realizedNoReset)

448
449
450
451
* --- Total Transfer and Spill ------------------------------------------------

    // Total transfer of energy between nodes
    r_gnnTotalTransfer(gn2n(grid, from_node, to_node))
452
        = sum(ft_realizedNoReset(f, startp(t)),
453
            + r_transfer(grid, from_node, to_node, f, t)
454
                * p_stepLengthNoReset(m, f, t)
455
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
456
457
            ); // END sum(ft_realizedNoReset)

458
459
    // Total energy spill from nodes
    r_gnTotalSpill(grid, node_spill(node))
460
        = sum(ft_realizedNoReset(f, startp(t)),
461
462
            + r_spill(grid, node, f, t)
                * p_stepLengthNoReset(m, f, t)
463
                * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
464
            ); // END sum(ft_realizedNoReset)
465

466
467
468
469
* =============================================================================
* --- Futher Time Step Independent Results ------------------------------------
* =============================================================================

470
* --- Scaling Marginal Values to EUR/MWh from MEUR/MWh ------------------------
471
472

// Energy balance
473
r_balanceMarginal(gn(grid, node), ft_realizedNoReset(f, startp(t)))
474
475
476
    = 1e6 * r_balanceMarginal(grid, node, f, t);

// Reserve balance
477
r_resDemandMarginal(restypeDirectionGroup(restype, up_down, group), ft_realizedNoReset(f, startp(t)))
478
    = 1e6 * r_resDemandMarginal(restype, up_down, group, f, t);
479

480
481
* --- Total Generation Results ------------------------------------------------

482
483
// Total generation in gn
r_gnTotalGen(gn(grid, node))
484
485
    = sum(gnu_output(grid, node, unit), r_gnuTotalGen(grid, node, unit));

486
487
488
// Total generation in g
r_gTotalGen(grid)
    = sum(gn(grid, node), r_gnTotalGen(grid, node));
489

490
// Total generation gnu/gn shares
491
r_gnuTotalGenShare(gnu_output(grid, node, unit))${ r_gnTotalGen(grid, node) > 0 }
492
493
494
495
    = r_gnuTotalGen(grid, node, unit)
        / r_gnTotalGen(grid, node);

// Total generation gn/g shares
496
r_gnTotalGenShare(gn(grid, node))${ r_gTotalGen(grid) > 0 }
497
498
499
    = r_gnTotalGen(grid, node)
        / r_gTotalGen(grid);

500
501
502
503
504
505
* --- Total Dummy Generation Results ------------------------------------------

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

506
507
* --- Total Energy Consumption Results ----------------------------------------

508
509
// Total consumption on each gn over the simulation
r_gnTotalConsumption(gn(grid, node))
510
    = sum(ft_realizedNoReset(f, startp(t)),
Niina Helistö's avatar
Niina Helistö committed
511
        + r_gnConsumption(grid, node, f ,t)
512
            * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
Niina Helistö's avatar
Niina Helistö committed
513
        );
514

515
516
517
// Total consumption in each grid over the simulation
r_gTotalConsumption(grid)
    = sum(gn(grid, node), r_gnTotalConsumption(grid, node));
518

519
// Total consumption gn/g share
520
r_gnTotalConsumptionShare(gn(grid, node))${ r_gTotalConsumption(grid) > 0 }
521
522
523
    = r_gnTotalConsumption(grid, node)
        / r_gTotalConsumption(grid);

524
* --- Total Energy Generation Results Per Input Type --------------------------
525

526
// Total energy generation in grids per input type over the simulation
527
528
r_gTotalGenFuel(grid, node_)
    = sum(gn(grid, node), r_gnTotalGenFuel(grid, node, node_));
529

530
// Total overall energy generation per input type over the simulation
531
532
r_totalGenFuel(node_)
    = sum(gn(grid, node), r_gnTotalGenFuel(grid, node, node_));
533

534
// Total energy generation in gn per input type as a share of total energy generation in gn across all input types
535
536
r_gnTotalGenFuelShare(gn(grid, node), node_)${ r_gnTotalGen(grid, node) }
    = r_gnTotalGenFuel(grid, node, node_)
537
        / r_gnTotalGen(grid, node);
538
539
540

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

541
542
543
// Total spilled energy in each grid over the simulation
r_gTotalSpill(grid)
    = sum(gn(grid, node_spill(node)), r_gnTotalSpill(grid, node));
544

545
// Total spilled energy gn/g share
546
r_gnTotalSpillShare(gn(grid, node_spill))${ r_gTotalSpill(grid) > 0 }
547
548
549
    = r_gnTotalSpill(grid, node_spill)
        / r_gTotalSpill(grid);

550
* --- Total Costs Results (discounted) ----------------------------------------
551

Niina Helistö's avatar
Niina Helistö committed
552
553
// Total realized operating costs on each gn over the simulation
r_gnTotalRealizedOperatingCost(gn(grid, node))
554
    = sum(ft_realizedNoReset(f, startp(t)),
Niina Helistö's avatar
Niina Helistö committed
555
        + r_gnRealizedOperatingCost(grid, node, f ,t)
556
            * 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
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
        );

// 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
572
r_gnTotalRealizedOperatingCostShare(gn(grid, node))${ r_gTotalRealizedOperatingCost(grid) > 0 }
Niina Helistö's avatar
Niina Helistö committed
573
574
575
576
577
578
579
580
581
582
583
    = 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));

584
585
// Total realized costs on each gn over the simulation
r_gnTotalRealizedCost(gn(grid, node))
Niina Helistö's avatar
Niina Helistö committed
586
587
588
589
590
591
592
    = 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)
593
                / 2 // Half of the link costs are allocated to the receiving end
Niina Helistö's avatar
Niina Helistö committed
594
595
596
            )
        + sum(gn2n_directional(grid, node, to_node),
            + r_gnnLinkInvestmentCost(grid, node, to_node)
597
                / 2 // Half of the link costs are allocated to the sending end
Niina Helistö's avatar
Niina Helistö committed
598
            );
599

600
601
602
603
// Total realized net costs on each gn over the simulation
r_gnTotalRealizedNetCost(gn(grid, node))
    = r_gnTotalRealizedCost(grid, node) - r_gnStorageValueChange(grid, node);

604
605
606
// Total realized costs on each grid over the simulation
r_gTotalRealizedCost(grid)
    = sum(gn(grid, node), r_gnTotalRealizedCost(grid, node));
607

608
609
610
611
// Total realized net costs on each grid over the simulation
r_gTotalRealizedNetCost(grid)
    = sum(gn(grid, node), r_gnTotalRealizedNetCost(grid, node));

612
// Total realized costs gn/g share
613
r_gnTotalRealizedCostShare(gn(grid, node))${ r_gTotalRealizedCost(grid) > 0 }
614
615
616
    = r_gnTotalRealizedCost(grid, node)
        / r_gTotalRealizedCost(grid);

617
618
// Total realized costs over the simulation
r_totalRealizedCost
619
    = sum(gn(grid, node), r_gnTotalRealizedCost(grid, node));
620

Niina Helistö's avatar
Niina Helistö committed
621
// Total realized net operating costs over the simulation
622
623
624
r_totalRealizedNetCost
    = sum(gn(grid, node), r_gnTotalRealizedNetCost(grid, node));

625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
// 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;

645
646
647
* --- Reserve Provision Overlap Results ---------------------------------------

// Calculate the overlapping reserve provisions
648
649
650
651
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_);
652

653
654
* --- Total Reserve Provision Results -----------------------------------------

655
656
657
658
659
// 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)
660

661
662
663
664
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));
665
666
667

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

668
// Total unit online hours per sub-unit over the simulation
669
r_uTotalOnlinePerUnit(unit)${ p_unit(unit, 'unitCount') > 0 }
670
671
672
    = r_uTotalOnline(unit)
        / p_unit(unit, 'unitCount');

673
674
// Total sub-unit startups over the simulation
r_uTotalStartup(unit, starttype)
675
    = sum(ft_realizedNoReset(f, startp(t)),
676
        + r_startup(unit, starttype, f, t)
677
            * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
678
679
680
681
        ); // END sum(ft_realizedNoReset)

// Total sub-unit shutdowns over the simulation
r_uTotalShutdown(unit)
682
    = sum(ft_realizedNoReset(f, startp(t)),
683
        + r_shutdown(unit, f, t)
684
            * sum(msft_realizedNoReset(m, s, f, t), p_msProbability(m, s) * p_msWeight(m, s))
685
686
        ); // END sum(ft_realizedNoReset)

687
688
689
690
691
692
693
694
* --- Sum results for groups --------------------------------------------------

// gnTotalgen in units that belong to gnuGroups over the simulation
r_gnTotalGenGnuGroup(grid, node, group)
    = sum(unit $ {gnuGroup(grid, node, unit, group)},
        + r_gnuTotalGen(grid, node, unit)
         ); // END sum(unit)

695
696
* --- Diagnostic Results ------------------------------------------------------

697
// Only include these if '--diag=yes' given as a command line argument
698
$iftheni.diag '%diag%' == yes
699
// Estimated coefficients of performance
700
d_cop(unit, ft_realizedNoReset(f, startp(t)))$sum(gnu_input(grid, node, unit), 1)
701
702
703
704
705
706
707
    = 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))}
708
709
            ]
        + Eps; // Eps to correct GAMS plotting (zeroes are not skipped)
710

711
712
// Estimated efficiency, calculated from inputs
d_eff(unit(unit), ft_realizedNoReset(f, t))$[ord(t) > mSettings(m, 't_start') + mSettings(m, 't_initializationPeriod')]
713
714
715
    = sum(gnu_output(grid, node, unit),
        + r_gen(grid, node, unit, f, t)
        ) // END sum(gnu_output)
716
717
        / [ sum(gnu_input(grid, node, unit),
                + abs(r_gen(grid, node, unit, f, t))
718
                ) // END sum(gnu_input)
719
            + 1${not sum(gnu_input(grid, node, unit), abs(r_gen(node, unit, f, t)))}
720
721
            ]
        + Eps; // Eps to correct GAMS plotting (zeroes are not skipped)
722
$endif.diag
723

724
); // END loop(m)
725