dleutnant / swmmr

R Interface for US EPA's SWMM
https://cran.r-project.org/package=swmmr
39 stars 15 forks source link

Running *.inp file after I edit it in R #57

Closed ashish-shrs closed 3 years ago

ashish-shrs commented 3 years ago

I am trying to change the rainfall and parameter value of the input file and trying to re-run it in R without having to save the *.inp file with new edit and read it again and run. My question is can I do that? And my issue is as below:

_inp = read_inp("D:/Model_Issues/Model1.inp") # Here, I read the inp file

for (j in 1:length(inp$subcatchments$Name)){ # Here, I changed old rain gauge to new one _inp$subcatchments$Rain Gage[j] = "NEWRaindata" }

_runswmm(inp) # So, I am trying to run that edited inp file. This command doesn't work. The issue is how do I make this input file run, since I changed something in *.inp file

_run_swmm("Model1.inp") # Only way I could run it is from this command which means it is reading from the directory. So I have to save the above edits in *.inp using _writeinp and read it again before I could run it. And doing this gave me issue #56

Looking forward to your tips/suggestions. Thanking you and regards.

dleutnant commented 3 years ago

run_swmm() calls the SWMM5 engine which is in fact the SWMM5.exe. This implies that a model input file (.inp) needs to be physically on disk. The system call for MS Windows basically is "c:/Program Files (x86)//EPA SWMM 5.1.015/swmm5.exe path_to_input.inp path_to_report.rpt path_to_binary_out.out".

The alternative would be to integrate the full SWMM5 code into R which would be doable but requires substantial efforts. One would then have the full simulation within the R environment which means one could store all simulation results in RAM with all its pros and cons.