-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputData.py
284 lines (246 loc) · 8.28 KB
/
inputData.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
import numpy as np
from time import time
import os
class InputData:
DUMMY_INDEX = -99
def __init__(self, inputFile):
self.workingSatEntry = 0
self.numInletThroats = 0
self.averageThroatLength = 0.0
self.networkSeparation = 0.0
self.connectionsRemoved = 0
self.useAvrXOverThroatLen = False
self.addPeriodicBC = False
self.useAvrPbcThroatLen = False
self.data = self.inputdata(inputFile)
self.cwd = os.path.dirname(inputFile)
def inputdata(self, inputFile):
lines = iter(list(filter(None, (
line.partition("%")[0].rstrip() for line in open(inputFile)))))
data = {}
for i in lines:
while ';' not in i:
i = i+next(lines)
i = i.rstrip(";").split()
key, value = i[0], []
for j in i[1:]:
try:
value.append(int(j))
except ValueError:
try:
value.append(float(j))
except ValueError:
value.append(j)
data[key] = value[0] if len(value) == 1 else value
return data
def network(self):
if self.data['NETWORK']:
return self.data['NETWORK'][1]
elif self.data['TITLE']:
return self.data['TITLE']
else:
print('\nError: Network name was not stated!!')
exit()
def randSeed(self):
if self.data["RAND_SEED"]:
return self.data["RAND_SEED"]
else:
return int(time.time())
def __calcBox__(self):
if self.data['CALC_BOX']:
return self.data['CALC_BOX']
else:
return [0.5, 1.0]
def satControl(self):
if self.data["SAT_CONTROL"]:
if len(self.data["SAT_CONTROL"]) % 11 == 0:
satControl = []
a = 0
while len(self.data["SAT_CONTROL"]) > a:
satControl.append(self.data["SAT_CONTROL"][a:a+11])
a += 11
data = np.array(satControl)[:, 0].astype('float')
if ((data < 0) | (data > 1)).any():
print("\nError: Saturations to be given as fractions")
exit()
return satControl
else:
print("\nError: Invalid entry for the SAT_CONTROL keyword")
exit()
else:
return False
def satCovergence(self):
if self.data["SAT_COVERGENCE"]:
return self.data["SAT_COVERGENCE"]
else:
return [10, 0.02, 0.8, 2.0, 'F']
def initConAng(self, case):
if case == 'INIT_CONT_ANG':
data = np.array(self.data['INIT_CONT_ANG'])
wettClass = data[0].astype('int')
minAng, maxAng = data[1:3].astype('float')*np.arccos(-1.0)/180
delta, eta = data[3:5].astype('float')
try:
distModel = data[5]
sepAng = data[6].astype('float')*np.arccos(-1.0)/180
except ValueError:
distModel = 'rand'
sepAng = 25.2*np.arccos(-1.0)/180
elif case == 'EQUIL_CON_ANG':
data = np.array(self.data['EQUIL_CON_ANG'])
wettClass = data[0].astype('int')
minAng, maxAng = data[1:3].astype('float')*np.arccos(-1.0)/180
delta, eta = data[3:5].astype('float')
try:
distModel = data[5]
sepAng = data[6].astype('float')*np.arccos(-1.0)/180
except ValueError:
distModel = 'rand'
sepAng = 25.2*np.arccos(-1.0)/180
else:
print('\nError: Both keyword INIT_CONT_ANG and EQUIL_CON_ANG are \
missing!')
return wettClass, minAng, maxAng, delta, eta, distModel, sepAng
def res_format(self):
if self.data["RES_FORMAT"]:
res_form = self.data["RES_FORMAT"]
matlab_format = (res_form.lower() == "matlab")
excel_format = (res_form.lower() == "excel") or (
res_form.lower() == "excelandmicroporosity")
mcp_format = (res_form.lower() == "excelandmicroporosity") or (
res_form.lower() == "upscaling")
else:
matlab_format = False
excel_format = False
mcp_format = False
return matlab_format, excel_format, mcp_format
def fluidproperties(self):
if self.data["FLUID"]:
[intfac_ten, wat_visc, oil_visc, wat_resist, oil_resist, wat_dens,
oil_dens] = self.data["FLUID"]
intfac_ten *= 1.0E-3 # Get it into N/m
wat_visc *= 1.0E-3 # Get it into Pa.s
oil_visc *= 1.0E-3 # Get it into Pa.s
else:
intfac_ten = 30.0E-3
wat_visc = 1.0E-3
oil_visc = 1.0E-3
wat_resist = 1.0
oil_resist = 1000.0
wat_dens = 1000.0
oil_dens = 1000.0
return intfac_ten, wat_visc, oil_visc, wat_resist, oil_resist, \
wat_dens, oil_dens
def relPermDef(self):
data = input("REL_PERM_DEF: ")
if data.strip():
# Process the data as needed
pass
else:
flowRef = "single"
return flowRef
def prsBdrs(self):
data = input("PRS_BDRS: ")
if data.strip():
# Process the data as needed
pass
else:
return False
def matBal(self):
data = input("MAT_BAL: ")
if data.strip():
# Process the data as needed
pass
else:
return False
def apexPrs(self):
data = input("APEX_PRS: ")
if data.strip():
# Process the data as needed
pass
else:
return False
def sourceNode(self):
data = input("POINT_SOURCE: ")
if data.strip():
sourceNode = int(data)
return sourceNode
else:
return 0
'''def solverTune(self):
data = input("SOLVER_TUNE: ")
if data.strip():
# Process the data as needed
pass
else:
eps = 1.0E-15
scaleFact = 5
slvrOutput = 0
condCutOff = 0.0
verbose = False
return [eps, scaleFact, slvrOutput, verbose, condCutOff]
def poreFillWgt(self):
data = input("PORE_FILL_WGT: ")
if data.strip():
# Process the data as needed
pass
else:
weights = [0.0, 15000.0, 15000.0, 15000.0, 15000.0, 15000.0]
return weights
def poreFillAlg(self):
data = input("PORE_FILL_ALG: ")
if data.strip():
# Process the data as needed
pass
else:
algorithm = "blunt2"
return algorithm
def getModifyRadDistOptions(self):
data = input("MODIFY_RAD_DIST: ")
if data.strip():
# Process the data as needed
pass
else:
throatModel = 0
poreModel = 0
throatOptions = ""
poreOptions = ""
maintainLtoR = False
writeDistToFile = False
numPtsRDist = 0
def getModifyGDist(self):
data = input("MODIFY_G_DIST: ")
if data.strip():
# Process the data as needed
pass
else:
throatModel = 0
poreModel = 0
throatOptions = ""
poreOptions = ""
writeDistToFile = False
numPts = 0
def getModifyPoro(self):
data = input("MODIFY_PORO: ")
if data.strip():
# Process the data as needed
pass
else:
netPoroTrgt = 0.0
clayPoroTrgt = 0.0
def modifyConnNum(self):
data = input("MODIFY_CONN_NUM: ")
if data.strip():
# Process the data as needed
pass
else:
targetConnNum = 0.0
model = ""
def getModifyModelSize(self):
data = input("MODIFY_MOD_SIZE: ")
if data.strip():
# Process the data as needed
pass
else:
scaleFactor = 0.0
'''