-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
146 lines (119 loc) · 5.73 KB
/
main.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
from datetime import date
import sys
import os
import pandas as pd
from inputData import InputData
from network import Network
from sPhase import SinglePhase
from tPhaseD import TwoPhaseDrainage
from SecondaryProcesses import SecDrainage, SecImbibition
from tPhaseImb import TwoPhaseImbibition
from plot import makePlot
# __DATE__ = "Jul 25 , 2023"
__DATE__ = date.today().strftime("%b") + " " + str(date.today().day) + ", " +\
str(date.today().year)
def main():
try:
input_file_name = ""
print("\nNetwork Model Code version 2 alpha, built: ", __DATE__, "\n")
if len(sys.argv) > 1:
input_file_name = sys.argv[1]
else:
input_file_name = input("Please input data file : ")
input_data = InputData(input_file_name)
netsim = Network(input_file_name)
# Single Phase computation
netsim = SinglePhase(netsim)
netsim.singlephase()
toPlot = True
compWithLitData = True
compWithPrevData = True
drainPlot = False
imbibePlot = False
writeData = False
writeTrappedData = True
fillTillNWDisconnected = True
# two Phase simulations
if input_data.satControl():
firstDrainCycle = True
firstImbCycle = True
netsim.fillTillNWDisconnected = fillTillNWDisconnected
for j in range(len(input_data.satControl())):
netsim.finalSat, Pc, netsim.dSw, netsim.minDeltaPc,\
netsim.deltaPcFraction, netsim.calcKr, netsim.calcI,\
netsim.InjectFromLeft, netsim.InjectFromRight,\
netsim.EscapeFromLeft, netsim.EscapeFromRight =\
input_data.satControl()[j]
netsim.filling = True
if netsim.finalSat < netsim.satW:
# Drainage process
netsim.is_oil_inj = True
netsim.maxPc = Pc
if firstDrainCycle:
(netsim.wettClass, netsim.minthetai, netsim.maxthetai,
netsim.delta, netsim.eta, netsim.distModel, netsim.sepAng) =\
input_data.initConAng('INIT_CONT_ANG')
netsim = TwoPhaseDrainage(netsim, writeData=writeData,
writeTrappedData=writeTrappedData)
netsim.prop_drainage = {}
netsim.prop_drainage['contactAng'] = netsim.contactAng.copy()
netsim.prop_drainage['thetaRecAng'] = netsim.thetaRecAng.copy()
netsim.prop_drainage['thetaAdvAng'] = netsim.thetaAdvAng.copy()
firstDrainCycle = False
else:
netsim = SecDrainage(netsim, writeData=writeData,
writeTrappedData=writeTrappedData)
netsim.drainage()
if drainPlot:
drainage_results = {}
drainage_results['model'] = pd.read_csv(
netsim.fQ.name, names=[
'satW', 'qWout', 'krw', 'qNWout', 'krnw', 'capPres', 'invasions'],
sep=',', skiprows=18, index_col=False)
else:
# Imbibition process
netsim.minPc = Pc
if firstImbCycle:
(netsim.wettClass, netsim.minthetai, netsim.maxthetai,
netsim.delta, netsim.eta, netsim.distModel, netsim.sepAng) =\
input_data.initConAng('EQUIL_CON_ANG')
netsim = TwoPhaseImbibition(netsim, writeData=writeData,
writeTrappedData=writeTrappedData)
netsim.prop_imbibition = {}
netsim.prop_imbibition['contactAng'] = netsim.contactAng.copy()
netsim.prop_imbibition['thetaRecAng'] = netsim.thetaRecAng.copy()
netsim.prop_imbibition['thetaAdvAng'] = netsim.thetaAdvAng.copy()
firstImbCycle = False
else:
netsim = SecImbibition(netsim, writeData=writeData,
writeTrappedData=writeTrappedData)
netsim.imbibition()
if imbibePlot:
imbibition_results = {}
imbibition_results['model'] = pd.read_csv(
netsim.fQ.name, names=[
'satW', 'qWout', 'krw', 'qNWout', 'krnw', 'capPres', 'invasions'],
sep=',', skiprows=18, index_col=False)
if toPlot:
if drainPlot:
mkD = makePlot(netsim._num, netsim.title, drainage_results,
compWithLitData, compWithPrevData, True, False, include=None)
mkD.pcSw()
mkD.krSw()
if imbibePlot:
mkI = makePlot(netsim._num, netsim.title, imbibition_results,
compWithLitData, compWithPrevData, False, True, include=None)
mkI.pcSw()
mkI.krSw()
#from IPython import embed; embed()
else:
pass
except Exception as exc:
print("\n\n Exception on processing: \n", exc, "Aborting!\n")
return 1
except:
print("\n\n Unknown exception! Aborting!\n")
return 1
return 0
if __name__ == "__main__":
sys.exit(main())