-
Notifications
You must be signed in to change notification settings - Fork 3
/
equivalent_time_utilities.R
138 lines (138 loc) · 4.48 KB
/
equivalent_time_utilities.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#' @section Equivalent_time functions:
#'
#' These functions are used in the estimation of the aquifer parameters for the recovery and variable rate tests.
#'
#' The functions included in this section are:
#' recovery_equivalent_time, variable_rate_equivalent_time
#'
#' @docType package
#' @name pumpingtest
NULL
#' @title
#' recovery_equivalent_time
#' @description
#' Function to calculate the equivalent time of the recovery tests
#' @param t_recovery Vector with the times since recovery started
#' @param s_recovery Vector with the drawdowns since recovery started
#' @param pump_history Vector with the pump history of the test
#' @return
#' A list with
#' \itemize{
#' \item ta equivalent time
#' \item sa drawdown corresponding to equivalent time
#' }
#' @author
#' Oscar Garcia-Cabrejo \email{khaors@gmail.com}
#' @export
#' @family equivalent_time functions
#' @references
#' Agarwal, R. (1980). A New Method To Account For Producing Time Effects When Drawdown
#' Type Curves Are Used To Analyze Pressure Buildup And Other Test Data. SPE Paper 9289.
#' @examples
#' data(agarwal_recovery)
#' pump_history <- 14400
#' agarwal_corr <- recovery_equivalent_time(agarwal_recovery$t,
#' agarwal_recovery$s,
#' pump_history)
recovery_equivalent_time <- function(t_recovery, s_recovery, pump_history){
if(class(t_recovery) != 'numeric'){
stop('Numeric vector required for time')
}
if(class(s_recovery) != 'numeric'){
stop('Numeric vector required for drawdown')
}
if(class(pump_history) != 'numeric'){
stop('Numeric information required for pump history')
}
n <- length(pump_history);
if( n == 1 ){
ta <- pump_history*t_recovery/(pump_history+t_recovery)
#print(ta)
}
else {
t_pumping <- pump_history[,1]
q_pumping <- pump_history[,2]
ta <- t_pumping[(n-1)]/(t_recovery+t_pumping[(n-1)])^(q_pumping[1]/(q_pumping[n-1]-q_pumping[n]))
for (j in 2:(n-1)){
ta <- ta*((t_pumping[n-1]-t_pumping[j-1])/(t_recovery+t_pumping[n-1]-t_pumping[j-1]))^
((q_pumping[j]-q_pumping[j-1])/(q_pumping[n-1]-q_pumping[n]))
}
ta <- ta*t_recovery;
}
pos_valid <- !duplicated(ta);
ta <- ta[pos_valid]
sa <- s_recovery[pos_valid];
results <- list(ta = ta, sa = sa)
return(results)
}
#' @title
#' variable_rate_equivalent_time
#' @description
#' Function to calculate the equivalent time required in the variable-rate tests.
#' @param t Vector with the times since pumping started
#' @param s Vector with the drawdowns since pumping started
#' @param pump_history Vector with the pump history of the test
#' @return
#' A list with
#' \itemize{
#' \item ta equivalent time
#' \item sa drawdown corresponding to equivalent time
#' }
#' @author
#' Oscar Garcia-Cabrejo \email{khaors@gmail.com}
#' @export
#' @family equivalent_time functions
#' @references
#' Birsoy, Y.K. and W.K. Summers, 1980. Determination of aquifer parameters from step tests
#' and intermittent pumping, Ground Water, vol. 18, no. 2, pp. 137-146.
variable_rate_equivalent_time <- function(t, s, pump_history){
if(class(t) != 'numeric'){
stop('Numeric vector required for time')
}
if(class(s) != 'numeric'){
stop('Numeric vector required for drawdown')
}
if(class(pump_history) != 'matrix'){
stop('Numeric information required for pump history')
}
Q <- pump_history
dQ <- diff(pump_history[,2])
dQ <- c(pump_history[1,2], dQ)
nperiod <- nrow(pump_history)
ntimes <- length(t)
starting_times <- vector("numeric", length = (nperiod+1))
starting_times[1] <- 0
starting_times[2:(nperiod+1)] <- pump_history[,1]
pump_history1 <- vector('numeric', length = length(t))
equiv_time <- vector('numeric', length = length(t))
equiv_time[1:length(t)] <- 1
for(i in 1:nperiod){
if(i == 1){
current_t <- pump_history[i,1]
current_pos <- t <= current_t
}
else{
ct1 <- pump_history[(i-1),1]
ct2 <- pump_history[i,1]
current_pos <- t > ct1 & t <= ct2
}
pump_history1[current_pos] <- i
}
#
for(j in 1:ntimes){
n1<- pump_history1[j]
for(i in 1:n1){
equiv_time[j] <- equiv_time[j]*(t[j]-starting_times[i])^(dQ[i]/Q[n1,2])
}
}
#
pos_valid <- !duplicated(equiv_time)
equiv_time <- equiv_time[pos_valid]
s <- s[pos_valid]
equiv_time.sort <- sort(equiv_time, index.return = TRUE)
equiv_time <- equiv_time.sort$x
lQ <- Q[pump_history1,2]
sa <- s[equiv_time.sort$ix]/lQ[equiv_time.sort$ix]
results <- list(ta = equiv_time, sa = sa)
return(results)
}