rtemporary-filescalibration

Function `run_swmm` in R package "swmmr" fails to create ".rpt" and ".out" files?


I am running a SWMM calibration example included in the R package "swmmr" (https://cran.r-hub.io/web/packages/swmmr/vignettes/How_to_autocalibrate_a_SWMM_model_with_swmmr.html). When I try to run the function run_swmm, the "rpt" and "out" files are not created.

Below are my steps and I wonder how to fix the error? Thank you.

  1. Install SWMM from https://www.epa.gov/water-research/storm-water-management-model-swmm

  2. SWMM calibration in R using "swmmr"

     remotes::install_github("dleutnant/swmmr")
     install.packages("DEoptim")
     library(swmmr)
     library(DEoptim)
    
     inp_file <- system.file("extdata", "Example1.inp", package = "swmmr", mustWork = TRUE)
     tmp_rpt_file <- tempfile(tmpdir = "D:/SWMM_example", fileext = ".rpt")
     tmp_out_file <- tempfile(tmpdir = "D:/SWMM_example", fileext = ".out")
    
     swmm_files <- run_swmm(inp = inp_file, rpt = tmp_rpt_file, 
                            out = tmp_out_file, 
                            exec = "D:/SWMM/EPA SWMM 5.2.3 (64-bit)/epaswmm5.exe")
    

When running the code, SWMM will run automatically, and I usually close it after 10-15 seconds so that it can finish running the example. It is expected that the ".rpt" and ".out" files will be created under "D:/SWMM_example".

However, some warnings occur as below. It seems that run_swmm fails to create the ".rpt" and ".out" files. I am not sure how to solve the issue.

enter image description here

Thanks to @Johannes Titz, I need to find the path to the command line SWMM swmm5.exe instead of the GUI SWMM epaswmm5.exe. I install the 64-bit SWMM and then use the tool Everything to search for "swmm5.exe", however, I could not find swmm5.exe on my laptop. I can only find epaswmm5.exe. I wonder how I should find swmm5.exe? Thank you.

enter image description here


Solution

  • You are not calling the command line interface of swmm but the GUI. I think you need to change the executable to "swmm5.exe". Reading the doc you will see that the default is also swmm5.exe and not epaswmm5.exe:

    exec

    Name and path to swmm5 executable. If not manually set, the following paths are looked up when package gets loaded: windows: "C:/Program Files (x86)/EPA SWMM 5.X.XXX/swmm5.exe" not windows: "/usr/local/bin/swmm5" , "/usr/bin/swmm5"

    Could you give this a try and report back? At least for me, this runs totally fine with swmm5.exe

    Edit: The R-package was released in 2018 so I installed the swmm-version of that time, which was 5.1.013. On the newest version the naming seems to have changed to runswmm.exe. Can you try this?