-
Notifications
You must be signed in to change notification settings - Fork 5
/
war.py
294 lines (201 loc) · 9.37 KB
/
war.py
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 27 17:53:21 2017
@author: pianarol
"""
import hypy as hp
import scipy as sp
import numpy as np
import math
import matplotlib.pyplot as plt
###function lap ###
def lap(x,p):
'''WAR_LAP - Warren and Root (1963) solution in Laplace domain
Syntax:
hp.war.lap(x,p) provides the dimensionless drawdown at the well
x(1) = sigma
x(2) = lamda
p = Laplace parameter
See also: war_dls'''
s = x[0]
l = x[1]
s = 1/p*sp.special.kv(0,math.sqrt(p+(l*s*p)/(s*p+1)))
return s
###function dls ###
def dls(x,td):
'''WAR_DLS - Dimensionless drawdown of Warren and Root (1963) solution
Syntax: hp.war.dls(x,t)
x(1) = sigma
x(2) = lamda
t = time
Description:
Calculates the dimensionless drawdown
References:
Warren, J. E., and P. J. Root (1963), The behaviour of naturally
fractured reservoirs, Society of Petroleum Engineers Journal, 3,
245-255.
See also: war_lap'''
sd = []
for i in range(0, len(td)):
sd.append(hp.stefhest('war.lap',x,td[i]))
return sd
###function dim ###
def dim(p,t):
'''WAR_DIM - Warren and Root (1965) solution
Syntax: s = hp.war.dim( p, t)
p(1) = a = slope of Jacob Straight Line
p(2) = t0 = intercept with the horizontal axis for
the early time asymptote
p(3) = t1 = intercept with the horizontal axis for
the late time asymptote
p(4) = tm = time of the minimum of the derivative
Description:
Calculate the drawdown at time t for confined aquifer with double
porosity
Example:
s=war_dim(p,t)
See also: war_dmo, war_rpt, war_gss'''
a = p[0]
t0 = p[1]
t1 = p[2]
tm = p[3]
td = 0.445268*t/t0
sigma = (t1-t0)/t0
lambada = 2.2458394*t0*math.log(abs(t1/t0))/tm #changed the name, otherwise gives an error
sd = dls([sigma,lambada],td)
s = []
for i in range(0,len(sd)):
s.append(0.868589*a*sd[i])
return s
###function gss ###
def gss(t,s):
'''WAR_GSS - First guess for the parameters of the Warren and Root solution
Syntax: p = hp.war.gss(t,s)
p(1) = a = slope of Jacob Straight Line
p(2) = t0 = intercept with the horizontal axis for
the early time asymptote
p(3) = t1 = intercept with the horizontal axis for
the late time asymptote
p(4) = tm = time of the minimum of the derivative
t = time
s = drawdown
Description:
First guess for the parameters of the Warren and Root solution
See also: war_dmo, war_dim, war_rpt'''
td,d = hp.ldiffs(t,s,npoints=40)
dd = np.mean(d[len(d)-4:len(d)])
a = math.log(10)*dd
t0 = t[0]/math.exp(s[-1]/dd)
t1 = t[-1]/math.exp(s[-1]/dd)
i = np.argmin(d)
tm = td[i-2]
tm = np.float(tm)
p = []
p.append(a)
p.append(t0)
p.append(t1)
p.append(tm)
return p
###function rpt ###
def rpt(p,t,s,d, name, ttle = 'Interference test', Author = 'My name', Rapport = 'My Rapport', filetype = 'img'):
'''WAR_RPT - Produces the final figure and results for the Warren and Root model
Syntax: hp.war.rpt( p, t, s, d, ttle )
p(1) = a = slope of Jacob Straight Line
p(2) = t0 = intercept with the horizontal axis for the early time asymptote
p(3) = t1 = intercept with the horizontal axis for the late time asymptote
p(4) = tm = time of the minimum of the derivative
t = measured time
s = measured drawdown
d(1) = Q = Pumping rate
d(2) = r = Distance to the pumping well
ttle = Title of the figure
Description:
Produces the final figure and results for the Warren and Root model
See also: war_dmo, war_dim, war_gss'''
#Rename the parameters for a more intuitive check of the formulas
Q = d[0]
r = d[1]
a = p[0]
t0 = p[1]
t1 = p[2]
tm = p[3]
#Compute the transmissivity, storativity and radius of influence
Tf=0.1832339*Q/a
Sf=2.245839*Tf*t0/r**2
Sm=2.245839*Tf*t1/r**2-Sf;
sigma = (t1-t0)/t0
lambada = 2.2458394*t0*math.log(t1/t0)/tm
#Calls an internalscript that computes drawdown, derivative and residuals
#script rpt.cmp
tc,sc,mr,sr,rms = hp.script.cmp(p,t,s,'war')
#script rpt_plt
#calculate the derivative of the data
td, sd = hp.ldiffs(t,s, npoints=30)
#keep only positive derivatives
td, sd = hp.hyclean(td,sd)
#compute the derivative of the model
tdc,sdc = hp.ldiff(tc,sc)
#keep only positive derivatives
tdc,sdc = hp.hyclean(tdc,sdc)
#plots the data and model in bi-logarithmic scale
if filetype == 'pdf':
fig = plt.figure()
fig.set_size_inches(8, 6)
fig.text(0.125, 1, Author, fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, 0.95, Rapport, fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, -0.05, 'Test Data : ', fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.1, 'Discharge rate : {:3.2e} m³/s'.format(Q), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.15, 'Radial distance : {:0.2g} m '.format(r), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, -0.25, 'Hydraulic parameters :', fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.30, 'Transmissivity Tf : {:3.1e} m²/s'.format(Tf), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.35, 'Storativity Sf : {:3.1e}'.format(Sf), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.40, 'Storativity Sm : {:3.1e}'.format(Sm), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.45, 'Interporosity flow lambda : {:0.2e}'.format(lambada), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, -0.55, 'Fitting parameters :' , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.60, 'slope a : {:0.2g} m '.format(a) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.65, 'intercept t0 : {:0.2g} s'.format(t0) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.70, 'intercept t1 : {:0.2g} s'.format(t1) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.75, 'Minimum deruvatuve tm : {:0.2g} s'.format(tm) , fontsize=14, transform=plt.gcf().transFigure)
ax1 = fig.add_subplot(111)
ax1.set_xlabel('Time in seconds')
ax1.set_ylabel('Drawdown in meters')
ax1.set_title(ttle)
ax1.loglog(t, s, c='b',marker = 'o', linestyle = '', label = 'drawdown')
ax1.loglog(td, sd, c='r',marker = 'x', linestyle = '', label = 'Derivative')
ax1.loglog(tc, sc, c='g', label = 'Warren and Root (1965) Model')
ax1.loglog(tdc, sdc, c='y', label = 'Model derivative')
ax1.grid(True)
ax1.legend()
plt.show()
fig.savefig('war_rapport.pdf', bbox_inches = 'tight')
if filetype == 'img':
fig = plt.figure()
fig.set_size_inches(8, 6)
fig.text(0.125, 1, Author, fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, 0.95, Rapport, fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, -0.05, 'Test Data : ', fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.1, 'Discharge rate : {:3.2e} m³/s'.format(Q), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.15, 'Radial distance : {:0.2g} m '.format(r), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, -0.25, 'Hydraulic parameters :', fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.30, 'Transmissivity Tf : {:3.1e} m²/s'.format(Tf), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.35, 'Storativity Sf : {:3.1e}'.format(Sf), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.40, 'Storativity Sm : {:3.1e}'.format(Sm), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.45, 'Interporosity flow lambda : {:0.2e}'.format(lambada), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, -0.55, 'Fitting parameters :' , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.60, 'slope a : {:0.2g} m '.format(a) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.65, 'intercept t0 : {:0.2g} s'.format(t0) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.70, 'intercept t1 : {:0.2g} s'.format(t1) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.75, 'Minimum deruvatuve tm : {:0.2g} s'.format(tm) , fontsize=14, transform=plt.gcf().transFigure)
ax1 = fig.add_subplot(111)
ax1.set_xlabel('Time in seconds')
ax1.set_ylabel('Drawdown in meters')
ax1.set_title(ttle)
ax1.loglog(t, s, c='b',marker = 'o', linestyle = '', label = 'drawdown')
ax1.loglog(td, sd, c='r',marker = 'x', linestyle = '', label = 'Derivative')
ax1.loglog(tc, sc, c='g', label = 'Warren and Root (1965) Model')
ax1.loglog(tdc, sdc, c='y', label = 'Model derivative')
ax1.grid(True)
ax1.legend()
plt.show()
fig.savefig('war_rapport.png', bbox_inches = 'tight')