# NOT RUN {
if (is_avail_eplus(8.8)) {
idf_name <- "1ZoneUncontrolled.idf"
epw_name <- "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
idf_path <- file.path(eplus_config(8.8)$dir, "ExampleFiles", idf_name)
epw_path <- file.path(eplus_config(8.8)$dir, "WeatherData", epw_name)
# copy to tempdir
file.copy(c(idf_path, epw_path), tempdir())
# create an EplusJob from local an IDF and an EPW file
job <- eplus_job(file.path(tempdir(), idf_name), file.path(tempdir(), epw_name))
# get paths of idf and epw
job$path("all")
job$path("idf")
job$path("epw")
# get current job status
job$status()
# check if the job has been run before
job$status()$run_before
# run the job in waiting mode
job$run(wait = TRUE)
# check the job status again
job$status()$run_before
job$status()$successful
# get output directory
job$output_dir()
# open the output directory
job$output_dir(open = TRUE)
# check simulation errors
job$errors()
# check simulation errors, only including warnings and errors
job$errors(info = FALSE)
# get the file path of an output with a given suffix
job$locate_output(".err")
# give an error when simulation did not complete successfully or that file
# does not exist
job$locate_output(".exe", strict = TRUE)
# retrieve simulation results will fail if there is no EnergyPlus SQL output.
job$report_data_dict()
# instead, using `$run()` method in Idf class, which will add an
# `Output:SQLite` object automatically
idf <- read_idf(file.path(tempdir(), idf_name))
job <- idf$run(file.path(tempdir(), epw_name), dir = NULL)
# get report data dictionary
str(job$report_data_dict())
# extract all report data
str(job$report_data())
# extract some report variable
str(job$report_data(name = "EnergyTransfer:Building", case = NULL))
# add a "Case" column in the returned data.table
str(job$report_data(name = "EnergyTransfer:Building", case = "Test"))
# change the format of datetime column in the returned data.table
str(job$report_data(name = "EnergyTransfer:Building", year = 2016L, tz = Sys.timezone()))
# get all tabular data
str(job$tabular_data())
}
# }
Run the code above in your browser using DataLab