knitr::opts_chunk$set(echo = TRUE)
fbAntares
allows to model flow-based domains into adequacy studies using the software Antares, with the following main functionalities:
1. Preparation of the input of an Antares study to include a modelling a flow-based in the CWE-AT area
2. Post-processing and visualisation of Antares’ results
This vignette describes the second set of functionnalities : the post-processing of the simulation results.
# Set Antares study path and read the simulation results study <- "MyStuDy" opts <- antaresRead::setSimulationPath(study, 2) dta <- antaresRead::readAntares( areas = c("fr", "be", "de", "nl", "at"), links = c("be - de","be - fr","be - nl", "de - fr","de - nl", "at - de"), mcYears = 1:10, select = c("LOLD", "UNSP. ENRG", "DTG MRG", "UNSP. ENRG", "BALANCE", "FLOW LIN."), opts = opts) # Add to the results the time series of typical flow-based days dta <- addTypicalDayId(dta) # Visualise the flow-based exchanges (position in the flow-based domains) # Plot a domain and the matching output positions plotNetPositionFB(fb_opts = opts, data = dta, areaName = "cwe_at", dayType = 1, hour = c(0, 19), country1 = "BE", country2 = "FR") # Run a shiny application to visualise the domains and matching output positions runAppPosition(dta) # Add to the results a calculation of the net position of the countries within an area (by default, position in CWE) dta <- addNetPosition(data, opts = antaresRead::simOptions(), inAreas = c("be", "de", "fr", "nl", "at"), newName = "_CWEAt")
antaresRead::setSimulationPath("MyStuDy", 1) dta <- readAntares(areas = "all", links = "all", clusters = "all" ,mcYears = 1:10) dta <- addTypicalDayId(data = dta)
The function addTypicalDayId()
adds to an Antares output table a column indicating the id of the used flow-based typical days at each timestep. It uses the following parameters :
data
: Antares output table (loaded by the function antaresRead::readAntares
), the function will add a column to this tablefb_opts
: flow-based model localisation, where the function will read the flow-based time-series to add to the results. It can be a flow-based model designed by setFlowbasedPath()
. By default, it will use the odel stored in the Antares study indicated by antaresRead::simOptions()
Preliminary step: load the simulation results.
opts <- antaresRead::setSimulationPath("MyStuDy", 2) dta <- antaresRead::readAntares( areas = c("fr", "be", "de", "nl"), links = c("be - de","be - fr","be - nl","de - fr","de - nl"), mcYears = 1:10, select = c("LOLD", "UNSP. ENRG", "DTG MRG", "UNSP. ENRG", "BALANCE", "FLOW LIN."))
If you use the virtual area, the only differences are in the areas and the links. For the area you have to add a new area, zz_flowbased and for the links, you have to change them and them in links from the real areas to the virtual one.
optsVirtual <- antaresRead::setSimulationPath("MyStuDy", 3) dtaVirtual <- antaresRead::readAntares( areas = c("fr", "be", "de", "nl", "at", "zz_flowbased"), links = c("be - zz_flowbased", "fr - zz_flowbased", "nl - zz_flowbased", "de - zz_flowbased", "at - zz_flowbased"), mcYears = 1:2, select = c("LOLD", "UNSP. ENRG", "DTG MRG", "UNSP. ENRG", "BALANCE", "FLOW LIN."), opts = opts)
The function plotNetPositionFB()
is used after running an Antares simulation to visualize how the domains have been used by the optimizer to fix the exchanges in the CWE area.
The parameters used by the function are the following (example on how to use them are described below):
data
: antaresDataList
Antares output data, imported with readAntares()
. It can be a filtered (time or loss of load) antaresDataList.dayType
: numeric vector of typical days' domains to plot or "all"hour
: numeric vector of hours to plot (between 0 and 23) or "all"country1
: name of the country in axis Xcountry2
: name of the country in axis Yfb_opts
: flow-based model, either defined by setFlowbasedPath()
or in the study indicated by setSimulationPath()
. By default : antaresRead::simOptions()
filteringEmptyDomains
: boolean, if TRUE, the function will not plot the domains which are not used in the data. By default, it is FALSE.nbMaxPt
: maximum number of points plotted on the graph. It can be increased (which increases computation time). By default, the value is 10000.areaName
: character, name of the area of your study, possible values are
cwe_at (default), cwe and other. If you choose other, you have to give a csv file
which explains how your area work.palette
: color range, by default rainbow.The user chooses the typical day(s) and hour(s), the function will plot the required domain(s) and search the Antares results to calculate the net positions whenever these domains were used by the optimiser.
## Plot the typical day 1 at hours 0 and 19 and the matching net positions on a Belgium-France graph plotNetPositionFB(fb_opts = opts, data = dta, dayType = 1, hour = c(0, 19), country1 = "BE", country2 = "FR")
## Plot the three typical days of summer at hour 19 and the matching net positions plotNetPositionFB(fb_opts = opts, data = dta, dayType = c(1,2,3), hour = c(19), country1 = "BE", country2 = "FR")
By default, the function draws all the times matching the domains in the entire results table. It is then possible to filter the input table. If so, the parameter filteringEmptyDomains
can be set to TRUE and the parameters dayType
and hour
to ALL. The function will then try and print all the domains, but actually keep only the ones used in the table.
## Plot only one time, without knowing the used flow-based domain dta$areas <- dta$areas[timeId == 5659,] plotNetPositionFB(fb_opts = opts, data = dta, areaName = "cwe_at", dayType = "all", hour = "all", filteringEmptyDomains = TRUE, country1 = "FR", country2 = "DE")
Because of the format of the Antares data table, some caution must be observed when filtering it. For example, to keep only the situations where there is unsupplied energy, one must keep all the rows representing this specific time. Example :
## An exemple of authorized filter : idC <- c(antaresRead::getIdCols(dta$areas)) idC <- idC[idC!="area"] LOLD <- dta$areas[,lapply(.SD, sum), by = idC, .SDcols = "LOLD"] LOLD <- LOLD[LOLD!=0] LOLD[,LOLD := NULL] # Merge to filter data dta$areas <- merge(dta$areas, LOLD, by = idC) ## End filter ## plot domains plotNetPositionFB(fb_opts = opts, data = dta, dayType = "all", hour = c(19), country1 = "BE", country2 = "FR", filteringEmptyDomains = TRUE) ## or with the virtual fb area plotNetPositionFB(fb_opts = optsVirtual, data = dtaVirtual, dayType = "all", hour = c(19), country1 = "BE", country2 = "FR", filteringEmptyDomains = TRUE)
One can also visualise the net positions graphs in a shiny application launched with runAppPosition
. Threee parameters only are used (data
, fb_opts
and country_list), the others are available directly in the app.
runAppPosition(dta)
The same filters can also be applied beforehand to select only timesteps with unsupplied energy.
opts <- antaresRead::setSimulationPath("MyStuDy", 2) data <- readAntares(area = "all", links = "all", mcYears = 1) ##Add net position for CWE data <- addNetPosition(data, opts) ##Add net position for CWE+AT data <- addNetPosition(data, opts inAreas = c("be", "de", "fr", "nl", "at"), newName = "_CWEAt")
The function addNetPosition()
adds to an Antares output table a column calculating the net position of areas within an interconnected group of areas, based on the exchanged flows. This can be used for flow-based calculation (to get net positions in the CWE perimeter). It uses the following parameters :
data
: Antares output table (loaded by the function antaresRead::readAntares()
), the function will add a column to this tableopts
: simulation parameters returned by the function setSimulationPath()
: this represents the directory of the Antares study. The default path is indicated by antaresRead::simOptions()
.inAreas
: lists of areas belonging to the perimeter, whose exchanges are going to be taken into account in the balance calculation. All links connecting two areas in this list are taken into account, the links connected to only one area (or none) are ignored. By default, the list is c("be", "de", "fr", "nl"), the calculation is carried out on the CWE perimeter.newName
: suffix added to the calculated column name. By default, it is "_CWEAt".Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.