3b_inputsLoop.gms 6.83 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$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
17

18
* =============================================================================
19
* --- Update the Forecast Data ------------------------------------------------
20
* =============================================================================
21

22
23
put log 'ord tSolve: ';
put log ord(tSolve) /;
24
putclose log;
25

26
if (ord(tSolve) >= tForecastNext(mSolve),
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
    // Read data defined to be updated
    if (mTimeseries_loop_read(mSolve, 'ts_effUnit'),
        put_utility 'gdxin' / 'input\ts_effUnit\' tSolve.tl:0 '.gdx';
        execute_load ts_effUnit
        );
    if (mTimeseries_loop_read(mSolve, 'ts_effGroupUnit'),
        put_utility 'gdxin' / 'input\ts_effGroupUnit\' tSolve.tl:0 '.gdx';
        execute_load ts_effGroupUnit
        );
    if (mTimeseries_loop_read(mSolve, 'ts_influx'),
        put_utility 'gdxin' / 'input\ts_influx\' tSolve.tl:0 '.gdx';
        execute_load ts_influx
        );
    if (mTimeseries_loop_read(mSolve, 'ts_cf'),
        put_utility 'gdxin' / 'input\ts_cf\' tSolve.tl:0 '.gdx';
        execute_load ts_cf
        );
    if (mTimeseries_loop_read(mSolve, 'ts_reserveDemand'),
        put_utility 'gdxin' / 'input\ts_reserveDemand\' tSolve.tl:0 '.gdx';
        execute_load ts_reserveDemand
        );
    if (mTimeseries_loop_read(mSolve, 'ts_node'),
        put_utility 'gdxin' / 'input\ts_node\' tSolve.tl:0 '.gdx';
        execute_load ts_node
        );
    if (mTimeseries_loop_read(mSolve, 'ts_fuelPriceChange'),
        put_utility 'gdxin' / 'input\ts_fuelPriceChange\' tSolve.tl:0 '.gdx';
        execute_load ts_fuelPriceChange
        );
    if (mTimeseries_loop_read(mSolve, 'ts_unavailability'),
        put_utility 'gdxin' / 'input\ts_unavailability\' tSolve.tl:0 '.gdx';
        execute_load ts_unavailability
        );

61
    // Update the next forecast
62
    tForecastNext(mSolve)
63
        = tForecastNext(mSolve) + mSettings(mSolve, 't_forecastJump');
64
);
65

66
$ontext
67
68
69
    // Define t_latestForecast
    Option clear = t_latestForecast;
    t_latestForecast(tSolve) = yes;
70
71

    // Define updated time window
72
    Option clear = tt_forecast;
73
    tt_forecast(t_full(t))${    ord(t) >= ord(tSolve)
74
                                and ord(t) <= ord(tSolve) + mSettings(mSolve, 't_forecastLengthUnchanging') + mSettings(mSolve, 't_forecastJump')
75
                                }
76
        = yes;
77

78
79
80
    // Define temporary time displacement to reach t_latestForecast
    Option clear = ddt;
    ddt(tt_forecast(t)) = ord(tSolve) - ord(t);
81

82
83
* --- Update Forecast Data ----------------------------------------------------

84
85
86
87
    ts_cf(flowNode(flow, node), f_solve(f), tt_forecast(t))${   ts_forecast(flow, node, t+ddt(t), f, t) // Only update data for capacity factors with forecast. NOTE! This results in problems if the forecast has values of zero!
                                                                and mf(mSolve, f)
                                                                }
        = ts_forecast(flow, node, t+ddt(t), f, t);
88
89

* --- Read the Tertiary Reserve Requirements ----------------------------------
90
91
92

    put_utility 'gdxin' / 'input\tertiary\' tSolve.tl:0 '.gdx';
    execute_load ts_tertiary;
Topi Rasku's avatar
Topi Rasku committed
93
94
95
96
    ts_reserveDemand(restypeDirectionNode('tertiary', up_down, node), f_solve(f), tt_forecast(t))${ mf(mSolve, f)
                                                                                                    and not mf_realization(mSolve, f)
                                                                                                    and flowNode('wind', node)
                                                                                                    }
97
98
        = ts_tertiary('wind', node, t+ddt(t), up_down, t)
            * sum(flowUnit('wind', unit), p_gnu('elec', node, unit, 'maxGen'));
99

100
$offtext
101

102
103

* --- Improve forecasts -------------------------------------------------------
104
$ontext
105
// !!! TEMPORARY MEASURES !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
106

107
108
if(mSettings(mSolve, 'forecasts') > 0,

109
110
111
112
113
114
115
    // Define updated time window
    Option clear = tt_forecast;
    tt_forecast(t_full(t))${    ord(t) >= ord(tSolve)
                                and ord(t) <= ord(tSolve) + mSettings(mSolve, 't_forecastLengthUnchanging') + mSettings(mSolve, 't_forecastJump')
                                }
        = yes;

116
    // Define updated time window
117
    Option clear = tt;
Topi Rasku's avatar
Topi Rasku committed
118
    tt(tt_forecast(t))${    ord(t) > ord(tSolve)
119
120
                            and ord(t) <= ord(tSolve) + f_improve
                            }
121
        = yes;
122

123
124
125
126
127
128
129
130
131
132
    // Temporary forecast displacement to reach the central forecast
    Option clear = ddf;
    ddf(f_solve(f), tt(t))${ not mf_central(mSolve, f) }
        = sum(mf_central(mSolve, f_), ord(f_) - ord(f));

    // Temporary forecast displacement to reach the realized forecast
    Option clear = ddf_;
    ddf_(f_solve(f), tt(t))${ not mf_realization(mSolve, f) }
        = sum(mf_realization(mSolve, f_), ord(f_) - ord(f));

133
    // Calculate the upper and lower forecasts based on the original central forecast
134
135
136
137
138
    ts_cf(flowNode(flow, node), f_solve(f), tt(t))${    not mf_realization(mSolve, f)
                                                        and not mf_central(mSolve, f)
                                                        }
                = ts_cf(flow, node, f, t) - ts_cf(flow, node, f+ddf(f,t), t);

139
    // Improve forecasts during the dispatch
140
141
    // Improve central capacity factors, linear improvement towards fRealization
    ts_cf(flowNode(flow, node), f_solve(f), tt(t))${    not mf_realization(mSolve, f)
142
                                                        and mf_central(mSolve, f)
143
                                                        }
144
145
146
147
        = (
            (ord(t) - ord(tSolve)) * ts_cf(flow, node, f, t)
            + (f_improve + ord(tSolve) - ord(t)) * ts_cf(flow, node, f+ddf_(f,t), t)
            )
148
                / f_improve;
149
150
151
152
153
154
155

    // Update the upper and lower forecasts based on the improved central forecast
    ts_cf(flowNode(flow, node), f_solve(f), tt(t))${    not mf_realization(mSolve, f)
                                                        and not mf_central(mSolve, f)
                                                        }
        = min(max( ts_cf(flow, node, f, t) + ts_cf(flow, node, f+ddf(f,t), t), 0),1);

156
); // END IF forecasts
157
$offtext