-
Guillaume Perréal authoredd04e9e4d
title: "How to run several hydrus models in batch mode"
output: html_notebook
Prerequires
- You must have created a reference model using the GUI. Create a permanent model within a folder located in your User directory.
- Make sure to uncheck the box Hit Enter at the End? located in the Print Information window.
- Copy the appropriate exe file from Program Files directory (Hydrus is usually installed within a folder named PC-progress) to your model folder.
For example, if you want to run a dual porosity 1D model, you must copy the file named H1D_Dual.exe.
load functions and define paths
You need to specify the location of the rhydrus folder:
rhydrus.folder <- "C:/Users/forquet/Documents/script_R/rhydrus"
To load all necessary functions, source these two files:
filename <- paste0(rhydrus.folder,"/file_manip.R")
source(filename)
filename <- paste0(rhydrus.folder,"/simulation_fcn.R")
source(filename)
The main directory, i.e. where you saved your model and where a new folder will be created for each run you will set up.
main.directory <- "C:/Users/forquet/Documents/script_R/rhydrus_demo/PF_1pulse"
setwd(main.directory)
Indicate the number of run to be carried out:
nb.runs <- 2
As explained earlier, each simulation results will be placed in a new folder. It's name will be composed of a common root and the number of the run. The common root is named generic.name.
generic.name <- "PF_Model_"
With the main directory, you must have placed a gui file ending with an extension .h1d and a folder containing all input and output files. The name of this folder must be saved within the variable hydrus.folder.
hydrus.folder <- "DPo_1pulse_modifpdt_180108"
Now you must specify the new hydraulic parameters you want to use for each run. in this example we run a dual porosity model with 2 materials. Therefore you must create a matrix for each material with the number of line equal to the number of run and the number of columns equal to the number of parameters (9 in dual porosity model).
# material 1
deposit <- matrix(c(0, 0.05, 0.12, 1.8, 5, 0.5, 0.64, 0.79, 0.05, 0, 0.05, 0.12, 1.8, 5, 0.5, 0.64, 0.79, 0.05),ncol=9,byrow=TRUE)
# material 2
gravel <- matrix(c(0, 0.1, 0.572, 2.917, 300, 0.5, 0.052, 0.4, 0, 0, 0.1, 0.572, 2.917, 300, 0.5, 0.052, 0.4, 0),ncol=9,byrow=TRUE)
A list is created made of a data.frame for each run
new.data <- list()
for (i in 1:nb.runs){
new.data[[i]] <- rbind(deposit[i,],gravel[i,])
}
Next we use the simulation.setup function to create all the folders and to copy input files.
simulation.setup(nb.runs,generic.name,main.directory,hydrus.folder,new.data,hydrus.version="1D")
Finally, we run the simulations using the function simulation.run. This function output the computing time:
output <- simulation.run(2,paste0(rhydrus.folder,"/processor_load.bat"),main_directory,generic.name,hydrus.calc="H1D_Dual.exe")