Commit ba63bbfe authored by Topi Rasku's avatar Topi Rasku
Browse files

Implementing a new set "flowNode" to increase capacity factor calculation performance.

parent b08de721
......@@ -45,7 +45,8 @@ Sets
group "A group of units and transfer links"
* --- Nodes -----------------------------------------------------------------
node_spill(node) "Nodes that can spill; used to remove v_spill variables where not relevant"
node_spill(node) "Nodes that can spill; used to remove v_spill variables where not relevant"
flowNode(flow, node) "Flows at nodes"
* --- Sets bounding geography and units -------------------------------------
gn(grid, node) "Grids and their nodes"
......
......@@ -318,6 +318,12 @@ p_gnBoundaryPropertiesForStates(gn(grid, node), param_gnBoundaryTypes, 'multipli
and sum(param_gnBoundaryProperties, p_gnBoundaryPropertiesForStates(grid, node, param_gnBoundaryTypes, param_gnBoundaryProperties))
} = 1; // If multiplier has not been set, set it to 1 by default
* --- Other Node Properties ---------------------------------------------------
// Flows at nodes
flowNode(flow, node)${ sum((f, t), ts_cf(flow, node, f, t)) }
= yes;
* =============================================================================
* --- Reserves Sets & Parameters ----------------------------------------------
* =============================================================================
......
......@@ -15,7 +15,9 @@ 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
* --- Update the data with forecasts ------------------------------------------
* =============================================================================
* --- Update Forecast Data ----------------------------------------------------
* =============================================================================
put log 'ord tSolve: ';
put log ord(tSolve) /;
......@@ -24,35 +26,37 @@ if (mSettings(mSolve, 'readForecastsInTheLoop') and ord(tSolve) >= tForecastNext
put_utility 'gdxin' / 'input\forecasts\' tSolve.tl:0 '.gdx';
execute_load ts_forecast = forecast;
// Update the next forecast
tForecastNext(mSolve)${ ord(tSolve) >= tForecastNext(mSolve)
} = tForecastNext(mSolve) + mSettings(mSolve, 't_ForecastJump');
// Update tForecastNext
tForecastNext(mSolve)${ ord(tSolve) >= tForecastNext(mSolve) }
= tForecastNext(mSolve) + mSettings(mSolve, 't_ForecastJump');
// Define tLatestForecast
Option clear = tLatestForecast;
tLatestForecast(t)$(ord(t) = ord(tSolve)) = yes;
tLatestForecast(tSolve) = yes;
// Define updated time window
Option clear = tt_;
tt_(t)${ ord(t) >= ord(tSolve)
and ord(t) <= ord(tSolve) + mSettings(mSolve, 't_forecastLength') + mSettings(mSolve, 't_ForecastJump')
}
Option clear = tt;
tt(tFull(t))${ ord(t) >= ord(tSolve)
and ord(t) <= ord(tSolve) + mSettings(mSolve, 't_forecastLength') + mSettings(mSolve, 't_ForecastJump')
}
= yes;
// Update capacity factor data
loop(tLatestForecast, // There should be only one latest forecast
ts_cf(flow, node, f, tt_(t))${ ts_forecast(flow, node, tLatestForecast, 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,tLatestForecast,f,t);
);
* --- Update Data -------------------------------------------------------------
// There should be only one latest forecast
loop(tLatestForecast,
ts_cf(flowNode(flow, node), fSolve(f), tt(t))${ ts_forecast(flow, node, tLatestForecast, 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, tLatestForecast, f, t);
); // END loop(tLatestForecast)
// Read the tertiary reserve requirements
put_utility 'gdxin' / 'input\tertiary\' tSolve.tl:0 '.gdx';
execute_load ts_tertiary;
ts_reserveDemand('tertiary', up_down, node, f, tt_(t))${ mf(mSolve, f)
and gn('elec', node)
and not mfRealization(mSolve, f)
}
ts_reserveDemand(resTypeDirectionNode('tertiary', up_down, node), fSolve(f), tt(t))${ mf(mSolve, f)
and not mfRealization(mSolve, f)
}
* = min(500, ts_tertiary('wind', node, tSolve, up_down, t) * sum(flowUnit('wind', unit), p_gnu('elec', node, unit, 'maxGen')));
= max(p_nReserves(node, 'primary', up_down), ts_tertiary('wind', node, tSolve, up_down, t) * sum(flowUnit('wind', unit), p_gnu('elec', node, unit, 'maxGen')));
......@@ -66,20 +70,21 @@ putclose log;
if(mSettings(mSolve, 'forecasts') > 0,
// Define updated time window
Option clear = tt_;
tt_(t)${ ord(t) >= ord(tSolve)
and ord(t) <= ord(tSolve) + f_improve
}
Option clear = tt;
tt(t)${ ord(t) >= ord(tSolve)
and ord(t) <= ord(tSolve) + f_improve
}
= yes;
// Improve capacity factors, linear improvement towards fRealization
loop(mfRealization(mSolve, f_),
ts_cf(flow, node, f, tt_(t))${ not mfRealization(mSolve, f)
and mfRealization(mSolve, f_)
and mf(mSolve, f)
} = (
(ord(t) - ord(tSolve)) * ts_cf(flow, node, f, t)
+ (f_improve + ord(tSolve) - ord(t)) * ts_cf(flow, node, f_, t)
) / f_improve;
ts_cf(flowNode(flow, node), fSolve(f), tt(t))${ not mfRealization(mSolve, f)
and mf(mSolve, f)
}
= [
(ord(t) - ord(tSolve)) * ts_cf(flow, node, f, t)
+ (f_improve + ord(tSolve) - ord(t)) * ts_cf(flow, node, f_, t)
]
/ f_improve;
);
); // END IF forecasts
......@@ -197,8 +197,7 @@ loop(counter${mInterval(mSolve, 'intervalLength', counter)},
// Select time series data matching the intervals, for intervalLength = 1, this is trivial.
ts_influx_(gn(grid, node), ft(fSolve, tInterval(t))) = ts_influx(grid, node, fSolve, t+dt_circular(t));
ts_cf_(flow, node, ft(fSolve, tInterval(t)))${ sum(grid, gn(grid, node)) } // Only include nodes that have a grid attributed to them
= ts_cf(flow, node, fSolve, t+dt_circular(t));
ts_cf_(flowNode(flow, node), ft(fSolve, tInterval(t))) = ts_cf(flow, node, fSolve, t+dt_circular(t));
ts_unit_(unit, param_unit, ft(fSolve, tInterval(t)))${ p_unit(unit, 'useTimeseries') } // Only include units that have timeseries attributed to them
= ts_unit(unit, param_unit, fSolve, t+dt_circular(t));
// Reserve demand relevant only up until t_reserveLength
......@@ -261,8 +260,7 @@ loop(counter${mInterval(mSolve, 'intervalLength', counter)},
ts_influx_(gn(grid, node), fSolve, t)
= sum(tt(t_), ts_influx(grid, node, fSolve, t_+dt_circular(t_)))
/ p_stepLength(mSolve, fSolve, t);
ts_cf_(flow, node, fSolve, t)${ sum(grid, gn(grid, node)) // Only include nodes with grids attributed to them
}
ts_cf_(flowNode(flow, node), fSolve, t)
= sum(tt(t_), ts_cf(flow, node, fSolve, t_+dt_circular(t_)))
/ p_stepLength(mSolve, fSolve, t);
ts_unit_(unit, param_unit, fSolve, t)${ p_unit(unit, 'useTimeseries') } // Only include units with timeseries attributed to them
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment