Commit 5b80cca3 authored by Topi Rasku's avatar Topi Rasku
Browse files

Implementing a new set "flowNode", which includes nodes with flows in them....

Implementing a new set "flowNode", which includes nodes with flows in them. Using it for increasing the performance of "periodicLoop" and "inputsLoop".
parent e925c011
......@@ -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) "Nodes with flows"
* --- 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 ---------------------------------------------------
// Nodes with flows
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 the Forecast Data ------------------------------------------------
* =============================================================================
put log 'ord tSolve: ';
put log ord(tSolve) /;
......@@ -39,15 +41,120 @@ if (mSettings(mSolve, 'readForecastsInTheLoop') and ord(tSolve) >= tForecastNext
}
= yes;
// Update capacity factor data
* --- Update Forecast Data ----------------------------------------------------
loop(tLatestForecast, // There should be only one latest forecast
ts_cf(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_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);
);
* );
// !!! REALVALUE SPECIFIC !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$ontext
// Force the upper and lower forecasts to include the realization
ts_cf(flow, node, 'f01', tt(t))${ mf(mSolve, 'f01')
and not fRealization('f01')
and not fCentral('f01')
} = min(ts_cf(flow, node, 'f01', t), sum(fRealization(f_), ts_cf(flow, node, f_, t)));
ts_cf(flow, node, 'f03', tt(t))${ mf(mSolve, 'f03')
and not fRealization('f03')
and not fCentral('f03')
} = max(ts_cf(flow, node, 'f03', t), sum(fRealization(f_), ts_cf(flow, node, f_, t)));
$offtext
// Ambient temperatures, need to be weighted with the GFA densities of the different regions that are aggregated into the nodes
ts_nodeState('heat', '74FI_ambient', 'reference', fSolve(f), tt_(t))${ gn_state('heat', '74FI_ambient')
and mfCentral(mSolve, f)
and not mfRealization(mSolve, f)
}
= + 0.1075 * ts_forecast('temperature', 'FI_1', tLatestForecast, f, t)
+ 0.8925 * ts_forecast('temperature', 'FI_2', tLatestForecast, f, t)
;
ts_nodeState('heat', '75FI_ambient', 'reference', fSolve(f), tt_(t))${ gn_state('heat', '75FI_ambient')
and mfCentral(mSolve, f)
and not mfRealization(mSolve, f)
}
= + 0.3332 * ts_forecast('temperature', 'FI_3', tLatestForecast, f, t)
+ 0.1644 * ts_forecast('temperature', 'FI_4', tLatestForecast, f, t)
+ 0.0848 * ts_forecast('temperature', 'FI_5', tLatestForecast, f, t)
+ 0.1086 * ts_forecast('temperature', 'FI_6', tLatestForecast, f, t)
+ 0.3090 * ts_forecast('temperature', 'FI_7', tLatestForecast, f, t)
;
*$ontext
// Minimum forecasts
ts_nodeState('heat', '74FI_ambient', 'reference', 'f01', tt_(t))${ gn_state('heat', '74FI_ambient')
and not mfRealization(mSolve, 'f01')
and not mfCentral(mSolve, 'f01')
}
= min(
ts_forecast('temperature', 'FI_1', tLatestForecast, 'f01', t),
ts_forecast('temperature', 'FI_2', tLatestForecast, 'f01', t)
)
;
ts_nodeState('heat', '75FI_ambient', 'reference', 'f01', tt_(t))${ gn_state('heat', '75FI_ambient')
and not mfRealization(mSolve, 'f01')
and not mfCentral(mSolve, 'f01')
}
= min(
ts_forecast('temperature', 'FI_3', tLatestForecast, 'f01', t),
ts_forecast('temperature', 'FI_4', tLatestForecast, 'f01', t),
ts_forecast('temperature', 'FI_5', tLatestForecast, 'f01', t),
ts_forecast('temperature', 'FI_6', tLatestForecast, 'f01', t),
ts_forecast('temperature', 'FI_7', tLatestForecast, 'f01', t)
)
;
// Maximum forecasts
ts_nodeState('heat', '74FI_ambient', 'reference', 'f03', tt_(t))${ gn_state('heat', '74FI_ambient')
and not mfRealization(mSolve, 'f03')
and not mfCentral(mSolve, 'f03')
}
= max(
ts_forecast('temperature', 'FI_1', tLatestForecast, 'f03', t),
ts_forecast('temperature', 'FI_2', tLatestForecast, 'f03', t)
)
;
ts_nodeState('heat', '75FI_ambient', 'reference', 'f03', tt_(t))${ gn_state('heat', '75FI_ambient')
and not mfRealization(mSolve, 'f03')
and not mfCentral(mSolve, 'f03')
}
= max(
ts_forecast('temperature', 'FI_3', tLatestForecast, 'f03', t),
ts_forecast('temperature', 'FI_4', tLatestForecast, 'f03', t),
ts_forecast('temperature', 'FI_5', tLatestForecast, 'f03', t),
ts_forecast('temperature', 'FI_6', tLatestForecast, 'f03', t),
ts_forecast('temperature', 'FI_7', tLatestForecast, 'f03', t)
)
;
*$offtext
$ontext
// Correction to the level of the central temperature forecast, starting from the current temperature
ts_nodeState(gn_state(grid, node), 'reference', f, tt(t))${ mf(mSolve, f)
and sum(param_gnBoundaryTypes, p_gnBoundaryPropertiesForStates(grid, node, param_gnBoundaryTypes, 'useTimeseries'))
and not fRealization(f)
} = + ts_nodeState(grid, node, 'reference', f, t)
- sum(fCentral(f_), ts_nodeState(grid, node, 'reference', f_, tLatestForecast))
+ sum(fRealization(f_), ts_nodeState(grid, node, 'reference', f_, tLatestForecast))
;
// Force the minimum and maximum forecasts to include the realization
ts_nodeState(gn_state(grid, node), 'reference', 'f01', tt(t))${ mf(mSolve, 'f01')
and not fRealization('f01')
and not fCentral('f01')
and ts_nodeState(grid, node, 'reference', 'f01', t)
} = min(ts_nodeState(grid, node, 'reference', 'f01', t), sum(fRealization(f_), ts_nodeState(grid, node, 'reference', f_, t)))
;
ts_nodeState(gn_state(grid, node), 'reference', 'f03', tt(t))${ mf(mSolve, 'f03')
and not fRealization('f03')
and not fCentral('f03')
and ts_nodeState(grid, node, 'reference', 'f03', t)
} = max(ts_nodeState(grid, node, 'reference', 'f03', t), sum(fRealization(f_), ts_nodeState(grid, node, 'reference', f_, t)))
;
$offtext
); // END loop(tLatestForecast)
* --- Read the Tertiary Reserve Requirements ----------------------------------
// 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)
......@@ -62,8 +169,9 @@ if (mSettings(mSolve, 'readForecastsInTheLoop') and ord(tSolve) >= tForecastNext
putclose log;
* --- Improve forecasts -------------------------------------------------------
$ontext
// !!! TEMPORARY MEASURES !!!
*$ontext
// !!! TEMPORARY MEASURES !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if(mSettings(mSolve, 'forecasts') > 0,
// Define updated time window
......@@ -73,15 +181,52 @@ if(mSettings(mSolve, 'forecasts') > 0,
}
= yes;
// Improve capacity factors, linear improvement towards fRealization
// Improve forecasts during the dispatch
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;
);
// Improve central capacity factors, linear improvement towards fRealization
ts_cf(flowNode(flow, node), fSolve(f), tt_(t))${ not mfRealization(mSolve, f)
and mfCentral(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;
// Upper and lower forecasts include realization?
ts_cf(flowNode(flow, node), fSolve('f01'), tt_(t))
= min(
ts_cf(flow, node, 'f01', t),
ts_cf(flow, node, f_, t)
);
ts_cf(flowNode(flow, node), fSolve('f03'), tt_(t))
= max(
ts_cf(flow, node, 'f03', t),
ts_cf(flow, node, f_, t)
);
// !!! REALVALUE SPECIFIC !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Also improve ambient temperature forecasts
ts_nodeState(gn_state(grid, node), 'reference', fSolve(f), tt_(t))${ not mfRealization(mSolve, f)
and mfCentral(mSolve, f)
}
= (
(ord(t) - ord(tSolve)) * ts_nodeState(grid, node, 'reference', f, t)
+ (f_improve + ord(tSolve) - ord(t)) * ts_nodeState(grid, node, 'reference', f_, t)
)
/ f_improve;
// Upper and lower forecasts include realization?
ts_nodeState(gn_state(grid, node), 'reference', fSolve('f01'), tt_(t))
= min(
ts_nodeState(grid, node, 'reference', 'f01', t),
ts_nodeState(grid, node, 'reference', f_, t)
);
ts_nodeState(gn_state(grid, node), 'reference', fSolve('f03'), tt_(t))
= max(
ts_nodeState(grid, node, 'reference', 'f03', t),
ts_nodeState(grid, node, 'reference', f_, t)
);
); // END loop(mfRealization)
); // END IF forecasts
$offtext
*$offtext
......@@ -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