-
Notifications
You must be signed in to change notification settings - Fork 0
/
FinalProject_Wells' Drawdown
340 lines (279 loc) · 12.4 KB
/
FinalProject_Wells' Drawdown
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# Final Project, May 11th 2022
# Wang Xi
# Import libraries
import matplotlib.pyplot as plt
from scipy.integrate import quad
import numpy as np
import os # for setting up working directory
import pandas as pd
from pulp import *
# Set working directory
os.chdir("C:\\Users\\xw041\\OneDrive - Texas Tech University\\Desktop\\TTU_8th_2022 Spring\\CE 5331 Optimization and Decision Making 1\\Final project")
os.getcwd()
# Read data and define mu
wells = pd.read_csv("wells.csv")
wells.columns
X = wells["X_Feet"]
Y = wells['Y_Feet']
Dj = wells['Well_Depth']*0.75
WellID =wells.WellID
rj = wells['Well_Radius_in']/12 # convert radius unit from inch to feet
S = 0.001 # bounds??? [0.0009, 0.0025] for interval linear programming
K = 350 # bounds??? [200, 700] for interval linear programming
t = 30*366 # 30 years converted into days, 366 days not 365 days for conservative consideration
# lower bound and upper bound of confidence interval
# mean is 100 gpcd (gallons per capita per day)
# variance is 15 gpcd
# 95% efficiency, t-value = 2.262 since df =9 (10 wells-1)
lb = 100 - 2.262*((15/10)**(1/2))
lb # 97.22962710091223
ub = 100 + 2.262*((15/10)**(1/2))
ub # 102.77037289908777
Qjl=lb*30000*0.13368 # lower bound, smallest population, gallon converted into ft^3/day (same as /7.48)
Qjl # 389929.69652549835
Qju=ub*40000*0.13368 # upper bound, largest population, gallon converted into ft^3/day
Qju # 549533.7379660021
# Plot Well locaations
plt.plot(X, Y, "bo")
plt.xlabel("Well Location x (ft)")
plt.ylabel("Well Location y (ft)")
plt.grid()
plt.title("Well Location Plot")
for i, txt in enumerate(WellID):
plt.annotate(txt, (X[i], Y[i]))
plt.show()
# Calculating the distances
rij1 = []
rij2 = []
rij3 = []
rij4 = []
for i in range(0,10,1):
dist1 = (((X[i]-0)**2 +(Y[i]-0)**2))**0.5
dist2 = (((X[i]-0)**2 +(Y[i]-5280)**2))**0.5
dist3 = (((X[i]-5280)**2 +(Y[i]-5280)**2))**0.5
dist4 = (((X[i]-5280)**2 +(Y[i]-0)**2))**0.5
rij1.append(dist1)
rij2.append(dist2)
rij3.append(dist3)
rij4.append(dist4)
# Modified Theis Function
def well_func(rij, rj, S, K, t):
u = ((rij*rij)*S)/(4*K*rj*t) # define mu function
Euler = 0.57721566
G = np.exp(-1*Euler)
b = ((2-2*G)/(2*G-G*G))**0.5
hi = ((1-G)*(G*G-6*G+12))/(3*G*(2-G)*(2-G)*b)
q = (20/47)*(u**((31/26)**0.5))
h = (1/(1+(u**(3/2))))+((hi*q)/(1+q))
nume = (np.exp(-1*u))*(np.log(1+(G/u)-((1-G)/((h+b*u)*(h+b*u)))))
deno = G + ((1-G)*(np.exp((-1*u)/(1-G))))
Wu = nume/deno
return (Wu)
# Theis values for 4 corners
r1 = pd.to_numeric(rij1)
r2 = pd.to_numeric(rij2)
r3 = pd.to_numeric(rij3)
r4 = pd.to_numeric(rij4)
corner1 = well_func(r1, rj, S, K, t)
corner1
corner2 = well_func(r2, rj, S, K, t)
corner3 = well_func(r3, rj, S, K, t)
corner4 = well_func(r4, rj, S, K, t)
# cost = $0.1 per kWH, converted into cubic ft, need be multiplied by 3.41
# add 'dollar' sign for test
print("The maximal energy cost per day is:${}".format(round(0.1*0.5*(Qjl + Qju)/24*3.41,2)))
# The maximal energy cost per day is:$6674.10
print("The maximal energy cost per year is:${}".format(round(0.1*0.5*(Qjl + Qju)/24/365*3.41,2)))
# The maximal energy cost per year is:$18.29
# 1st corner
# Integer Programing Model
IDENTIFIERS = ['WellID_1','WellID_2','WellID_3','WellID_4','WellID_5','WellID_6',
'WellID_7','WellID_8','WellID_9','WellID_10']
dd1 = dict(zip(IDENTIFIERS, [1/2*(Qjl + Qju)*corner1[0]/(4*np.pi*K*Dj[0]),
1/2*(Qjl + Qju)*corner1[1]/(4*np.pi*K*Dj[1]),
1/2*(Qjl + Qju)*corner1[2]/(4*np.pi*K*Dj[2]),
1/2*(Qjl + Qju)*corner1[3]/(4*np.pi*K*Dj[3]),
1/2*(Qjl + Qju)*corner1[4]/(4*np.pi*K*Dj[4]),
1/2*(Qjl + Qju)*corner1[5]/(4*np.pi*K*Dj[5]),
1/2*(Qjl + Qju)*corner1[6]/(4*np.pi*K*Dj[6]),
1/2*(Qjl + Qju)*corner1[7]/(4*np.pi*K*Dj[7]),
1/2*(Qjl + Qju)*corner1[8]/(4*np.pi*K*Dj[8]),
1/2*(Qjl + Qju)*corner1[9]/(4*np.pi*K*Dj[9])]))
dd1
n = len(IDENTIFIERS)
n # 10 wells
x = LpVariable.dicts("x", indexs = IDENTIFIERS, lowBound=0, upBound=1, cat='Integer', indexStart=[])
x
# lowwerbound=0 and upperbound=1 is for binary integer boundaries
# cat='Integer' is important, because continuous is default
model = LpProblem(name="Drawdown", sense=LpMinimize)
# Create decision variables
# P = LpVariable('pulp', lowBound=0, upBound=None, cat='Continuous')
# minimize the obj function: Qj = [Qjl, Qju]
model += lpSum([x[i]*dd1[i] for i in IDENTIFIERS]), "Objective wells drawdown"
# prob += lpSum([P[i] for i in IDENTIFIERS]) >= Qjl, "Constraint for 30,000 population-gpcd"
# prob += lpSum([P[i] for i in IDENTIFIERS]) <= Qju, "Constraint for 40,000 population-gpcd"
model += lpSum([x[i] for i in IDENTIFIERS]) >= 4, "Constraint is what the city chooses at least 4 wells for production"
model += lpSum([x[i] for i in IDENTIFIERS]) <= 6, "Constraint is what the city chooses at most 6 wells for production"
model.solve(solver=GLPK(msg=False))
print("Status:", LpStatus[model.status])
for v in model.variables():
print(v.name, "=", v.varValue)
total_dd1 = value(model.objective)
total_dd1 # 9.666200055392071 (per year)
# Result, selected WellIDs: 2,3,7,9
x_WellID_1 = 0
x_WellID_10 = 0
x_WellID_2 = 1
x_WellID_3 = 1
x_WellID_4 = 0
x_WellID_5 = 0
x_WellID_6 = 0
x_WellID_7 = 1
x_WellID_8 = 0
x_WellID_9 = 1
# 2nd corner
# Integer Programing Model
IDENTIFIERS = ['WellID_1','WellID_2','WellID_3','WellID_4','WellID_5','WellID_6','WellID_7','WellID_8','WellID_9','WellID_10']
dd2 = dict(zip(IDENTIFIERS, [1/2*(Qjl + Qju)*corner2[0]/(4*np.pi*K*Dj[0]),
1/2*(Qjl + Qju)*corner2[1]/(4*np.pi*K*Dj[1]),
1/2*(Qjl + Qju)*corner2[2]/(4*np.pi*K*Dj[2]),
1/2*(Qjl + Qju)*corner2[3]/(4*np.pi*K*Dj[3]),
1/2*(Qjl + Qju)*corner2[4]/(4*np.pi*K*Dj[4]),
1/2*(Qjl + Qju)*corner2[5]/(4*np.pi*K*Dj[5]),
1/2*(Qjl + Qju)*corner2[6]/(4*np.pi*K*Dj[6]),
1/2*(Qjl + Qju)*corner2[7]/(4*np.pi*K*Dj[7]),
1/2*(Qjl + Qju)*corner2[8]/(4*np.pi*K*Dj[8]),
1/2*(Qjl + Qju)*corner2[9]/(4*np.pi*K*Dj[9])]))
dd2
n = len(IDENTIFIERS)
n # 10 wells
x = LpVariable.dicts("x", indexs = IDENTIFIERS, lowBound=0, upBound=1, cat='Integer', indexStart=[])
x
# lowwerbound=0 and upperbound=1 is for binary integer boundaries
# cat='Integer' is important, because continuous is default
model = LpProblem(name="Drawdown", sense=LpMinimize)
# Create decision variables
# P = LpVariable('pulp', lowBound=0, upBound=None, cat='Continuous')
# minimize the obj function: Qj = [Qjl, Qju]
model += lpSum([x[i]*dd2[i] for i in IDENTIFIERS]), "Objective wells drawdown"
# prob += lpSum([P[i] for i in IDENTIFIERS]) >= Qjl, "Constraint for 30,000 population-gpcd"
# prob += lpSum([P[i] for i in IDENTIFIERS]) <= Qju, "Constraint for 40,000 population-gpcd"
model += lpSum([x[i] for i in IDENTIFIERS]) >= 4, "Constraint is what the city chooses at least 4 wells for production"
model += lpSum([x[i] for i in IDENTIFIERS]) <= 6, "Constraint is what the city chooses at most 6 wells for production"
model.solve(solver=GLPK(msg=False))
print("Status:", LpStatus[model.status])
for v in model.variables():
print(v.name, "=", v.varValue)
total_dd2 = value(model.objective)
total_dd2 # 9.056858989565159 (per year)
# Result, selected WellIDs; 3,5,8,9
x_WellID_1 = 0
x_WellID_10 = 0
x_WellID_2 = 0
x_WellID_3 = 1
x_WellID_4 = 0
x_WellID_5 = 1
x_WellID_6 = 0
x_WellID_7 = 0
x_WellID_8 = 1
x_WellID_9 = 1
# 3rd corner
# Integer Programing Model
IDENTIFIERS = ['WellID_1','WellID_2','WellID_3','WellID_4','WellID_5','WellID_6','WellID_7','WellID_8','WellID_9','WellID_10']
dd3 = dict(zip(IDENTIFIERS, [1/2*(Qjl + Qju)*corner3[0]/(4*np.pi*K*Dj[0]),
1/2*(Qjl + Qju)*corner3[1]/(4*np.pi*K*Dj[1]),
1/2*(Qjl + Qju)*corner3[2]/(4*np.pi*K*Dj[2]),
1/2*(Qjl + Qju)*corner3[3]/(4*np.pi*K*Dj[3]),
1/2*(Qjl + Qju)*corner3[4]/(4*np.pi*K*Dj[4]),
1/2*(Qjl + Qju)*corner3[5]/(4*np.pi*K*Dj[5]),
1/2*(Qjl + Qju)*corner3[6]/(4*np.pi*K*Dj[6]),
1/2*(Qjl + Qju)*corner3[7]/(4*np.pi*K*Dj[7]),
1/2*(Qjl + Qju)*corner3[8]/(4*np.pi*K*Dj[8]),
1/2*(Qjl + Qju)*corner3[9]/(4*np.pi*K*Dj[9])]))
dd3
n = len(IDENTIFIERS)
n # 10 wells
x = LpVariable.dicts("x", indexs = IDENTIFIERS, lowBound=0, upBound=1, cat='Integer', indexStart=[])
x
# lowwerbound=0 and upperbound=1 is for binary integer boundaries
# cat='Integer' is important, because continuous is default
model = LpProblem(name="Drawdown", sense=LpMinimize)
# Create decision variables
# P = LpVariable('pulp', lowBound=0, upBound=None, cat='Continuous')
# minimize the obj function: Qj = [Qjl, Qju]
model += lpSum([x[i]*dd3[i] for i in IDENTIFIERS]), "Objective wells drawdown"
# prob += lpSum([P[i] for i in IDENTIFIERS]) >= Qjl, "Constraint for 30,000 population-gpcd"
# prob += lpSum([P[i] for i in IDENTIFIERS]) <= Qju, "Constraint for 40,000 population-gpcd"
model += lpSum([x[i] for i in IDENTIFIERS]) >= 4, "Constraint is what the city chooses at least 4 wells for production"
model += lpSum([x[i] for i in IDENTIFIERS]) <= 6, "Constraint is what the city chooses at most 6 wells for production"
model.solve(solver=GLPK(msg=False))
print("Status:", LpStatus[model.status])
for v in model.variables():
print(v.name, "=", v.varValue)
total_dd3 = value(model.objective)
total_dd3 # 8.19348839649178 (per year)
# Result, selected WellIDs: 5,7,8,9
x_WellID_1 = 0
x_WellID_10 = 0
x_WellID_2 = 0
x_WellID_3 = 0
x_WellID_4 = 0
x_WellID_5 = 1
x_WellID_6 = 0
x_WellID_7 = 1
x_WellID_8 = 1
x_WellID_9 = 1
# 4th corner
# Integer Programing Model
IDENTIFIERS = ['WellID_1','WellID_2','WellID_3','WellID_4','WellID_5','WellID_6','WellID_7','WellID_8','WellID_9','WellID_10']
dd4 = dict(zip(IDENTIFIERS, [1/2*(Qjl + Qju)*corner4[0]/(4*np.pi*K*Dj[0]),
1/2*(Qjl + Qju)*corner4[1]/(4*np.pi*K*Dj[1]),
1/2*(Qjl + Qju)*corner4[2]/(4*np.pi*K*Dj[2]),
1/2*(Qjl + Qju)*corner4[3]/(4*np.pi*K*Dj[3]),
1/2*(Qjl + Qju)*corner4[4]/(4*np.pi*K*Dj[4]),
1/2*(Qjl + Qju)*corner4[5]/(4*np.pi*K*Dj[5]),
1/2*(Qjl + Qju)*corner4[6]/(4*np.pi*K*Dj[6]),
1/2*(Qjl + Qju)*corner4[7]/(4*np.pi*K*Dj[7]),
1/2*(Qjl + Qju)*corner4[8]/(4*np.pi*K*Dj[8]),
1/2*(Qjl + Qju)*corner4[9]/(4*np.pi*K*Dj[9])]))
dd4
n = len(IDENTIFIERS)
n # 10 wells
x = LpVariable.dicts("x", indexs = IDENTIFIERS, lowBound=0, upBound=1, cat='Integer', indexStart=[])
x
# lowwerbound=0 and upperbound=1 is for binary integer boundaries
# cat='Integer' is important, because continuous is default
model = LpProblem(name="Drawdown", sense=LpMinimize)
# Create decision variables
# P = LpVariable('pulp', lowBound=0, upBound=None, cat='Continuous')
# minimize the obj function: Qj = [Qjl, Qju]
model += lpSum([x[i]*dd4[i] for i in IDENTIFIERS]), "Objective wells drawdown"
# prob += lpSum([P[i] for i in IDENTIFIERS]) >= Qjl, "Constraint for 30,000 population-gpcd"
# prob += lpSum([P[i] for i in IDENTIFIERS]) <= Qju, "Constraint for 40,000 population-gpcd"
model += lpSum([x[i] for i in IDENTIFIERS]) >= 4, "Constraint is what the city chooses at least 4 wells for production"
model += lpSum([x[i] for i in IDENTIFIERS]) <= 6, "Constraint is what the city chooses at most 6 wells for production"
model.solve(solver=GLPK(msg=False))
print("Status:", LpStatus[model.status])
for v in model.variables():
print(v.name, "=", v.varValue)
total_dd4 = value(model.objective)
total_dd4 # 8.42070024808662 (per year)
# Result, Selected WellIDs: 2,7,8,9
x_WellID_1 = 0
x_WellID_10 = 0
x_WellID_2 = 1
x_WellID_3 = 0
x_WellID_4 = 0
x_WellID_5 = 0
x_WellID_6 = 0
x_WellID_7 = 1
x_WellID_8 = 1
x_WellID_9 = 1
# Conclusion
# Corner 1's Result, selected WellIDs: 2,3,7,9
# Corner 2's Result, selected WellIDs; 3,5,8,9
# Corner 3's Result, selected WellIDs: 5,7,8,9
# Corner 4's Result, Selected WellIDs: 2,7,8,9
# common well ID is 9
# total well ID is 2,3,5,7,8,9