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.

1 - Summary

# 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")

2 - Post-processing : addition of typical days time series

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 :

4 - Visualisation of the flow-based exchanges positions

Preliminary step: load the simulation results.

a - The case with the old format

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."))

b - The case with the virtual area

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)

4.1 - Plot the net positions in CWE calculated by Antares and the used flow-based domains

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):

Plot a domain and the matching net positions

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")

Drawing

## 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")

Drawing

Select a date (or mcYear...) and plot the matching domains

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")

Drawing

Filtering example : plot the net positions of situations of unsupplied energy

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)

Drawing

4.2 - Run a shiny application to visualise the net positions calculated by Antares and the flow-based domains

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)

Drawing

The same filters can also be applied beforehand to select only timesteps with unsupplied energy.

5 - Post-processing : addition of the exchange position

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 :



rte-antares-rpackage/fbAntares documentation built on June 1, 2022, 6:20 p.m.