This is the classical and simple example of predicting production in a reservoir given an OOIP.
The MBAL server is started the same way as in Prosper and GAP.
library(rOpenserver) # Initialize OpenServer # mbal_server <- .OpenServer$new() mbal_server <- openserver() # Start Prosper cmd = "MBAL.START" mbal_server$DoCmd(cmd) #> [1] 0
We use a simple function to get the MBAl model filename. This function can be later generalized to retrieve any model type.
get_mbal_model <- function(model) { # get the well model models_dir <- system.file("models", package = "rOpenserver") model_file <- file.path(models_dir, model) if (!file.exists(model_file)) stop("Model not found ...") else return(model_file) }
Now, we open the MBAL model using the function shown above.
Let’s keep in mind that MBAL opens files a little bit different. The filename needs to be surrounded with double quotes "
, not single quotes '
as in Prosper or GAP. We make that slight change and open the model.
# MBAL opens files a little bit different. The filename needs to be surrounded with # double quote not single quotes as in Prosper or GAP. model_file <- get_mbal_model(model = "oil.mbi") print(model_file) #> [1] "C:/Users/ipm/AppData/Local/Temp/RtmpwBxUCZ/temp_libpath1b2cc5956da/rOpenserver/models/oil.mbi" open_cmd <- 'MBAL.OPENFILE' open_cmd <- paste0(open_cmd, '("', model_file, '")') print(open_cmd) #> [1] "MBAL.OPENFILE(\"C:/Users/ipm/AppData/Local/Temp/RtmpwBxUCZ/temp_libpath1b2cc5956da/rOpenserver/models/oil.mbi\")" DoCmd(mbal_server, open_cmd) # using S3 dispatch of R6 class #> [1] 0
Enter the OOIP and write to MBAL.
ooip <- 300 DoSet(mbal_server, "MBAL.MB.TANK.OOIP", ooip)
And extract the first row of the table generated by the prediction.
# we get the oil rate from the first in the results table DoGet(mbal_server, "MBAL.MB.TRES[2][0][0].OILRATE") #> [1] "11491.032258065"