2b_equations.gms 87.5 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
20
21
* =============================================================================
* --- Penalty Definitions -----------------------------------------------------
* =============================================================================

Topi Rasku's avatar
Topi Rasku committed
22
$setlocal def_penalty 1e4
23
24
25
26
27
28
29
30
Scalars
    PENALTY "Default equation violation penalty" / %def_penalty% /
;
Parameters
    PENALTY_BALANCE(grid) "Penalty on violating energy balance eq. (EUR/MWh)"
    PENALTY_RES(restype, up_down) "Penalty on violating a reserve (EUR/MW)"
;
PENALTY_BALANCE(grid) = %def_penalty%;
31
PENALTY_RES(restype, up_down) = 0.9*%def_penalty%;
32
33
34
35
36
37


* =============================================================================
* --- Equation Declarations ---------------------------------------------------
* =============================================================================

38
equations
39
    // Objective Function, Energy Balance, and Reserve demand
40
    q_obj "Objective function"
41
    q_balance(grid, node, mType, f, t) "Energy demand must be satisfied at each node"
42
    q_resDemand(restype, up_down, node, f, t) "Procurement for each reserve type is greater than demand"
43
44

    // Unit Operation
45
46
    q_maxDownward(mType, grid, node, unit, f, t) "Downward commitments will not undercut power plant minimum load constraints or maximum elec. consumption"
    q_maxUpward(mType, grid, node, unit, f, t) "Upward commitments will not exceed maximum available capacity or consumed power"
47
    q_startup(mType, unit, f, t) "Capacity started up is greater than the difference of online cap. now and in the previous time step"
48
49
    q_startuptype(mType, starttype, unit, f, t) "Startup type depends on the time the unit has been non-operational"
    q_onlineLimit(mType, unit, f, t) "Number of online units limited for units with startup constraints and investment possibility"
50
51
    q_onlineMinUptime(mType, unit, f, t) "Unit must stay operational if it has started up during the previous minOperationHours hours"
*    q_minDown(mType, unit, f, t) "Unit must stay non-operational if it has shut down during the previous minShutdownHours hours"
52
    q_genRamp(mType, grid, node, s, unit, f, t) "Record the ramps of units with ramp restricitions or costs"
53
*    q_genRampChange(grid, node, mType, s, unit, f, t) "Record the ramp rates of units with ramping costs"
54
55
56
    q_rampUpLimit(mType, grid, node, s, unit, f, t) "Up ramping limited for units"
    q_runUp(mType, grid, node, unit, f, t) "Record the ramps of units with ramp restricitions or costs"
    q_runUpLastInterval(mType, grid, node, unit, f, t) "Record the ramps of units with ramp restricitions or costs"
57
58
59
*    q_rampDownLimit(grid, node, mType, s, unit, f, t) "Down ramping limited for units"
    q_outputRatioFixed(grid, node, grid, node, unit, f, t) "Force fixed ratio between two energy outputs into different energy grids"
    q_outputRatioConstrained(grid, node, grid, node, unit, f, t) "Constrained ratio between two grids of energy output; e.g. electricity generation is greater than cV times unit_heat generation in extraction plants"
60
    q_conversionDirectInputOutput(effSelector, unit, f, t) "Direct conversion of inputs to outputs (no piece-wise linear part-load efficiencies)"
Juha Kiviluoma's avatar
Juha Kiviluoma committed
61
62
63
    q_conversionSOS2InputIntermediate(effSelector, unit, f, t)   "Intermediate output when using SOS2 variable based part-load piece-wise linearization"
    q_conversionSOS2Constraint(effSelector, unit, f, t)          "Sum of v_sos2 has to equal v_online"
    q_conversionSOS2IntermediateOutput(effSelector, unit, f, t)  "Output is forced equal with v_sos2 output"
64
65
66
67
68
69
70
71
72
73
74
    q_fixedGenCap1U(grid, node, unit, t) "Fixed capacity ratio of a unit in one node versus all nodes it is connected to"
    q_fixedGenCap2U(grid, node, unit, grid, node, unit, t) "Fixed capacity ratio of two (grid, node, unit) pairs"

    // Energy Transfer
    q_transfer(grid, node, node, f, t) "Rightward and leftward transfer must match the total transfer"
    q_transferRightwardLimit(grid, node, node, f, t) "Transfer of energy and capacity reservations to the rightward direction are less than the transfer capacity"
    q_transferLeftwardLimit(grid, node, node, f, t) "Transfer of energy and capacity reservations to the leftward direction are less than the transfer capacity"
    q_resTransferLimitRightward(grid, node, node, f, t) "Transfer of energy and capacity reservations are less than the transfer capacity to the rightward direction"
    q_resTransferLimitLeftward(grid, node, node, f, t) "Transfer of energy and capacity reservations are less than the transfer capacity to the leftward direction"

    // State Variables
75
    q_stateSlack(grid, node, slack, f, t) "Slack variable greater than the difference between v_state and the slack boundary"
76
77
    q_stateUpwardLimit(grid, node, mType, f, t) "Limit the commitments of a node with a state variable to the available headrooms"
    q_stateDownwardLimit(grid, node, mType, f, t) "Limit the commitments of a node with a state variable to the available headrooms"
78
*    q_boundState(grid, node, node, mType, f, t) "Node state variables bounded by other nodes"
79
    q_boundStateMaxDiff(grid, node, node, mType, f, t) "Node state variables bounded by other nodes (maximum state difference)"
80
    q_boundCyclic(grid, node, mType, s, s) "Cyclic bound for the first and the last states of samples"
81
*    q_boundCyclicSamples(grid, node, mType, s, f, t, s_, f_, t_) "Cyclic bound inside or between samples"
82

83
    // Policy
84
    q_capacityMargin(grid, node, f, t) "There needs to be enough capacity to cover energy demand plus a margin"
Niina Helistö's avatar
Niina Helistö committed
85
    q_emissioncap(gngroup, emission) "Limit for emissions"
86
    q_instantaneousShareMax(gngroup, group, f, t) "Maximum instantaneous share of generation and controlled import from a group of units and links"
Niina Helistö's avatar
Niina Helistö committed
87
88
    q_energyShareMax(gngroup, group) "Maximum energy share of generation and import from a group of units"
    q_energyShareMin(gngroup, group) "Minimum energy share of generation and import from a group of units"
89
    q_inertiaMin(gngroup, f, t) "Minimum inertia in a group of nodes"
90
91
;

92
93
94
95
96
* =============================================================================
* --- Equation Definitions ----------------------------------------------------
* =============================================================================

* --- Objective Function ------------------------------------------------------
97
98

q_obj ..
Topi Rasku's avatar
Topi Rasku committed
99
100

    + v_obj * 1e6
101
102
103
104
105
106

    =E=

    // Sum over all the samples, forecasts, and time steps in the current model
    + sum(msft(m, s, f, t),
        // Probability (weight coefficient) of (s,f,t)
Topi Rasku's avatar
Topi Rasku committed
107
        + p_msft_probability(m, s, f, t)
108
109
110
111
112
            * [
                // Time step length dependent costs
                + p_stepLength(m, f, t)
                    * [
                        // Variable O&M costs
113
                        + sum(gnuft(gnu_output(grid, node, unit), f, t),  // Calculated only for output energy
114
                            + v_gen(grid, node, unit, f, t)
115
116
117
118
                                * p_unit(unit, 'omCosts')
                            ) // END sum(gnu_output)

                        // Fuel and emission costs
119
120
                        + sum(uFuel(unit, 'main', fuel)${uft(unit, f, t)},
                            + v_fuelUse(fuel, unit, f, t)
121
                                * [
122
                                    + ts_fuelPrice_(fuel ,t)
123
                                    + sum(emission, // Emission taxes
124
                                        + p_unitFuelEmissionCost(unit, fuel, emission)
125
126
                                        )
                                    ] // END * v_fuelUse
Topi Rasku's avatar
Topi Rasku committed
127
                            ) // END sum(uFuel)
128

Topi Rasku's avatar
Topi Rasku committed
129
                        // Node state slack variable costs
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
                        + sum(gn_stateSlack(grid, node),
                            + sum(slack${p_gnBoundaryPropertiesForStates(grid, node, slack, 'slackCost')},
                                + v_stateSlack(grid, node, slack, f, t)
                                    * p_gnBoundaryPropertiesForStates(grid, node, slack, 'slackCost')
                                ) // END sum(slack)
                            ) // END sum(gn_stateSlack)

                        // Dummy variable penalties
                        // Energy balance feasibility dummy varible penalties
                        + sum(inc_dec,
                            + sum(gn(grid, node),
                                + vq_gen(inc_dec, grid, node, f, t)
                                    * PENALTY_BALANCE(grid)
                                ) // END sum(gn)
                            ) // END sum(inc_dec)

                        // Reserve provision feasibility dummy variable penalties
                        + sum(restypeDirectionNode(restype, up_down, node),
                            + vq_resDemand(restype, up_down, node, f, t)
                                * PENALTY_RES(restype, up_down)
                            ) // END sum(restypeDirectionNode)

                        ] // END * p_stepLength

154
                // Start-up costs, initial startup free as units could have been online before model started
155
                + sum(uft_online(unit, f, t),
156
                    + sum(unitStarttype(unit, starttype),
157
158
                        + v_startup(unit, starttype, f, t) // Cost of starting up
                            * [ // Startup variable costs
159
                                + p_uStartup(unit, starttype, 'cost', 'unit')
160
161

                                // Start-up fuel and emission costs
162
                                + sum(uFuel(unit, 'startup', fuel),
Topi Rasku's avatar
Topi Rasku committed
163
                                    + p_uStartup(unit, starttype, 'consumption', 'unit')${ not unit_investLP(unit) }
164
                                        * [
165
                                            + ts_fuelPrice_(fuel, t)
166
                                            + sum(emission, // Emission taxes of startup fuel use
167
                                                + p_unitFuelEmissionCost(unit, fuel, emission)
168
169
170
171
172
173
                                                ) // END sum(emission)
                                            ] // END * p_uStartup
                                        ) // END sum(uFuel)
                                ] // END * v_startup
                        ) // END sum(starttype)
                    ) // END sum(uft_online)
174
175
$ontext
                // !!! PENDING CHANGES !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
176
                // Ramping costs
177
178
                + sum(gnuft_ramp(grid, node, unit, f, t)${  p_gnu(grid, node, unit, 'rampUpCost')
                                                            or p_gnu(grid, node, unit, 'rampDownCost')
179
180
181
182
                                                            },
                    + p_gnu(grid, node, unit, 'rampUpCost') * v_genRampChange(grid, node, unit, 'up', f, t)
                    + p_gnu(grid, node, unit, 'rampDownCost') * v_genRampChange(grid, node, unit, 'down', f, t)
                    ) // END sum(gnuft_ramp)
183
$offtext
184
                ]  // END * p_sft_probability(s,f,t)
185

186
187
        ) // END sum over msft(m, s, f, t)

188
    // Cost of energy storage change
189
    + sum(gn_state(grid, node),
190
        + sum(mft_start(m, f, t)${  p_storageValue(grid, node, t)
191
192
                                    and active(m, 'storageValue')
                                    },
193
194
            + v_state(grid, node, f, t)
                * p_storageValue(grid, node, t)
195
196
                * sum(ms(m, s)${ p_msft_probability(m, s, f, t) },
                    + p_msft_probability(m, s, f, t)
197
198
                    ) // END sum(s)
            ) // END sum(mftStart)
199
        - sum(mft_lastSteps(m, f, t)${  p_storageValue(grid, node, t)
200
201
                                        and active(m, 'storageValue')
                                        },
202
203
            + v_state(grid, node, f, t)
                * p_storageValue(grid, node, t)
204
205
                * sum(ms(m, s)${p_msft_probability(m, s, f, t)},
                    + p_msft_probability(m, s, f, t)
206
207
208
209
210
211
                    ) // END sum(s)
            ) // END sum(mftLastSteps)
        ) // END sum(gn_state)

    // Investment Costs
    + sum(t_invest(t),
212

213
214
        // Unit investment costs
        + sum(gnu(grid, node, unit),
215
            + v_invest_LP(unit, t)${ unit_investLP(unit) }
216
217
                * p_gnu(grid, node, unit, 'invCosts')
                * p_gnu(grid, node, unit, 'annuity')
218
            + v_invest_MIP(unit, t)${ unit_investMIP(unit) }
219
220
221
222
223
224
                * p_gnu(grid, node, unit, 'unitSizeTot')
                * p_gnu(grid, node, unit, 'invCosts') * p_gnu(grid, node, unit, 'annuity')
            ) // END sum(gnu)

        // Transfer link investment costs
        + sum(gn2n_directional(grid, from_node, to_node),
225
            + v_investTransfer_LP(grid, from_node, to_node, t)${ not p_gnn(grid, from_node, to_node, 'investMIP') }
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 * v_investTransfer_LP
232
            + v_investTransfer_MIP(grid, from_node, to_node, t)${ p_gnn(grid, from_node, to_node, 'investMIP') }
233
234
235
236
237
238
239
240
241
242
                * [
                    + p_gnn(grid, from_node, to_node, 'unitSize')
                        * p_gnn(grid, from_node, to_node, 'invCost')
                        * p_gnn(grid, from_node, to_node, 'annuity')
                    + p_gnn(grid, to_node, from_node, 'unitSize')
                        * p_gnn(grid, to_node, from_node, 'invCost')
                        * p_gnn(grid, to_node, from_node, 'annuity')
                    ] // END * v_investTransfer_MIP
            ) // END sum(gn2n_directional)
        ) // END sum(t_invest)
243
;
244

245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
* --- Energy Balance ----------------------------------------------------------

q_balance(gn(grid, node), mft(m, f, t))${   not p_gn(grid, node, 'boundAll')
                                            } .. // Energy/power balance dynamics solved using implicit Euler discretization

    // The left side of the equation is the change in the state (will be zero if the node doesn't have a state)
    + p_gn(grid, node, 'energyStoredPerUnitOfState')${gn_state(grid, node)} // Unit conversion between v_state of a particular node and energy variables (defaults to 1, but can have node based values if e.g. v_state is in Kelvins and each node has a different heat storage capacity)
        * [
            + v_state(grid, node, f+df_central(f,t), t)                   // The difference between current
            - v_state(grid, node, f+df(f,t+dt(t)), t+dt(t))                     // ... and previous state of the node
            ]

    =E=

    // The right side of the equation contains all the changes converted to energy terms
    + p_stepLength(m, f, t) // Multiply with the length of the timestep to convert power into energy
        $$ifi '%rampSched%' == 'yes' / 2    // Averaging all the terms on the right side of the equation over the timestep here.
        * (
            // Self discharge out of the model boundaries
            - p_gn(grid, node, 'selfDischargeLoss')${gn_state(grid, node)}
                * [
266
                    + v_state(grid, node, f+df_central(f,t), t) // The current state of the node
267
268
269
270
271
272
273
                    $$ifi '%rampSched%' == 'yes' + v_state(grid, node, f+df(f,t+dt(t)), t+dt(t)) // and possibly averaging with the previous state of the node
                    ]

            // Energy diffusion from this node to neighbouring nodes
            - sum(to_node${gnn_state(grid, node, to_node)},
                + p_gnn(grid, node, to_node, 'diffCoeff')
                    * [
274
                        + v_state(grid, node, f+df_central(f,t), t)
275
276
277
278
279
280
281
282
                        $$ifi '%rampSched%' == 'yes' + v_state(grid, node, f+df(f,t+dt(t)), t+dt(t))
                        ]
                ) // END sum(to_node)

            // Energy diffusion from neighbouring nodes to this node
            + sum(from_node${gnn_state(grid, from_node, node)},
                + p_gnn(grid, from_node, node, 'diffCoeff')
                    * [
283
                        + v_state(grid, from_node, f+df_central(f,t), t) // Incoming diffusion based on the state of the neighbouring node
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
312
313
314
315
316
317
318
                        $$ifi '%rampSched%' == 'yes' + v_state(grid, from_node, f+df(f,t+dt(t)), t+dt(t)) // Ramp schedule averaging, NOTE! State and other terms use different indeces for non-ramp-schedule!
                        ]
                ) // END sum(from_node)

            // Controlled energy transfer, applies when the current node is on the left side of the connection
            - sum(node_${gn2n_directional(grid, node, node_)},
                + (1 - p_gnn(grid, node, node_, 'transferLoss')) // Reduce transfer losses
                    * [
                        + v_transfer(grid, node, node_, f, t)
                        $$ifi '%rampSched%' == 'yes' + v_transfer(grid, node, node_, f, t+dt(t)) // Ramp schedule averaging, NOTE! State and other terms use different indeces for non-ramp-schedule!
                        ]
                + p_gnn(grid, node, node_, 'transferLoss') // Add transfer losses back if transfer is from this node to another node
                    * [
                        + v_transferRightward(grid, node, node_, f, t)
                        $$ifi '%rampSched%' == 'yes' + v_transferRightward(grid, node, node_, f, t+dt(t)) // Ramp schedule averaging, NOTE! State and other terms use different indeces for non-ramp-schedule!
                        ]
                ) // END sum(node_)

            // Controlled energy transfer, applies when the current node is on the right side of the connection
            + sum(node_${gn2n_directional(grid, node_, node)},
                + [
                    + v_transfer(grid, node_, node, f, t)
                    $$ifi '%rampSched%' == 'yes' + v_transfer(grid, node_, node, f, t+dt(t)) // Ramp schedule averaging, NOTE! State and other terms use different indeces for non-ramp-schedule!
                    ]
                - p_gnn(grid, node_, node, 'transferLoss') // Reduce transfer losses if transfer is from another node to this node
                    * [
                        + v_transferRightward(grid, node_, node, f, t)
                        $$ifi '%rampSched%' == 'yes' + v_transferRightward(grid, node_, node, f, t+dt(t)) // Ramp schedule averaging, NOTE! State and other terms use different indeces for non-ramp-schedule!
                        ]
                ) // END sum(node_)

            // Interactions between the node and its units
            + sum(gnuft(grid, node, unit, f, t),
                + v_gen(grid, node, unit, f, t) // Unit energy generation and consumption
                $$ifi '%rampSched%' == 'yes' + v_gen(grid, node, unit, f, t+dt(t))
319
                )
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334

            // Spilling energy out of the endogenous grids in the model
            - v_spill(grid, node, f, t)${node_spill(node)}
            $$ifi '%rampSched%' == 'yes' - v_spill(grid, node, f, t)${node_spill(node)}

            // Power inflow and outflow timeseries to/from the node
            + ts_influx_(grid, node, f, t)   // Incoming (positive) and outgoing (negative) absolute value time series
            $$ifi '%rampSched%' == 'yes' + ts_influx_(grid, node, f, t+dt(t))

            // Dummy generation variables, for feasibility purposes
            + vq_gen('increase', grid, node, f, t) // Note! When stateSlack is permitted, have to take caution with the penalties so that it will be used first
            $$ifi '%rampSched%' == 'yes' + vq_gen('increase', grid, node, f, t+dt(t))
            - vq_gen('decrease', grid, node, f, t) // Note! When stateSlack is permitted, have to take caution with the penalties so that it will be used first
            $$ifi '%rampSched%' == 'yes' - vq_gen('decrease', grid, node, f, t+dt(t))
    ) // END * p_stepLength
335
;
336
337
338

* --- Reserve Demand ----------------------------------------------------------

339
340
q_resDemand(restypeDirectionNode(restype, up_down, node), ft(f, t)) ${   ord(t) < tSolveFirst + sum[mf(m, f), mSettings(m, 't_reserveLength')]
                                                                        and not [ restypeReleasedForRealization(restype)
341
342
                                                                                    and ft_realized(f, t)
                                                                                    ]
Topi Rasku's avatar
Topi Rasku committed
343
                                                                        } ..
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
    // Reserve provision by capable units on this node
    + sum(nuft(node, unit, f, t)${nuRescapable(restype, up_down, node, unit)},
        + v_reserve(restype, up_down, node, unit, f+df_nReserves(node, restype, f, t), t)
        ) // END sum(nuft)

    // Reserve provision to this node via transfer links
    + sum(gn2n_directional(grid, node_, node)${restypeDirectionNode(restype, up_down, node_)},
        + (1 - p_gnn(grid, node_, node, 'transferLoss') )
            * v_resTransferRightward(restype, up_down, node_, node, f+df_nReserves(node_, restype, f, t), t)             // Reserves from another node - reduces the need for reserves in the node
        ) // END sum(gn2n_directional)
    + sum(gn2n_directional(grid, node, node_)${restypeDirectionNode(restype, up_down, node_)},
        + (1 - p_gnn(grid, node, node_, 'transferLoss') )
            * v_resTransferLeftward(restype, up_down, node, node_, f+df_nReserves(node_, restype, f, t), t)             // Reserves from another node - reduces the need for reserves in the node
        ) // END sum(gn2n_directional)

    =G=

    // Demand for reserves
    + ts_reserveDemand_(restype, up_down, node, f, t)${p_nReserves(node, restype, 'use_time_series')}
    + p_nReserves(node, restype, up_down)${not p_nReserves(node, restype, 'use_time_series')}

    // Reserve provisions to another nodes via transfer links
    + sum(gn2n_directional(grid, node, node_)${restypeDirectionNode(restype, up_down, node_)},   // If trasferring reserves to another node, increase your own reserves by same amount
        + v_resTransferRightward(restype, up_down, node, node_, f+df_nReserves(node, restype, f, t), t)
        ) // END sum(gn2n_directional)
    + sum(gn2n_directional(grid, node_, node)${restypeDirectionNode(restype, up_down, node_)},   // If trasferring reserves to another node, increase your own reserves by same amount
        + v_resTransferLeftward(restype, up_down, node_, node, f+df_nReserves(node, restype, f, t), t)
        ) // END sum(gn2n_directional)

    // Reserve demand feasibility dummy variables
    - vq_resDemand(restype, up_down, node, f, t)

376
;
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414

* --- Maximum Downward Capacity -----------------------------------------------

q_maxDownward(m, gnuft(grid, node, unit, f, t))${   [   ord(t) < tSolveFirst + mSettings(m, 't_reserveLength') // Unit is either providing
                                                        and sum(restype, nuRescapable(restype, 'down', node, unit)) // downward reserves
                                                        ]
                                                    // NOTE!!! Could be better to form a gnuft_reserves subset?
                                                    or [ // the unit has an online variable
                                                        uft_online(unit, f, t)
                                                        and [
                                                            (unit_minLoad(unit) and p_gnu(grid, node, unit, 'unitSizeGen')) // generators with a min. load
                                                            or p_gnu(grid, node, unit, 'maxCons') // or consuming units with an online variable
                                                            ]
                                                        ] // END or
                                                    or [ // consuming units with investment possibility
                                                        gnu_input(grid, node, unit)
                                                        and [unit_investLP(unit) or unit_investMIP(unit)]
                                                        ]
                                                    } ..

    // Energy generation/consumption
    + v_gen(grid, node, unit, f, t)

    // Considering output constraints (e.g. cV line)
    + sum(gngnu_constrainedOutputRatio(grid, node, grid_, node_, unit),
        + p_gnu(grid_, node_, unit, 'cV')
            * v_gen(grid_, node_, unit, f, t)
        ) // END sum(gngnu_constrainedOutputRatio)

    // Downward reserve participation
    - sum(nuRescapable(restype, 'down', node, unit)${ord(t) < tSolveFirst + mSettings(m, 't_reserveLength')},
        + v_reserve(restype, 'down', node, unit, f+df_nReserves(node, restype, f, t), t) // (v_reserve can be used only if the unit is capable of providing a particular reserve)
        ) // END sum(nuRescapable)

    =G= // Must be greater than minimum load or maximum consumption  (units with min-load and both generation and consumption are not allowed)

    // Generation units, greater than minload
    + p_gnu(grid, node, unit, 'unitSizeGen')
415
        * sum(suft(effGroup, unit, f, t), // Uses the minimum 'lb' for the current efficiency approximation
416
417
418
419
            + p_effGroupUnit(effGroup, unit, 'lb')${not ts_effGroupUnit(effGroup, unit, 'lb', f, t)}
            + ts_effGroupUnit(effGroup, unit, 'lb', f, t)
            ) // END sum(effGroup)
        * [ // Online variables should only be generated for units with restrictions
420
421
            + v_online_LP(unit, f+df_central(f,t), t)${uft_onlineLP(unit, f, t)} // LP online variant
            + v_online_MIP(unit, f+df_central(f,t), t)${uft_onlineMIP(unit, f, t)} // MIP online variant
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
            ] // END v_online

    // Consuming units, greater than maxCons
    // Available capacity restrictions
    - p_unit(unit, 'availability')
        * [
            // Capacity factors for flow units
            + sum(flow${flowUnit(flow, unit)},
                + ts_cf_(flow, node, f, t)
                ) // END sum(flow)
            + 1${not unit_flow(unit)}
            ] // END * p_unit(availability)
        * [
            // Online capacity restriction
            + p_gnu(grid, node, unit, 'maxCons')${not uft_online(unit, f, t)} // Use initial maximum if no online variables
            + p_gnu(grid, node, unit, 'unitSizeCons')
                * [
439
                    // Capacity online
440
441
                    + v_online_LP(unit, f+df_central(f,t), t)${uft_onlineLP(unit, f, t)}
                    + v_online_MIP(unit, f+df_central(f,t), t)${uft_onlineMIP(unit, f, t)}
442
443
444
445
446
447
448
449

                    // Investments to additional non-online capacity
                    + sum(t_invest(t_)${    ord(t_)<=ord(t)
                                            and not uft_online(unit, f, t)
                                            },
                        + v_invest_LP(unit, t_)${unit_investLP(unit)} // NOTE! v_invest_LP also for consuming units is positive
                        + v_invest_MIP(unit, t_)${unit_investMIP(unit)} // NOTE! v_invest_MIP also for consuming units is positive
                        ) // END sum(t_invest)
450
451
                    ] // END * p_gnu(unitSizeCons)
            ] // END * p_unit(availability)
452
;
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488

* --- Maximum Upwards Capacity ------------------------------------------------

q_maxUpward(m, gnuft(grid, node, unit, f, t))${ [   ord(t) < tSolveFirst + mSettings(m, 't_reserveLength') // Unit is either providing
                                                    and sum(restype, nuRescapable(restype, 'up', node, unit)) // upward reserves
                                                    ]
                                                or [
                                                    uft_online(unit, f, t) // or the unit has an online variable
                                                        and [
                                                            [unit_minLoad(unit) and p_gnu(grid, node, unit, 'unitSizeCons')] // consuming units with min_load
                                                            or [p_gnu(grid, node, unit, 'maxGen')]                          // generators with an online variable
                                                            ]
                                                    ]
                                                or [
                                                    gnu_output(grid, node, unit) // generators with investment possibility
                                                    and (unit_investLP(unit) or unit_investMIP(unit))
                                                    ]
                                                }..
    // Energy generation/consumption
    + v_gen(grid, node, unit, f, t)

    // Considering output constraints (e.g. cV line)
    + sum(gngnu_constrainedOutputRatio(grid, node, grid_output, node_, unit),
        + p_gnu(grid_output, node_, unit, 'cV')
            * v_gen(grid_output, node_, unit, f, t)
        ) // END sum(gngnu_constrainedOutputRatio)

    // Upwards reserve participation
    + sum(nuRescapable(restype, 'up', node, unit)${ord(t) < tSolveFirst + mSettings(m, 't_reserveLength')},
        + v_reserve(restype, 'up', node, unit, f+df_nReserves(node, restype, f, t), t)
        ) // END sum(nuRescapable)

    =L= // must be less than available/online capacity

    // Consuming units
    + p_gnu(grid, node, unit, 'unitSizeCons')
489
        * sum(suft(effGroup, unit, f, t), // Uses the minimum 'lb' for the current efficiency approximation
490
491
492
493
            + p_effGroupUnit(effGroup, unit, 'lb')${not ts_effGroupUnit(effGroup, unit, 'lb', f, t)}
            + ts_effGroupUnit(effGroup, unit, 'lb', f, t)
            ) // END sum(effGroup)
        * [
494
495
            + v_online_LP(unit, f+df_central(f,t), t)${uft_onlineLP(unit, f, t)} // Consuming units are restricted by their min. load (consuming is negative)
            + v_online_MIP(unit, f+df_central(f,t), t)${uft_onlineMIP(unit, f, t)} // Consuming units are restricted by their min. load (consuming is negative)
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
            ] // END * p_gnu(unitSizeCons)

    // Generation units
    // Available capacity restrictions
    + p_unit(unit, 'availability') // Generation units are restricted by their (available) capacity
        * [
            // Capacity factor for flow units
            + sum(flow${flowUnit(flow, unit)},
                + ts_cf_(flow, node, f, t)
                ) // END sum(flow)
            + 1${not unit_flow(unit)}
            ] // END * p_unit(availability)
        * [
            // Online capacity restriction
            + p_gnu(grid, node, unit, 'maxGen')${not uft_online(unit, f, t)} // Use initial maxGen if no online variables
            + p_gnu(grid, node, unit, 'unitSizeGen')
                * [
513
                    // Capacity online
514
515
                    + v_online_LP(unit, f+df_central(f,t), t)${uft_onlineLP(unit, f ,t)}
                    + v_online_MIP(unit, f+df_central(f,t), t)${uft_onlineMIP(unit, f, t)}
516
517
518
519
520
521
522
523

                    // Investments to non-online capacity
                    + sum(t_invest(t_)${    ord(t_)<=ord(t)
                                            and not uft_online(unit, f ,t)
                                            },
                        + v_invest_LP(unit, t_)${unit_investLP(unit)}
                        + v_invest_MIP(unit, t_)${unit_investMIP(unit)}
                        ) // END sum(t_invest)
524
525
                    ] // END * p_gnu(unitSizeGen)
            ] // END * p_unit(availability)
526
;
527
528
529

* --- Unit Startup and Shutdown -----------------------------------------------

530
q_startup(m, uft_online(unit, f, t))${ ord(t) + dt(t) > mSettings(m, 't_start') } ..
531
532

    // Units currently online
533
534
    + v_online_LP(unit, f+df_central(f,t), t)${uft_onlineLP(unit, f, t)}
    + v_online_MIP(unit, f+df_central(f,t), t)${uft_onlineMIP(unit, f, t)}
535
536
537
538

    =E=

    // Units previously online
539
    + v_online_LP(unit, f+df(f,t+dt(t)), t+dt(t))${ uft_onlineLP(unit, f+df(f,t+dt(t)), t+dt(t)) } // This reaches to tFirstSolve when dt = -1
540
    + v_online_MIP(unit, f+df(f,t+dt(t)), t+dt(t))${ uft_onlineMIP(unit, f+df(f,t+dt(t)), t+dt(t)) }
541
542
543
544
545

    // Unit online history (solve initial value), required because uft_online doesn't extend to before active modelling
    + r_online(unit, f+df(f,t+dt(t)), t+dt(t))${    not uft_onlineLP(unit, f+df(f,t+dt(t)), t+dt(t))
                                                    and not uft_onlineMIP(unit, f+df(f,t+dt(t)), t+dt(t))
                                                    }
546
547

    // Unit startup and shutdown
548
    + sum(unitStarttype(unit, starttype),
549
        + v_startup(unit, starttype, f, t-ceil[p_uRunUpTimeIntervals(unit)])  // THIS DOESN'T WORK WITH TIME STEPS LARGER THAN THE BASE INTERVAL
550
551
        ) // END sum(starttype)
    - v_shutdown(unit, f, t)
552
;
553

554
*--- Startup Type -------------------------------------------------------------
555
// !!! NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
556
557
558
// This formulation doesn't work as intended when unitCount > 1, as one recent
// shutdown allows for multiple hot/warm startups on subsequent time steps.
// Pending changes.
559

560
q_startuptype(m, starttypeConstrained(starttype), uft_online(unit, f, t))${ unitStarttype(unit, starttype) } ..
561
562
563
564
565
566
567

    // Startup type
    + v_startup(unit, starttype, f, t)

    =L=

    // Subunit shutdowns within special startup timeframe
568
    + sum(counter${dt_starttypeUnitCounter(starttype, unit, counter)},
569
        + v_shutdown(unit, f+df(f,t+dt_starttypeUnitCounter(starttype, unit, counter)), t+dt_starttypeUnitCounter(starttype, unit, counter))
570
    ) // END sum(counter)
571
;
572

573

574
575
*--- Online Limits with Startup Type Constraints and Investments --------------

576
q_onlineLimit(m, uft_online(unit, f, t))${  p_unit(unit, 'minShutdownHours')
577
578
579
580
                                            or unit_investLP(unit)
                                            or unit_investMIP(unit)
                                            } ..
    // Online variables
581
582
    + v_online_LP(unit, f+df_central(f,t), t)${uft_onlineLP(unit, f, t)}
    + v_online_MIP(unit, f+df_central(f,t), t)${uft_onlineMIP(unit, f ,t)}
583
584
585
586
587
588
589

    =L=

    // Number of existing units
    + p_unit(unit, 'unitCount')

    // Number of units unable to start due to restrictions
590
591
    - sum(counter${dt_downtimeUnitCounter(unit, counter)},
        + v_shutdown(unit, f+df(f,t+dt_downtimeUnitCounter(unit, counter)), t+dt_downtimeUnitCounter(unit, counter))
592
    ) // END sum(counter)
593
594
595
596
597
598
599
600
601
602

    // Investments into units
    + sum(t_invest(t_)${ord(t_)<=ord(t)},
        + v_invest_LP(unit, t_)
        + v_invest_MIP(unit, t_)
        ) // END sum(t_invest)
;

*--- Minimum Unit Uptime ------------------------------------------------------

603
q_onlineMinUptime(m, uft_online(unit, f, t))${  p_unit(unit, 'minOperationHours')
604
605
606
                                                } ..

    // Units currently online
607
608
    + v_online_LP(unit, f+df_central(f,t), t)${uft_onlineLP(unit, f, t)}
    + v_online_MIP(unit, f+df_central(f,t), t)${uft_onlineMIP(unit, f, t)}
609
610
611
612

    =G=

    // Units that have minimum operation time requirements active
613
    + sum(counter${dt_uptimeUnitCounter(unit, counter)},
614
        + sum(unitStarttype(unit, starttype),
615
            + v_startup(unit, starttype, f+df(f,t+dt_uptimeUnitCounter(unit, counter)), t+dt_uptimeUnitCounter(unit, counter))
616
            ) // END sum(starttype)
617
    ) // END sum(counter)
618
619
;

620
621
* --- Ramp Constraints --------------------------------------------------------
// !!! CURRENTLY REMOVED, PENDING CHANGE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
622
q_genRamp(m, gn(grid, node), s, uft(unit, f, t))${  gnuft_ramp(grid, node, unit, f, t)
623
624
625
626
                                                    and ord(t) > msStart(m, s)
                                                    and ord(t) <= msEnd(m, s)
                                                    } ..

627
628
    + v_genRamp(grid, node, unit, f, t)
        / p_stepLength(m, f, t)
629
630
    =E=
    // Change in generation over the time step
631
    + v_gen(grid, node, unit, f, t)
632
    - v_gen(grid, node, unit, f+df(f,t), t+dt(t))
633
634
;
* -----------------------------------------------------------------------------
635
$ontext
636
q_genRampChange(m, gn(grid, node), s, unit, ft(f, t))${ gnuft_ramp(grid, node, unit, f, t)
Niina Helistö's avatar
Niina Helistö committed
637
638
639
*                                                     and ord(t) > mSettings(m, 't_start')
                                                     and ord(t) > msStart(m, s)
                                                     and ord(t) <= msEnd(m, s)
640
641
642
643
                                                     and [ p_gnu(grid, node, unit, 'rampUpCost')
                                                           or p_gnu(grid, node, unit, 'rampDownCost')
                                                           ]
                                                     } ..
644
645
    + v_genRampChange(grid, node, unit, 'up', f+pf(f,t), t+dt(t))
    - v_genRampChange(grid, node, unit, 'down', f+pf(f,t), t+dt(t))
646
    =E=
647
    + v_genRamp(grid, node, unit, f, t)
648
    - v_genRamp(grid, node, unit, f+pf(f,t), t+dt(t));
649
650
$offtext

651
652
653
654
* --- Ramp Up Limits ----------------------------------------------------------
// !!! PENDING CHANGES !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// The way ramp limits are defined are waiting changes, so these equations have
// to be rewritten in the future.
655
q_rampUpLimit(m, gn(grid, node), s, unit, ft(f, t))${ gnuft_ramp(grid, node, unit, f, t)
656
657
658
659
                                                   and ord(t) > msStart(m, s)
                                                   and msft(m, s, f, t)
                                                   and p_gnu(grid, node, unit, 'maxRampUp')
                                                   } ..
660
661
  + v_genRamp(grid, node, unit, f, t+dt(t))
  + sum(resType, v_reserve(resType, 'up', node, unit, f, t+dt(t)))
662
  =L=
663
    // Ramping capability of units without an online variable in the previous and in the current time steps
664
  + (
665
666
667
668
669
670
      + ( p_gnu(grid, node, unit, 'maxGen') + p_gnu(grid, node, unit, 'maxCons') )${not uft_online(unit, f, t)}
      + sum(t_$(t_invest(t_) and ord(t_)<=ord(t)),
          + v_invest_LP(unit, t_)${not uft_onlineLP(unit, f+df(f,t), t+dt(t)) and p_gnu(grid, node, unit, 'maxGenCap')}
          + v_invest_LP(unit, t_)${not uft_onlineLP(unit, f+df(f,t), t+dt(t)) and p_gnu(grid, node, unit, 'maxConsCap')}
          + v_invest_MIP(unit, t_)${not uft_onlineMIP(unit, f+df(f,t), t+dt(t))}
              * p_gnu(grid, node, unit, 'unitSizeTot')
671
        )
Juha Kiviluoma's avatar
Juha Kiviluoma committed
672
    )
673
      * p_gnu(grid, node, unit, 'maxRampUp')
674
675
      * 60   // Unit conversion from [p.u./min] to [p.u./h]
    // Ramping capability of units with an online variable both in the previous time step and the current time step
676
  + (
677
678
679
      + v_online_LP(unit, f, t)${uft_onlineLP(unit, f, t)}
      + v_online_MIP(unit, f, t)${uft_onlineMIP(unit, f, t)}
      - v_shutdown(unit, f, t)${uft_online(unit, f, t)}
680
    )
681
682
683
684
685
686
687
688
689
690
      * p_gnu(grid, node, unit, 'unitSizeTot')
      // I don't see why we need to scale - v_online_LP should contain number of units started up just like v_online_MIP (Juha) / {
      //    + 1${  not unit_investLP(unit)
      //           or not p_gnu(grid, node, unit, 'unitSizeGenTot')
      //        }
      //    + sum(gnu(grid_, node_, unit)${ unit_investLP(unit)
      //                                    and p_gnu(grid, node, unit, 'unitSizeGenNet')
      //          }, p_gnu(grid_, node_, unit, 'unitSizeTot')
      //      )
      //  } // Scaling factor to calculate online capacity in gn(grid, node) in the case of continuous investments
691
      * p_gnu(grid, node, unit, 'maxRampUp')
692
693
      * 60   // Unit conversion from [p.u./min] to [p.u./h]
  // Units started up in the previous time-step are assumed to start to their minload and
694
  // newly shutdown units are assumed to be shut down from their minload.
695
$ontext
696
  + (
697
698
      + sum(starttype${unitStarttype(unit, starttype)}, v_startup(unit, starttype, f, t)) )
      * p_gnu(grid, node, unit, 'unitSizeTot')
699
      / {
700
          + 1${not unit_investLP(unit) or not p_gnu(grid, node, unit, 'unitSizeTot')}
701
          + sum(gnu(grid_, node_, unit)${ unit_investLP(unit)
702
                                          and p_gnu(grid, node, unit, 'unitSizeTot')
703
704
705
                }, p_gnu(grid_, node_, unit, 'unitSizeTot')
            )
        } // Scaling factor to calculate online capacity in gn(grid, node) in the case of continuous investments
706
707
708
      * sum(suft(effGroup, unit, f+df(f,t), t), p_effGroupUnit(effGroup, unit, 'lb')
    )$uft_online(unit, f, t)
$offtext
709
710
711
712
// Note: This constraint does not limit ramping properly for example if online subunits are
// producing at full capacity (= not possible to ramp up) and more subunits are started up.
// Take this into account in q_maxUpward or in another equation?:
// v_gen =L= (v_online(t-1) - v_shutdown(t-1)) * unitSize + v_startup(t-1) * unitSize * minLoad
713
;
714
$ontext
715
716
717
718
719
* --- Ramp Down Limits --------------------------------------------------------
q_rampDownLimit(gn(grid, node), m, s, unit, ft(f, t))${ gnuft_ramp(grid, node, unit, f, t)
                                                     and ord(t) > msStart(m, s)
                                                     and msft(m, s, f, t)
                                                     and p_gnu(grid, node, unit, 'maxRampDown')
720
                                                     and (uft_online_incl_previous(unit, f+df(f,t), t+dt(t))
721
722
723
                                                             or unit_investLP(unit)
                                                             or unit_investMIP(unit))
                                                     } ..
724
725
  + v_genRamp(grid, node, unit, f, t+dt(t))
  + sum(resType, v_reserve(resType, 'down', node, unit, f, t+dt(t)))
726
727
728
  =G=
    // Ramping capability of units without online variable
  - (
729
      + ( p_gnu(grid, node, unit, 'maxGen') - p_gnu(grid, node, unit, 'maxCons') )${not uft_online_incl_previous(unit, f+df(f,t), t+dt(t))}
730
      + sum(t_$(ord(t_)<=ord(t)),
731
732
733
          + v_invest_LP(grid, node, unit, t_)${not uft_online_incl_previous(unit, f+df(f,t), t+dt(t)) and p_gnu(grid, node, unit, 'maxGenCap')}
          - v_invest_LP(grid, node, unit, t_)${not uft_online_incl_previous(unit, f+df(f,t), t+dt(t)) and p_gnu(grid, node, unit, 'maxConsCap')}
          + v_invest_MIP(unit, t_)${not uft_online_incl_previous(unit, f+df(f,t), t+dt(t))}
734
              * p_gnu(grid, node, unit, 'unitSizeGenNet')
735
        )
Juha Kiviluoma's avatar
Juha Kiviluoma committed
736
    )
737
      * p_gnu(grid, node, unit, 'maxRampDown')
738
      * 60   // Unit conversion from [p.u./min] to [p.u./h]
739
740
    // Ramping capability of units that were online both in the previous time step and the current time step
  - (
741
742
743
      + v_online_LP(unit, f+df(f,t), t+dt(t))${uft_online_incl_previous(unit, f+df(f,t), t+dt(t))}
      + v_online(unit, f+df(f,t), t+dt(t))${uft_online_incl_previous(unit, f+df(f,t), t+dt(t))}
      - v_shutdown(unit, f+cf(f,t), t+dt(t))${uft_online_incl_previous(unit, f+df(f,t), t+dt(t))}
Juha Kiviluoma's avatar
Juha Kiviluoma committed
744
    )
745
746
747
748
749
750
751
752
753
754
755
      * p_gnu(grid, node, unit, 'unitSizeGenNet')
      / {
          + 1${  not unit_investLP(unit)
                 or not p_gnu(grid, node, unit, 'unitSizeGenNet')
              }
          + sum(gnu(grid_, node_, unit)${ unit_investLP(unit)
                                          and p_gnu(grid, node, unit, 'unitSizeGenNet')
                }, p_gnu(grid_, node_, unit, 'unitSizeTot')
            )
        } // Scaling factor to calculate online capacity in gn(grid, node) in the case of continuous investments
      * p_gnu(grid, node, unit, 'maxRampDown')
756
      * 60   // Unit conversion from [p.u./min] to [p.u./h]
757
758
759
  // Newly started units are assumed to start to their minload and
  // newly shutdown units are assumed to be shut down from their minload.
  + (
760
761
762
      + sum(starttype$unitStarttype(unit, starttype), v_startup(unit, starttype, f+cf(f,t), t+dt(t)))
      - v_shutdown(unit, f+cf(f,t), t+dt(t))
    )${uft_online_incl_previous(unit, f+df(f,t), t+dt(t))}
763
764
765
766
767
768
769
770
771
      * p_gnu(grid, node, unit, 'unitSizeGenNet')
      / {
          + 1${not unit_investLP(unit) or not p_gnu(grid, node, unit, 'unitSizeGenNet')}
          + sum(gnu(grid_, node_, unit)${ unit_investLP(unit)
                                          and p_gnu(grid, node, unit, 'unitSizeGenNet')
                }, p_gnu(grid_, node_, unit, 'unitSizeTot')
            )
        } // Scaling factor to calculate online capacity in gn(grid, node) in the case of continuous investments
      * sum(suft(effGroup, unit, f+cf(f,t), t), p_effGroupUnit(effGroup, unit, 'lb'))
772
;
773
774
$offtext

775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
q_runUp(m, gn(grid,node), uft_online(unit, f, t))$(p_uRunUpTimeIntervals(unit) > 1) ..
    // Energy generation/consumption
    + v_genRamp(grid, node, unit, f, t)

    =E=

    + sum(t_$(ord(t_) <= ord(t) + floor[p_uRunUpTimeIntervals(unit)] and uft_online(unit, f, t_)),
        + sum(unitStarttype(unit, starttype),
            + v_startup(unit, starttype, f, t_)
          )
      ) * p_unit(unit, 'rampSpeedToMinLoad')
;

q_runUpLastInterval(m, gn(grid,node), uft_online(unit, f, t))$(p_unit(unit, 'op00') > 0 and p_unit(unit, 'rampSpeedToMinLoad')) ..
    // Energy generation/consumption
    + v_genRamp(grid, node, unit, f, t)

    =L=

    + sum(t_$(ord(t_) = ord(t) + ceil[p_uRunUpTimeIntervals(unit)] and uft_online(unit, f, t_)),
        + sum(unitStarttype(unit, starttype),
            + v_startup(unit, starttype, f, t_)
          )
      ) * p_uMaxRampInLastRunUpInterval(unit)
;

801
802
803
804
805
806
807
808
809
810
811
812
813
814
* --- Fixed Output Ratio ------------------------------------------------------

q_outputRatioFixed(gngnu_fixedOutputRatio(grid, node, grid_, node_, unit), ft(f, t))${  uft(unit, f, t)
                                                                                        } ..

    // Generation in grid
    + v_gen(grid, node, unit, f, t)
        / p_gnu(grid, node, unit, 'cB')

    =E=

    // Generation in grid_
    + v_gen(grid_, node_, unit, f, t)
        / p_gnu(grid_, node_, unit, 'cB')
815
;
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830

* --- Constrained Output Ratio ------------------------------------------------

q_outputRatioConstrained(gngnu_constrainedOutputRatio(grid, node, grid_, node_, unit), ft(f, t))${  uft(unit, f, t)
                                                                                                    } ..

    // Generation in grid
    + v_gen(grid, node, unit, f, t)
        / p_gnu(grid, node, unit, 'cB')

    =G=

    // Generation in grid_
    + v_gen(grid_, node_, unit, f, t)
        / p_gnu(grid_, node_, unit, 'cB')
Juha Kiviluoma's avatar
Juha Kiviluoma committed
831
;
832
833
834

* --- Direct Input-Output Conversion ------------------------------------------

835
q_conversionDirectInputOutput(suft(effDirect(effGroup), unit, f, t)) ..
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852

    // Sum over endogenous energy inputs
    - sum(gnu_input(grid, node, unit),
        + v_gen(grid, node, unit, f, t)
        ) // END sum(gnu_input)

    // Sum over fuel energy inputs
    + sum(uFuel(unit, 'main', fuel),
        + v_fuelUse(fuel, unit, f, t)
        ) // END sum(uFuel)

    =E=

    // Sum over energy outputs
    + sum(gnu_output(grid, node, unit),
        + v_gen(grid, node, unit, f, t)
            * [ // Heat rate
853
                + p_effUnit(effGroup, unit, effGroup, 'slope')${ not ts_effUnit(effGroup, unit, effGroup, 'slope', f, t) }
854
                + ts_effUnit(effGroup, unit, effGroup, 'slope', f, t)
855
856
857
                ] // END * v_gen
        ) // END sum(gnu_output)

858
    // Consumption of keeping units online (no-load fuel use)
859
860
861
862
    + sum(gnu_output(grid, node, unit),
        + p_gnu(grid, node, unit, 'unitSizeGen')
        ) // END sum(gnu_output)
        * [
863
864
            + v_online_LP(unit, f+df_central(f,t), t)${uft_onlineLP(unit, f, t)}
            + v_online_MIP(unit, f+df_central(f,t), t)${uft_onlineMIP(unit, f, t)}
865
866
            ] // END * sum(gnu_output)
        * [
867
868
            + p_effGroupUnit(effGroup, unit, 'section')${not ts_effUnit(effGroup, unit, effDirect, 'section', f, t)}
            + ts_effUnit(effGroup, unit, effGroup, 'section', f, t)
869
            ] // END * sum(gnu_output)
870
;
871
872
873

* --- SOS2 Efficiency Approximation -------------------------------------------

874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
q_conversionSOS2InputIntermediate(suft(effLambda(effGroup), unit, f, t)) ..

    // Sum over endogenous energy inputs
    - sum(gnu_input(grid, node, unit),
        + v_gen(grid, node, unit, f, t)
        ) // END sum(gnu_input)

    // Sum over fuel energy inputs
    + sum(uFuel(unit, 'main', fuel),
        + v_fuelUse(fuel, unit, f, t)
        ) // END sum(uFuel)

    =E=

    // Sum over the endogenous outputs of the unit
    + sum(gnu_output(grid, node, unit), p_gnu(grid, node, unit, 'unitSizeGen'))
        * [
            // Consumption of generation
892
            + sum(effGroupSelectorUnit(effGroup, unit, effSelector),
893
894
895
896
897
898
899
900
901
902
903
904
                + v_sos2(unit, f, t, effSelector)
                    * [ // Operation points convert the v_sos2 variables into share of capacity used for generation
                        + p_effUnit(effGroup, unit, effSelector, 'op')${not ts_effUnit(effGroup, unit, effSelector, 'op', f, t)}
                        + ts_effUnit(effGroup, unit, effSelector, 'op', f, t)
                        ] // END * v_sos2
                    * [ // Heat rate
                        + p_effUnit(effGroup, unit, effSelector, 'slope')${not ts_effUnit(effGroup, unit, effSelector, 'slope', f, t)}
                        + ts_effUnit(effGroup, unit, effSelector, 'slope', f, t)
                        ] // END * v_sos2
                ) // END sum(effSelector)

            // Consumption of keeping units online
905
            + v_online_MIP(unit, f+df_central(f,t), t)${uft_onlineMIP(unit, f, t)}
906
907
                * p_effGroupUnit(effGroup, unit, 'section')
            ] // END * sum(gnu_output)
908
;
909
910
911
912
913
914

* --- SOS 2 Efficiency Approximation Online Variables -------------------------

q_conversionSOS2Constraint(suft(effLambda(effGroup), unit, f, t)) ..

    // Total value of the v_sos2 equals the number of online units
915
    + sum(effGroupSelectorUnit(effGroup, unit, effSelector),
916
917
918
919
920
921
        + v_sos2(unit, f, t, effSelector)
        ) // END sum(effSelector)

    =E=

    // Number of units online
922
    + v_online_MIP(unit, f+df_central(f,t), t)${uft_onlineMIP(unit, f, t)}
923
;
924
925
926
927
928
929
930
931
932

* --- SOS 2 Efficiency Approximation Output Generation ------------------------

q_conversionSOS2IntermediateOutput(suft(effLambda(effGroup), unit, f, t)) ..

    // Endogenous energy output
    + sum(gnu_output(grid, node, unit),
        + p_gnu(grid, node, unit, 'unitSizeGen')
        ) // END sum(gnu_output)
933
        * sum(effGroupSelectorUnit(effGroup, unit, effSelector),
934
935
936
937
938
939
940
941
942
943
944
945
946
            + v_sos2(unit, f, t, effSelector)
            * [ // Operation points convert v_sos2 into share of capacity used for generation
                + p_effUnit(effGroup, unit, effSelector, 'op')${not ts_effUnit(effGroup, unit, effSelector, 'op', f, t)}
                + ts_effUnit(effGroup, unit, effSelector, 'op', f, t)
                ] // END * v_sos2
            ) // END sum(effSelector)

    =E=

    // Energy output into v_gen
    + sum(gnu_output(grid, node, unit),
        + v_gen(grid, node, unit, f, t)
        ) // END sum(gnu_output)
Juha Kiviluoma's avatar
Juha Kiviluoma committed
947
;
948

949
950
951
952
953
*--- Fixed Investment Ratios --------------------------------------------------
// !!! PENDING FIX !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// v_invest(unit) instead of the old v_invest(grid, node, unit)
// Are these even necessary anymore, if investment is unitwise?
// Maybe for batteries etc?
954

955
956
q_fixedGenCap1U(gnu(grid, node, unit), t_invest(t))${   unit_investLP(unit)
                                                        } ..
957

958
959
    // Investment
    + v_invest_LP(unit, t)
960
961
962

    =E=

963
964
965
966
967
968
969
970
    // Capacity Ratios?
    + sum(gn(grid_, node_),
        + v_invest_LP(unit, t)
        ) // END sum(gn)
        * p_gnu(grid, node, unit, 'unitSizeTot')
        / sum(gn(grid_, node_),
            + p_gnu(grid_, node_, unit, 'unitSizeTot')
            ) // END sum(gn)
971
;
972

973
974
975
*--- Fixed Investment Ratios 2 ------------------------------------------------
// !!! PENDING FIX !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// See notes in the above equation
976

977
978
q_fixedGenCap2U(grid, node, unit, grid_, node_, unit_, t_invest(t))${   p_gnugnu(grid, node, unit, grid_, node_, unit_, 'capacityRatio')
                                                                        } ..
979

980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
    // Investment
    + v_invest_LP(unit, t)
    + v_invest_MIP(unit, t)

    =E=

    // Capacity Ratio?
    + p_gnugnu(grid, node, unit, grid_, node_, unit_, 'capacityRatio')
        * [
            + v_invest_LP(unit_, t)
            + v_invest_MIP(unit_, t)
            ] // END * p_gngnu(capacityRatio)
;

* --- Total Transfer Limits ---------------------------------------------------

q_transfer(gn2n_directional(grid, node, node_), ft(f, t)) ..

    // Rightward + Leftward
    + v_transferRightward(grid, node, node_, f, t)
    - v_transferLeftward(grid, node, node_, f, t)