First it’s necessary to load the package:
# CRAN limite CPU usage
::setDTthreads(2)
data.tablelibrary(antaresEditObject)
You need to set the path to an Antares study in “input” mode:
::setSimulationPath(path = "path/to/study", simulation = "input") antaresRead
Or you can simply create a new study:
createStudy("path/to/study")
Before modifying your study, you can save it in an archive:
backupStudy(what = "input")
This will create a .tar.gz
file in your study folder.
You can create a new area with:
createArea(name = "myarea")
# The new area should appear here:
::getAreas() antaresRead
You can specify the localization of the area on the map, and also its color.
There are two helper functions for area parameters:
filteringOptions()
for filtering options, like filter-year-by-year
nodalOptimizationOptions()
for nodal optimizations options.You can initialize a cluster with some parameters:
createCluster(
area = "myarea",
cluster_name = "myareacluster",
group = "other",
unitcount = 1,
nominalcapacity = 8400,
`min-down-time` = 0,
`marginal-cost` = 0.010000,
`market-bid-cost` = 0.010000
)
You can also edit the settings of an existing cluster:
editCluster(
area = "myarea",
cluster_name = "myareacluster",
nominalcapacity = 10600.000
)
createLink(
from = "area1",
to = "area2",
propertiesLink = propertiesLinkOptions(
hurdles_cost = FALSE,
transmission_capacities = "enabled"
), dataLink = NULL
)
You can edit the settings of an existing link:
editLink(
from = "area1",
to = "area2",
transmission_capacities = "infinite"
)
createBindingConstraint(
name = "myconstraint",
values = matrix(data = c(rep(c(19200, 0, 0), each = 366)), ncol = 3),
enabled = FALSE,
timeStep = "daily",
operator = "both",
coefficients = c("fr%myarea" = 1)
)
<- data.frame(
pspData area = c("a", "b"),
installedCapacity = c(800,900)
)
createPSP(
areasAndCapacities = pspData,
efficiency = 0.75
)
<- data.frame(
dsrData area = c("a", "b"),
unit = c(10,20),
nominalCapacity = c(100, 120),
marginalCost = c(52, 65),
hour = c(3, 7)
)
createDSR(dsrData)
For example, set the output of simulation year by year, and limit the number of Monte-Carlo years to 10:
updateGeneralSettings(year.by.year = TRUE, nbyears = 10)
You can remove areas, links, clusters and binding constraints from input folder with remove*
functions, e.g.:
removeArea("myarea")
First, update general settings to activate time series to generate:
updateGeneralSettings(generate = "thermal")
Then run TS-generator:
runTsGenerator(
path_solver = "C:/path/to/antares-solver.exe",
show_output_on_console = TRUE
)
Launch an Antares simulation from R:
runSimulation(
name = "myAwesomeSimulation",
mode = "economy",
path_solver = "C:/path/to/antares-solver.exe",
show_output_on_console = TRUE
)
To update an existing time series and write it, you can use the following commands :
# Filepath of the study, version >= 820
<- file.path("", "", "")
my_study <- setSimulationPath(my_study, simulation ="input")
opts $timeIdMax <- 8760
opts
# Links, use only one link
<- as.character(getLinks()[1])
my_link <- readInputTS(linkCapacity = my_link, opts = opts)
ts_input
# Sort the data to ensure its reliability
::setorder(ts_input, cols = "tsId", "timeId")
data.table
# Reshape to wide format : writeInputTS expects a 8760 * N matrix
<- c("transCapacityDirect", "transCapacityIndirect")
metrics <- data.table::dcast(ts_input,
ts_input_reformatted ~ tsId,
timeId value.var = metrics
)# Add a value my_param to your matrix
<- 123
my_param writeInputTS(data = ts_input_reformatted[,2:ncol(ts_input_reformatted)] + my_param,
type = "tsLink",
link = my_link,
overwrite = TRUE,
opts = opts
)
# Thermal, use only one area and one cluster
<- "zone"
my_area <- "mon_cluster"
my_cluster <- readInputTS(thermalAvailabilities = my_area, opts = opts)
ts_input <- ts_input[cluster == paste0(my_area,"_",my_cluster)]
ts_input
# Sort the data to ensure its reliability
::setorder(ts_input, cols = "tsId", "timeId")
data.table
# Reshape to wide format : writeInputTS expects a 8760 * N matrix
<- c("ThermalAvailabilities")
metrics <- data.table::dcast(ts_input,
ts_input_reformatted ~ tsId,
timeId value.var = metrics
)
# Add a value my_param to your matrix
<- 1000
my_param editCluster(area = my_area,
cluster_name = my_cluster,
time_series = ts_input_reformatted[,2:ncol(ts_input_reformatted)] + my_param,
opts = opts
)
# Run of River, use only one area
<- "zone"
my_area <- readInputTS(ror = my_area, opts = opts)
ts_input
# Sort the data to ensure its reliability
::setorder(ts_input, cols = "tsId", "timeId")
data.table
# Reshape to wide format : writeInputTS expects a 8760 * N matrix
<- c("ror")
metrics <- data.table::dcast(ts_input,
ts_input_reformatted ~ tsId,
timeId value.var = metrics
)
# Add a value my_param to your matrix
<- 1000
my_param writeInputTS(area = my_area,
type = "hydroROR",
data = ts_input_reformatted[,2:ncol(ts_input_reformatted)] + my_param,
overwrite = TRUE,
opts = opts
)
# set the path to an Antares study
<- file.path("", "", "")
my_study <- setSimulationPath(my_study, simulation ="input")
opts
# choose geographic trimming when creating new Antares areas
# default filtering : c("hourly","daily","weekly","monthly","annual")
<- c("weekly","monthly")
initial_filtering_synthesis <- c("monthly","annual")
initial_filtering_year_by_year
<- createArea(name = "area1",
opts filtering = filteringOptions(
filter_synthesis = initial_filtering_synthesis,
filter_year_by_year = initial_filtering_year_by_year),
opts = opts)
<- createArea(name = "area2",opts = opts)
opts <- createLink(from = "area1",
opts to = "area2",
propertiesLink = propertiesLinkOptions(
filter_synthesis = initial_filtering_synthesis,
filter_year_by_year = initial_filtering_year_by_year),
opts = opts)
# check the initial filters
<- getGeographicTrimming(areas="area1",links=TRUE,opts=opts)
initial_GT print(initial_GT$areas[["area1"]])
print(initial_GT$links[["area1 - area2"]])
# edit geographic trimming of an existing area or link
<- c("monthly")
new_filtering_synthesis <- c("annual")
new_filtering_year_by_year
<- editArea(name = "area1",
opts filtering = list(
"filter_synthesis" = paste(new_filtering_synthesis,collapse = ", ")
"filter_year_by_year" = paste(new_filtering_year_by_year,collapse = ", ")),
opts = opts)
<- editLink(from = "area1",
opts to = "area2",
filter_year_by_year = new_filtering_year_by_year,
filter_synthesis = new_filtering_synthesis,
opts = opts)
# check the new filters
<- antaresRead::getGeographicTrimming(areas="area1",links=TRUE,opts=opts)
new_GT print(new_GT$areas[["area1"]])
print(new_GT$links[["area1 - area2"]])
# important : make sure that `geographic-trimming` parameter is activated in general settings
<- updateGeneralSettings(geographic.trimming = TRUE,opts = opts) opts