gimms 0.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
gimms/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ from .__version__ import __version__
2
+ from .core import greet
3
+
4
+ __all__ = ["__version__", "greet"]
gimms/__version__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "0.0.0"
@@ -0,0 +1,114 @@
1
+
2
+ def apply_fault_perms(geo, dat, fault_dir):
3
+ """ fault_dir is expected to be like:
4
+ { 'A': 2,
5
+ 'B': 2,
6
+ 'C': 1, }
7
+ where 'A', 'B', ... are fault name used as part of rock type name
8
+ """
9
+
10
+ for lay in geo.layerlist[:0:-1]:
11
+ layername = lay.name
12
+ print(lay.name)
13
+ fcols = {}
14
+
15
+ for col in geo.columnlist:
16
+ try:
17
+ bstats = dat.grid.block[col.name+layername].rocktype.name
18
+ #print bstats
19
+ for flt in bstats[1:3]:
20
+ if flt != '0':
21
+ if flt.isdigit(): continue
22
+ #print flt
23
+ #hello
24
+ try:
25
+ fcols[flt].append(col.name)
26
+ except KeyError:
27
+ fcols[flt] = []
28
+ fcols[flt].append(col.name)
29
+ except KeyError:
30
+ pass
31
+
32
+ #print 'Columns done'
33
+
34
+ faults1 = []
35
+ faults2 = []
36
+ for flt in fcols.keys():
37
+ #print flt
38
+ along_flt = fault_dir[flt]
39
+ if along_flt == 1:
40
+ faults1.append(flt)
41
+ else:
42
+ faults2.append(flt)
43
+
44
+ for flt in fcols.keys():
45
+ #print flt
46
+ along_flt = fault_dir[flt]
47
+ across_flt = along_flt%2+1
48
+
49
+ #print along_flt,across_flt
50
+ #hello
51
+
52
+ checkcons = []
53
+ checkdatcons = []
54
+ try:
55
+ for fcol in fcols[flt]:
56
+ #print fcol
57
+ for con in geo.column[fcol].connection:
58
+ col1 = con.column[0]
59
+ col2 = con.column[1]
60
+ #print col1,col2
61
+ try:
62
+ #print 'here'
63
+ datcon = dat.grid.connection[(col1.name+layername,col2.name+layername)]
64
+ except KeyError:
65
+ #print 'reverse'
66
+ try:
67
+ datcon = dat.grid.connection[(col2.name+layername,col1.name+layername)]
68
+ except KeyError:
69
+ #print 'no conn'
70
+ continue
71
+ checkcons.append(con)
72
+ checkdatcons.append(datcon)
73
+ #print col1.name+layername, block_faults[()][col1.name+layername], col2.name+layername, block_faults[()][col2.name+layername]
74
+
75
+ fltpres = []
76
+ bstats1 = dat.grid.block[col1.name+layername].rocktype.name
77
+ bstats2 = dat.grid.block[col2.name+layername].rocktype.name
78
+
79
+ for flt1 in bstats1[1:3]:
80
+ if flt1 in faults1: fltpres.append(1)
81
+ if flt1 in faults2: fltpres.append(2)
82
+ for flt2 in bstats2[1:3]:
83
+ if flt2 in faults1: fltpres.append(1)
84
+ if flt2 in faults2: fltpres.append(2)
85
+ if bstats1[1] == '0': fltpres.append(0)
86
+ if bstats2[1] == '0': fltpres.append(0)
87
+
88
+ #print bstats1,bstats2,fltpres
89
+ if 1 in fltpres and 2 in fltpres:
90
+ dummy = 1
91
+ elif 0 in fltpres:
92
+ #across fault connection
93
+ flttmp = set(fltpres)
94
+ flttmp.remove(0)
95
+ along_flt = list(flttmp)[0]
96
+ if datcon.direction == along_flt:
97
+ datcon.direction = across_flt
98
+ else:
99
+ along_flt = list(set(fltpres))[0]
100
+ across_flt = along_flt%2+1
101
+ if datcon.direction == across_flt:
102
+ if bstats1[1:3] == bstats2[1:3]:
103
+ datcon.direction = along_flt
104
+ #print along_flt, across_flt
105
+ except KeyError:
106
+ pass
107
+ #print 'Plotting'
108
+
109
+ #execfile('plot_perm_angle.py')
110
+
111
+
112
+ dat.grid.clean_rocktypes()
113
+ dat.grid.sort_rocktypes()
114
+
@@ -0,0 +1,169 @@
1
+ from t2data import t2data
2
+
3
+ import os
4
+
5
+ def apply_vertical_fault_k_dir(geo, dat, fault_dir, resetConns):
6
+ """ fault_dir is expected to be like:
7
+ { 'A': 2,
8
+ 'B': 2,
9
+ 'C': 1, }
10
+ where 'A', 'B', ... are fault name used as part of rock type name
11
+ """
12
+
13
+ if resetConns:
14
+ datnoperm = t2data()
15
+ datnoperm.grid.fromgeo(geo)
16
+
17
+ print ('resetting connections')
18
+ for conn in dat.grid.connection.keys():
19
+ dat.grid.connection[conn].direction = datnoperm.grid.connection[conn].direction
20
+
21
+ print ('done reset')
22
+
23
+ dat.write('tmp.dat')
24
+ dat = t2data('tmp.dat')
25
+ os.remove('tmp.dat')
26
+
27
+
28
+ #block_stats = np.load(NSmodelpath+'block_fault_stats.npy')
29
+ #block_faults = np.load(NSmodelpath+'block_faults.npy')
30
+
31
+ fblks = {}
32
+
33
+ for blkname in geo.block_name_list:
34
+ rtname = dat.grid.block[blkname].rocktype.name
35
+ flts = []
36
+ if rtname[1] in fault_dir: flts.append(rtname[1])
37
+ if rtname[2] in fault_dir: flts.append(rtname[2])
38
+ #if rtname[3] in fault_index.keys(): flts.append(fault_index[rtname[3]])
39
+ #if len(flts) > 0: print col.name+layername,flts
40
+ for flt in flts:
41
+ if flt in fblks.keys():
42
+ fblks[flt].append(blkname)
43
+ else:
44
+ fblks[flt] = []
45
+ fblks[flt].append(blkname)
46
+
47
+ #print fblks
48
+ #print 'Blocks done'
49
+
50
+ faults1 = []
51
+ faults2 = []
52
+ for flt in fblks.keys():
53
+ #print flt
54
+ along_flt = fault_dir[flt]
55
+ if along_flt == 1:
56
+ faults1.append(flt)
57
+ else:
58
+ faults2.append(flt)
59
+
60
+ for flt in fblks.keys():
61
+ along_flt = fault_dir[flt]
62
+ across_flt = along_flt%2+1
63
+ #print flt, along_flt, across_flt
64
+
65
+ checkcons = []
66
+ checkdatcons = []
67
+ if flt in fblks.keys():
68
+ for fblk in fblks[flt]:
69
+ #print fblk
70
+ layername = fblk[3:5]
71
+ uplay = geo.layerlist[(geo.layerlist.index(geo.layer[layername])-1)]
72
+ upblk = fblk[0:3]+uplay.name
73
+ if geo.layerlist.index(geo.layer[layername]) < len(geo.layerlist)-1:
74
+ dnlay = geo.layerlist[(geo.layerlist.index(geo.layer[layername])+1)]
75
+ dnblk = fblk[0:3]+dnlay.name
76
+ else:
77
+ dnblk = fblk[0:3]+'xx'
78
+
79
+ #check above
80
+ try:
81
+ #if upblk not in fblks[flt]:
82
+ if dat.grid.block[upblk].rocktype.name[1] == '0':
83
+ # not above
84
+ #if fblk == ' sh88': print fblk,upblk
85
+ try:
86
+ datcon = dat.grid.connection[(fblk,upblk)]
87
+ except KeyError:
88
+ #if fblk == ' sh88': print 'reverse'
89
+ datcon = dat.grid.connection[(upblk,fblk)]
90
+
91
+ checkdatcons.append(datcon)
92
+ datcon.direction = across_flt
93
+ #if fblk == ' sh88': print datcon
94
+
95
+ for con in geo.column[fblk[0:3]].connection:
96
+ col1 = con.column[0]
97
+ col2 = con.column[1]
98
+ try:
99
+ #print 'here'
100
+ datcon = dat.grid.connection[(col1.name+layername,col2.name+layername)]
101
+ except KeyError:
102
+ #print 'reverse'
103
+ try:
104
+ datcon = dat.grid.connection[(col2.name+layername,col1.name+layername)]
105
+ except KeyError:
106
+ #print 'no conn'
107
+ continue
108
+ if ((col1.name+layername in fblks[flt]) and (col2.name+layername in fblks[flt])) :
109
+ # fault to fault so use fault_dir for permeability dir
110
+ #if fblk == ' sh88': print datcon, datcon.direction, across_flt
111
+ if datcon.direction == across_flt:
112
+ rtname1 = dat.grid.block[col1.name+layername].rocktype.name
113
+ rtname2 = dat.grid.block[col2.name+layername].rocktype.name
114
+ ## check if multiple faults
115
+ if rtname1[2] == '0' and rtname2[2] == '0':
116
+ datcon.direction = 3
117
+ checkcons.append(con)
118
+ checkdatcons.append(datcon)
119
+ #if fblk == ' sh88': print datcon
120
+ except KeyError:
121
+ pass
122
+
123
+ #check below
124
+ try:
125
+ #if fblk == ' pk25': fblk,dnblk
126
+ #if dnblk not in fblks[flt]:
127
+ if dat.grid.block[dnblk].rocktype.name[1] == '0':
128
+ # not below
129
+ try:
130
+ datcon = dat.grid.connection[(dnblk,fblk)]
131
+ except KeyError:
132
+ #print 'reverse'
133
+ datcon = dat.grid.connection[(fblk,dnblk)]
134
+
135
+ checkdatcons.append(datcon)
136
+ datcon.direction = across_flt
137
+ #if fblk == ' pk25': print datcon
138
+
139
+ for con in geo.column[fblk[0:3]].connection:
140
+ col1 = con.column[0]
141
+ col2 = con.column[1]
142
+ #print col1.name, col2.name
143
+ try:
144
+ #print 'here'
145
+ datcon = dat.grid.connection[(col1.name+layername,col2.name+layername)]
146
+ except KeyError:
147
+ #print 'reverse'
148
+ try:
149
+ datcon = dat.grid.connection[(col2.name+layername,col1.name+layername)]
150
+ except KeyError:
151
+ #print 'no conn'
152
+ continue
153
+ if ((col1.name+layername in fblks[flt]) and (col2.name+layername in fblks[flt])) :
154
+ # fault to fault so use fault_dir for permeability dir
155
+ if datcon.direction == across_flt:
156
+ rtname1 = dat.grid.block[col1.name+layername].rocktype.name
157
+ rtname2 = dat.grid.block[col2.name+layername].rocktype.name
158
+ ## check if multiple faults
159
+ if rtname1[2] == '0' and rtname2[2] == '0':
160
+ datcon.direction = 3
161
+ checkcons.append(con)
162
+ checkdatcons.append(datcon)
163
+ #if fblk == ' pk25': print datcon
164
+ except KeyError:
165
+ pass
166
+ #execfile('plot_perm_angle.py')
167
+
168
+
169
+
@@ -0,0 +1,68 @@
1
+ from t2data import rocktype
2
+
3
+ def connect_surface(geo, dat, lowestSurfLayer):
4
+ edgeblock = {}
5
+ for lay in geo.layerlist[1:lowestSurfLayer]:
6
+ edgenodes = {}
7
+ for col in geo.columnlist:
8
+ colnghcnt = len(col.neighbour)
9
+ blkname = col.name+lay.name
10
+ try:
11
+ blknghs = dat.grid.block[blkname].neighbour_name
12
+ except KeyError:
13
+ continue
14
+ for colconn in col.connection:
15
+ blk1 = colconn.column[0].name+lay.name
16
+ blk2 = colconn.column[1].name+lay.name
17
+ try:
18
+ testconn = dat.grid.connection[(blk1,blk2)]
19
+ except KeyError:
20
+ try:
21
+ testconn = dat.grid.connection[(blk1,blk2)]
22
+ except KeyError:
23
+ for nd in colconn.node:
24
+ edgenodes[nd.name] = 1
25
+ for col in geo.columnlist:
26
+ blkname = col.name+lay.name
27
+ try:
28
+ testblk = dat.grid.block[blkname]
29
+ except KeyError:
30
+ continue
31
+ for nd in col.node:
32
+ try:
33
+ edgetest = edgenodes[nd.name]
34
+ edgeblock[col.name+lay.name] = 1
35
+ except KeyError:
36
+ continue
37
+
38
+ surfblocks = set([])
39
+ for col in geo.columnlist:
40
+ lay = geo.column_surface_layer(col)
41
+ if int(lay.name) <= int(lowestSurfLayer):
42
+ blkname = col.name+lay.name
43
+ surfblocks.add(blkname)
44
+
45
+ for blkname in edgeblock.keys():
46
+ surfblocks.add(blkname)
47
+ downlay = geo.layerlist[int(blkname[3:5])+1]
48
+ downblkname = blkname[0:3]+downlay.name
49
+ surfblocks.add(downblkname)
50
+
51
+ for blockname in list(surfblocks):
52
+ rtname = dat.grid.block[blockname].rocktype.name
53
+ if rtname[3] == 'A':
54
+ newrtname = rtname[0:3]+'B'+rtname[4]
55
+ else:
56
+ newrtname = rtname[0:3]+'0'+rtname[4]
57
+ print(blockname,rtname, newrtname)
58
+ if newrtname not in dat.grid.rocktype.keys():
59
+ r0=rocktype(name=newrtname,permeability=[5.e-12,5.e-12,5.e-13])
60
+ r0.porosity = .25
61
+ r0.density = 2500
62
+ r0.conductivity = 2.5
63
+ r0.specific_heat=1000
64
+ dat.grid.add_rocktype(r0)
65
+ dat.grid.block[blockname].rocktype = dat.grid.rocktype[newrtname]
66
+
67
+ dat.grid.clean_rocktypes()
68
+ dat.grid.sort_rocktypes()
gimms/core.py ADDED
@@ -0,0 +1,3 @@
1
+ def greet(name: str = "world") -> str:
2
+ """Return a friendly greeting."""
3
+ return f"Hello, {name}!"
@@ -0,0 +1,18 @@
1
+ from t2data import t2generator
2
+
3
+ def create_background_heat(geo, dat, heatperarea):
4
+
5
+ layer=geo.layerlist[-1] # bottom layer
6
+
7
+ cols=[col for col in geo.columnlist]
8
+
9
+ for col in cols:
10
+ blockname=geo.block_name(layer.name,col.name)
11
+ area = col.area
12
+
13
+ genname = col.name+'88'
14
+ #print area2
15
+
16
+ gen=t2generator(name=genname,block=blockname,type='HEAT',gx=heatperarea*area)
17
+ dat.add_generator(gen)
18
+
@@ -0,0 +1,25 @@
1
+
2
+ def create_incon(geo, dat, waterCols, waterElevation, P0, S0, T0):
3
+
4
+ inc = dat.grid.incons([P0, S0+10.0, T0])
5
+
6
+ # approximate initial conditions:
7
+ rho = 998.
8
+ g = 9.81
9
+ for blk in dat.grid.blocklist:
10
+ if blk.name[3:5] == ' 0':
11
+ if blk.name[0:3] not in waterCols:
12
+ inc[blk.name] = [P0, 10.0+S0, T0]
13
+ else:
14
+ d = waterElevation-geo.column[blk.name[0:3]].surface
15
+ if d < 0.0:
16
+ print('Error! Depth less than 0.0 for column ',blk.name[3:5])
17
+ P = P0 + rho * g * d
18
+ inc[blk.name] = [P, 1.0e-6, T0]
19
+ else:
20
+ d = geo.column[blk.name[0:3]].surface-blk.centre[2]
21
+ P = P0 + rho * g * d
22
+ T = T0 + 30.0 * d / 1000.0
23
+ inc[blk.name] = [P, 1.0e-6, T]
24
+
25
+ return inc
@@ -0,0 +1,20 @@
1
+ from t2data import t2generator
2
+
3
+
4
+ def create_rainfall(geo, dat, infil, annrainkgsm2, enthalpy, excludecols):
5
+ massperarea = infil*annrainkgsm2
6
+
7
+ for col in geo.columnlist:
8
+ if col.name in excludecols:
9
+ continue
10
+ massperarea = infil*annrainkgsm2
11
+ layer = geo.column_surface_layer(col)
12
+ blockname=geo.block_name(layer.name,col.name)
13
+ area = col.area
14
+
15
+ genname = col.name+'99'
16
+ #print area2
17
+
18
+ gen=t2generator(name=genname,block=blockname,type='MASS',gx=massperarea*area,ex=enthalpy)
19
+ dat.add_generator(gen)
20
+
@@ -0,0 +1,23 @@
1
+ from t2data import rocktype
2
+
3
+ def create_rock_in_polygon(geo, dat, column_poly, polygon_rock_code):
4
+ for col in geo.columns_in_polygon(column_poly):
5
+ #print col.name
6
+ for lay in geo.layerlist[1:]:
7
+ blkname = col.name+lay.name
8
+ try:
9
+ oldrtname = dat.grid.block[blkname].rocktype.name
10
+ newrtname = oldrtname[0:4]+polygon_rock_code
11
+ if newrtname not in dat.grid.rocktype.keys():
12
+ r0=rocktype(name=newrtname,permeability=dat.grid.rocktype[oldrtname].permeability)
13
+ r0.porosity = dat.grid.rocktype[oldrtname].porosity
14
+ r0.density = dat.grid.rocktype[oldrtname].density
15
+ r0.conductivity = dat.grid.rocktype[oldrtname].conductivity
16
+ r0.specific_heat=dat.grid.rocktype[oldrtname].specific_heat
17
+ dat.grid.add_rocktype(r0)
18
+ dat.grid.block[blkname].rocktype = dat.grid.rocktype[newrtname]
19
+ except KeyError:
20
+ None
21
+
22
+ dat.grid.sort_rocktypes()
23
+ dat.grid.clean_rocktypes()
@@ -0,0 +1,37 @@
1
+ from t2data import rocktype
2
+
3
+ def create_reservoir_rock(geo, dat):
4
+ for col in geo.columnlist:
5
+ belowCap = False
6
+ capFound = False
7
+ #print col.name
8
+ for lay in geo.layerlist[1:]:
9
+ blkname = col.name+lay.name
10
+ try:
11
+ oldrtname = dat.grid.block[blkname].rocktype.name
12
+ if not capFound:
13
+ if oldrtname[3] == 'A':
14
+ #print 'Cap Found = ',blkname
15
+ capFound = True
16
+ else:
17
+ if oldrtname[3] != 'A':
18
+ belowCap = True
19
+ #print 'Below Cap = ',blkname
20
+ if oldrtname[3] == '0': continue
21
+ if not belowCap: continue
22
+ if oldrtname[3] == 'A': hello
23
+ #print 'In Reservoir = ',blkname
24
+ newrtname = oldrtname[0:3]+'2'+oldrtname[4]
25
+ if newrtname not in dat.grid.rocktype.keys():
26
+ r0=rocktype(name=newrtname,permeability=dat.grid.rocktype[oldrtname].permeability)
27
+ r0.porosity = dat.grid.rocktype[oldrtname].porosity
28
+ r0.density = dat.grid.rocktype[oldrtname].density
29
+ r0.conductivity = dat.grid.rocktype[oldrtname].conductivity
30
+ r0.specific_heat=dat.grid.rocktype[oldrtname].specific_heat
31
+ dat.grid.add_rocktype(r0)
32
+ dat.grid.block[blkname].rocktype = dat.grid.rocktype[newrtname]
33
+ except KeyError:
34
+ None
35
+
36
+ dat.grid.sort_rocktypes()
37
+ dat.grid.clean_rocktypes()
gimms/execfile3.py ADDED
@@ -0,0 +1,27 @@
1
+ import sys
2
+
3
+ if sys.version_info[0] >= 3:
4
+
5
+ def execfile3(filepath, globals=None, locals=None):
6
+
7
+ if globals is None:
8
+
9
+ globals = {}
10
+
11
+ globals.update({
12
+
13
+ "__file__": filepath,
14
+
15
+ "__name__": "__main__",
16
+
17
+ })
18
+
19
+ with open(filepath, 'rb') as file:
20
+
21
+ exec(compile(file.read(), filepath, 'exec'), globals, locals)
22
+
23
+ else:
24
+
25
+ def execfile3(filepath, globals=None, locals=None):
26
+
27
+ execfile(filepath,globals)
@@ -0,0 +1,103 @@
1
+
2
+
3
+ import numpy as np
4
+ from matplotlib import pyplot as plt
5
+ from PyPDF2 import PdfWriter, PdfReader
6
+
7
+ import os
8
+ from pathlib import Path
9
+
10
+ # Creating a routine that appends files to the output file
11
+ def append_pdf(input,output):
12
+ [output.add_page(input.pages[page_num]) for page_num in range(len(input.pages))]
13
+
14
+
15
+ def plot_fault_perms(geo, dat):
16
+
17
+ outputpath = 'Reports/'
18
+ Path(outputpath).mkdir(parents=True, exist_ok=True)
19
+
20
+ # Creating an object where pdf pages are appended to
21
+ output = PdfWriter()
22
+
23
+ infiles = []
24
+
25
+ fblks = {}
26
+
27
+ for lay in geo.layerlist[:0:-1]:
28
+ layername = lay.name
29
+ #print lay.name
30
+
31
+ fcols = []
32
+ porout = []
33
+ connscolour = {}
34
+
35
+ for col in geo.columnlist:
36
+ if col.name+layername in geo.block_name_list:
37
+ rtname = dat.grid.block[col.name+layername].rocktype.name
38
+ if rtname == '0ATM1':
39
+ porout.append(0.8)
40
+ elif rtname[1] == '0':
41
+ porout.append(0.5)
42
+ else:
43
+ fcols.append(col.name)
44
+ porout.append(0.0)
45
+ else:
46
+ porout.append(1.0)
47
+
48
+ #print 'Columns done'
49
+
50
+ checkcons = []
51
+ checkdatcons = []
52
+
53
+ for fcol in fcols:
54
+ for con in geo.column[fcol].connection:
55
+ col1 = con.column[0]
56
+ col2 = con.column[1]
57
+ try:
58
+ datcon = dat.grid.connection[(col1.name+layername,col2.name+layername)]
59
+ except KeyError:
60
+ try:
61
+ datcon = dat.grid.connection[(col1.name+layername,col2.name+layername)]
62
+ except KeyError:
63
+ continue
64
+ checkcons.append(con)
65
+ checkdatcons.append(datcon)
66
+ #print 'Plotting'
67
+
68
+ plt.gcf()
69
+ plt.clf()
70
+ plt.rc('font',size=6)
71
+
72
+ geo.layer_plot(plt=plt,layer=layername, variable=porout ,colourmap='binary',colourbar_limits=[0.0,1.0],linewidth=0.1)
73
+ for con,datcon in zip(checkcons,checkdatcons):
74
+ permdir = datcon.direction
75
+ if permdir == 1:
76
+ connscolour[con] = [[con.node[0].pos[0],con.node[1].pos[0]],[con.node[0].pos[1],con.node[1].pos[1]],'b-']
77
+ #plt.plot([con.node[0].pos[0],con.node[1].pos[0]],[con.node[0].pos[1],con.node[1].pos[1]],'b-')
78
+ elif permdir == 2:
79
+ connscolour[con] = [[con.node[0].pos[0],con.node[1].pos[0]],[con.node[0].pos[1],con.node[1].pos[1]],'r-']
80
+ else:
81
+ connscolour[con] = [[con.node[0].pos[0],con.node[1].pos[0]],[con.node[0].pos[1],con.node[1].pos[1]],'lime']
82
+ #plt.plot([con.node[0].pos[0],con.node[1].pos[0]],[con.node[0].pos[1],con.node[1].pos[1]],'r-')
83
+ #print col1, col2
84
+
85
+ for cc in connscolour:
86
+ plt.plot(connscolour[cc][0],connscolour[cc][1],connscolour[cc][2],linewidth=0.2)
87
+
88
+ filename = outputpath+'all_perm_dir_'+layername+'.pdf'
89
+ plt.savefig(filename,dpi=600,orientation='portrait')
90
+ infile = open(filename,'rb')
91
+ append_pdf(PdfReader(infile),output)
92
+ infiles.append(infile)
93
+ #plt.show()
94
+
95
+ # Writing all the collected pages to a file
96
+ output.write(open(outputpath+'all_perm_dir.pdf','wb'))
97
+
98
+ for i in infiles:
99
+ i.close()
100
+ for lay in geo.layerlist[:0:-1]:
101
+ layername = lay.name
102
+ filename = outputpath+'all_perm_dir_'+layername+'.pdf'
103
+ os.remove(filename)
@@ -0,0 +1,96 @@
1
+
2
+ from matplotlib import pyplot as plt
3
+ from PyPDF2 import PdfWriter, PdfReader
4
+ from matplotlib.colors import ListedColormap
5
+
6
+ import os
7
+ import json
8
+
9
+ # Creating a routine that appends files to the output file
10
+ def append_pdf(input,output):
11
+ [output.add_page(input.pages[page_num]) for page_num in range(len(input.pages))]
12
+
13
+ def plot_fault_vert_perm_dir(geo, dat):
14
+
15
+ blkrtnames = {}
16
+
17
+ outputpath = 'Reports/'
18
+
19
+ # Creating an object where pdf pages are appended to
20
+ output = PdfWriter()
21
+
22
+ infiles = []
23
+
24
+ fblks = {}
25
+
26
+ cmapTemp = ListedColormap([
27
+ 'white', # not dug
28
+ 'blue', # 10
29
+ 'red', # 20
30
+ 'lime', # 30
31
+ 'grey', # 40
32
+ ])
33
+
34
+ for lay in geo.layerlist[:0:-1]:
35
+ layername = lay.name
36
+ print (lay.name)
37
+ uplayer = geo.layerlist[(geo.layerlist.index(lay)-1)]
38
+ print (uplayer.name)
39
+
40
+ fcols = []
41
+ porout = []
42
+ connscolour = {}
43
+
44
+ for col in geo.columnlist:
45
+ try:
46
+ rtname = dat.grid.block[col.name+layername].rocktype.name
47
+ if rtname[1] != '0':
48
+ permdir = 3
49
+ try:
50
+ datcon = dat.grid.connection[(col.name+layername,col.name+uplayer.name)]
51
+ permdir = datcon.direction
52
+ except KeyError:
53
+ try:
54
+ datcon = dat.grid.connection[(col.name+uplayer.name,col.name+layername)]
55
+ permdir = datcon.direction
56
+ except KeyError:
57
+ pass
58
+ #print rtname, col.name, layername, uplayer.name, permdir
59
+ if permdir == 1:
60
+ porout.append(0.3)
61
+ elif permdir == 2:
62
+ porout.append(0.5)
63
+ else:
64
+ porout.append(0.7)
65
+ else:
66
+ porout.append(0.1)
67
+ except KeyError:
68
+ porout.append(1.0)
69
+
70
+ print ('Columns done')
71
+
72
+ print ('Plotting')
73
+
74
+ plt.gcf()
75
+ plt.clf()
76
+ plt.rc('font',size=6)
77
+
78
+ geo.layer_plot(plt=plt,layer=layername, variable=porout ,colourmap=cmapTemp,title='Layer '+layername+': '+str(lay.bottom)+' to '+str(lay.top),colourbar_limits=[0.0,1.0])#,plot_limits=((6000,12000),(2000,8000)))
79
+
80
+ filename = 'all_vperm_dir_'+layername+'.pdf'
81
+ plt.savefig(filename,dpi=600,orientation='portrait')
82
+ infile = open(filename,'rb')
83
+ append_pdf(PdfReader(infile),output)
84
+ infiles.append(infile)
85
+ #plt.show()
86
+
87
+ # Writing all the collected pages to a file
88
+ output.write(open(outputpath+'all_vert_perm_dir.pdf','wb'))
89
+
90
+ for i in infiles:
91
+ i.close()
92
+
93
+ for lay in geo.layerlist[:0:-1]:
94
+ layername = lay.name
95
+ filename = 'all_vperm_dir_'+layername+'.pdf'
96
+ os.remove(filename)
@@ -0,0 +1,30 @@
1
+ from mulgrids import *
2
+ from t2data import *
3
+ from collections import Counter
4
+
5
+ def most_common(lst):
6
+ data = Counter(lst)
7
+ return data.most_common(1)[0][0]
8
+
9
+ def rename_alteration(geo, dat, datf, geof):
10
+ qtree = geo.column_quadtree()
11
+
12
+ for blkname in geof.block_name_list[1:]:
13
+ if datf.grid.block[blkname].rocktype.name[0:4] == '000A':
14
+ frt = datf.grid.block[blkname].rocktype.name
15
+ newblk = geo.block_name_containing_point(datf.grid.block[blkname].centre,qtree=qtree)
16
+ if not newblk: continue
17
+ currt = dat.grid.block[newblk].rocktype.name
18
+ newrtname = currt[0:3]+'A'+currt[4]
19
+ if newrtname not in dat.grid.rocktype.keys():
20
+ r0=rocktype(name=newrtname,permeability=[1.e-16,1.e-16,1.e-16])
21
+ r0.porosity = .1
22
+ r0.density = 2500
23
+ r0.conductivity = 2.5
24
+ r0.specific_heat=1000
25
+ dat.grid.add_rocktype(r0)
26
+ dat.grid.block[newblk].rocktype = dat.grid.rocktype[newrtname]
27
+
28
+ dat.grid.clean_rocktypes()
29
+ dat.grid.sort_rocktypes()
30
+
@@ -0,0 +1,33 @@
1
+ from mulgrids import *
2
+ from t2data import *
3
+ from collections import Counter
4
+
5
+ def most_common(lst):
6
+ data = Counter(lst)
7
+ return data.most_common(1)[0][0]
8
+
9
+ def rename_faults(geo, dat, datf, geof):
10
+ qtree = geo.column_quadtree()
11
+
12
+ for blkname in geof.block_name_list[1:]:
13
+ if datf.grid.block[blkname].rocktype.name not in ['00001','atmos']:
14
+ frt = datf.grid.block[blkname].rocktype.name
15
+ newblk = geo.block_name_containing_point(datf.grid.block[blkname].centre,qtree=qtree)
16
+ if not newblk: continue
17
+ currt = dat.grid.block[newblk].rocktype.name
18
+ newrtname = currt[0]+frt[0:2]+currt[3:5]
19
+ if newrtname not in dat.grid.rocktype.keys():
20
+ if newrtname[3] == 'A':
21
+ r0=rocktype(name=newrtname,permeability=[1.e-16,1.e-16,1.e-16])
22
+ else:
23
+ r0=rocktype(name=newrtname,permeability=[1.e-15,1.e-15,1.e-15])
24
+ r0.porosity = .1
25
+ r0.density = 2500
26
+ r0.conductivity = 2.5
27
+ r0.specific_heat=1000
28
+ dat.grid.add_rocktype(r0)
29
+ dat.grid.block[newblk].rocktype = dat.grid.rocktype[newrtname]
30
+
31
+ dat.grid.clean_rocktypes()
32
+ dat.grid.sort_rocktypes()
33
+
gimms/renameUnknown.py ADDED
@@ -0,0 +1,15 @@
1
+
2
+
3
+ def rename_unknown_rock(geo, dat):
4
+ for blkname in geo.block_name_list:
5
+ if dat.grid.block[blkname].rocktype.name == 'UNK 1':
6
+ #print blkname
7
+ dlay = geo.layer[(' '+str(int(blkname[3:5])+1))[-2:]]
8
+ dblkname = blkname[0:3]+dlay.name
9
+ rtbelowname = dat.grid.block[dblkname].rocktype.name
10
+ #print dblkname, rtbelowname
11
+ dat.grid.block[blkname].rocktype = dat.grid.rocktype[rtbelowname]
12
+ #print blkname, oldrtname, newrtname, len(rtlist)
13
+
14
+ dat.grid.clean_rocktypes()
15
+ dat.grid.sort_rocktypes()
@@ -0,0 +1,50 @@
1
+
2
+ def set_standard_parameters(dat):
3
+
4
+ print (" *** Setting up Simulation Parameters ***")
5
+ #Parameters
6
+ dat.parameter['max_iterations'] = 0
7
+ dat.parameter['print_level'] = 3
8
+ dat.parameter['max_timesteps'] = 9999
9
+ dat.parameter['max_duration'] = 0
10
+ dat.parameter['print_interval'] = 9999
11
+ dat.parameter['tstart'] = 0.0
12
+ dat.parameter['tstop'] = 1e16
13
+ dat.parameter['const_timestep'] = 1000.
14
+ dat.parameter['timestep_reduction'] = 5.0
15
+
16
+ dat.parameter['gravity'] = 9.81
17
+ dat.parameter['option'][1] = 1
18
+ dat.parameter['option'][11] = 2
19
+ dat.parameter['option'][12] = 2
20
+ dat.parameter['option'][16] = 5
21
+ dat.parameter['option'][18] = 2
22
+ dat.parameter['option'][24] = 2
23
+ dat.parameter['default_incons'] = [1.04395e5, 9.8087e-7, 25]
24
+
25
+ dat.start = False
26
+
27
+ print (" *** Setting up RPCAP Parameters ***")
28
+ #RPCAP
29
+ dat.relative_permeability['type'] = 1.0
30
+ dat.relative_permeability['parameters'] = [0.5, 0.0, 1.0, 0.5]
31
+ dat.capillarity['type'] = 1
32
+ dat.capillarity['parameters'] = [0.0, 0.0, 1.0]
33
+
34
+ print (" *** Linear Equation Solver Parameters ***")
35
+ #LINEQ
36
+ dat.lineq['type'] = 2
37
+ dat.lineq['epsilon'] = 1e-11
38
+ dat.lineq['max_iterations'] = 999
39
+ dat.lineq['num_orthog'] = 100
40
+ dat.lineq['gauss'] = 1
41
+
42
+ print (" *** EOS Configuration ***")
43
+ #MULTI
44
+ dat.multi['num_components'] = 2
45
+ dat.multi['num_equations'] = 3
46
+ dat.multi['num_phases'] = 2
47
+ dat.multi['num_secondary_parameters'] = 6
48
+ dat.multi['eos'] = 'EWA'
49
+
50
+ dat.simulator = 'AUTOUGH2.2EWA'
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: gimms
3
+ Version: 0.0.2
4
+ Summary: A Python package for setting up TOUGH2 model from Leapfrog, based on JPO's script..
5
+ Author-email: Angus Yeh <a.yeh@auckland.ac.nz>, John O'Sullivan <jp.osullivan@auckland.ac.nz>
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.8
9
+ Requires-Dist: matplotlib
10
+ Requires-Dist: pypdf2
11
+ Requires-Dist: pytough
12
+ Description-Content-Type: text/markdown
13
+
14
+ gimms
15
+ =====
16
+
17
+ A minimal Python package scaffold for the gimms package.
18
+
19
+ Usage:
20
+
21
+ pip install .
22
+
23
+ Run tests with pytest.
24
+
25
+
26
+ ## Developer
27
+
28
+ ### Build and Publish
29
+
30
+ To bump version, create a tag, eg. `v0.1.0`
31
+
32
+ PyPI token is expected in ~/.pypirc
33
+
34
+ Publish to PyPI:
35
+
36
+ ```console
37
+ hatch build
38
+ hatch publish
@@ -0,0 +1,22 @@
1
+ gimms/__init__.py,sha256=Cf-VaLaSUHANyIbAZLawrVM8Q7bBgebP5hAIXnNxYKk,97
2
+ gimms/__version__.py,sha256=ShXQBVjyiSOHxoQJS2BvNG395W4KZfqMxZWBAR0MZrE,22
3
+ gimms/applyFaultPerms.py,sha256=B8sNToIDA6WmYRqDRVMv5QwdbuXdiShSnPHliNNIM2I,4486
4
+ gimms/applyVerticalFaultPerms.py,sha256=HuOk_N0GLYbaimsTHpTHk7cNDHMMIO66k1Y4f9tbZ9w,7468
5
+ gimms/connectSurface.py,sha256=TSfyr02UIDNbBDh_h31YgpF1Jz4JhW7b2Ib049JO_gE,2553
6
+ gimms/core.py,sha256=NsR4e25xFWIdeQtI3HXlZ8b_BZmj4nxq8y0Rzk3vtPE,106
7
+ gimms/createBackgroundHeat.py,sha256=j2w6AiUqXt0OPlVuOQLuyZ6NDVb725q0b56r6GGPCq8,460
8
+ gimms/createIncon_EWA_withWater.py,sha256=ts4exRYrX53mPNtqfBAufPIOWb2G0AYFZcDayz3RJJ8,863
9
+ gimms/createRainfall.py,sha256=ElsgxrOiNijRdGEiARvDOWjZYiAsVIsIeG60iDtn49o,604
10
+ gimms/createRefinedPolygonRock.py,sha256=QLaWllIMB8HgzsiafGHVx-OUdOAJBaxnen-BtYEctck,1125
11
+ gimms/createReservoirRock.py,sha256=2-7ju0rYUw2MHJFv1Kaaj8J5mu0VCZvsOv4HziSZxFQ,1651
12
+ gimms/execfile3.py,sha256=ETTn2T4JAv-wogKeuZZ3xdEYjLKWEJiwZIr-JlM5e8w,481
13
+ gimms/plotAllFaultPerms.py,sha256=_if_ORqX6kIiMRQD6fi-F19XfgEuH7CwV2HUxJTLtLE,3645
14
+ gimms/plotAllFaultVertPermDir.py,sha256=6fwNx_w40wjAqWovEUluSEUHXztt7JZOWU5tmL2_tyw,3007
15
+ gimms/renameAlterationfromDat.py,sha256=tjlfYVtKS2NvcGPpnTvCSXxPue5k36LjsQ5tKYvhRso,1143
16
+ gimms/renameFaultsfromDat.py,sha256=vbzd-MBE0fq7Qm7_l4NFe5kp35j9VxQg7VReqnhib8U,1307
17
+ gimms/renameUnknown.py,sha256=D4qveL-OG0Vhs4OOqJhUAjbyRb-9i_cbqu7qAd6dYMo,600
18
+ gimms/set_AUTOUGH2_EWA_standard_pararmeters.py,sha256=CXEVm-t7u5s2QQFQRGxo2zK-tICCWg5gelqQrX9MKI0,1620
19
+ gimms-0.0.2.dist-info/METADATA,sha256=OAAbyDV8z55sXputjzKoM6sHb146Fxi2XvRjdy0rom0,703
20
+ gimms-0.0.2.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
21
+ gimms-0.0.2.dist-info/licenses/LICENSE,sha256=v2spsd7N1pKFFh2G8wGP_45iwe5S0DYiJzG4im8Rupc,1066
22
+ gimms-0.0.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Your Name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.