Scenario Builder"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  eval = TRUE
)
 # CRAN limite CPU usage
data.table::setDTthreads(2)
library(antaresEditObject)

First let's create a new study with some areas and clusters:

path <- tempdir()
createStudy(path = path, study_name = "my-study")

# Set number of Monte-Carlo scenarios
updateGeneralSettings(nbyears = 10)

# First area
createArea("earth")
createCluster(area = "earth", cluster_name = "america", add_prefix = FALSE)
createCluster(area = "earth", cluster_name = "africa", add_prefix = FALSE)
createCluster(area = "earth", cluster_name = "europe", add_prefix = FALSE)

# Second one
createArea("moon")
createCluster(area = "moon", cluster_name = "tranquility", add_prefix = FALSE)
createCluster(area = "moon", cluster_name = "serenety", add_prefix = FALSE)

# More areas
createArea("titan")
createArea("ceres")

# Some links
createLink("earth", "moon")
createLink("moon", "titan")
createLink("moon", "ceres")

# Check what we have created
getAreas()
readClusterDesc()

We can read scenario builder data with:

readScenarioBuilder()

Currently it's empty. We need to create rules before updating data:

# All areas
scenarioBuilder(n_scenario = 3)
scenarioBuilder(n_scenario = 5)
# Specific area
scenarioBuilder(n_scenario = 3, areas = "earth")
# Specify an area for which to use random values
scenarioBuilder(n_scenario = 3, areas_rand = "earth")

Now we can update the scenario builder data:

my_scenario <- scenarioBuilder(n_scenario = 3)

# for load serie
updateScenarioBuilder(ldata = my_scenario, series = "load")

# equivalent as
updateScenarioBuilder(ldata = list(l = my_scenario))

Here we update data for serie load only. To update several series at once you can do:

my_scenario <- scenarioBuilder(n_scenario = 3)

updateScenarioBuilder(
  ldata = my_scenario, 
  series = c("load", "hydro", "solar")
)
load_scenario <- scenarioBuilder(n_scenario = 3)
hydro_scenario <- scenarioBuilder(n_scenario = 4)
solar_scenario <- scenarioBuilder(n_scenario = 5)

updateScenarioBuilder(ldata = list(
  l = load_scenario,
  h = hydro_scenario,
  s = solar_scenario
))

If you read scenario builder now, wet got:

readScenarioBuilder()

For thermal and renewables series, default behavior is to set rules to each clusters in the area :

my_scenario <- scenarioBuilder(n_scenario = 3)

updateScenarioBuilder(
  ldata = my_scenario, 
  series = "thermal"
)

readScenarioBuilder()$t

We can specify specific clusters with:

updateScenarioBuilder(
  ldata = my_scenario, 
  series = "thermal",
  clusters_areas = data.table::data.table(
    area = c("earth", "earth"),
    cluster = c("africa", "europe")
  )
)
readScenarioBuilder()$t

For NTC serie (Antares >= 8.2.0), it writes the scenario for all links :

updateScenarioBuilder(
  ldata = my_scenario, 
  series = "ntc"
)
readScenarioBuilder()$ntc

For writing scenario for a specific link you can do:

updateScenarioBuilder(
  ldata = my_scenario, 
  series = "ntc",
  links = "moon%ceres"
)
readScenarioBuilder()$ntc

Finally, you can remove all scenarios from a ruleset with:

clearScenarioBuilder()
unlink(file.path(path, "my-study"), recursive = TRUE)


Try the antaresEditObject package in your browser

Any scripts or data that you put into this service are public.

antaresEditObject documentation built on June 22, 2024, 9:39 a.m.