suppressPackageStartupMessages(library(rhdf5)) source("Rutils.R") # get well parameters: input and calculated params <- well.params() well.data <- params$out.data well.calc <- params$out.calc # build the full filename wells.dir <- "./" wellFile <- file.path(wells.dir, "WOODLIB.00.hdf5") # if the HDF file does not exist it will create one if (file.exists(wellFile)) { file.remove(wellFile) # option 1: remove the file } else { fid <- H5Fcreate(wellFile) } # h5createFile(well.file) h5save(well.data, well.calc, file = wellFile) #H5close() #h5wH <- h5write(well.data, file = wellFile, "welldata") # H5Dclose(did) # H5Sclose(sid) H5Fclose(fid) H5close()
# write a scalar library(rhdf5) wellFile <- file.path("./", "test.hdf5") # if the HDF file does not exist it will create one if (file.exists(wellFile)) file.remove(wellFile) if (!file.exists(wellFile)) fid <- H5Fcreate(wellFile) sid <- H5Screate_simple(c(1,1)) did <- H5Dcreate(fid, "THT", "H5T_STD_I32LE", sid) H5Dwrite(did, well.data$tht, h5spaceMem = sid, h5spaceFile = sid) H5Dclose(did) H5Sclose(sid) H5Fclose(fid)
well.params <- function(well.name = "ExampleGuo", depth.wh = 0, # depth at wellhead depth.bh = 9700, # depth at bottomhole diam.in = 1.995, GLR = 75, liq.rt = 758, wcut = 0.10, thp = 200, # tubing head pressure tht = 80, # tubing head temperature bht = 180, # bottomhole temperature API = 40, gas.sg = 0.7, wat.sg = 1.05, oil.visc = 5, ed = 0.0006, # relative roughness if.tens = 30, segments = 30, # number of depth segments model = "hagbr.mod", # VLP model selection salinity = 0 ) { # calculate segments and depths # depth counts have to be greater than segments to allocate the zero # or initial depth value # consider that in length.out parameter depths <- seq.int(from = depth.wh, to = depth.bh, length.out = segments+1) n <- length(depths) # which is the same as # rows # calculate temperature gradient temp.grad <- (bht - tht) / depth.bh # convert tubing diameter to ft diam <- diam.in /12 # calculate area in ft^2 area <- pi / 4 * diam^2 # calculate specific gravity of oil from API oil.sg <- 141.5 / (131.5 + API) # oil and water fractions wat.fraction <- wcut oil.fraction <- 1 - wat.fraction WOR <- wat.fraction / oil.fraction # calculate oil, gas and water rate at standard conditions # oil.srt, gas.srt, wat.srt # OIL.RT, GAS.RT, WAT.RT # oil.Srt, gas.Srt, wat.Srt oil.rt <- liq.rt * oil.fraction gas.rt <- liq.rt * GLR wat.rt <- liq.rt * wat.fraction # GOR GOR = (oil.rt + wat.rt) / oil.rt * GLR # total mass per STB = mass oil + mass water + mass gas. C42.3 mass.total <- oil.sg * 350 * (1 / (1+WOR)) + wat.sg * 350 * (WOR / (1+WOR)) + 0.0764 * GLR * gas.sg # calculate fluid properties at P, T conditions # input parameters out.data <- named.list( well.name, depth.wh, tht, depth.bh, bht, diam.in, ed, thp, liq.rt, wcut, API, oil.visc, gas.sg, GLR, wat.sg, salinity, if.tens ) # calculated parameters out.calc <- named.list( depths, n, temp.grad, diam, area, oil.sg, oil.fraction, wat.fraction, WOR, oil.rt, gas.rt, wat.rt, mass.total, GOR ) # put together input and calculated lists out.surf <- named.list(out.data, out.calc) return(out.surf) }
#' @param depth.wh depth at the wellhead double feet #' @param depth.bh depth of the well double feet #' @param diam.in inner diameter of tubing double inches #' @param liq.rt liquid rate double stb/day #' @param wcut watercut double percent #' @param GLR Gas Liquid Ratio double scf/stb #' @param thp tubing head pressure double psia #' @param tht tubing head temperature double deg Farenheit #' @param bht bottomhole temperature double deg Farenheit #' @param API oil gravity double API #' @param gas.sg specific gravity of gas double adim #' @param wat.sg specific gravity of water double adim #' @param oil.visc oil viscosity double cp #' @param ed relative roughness of pipe double adim #' @param if.tens interfacial tension double dyn/cm #' @param segments number of tubing segments int adim #' @param tol tolerance for iterations double adim #' @param model name of the model char #' @param salinity salinity of water double ppm
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.