Run simulations of EnergyPlus models.

run_idf(
  model,
  weather,
  output_dir,
  design_day = FALSE,
  annual = FALSE,
  expand_obj = TRUE,
  wait = TRUE,
  echo = TRUE,
  eplus = NULL
)

run_multi(
  model,
  weather,
  output_dir,
  design_day = FALSE,
  annual = FALSE,
  expand_obj = TRUE,
  wait = TRUE,
  echo = TRUE,
  eplus = NULL
)

Arguments

model

A path (for run_idf()) or a vector of paths (for run_multi()) of EnergyPlus IDF or IMF files.

weather

A path (for run_idf()) or a vector of paths (for run_multi()) of EnergyPlus EPW weather files. If set to NULL, design-day-only simulation will be triggered, regardless of the design-day value. For run_multi(), weather can also be a single EPW file path. In this case, that weather will be used for all simulations; otherwise, model and weather should have the same length. You can set to design-day-only simulation to some specific simulations by setting the corresponding weather to NA.

output_dir

Output directory path (for rum_idf()) or paths (for run_mult()). If NULL, the directory of input model is used. For run_multi(), output_dir, if not NULL, should have the same length as model. Any duplicated combination of model and output_dir is prohibited.

design_day

Force design-day-only simulation. For rum_multi(), design_day can also be a logical vector which has the same length as model. Note that design_day and annual cannot be all TRUE at the same time. Default: FALSE.

annual

Force annual simulation. For rum_multi(), annual can also be a logical vector which has the same length as model. Note that design_day and annual cannot be all TRUE at the same time. Default: FALSE.

expand_obj

Whether to run ExpandObjects preprocessor before simulation. Default: TRUE.

wait

If TRUE, R will hang on and wait all EnergyPlus simulations finish. If FALSE, all EnergyPlus simulations are run in the background, and a process object is returned.

echo

Only applicable when wait is TRUE. Whether to show standard output and error from EnergyPlus for run_idf() and simulation status for run_multi(). Default: TRUE.

eplus

An acceptable input (for run_idf()) or inputs (for run_multi()) of use_eplus() and eplus_config(). If NULL, which is the default, the version of EnergyPlus to use is determined by the version of input model. For run_multi(), eplus, if not NULL, should have the same length as model.

Value

  • For run_idf(), if wait is TRUE, a named list of 11 elements:

No.ColumnTypeDescription
1idfcharacter(1)Full path of input IDF file
2epwcharacter(1) or NULLFull path of input EPW file
3versioncharacter(1)Version of called EnergyPlus
4exit_statusinteger(1) or NULLExit status of EnergyPlus. NULL if terminated or wait is FALSE
5start_timePOSIXct(1)Start of time of simulation
6end_timePOSIXct(1) or NULLEnd of time of simulation. NULL if wait is FALSE
7output_dircharacter(1)Full path of simulation output directory
8energypluscharacter(1)Full path of called EnergyPlus executable
9stdoutcharacter(1) or NULLStandard output of EnergyPlus during simulation
10stderrcharacter(1) or NULLStandard error of EnergyPlus during simulation
11processr_processA process object which called EnergyPlus and ran the simulation

If wait is FALSE, the R process is directly returned. You can get the results by calling result <- proc$get_result() (proc is the returned process). Please note that in this case, result$process will always be NULL. But you can easily assign it by running result$process <- proc

  • For rum_multi(), if wait is TRUE, a data.table of 12 columns:

    No.ColumnTypeDescription
    1indexintegerIndex of simulation
    2statuscharacterSimulation status
    3idfcharacterFull path of input IDF file
    4epwcharacterFull path of input EPW file. NA for design-day-only simulation
    5versioncharacterVersion of EnergyPlus
    6exit_statusintegerExit status of EnergyPlus. NA if terminated
    7start_timePOSIXctStart of time of simulation
    8end_timePOSIXctEnd of time of simulation.
    9output_dircharacterFull path of simulation output directory
    10energypluscharacterFull path of called EnergyPlus executable
    11stdoutlistStandard output of EnergyPlus during simulation
    12stderrlistStandard error of EnergyPlus during simulation

    For column status, there are 4 possible values:

    • "completed": the simulation job is completed successfully

    • "failed": the simulation job ended with error

    • "terminated": the simulation job started but was terminated

    • "cancelled": the simulation job was cancelled, i.e. did not start at all

  • For run_multi(), if wait is FALSE, a r_process object of background R process which handles all simulation jobs is returned. You can check if the jobs are completed using $is_alive() and get the final data.table using $get_result() method.

Details

run_idf() is a wrapper of EnergyPlus itself, plus various pre-processors and post-processors which enables to run EnergyPlus model with different options.

run_multi() provides the functionality of running multiple models in parallel.

It is suggested to run simulations using EplusJob class and EplusGroupJob class, which provide much more detailed controls on the simulation and also methods to extract simulation outputs.

Note

If your input model has external file dependencies, e.g. FMU, schedule files, etc. run_idf() and run_multi() will not work if the output directory is different that where the input mode lives. If this is the case, parse the model using read_idf() and use Idf$run() or eplus_job() instead. They are able to automatically change the paths of external files to absolute paths or copy them into the output directory, based on your choice.

See also

EplusJob class and ParametricJob class which provide a more friendly interface to run EnergyPlus simulations and collect outputs.

Author

Hongyuan Jia

Examples

if (FALSE) { # \dontrun{
idf_path <- system.file("extdata/1ZoneUncontrolled.idf", package = "eplusr")

if (is_avail_eplus("8.8")) {
    # run a single model
    epw_path <- file.path(
        eplus_config("8.8")$dir,
        "WeatherData",
        "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
    )

    run_idf(idf_path, epw_path, output_dir = tempdir())

    # run multiple model in parallel
    idf_paths <- file.path(eplus_config("8.8")$dir, "ExampleFiles",
        c("1ZoneUncontrolled.idf", "1ZoneUncontrolledFourAlgorithms.idf")
    )
    epw_paths <- rep(epw_path, times = 2L)
    output_dirs <- file.path(tempdir(), tools::file_path_sans_ext(basename(idf_paths)))
    run_multi(idf_paths, epw_paths, output_dir = output_dirs)
}
} # }