0.1 readAntares

Most data from a simulation can be imported in the R session with function readAntares().

myPath<-"E:\\ANTARES\\Exemple_antares\\2_exemple_etudes_importantes\\TYNDP\\ST2030\\ST2030"
opts<-setSimulationPath(myPath, "20170830-1049eco-reference")

myData<-readAntares(
  areas = "all", 
  links="all", 
  clusters = "all", 
  linkCapacity = TRUE,
  mustRun = TRUE,
  showProgress = FALSE
)

0.2 Remove your virtual areas

You can remove your virtual areas and correct your initial data.

myConData<-removeVirtualAreas(
   x=myData,
   storageFlexibility = getAreas(select = c("pum", "tur", "z_dsr", "y_mul")), 
   newCols = FALSE
 )

0.4 antaresDataList : List of date.tables

Compute the number of areas with unsupplied energy

length(unique(myConData$areas[`UNSP. ENRG`>0]$area))
## [1] 19

Compute the number of areas with spilled energy

length(unique(myConData$areas[`SPIL. ENRG`>0]$area))
## [1] 24

Compute the number of links with congestion

length(unique(myConData$links[`CONG. PROB +`>0]$link)) 
## [1] 96
length(unique(myConData$links[`CONG. PROB -`>0]$link)) 
## [1] 98
length(unique(myConData$links[`CONG. PROB +`>0  | `CONG. PROB -`>0]$link)) 
## [1] 102
length(unique(myConData$links[`CONG. PROB +`>0  & `CONG. PROB -`>0]$link))
## [1] 89

Compute the sum of the spilled energy by area and order the result by the spilled energy

## PRINT ONLY RESULT 
kable(resCompute[, .SD[1:7], ])
area sumSpilled
es 2020833
gb 1664705
de 1555247
ie 951593
nl 497123
ni 206839
pt 175267

Compute the sum of the unsupplied energy by area and order the result by the unsupplied energy

## PRINT ONLY RESULT 
kable(resComputeUnsEne[, .SD[1:7], ])
area sumUnspilled
fr 38421
gb 5587
fi 3863
luf 1333
be 456
ee 419
pl 419

0.5 Explain the result for unsupplied energy in France: with rpart or others statical packages FactoMineR, kmeans

0.6 Explain the result for unsupplied energy in France without some variables

0.7 antaresViz : prodStack, exchangesStack and plot

Get the first year and the first date where there is more than 700MW of unsupplied energy in France and use prodStack to visualize the production stack for this week.

## [1] "mcYear :4"
## [1] "time :2018-01-05 18:00:00"
## [1] "timeId :115"
## [1] "day :5"
## [1] "mcYear :5"
## [1] "time :2018-02-08 18:00:00"
## [1] "timeId :931"
## [1] "day :8"

1 prodStack, exchangesStack

myDataFr<-suppressWarnings(readAntares(areas = "fr", mcYears = mcYears[1], showProgress = FALSE, links = "all", linkCapacity = TRUE))

prodStack(myDataFr, dateRange=c("2018-01-01 00:00:00", "2018-01-07 23:00:00"), interactive = FALSE, area="fr")
exchangesStack(myDataFr, dateRange=c("2018-01-01 00:00:00", "2018-01-07 23:00:00"), interactive = FALSE, area="fr")
plot(myDataFr$areas, dateRange=c("2018-01-01 00:00:00", "2018-01-07 23:00:00"), interactive = FALSE, elements="fr", variable="MRG. PRICE", mcYear=4, type="ts", stepPlot=TRUE)

2 use consolidated data

myDataFr<-suppressWarnings(readAntares(links = getLinks(areas = c("z_dsr450", "y_mul", "pum", "tur", "fr")), areas = getAreas(select = c("z_dsr450", "y_mul", "pum", "tur", "fr")), mcYears = 4, linkCapacity = TRUE, showProgress = FALSE))

myConDataFr<-removeVirtualAreas(
  x=myDataFr,
  storageFlexibility = getAreas(select = c("pum", "tur", "z_dsr", "y_mul")),
  newCols = FALSE, 
  reassignCosts = TRUE
)

prodStack(myConDataFr, dateRange=c("2018-01-01 00:00:00", "2018-01-07 23:00:00"), interactive = FALSE, area="fr")
exchangesStack(myConDataFr, dateRange=c("2018-01-01 00:00:00", "2018-01-07 23:00:00"), interactive = FALSE, area="fr")

3 antaresViz : plotMap

configure a layout or import one

#mlTyndp<-mapLayout(readLayout())
#plotMapLayout(mlTyndp)
#saveRDS(mlTyndp, file = "E:\\ANTARES\\Exemple_antares\\2_exemple_etudes_importantes\\TYNDP\\ST2030\\ST2030\\user\\mlTyndp2017_V2.rds")

mlTyndp<-readRDS(file = "E:\\ANTARES\\Exemple_antares\\2_exemple_etudes_importantes\\TYNDP\\ST2030\\mapLayoutTyndp.rds")

4 Data for Europe

myDataEurope<-suppressWarnings(readAntares(links = "all", areas = "all", linkCapacity = TRUE, showProgress = FALSE, mcYears = mcYears[1]))

myConDataEurope<-removeVirtualAreas(
  x=myDataEurope,
  storageFlexibility = getAreas(select = c("pum", "tur", "z_dsr", "y_mul")),
  newCols = FALSE
)

addLoadFactorLink(myConDataEurope)

5 Use plotMap

The flow value of Great Britain/France is equal to zero, these two countries have unsupplied energy.

The flow between Belgium/France is 1295 but the link is not congested because Belgium has no marge.

All others flows to France are congested.

plotMap(
  myConDataEurope, 
  mlTyndp, 
  sizeAreaVars=varPlotMap, 
  areaChartType="pie", 
  interactive = FALSE,
  sizeMiniPlot = TRUE, 
  colAreaVar="LOAD", 
  colLinkVar="congestion",
  sizeLinkVar="FLOW LIN.",
  popupAreaVars = c(varPlotMap, vecAde, "PSP", "LOAD", "SPIL. ENRG"), 
  timeId = 115, 
  type = "detail"
)

6 With interaction

plotMap(
  myConDataEurope, 
  mlTyndp, 
  .updateBtn = TRUE, 
  .updateBtnInit=TRUE
)

7 You can change color option with plotMapOption

linkColorScaleOpts<-colorScaleOptions(
  breaks = 1, 
  negCol = "#00FF00", 
  zeroCol = "#FFFFFF", 
  posCol = "#FF0000", 
  naCol = "#EEEEEE",
  levels = c(0,1)
)

resOptions<-plotMapOptions(
  linkColorScaleOpts = linkColorScaleOpts
)

plotMap(
  myConDataEurope, 
  mlTyndp, 
  sizeAreaVars=varPlotMap, 
  areaChartType="pie", 
  interactive = FALSE,
  sizeMiniPlot = TRUE, 
  colAreaVar="LOAD", 
  colLinkVar="congestion",
  sizeLinkVar="FLOW LIN.",
  popupAreaVars = c(varPlotMap, vecAde, "PSP", "LOAD", "SPIL. ENRG"), 
  timeId = 115, 
  type = "detail", 
  options = resOptions
)

8 Upward margin

ListMyDataFr<-list()
for(i in mcYears){

  ListMyDataFr[[i]]<-suppressWarnings(
    readAntares(
      links = "all", 
      areas = "all",  
      linkCapacity = TRUE, 
      showProgress = FALSE, 
      mcYears = i,
      hydroStorageMaxPower = TRUE
      )
    )
  
 ListMyDataFr[[i]]<-removeVirtualAreas(
   x=ListMyDataFr[[i]],
   storageFlexibility = getAreas(select = c("pum", "tur", "z_dsr", "y_mul")), 
   newCols = FALSE
 )}


resPlotMap<-list()
timeId<-NULL
for(i in mcYears){
  addLoadFactorLink(ListMyDataFr[[i]])
  addUpwardMargin(ListMyDataFr[[i]])
  
  ListMyDataFr[[i]]$areas[area=="tr", interconnectedUpwardMargin:=0]

}

9 Save memory and time with h5

Write your simulation in h5.

writeAntaresH5(
  path="E:\\ANTARES\\Exemple_antares\\2_exemple_etudes_importantes\\TYNDP\\ST2030\\ST2030\\writeH5",
  allData = FALSE, #thermalAvailabilites and hydroStorage were not exported
  misc = TRUE, 
  thermalAvailabilities = FALSE,
  hydroStorageMaxPower = TRUE, 
  reserve = TRUE,
  linkCapacity = TRUE,
  mustRun = TRUE, 
  writeAllSimulations = TRUE,
  writeMcAll = TRUE,
  nbCores=3,
  removeVirtualAreas=TRUE,
  storageFlexibility=getAreas(select = c("pum", "tur", "z_dsr", "y_mul")),
  newCols = FALSE,
  overwrite = TRUE, 
  timeSteps = "hourly"
)