gimu 0.3.0__tar.gz → 0.4.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gimu
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: A toolkit and python library for modelling at Geothermal Institute, University of Auckland.
5
5
  Project-URL: Documentation, https://github.com/cyeh015/gimu/blob/main/README.md
6
6
  Project-URL: Issues, https://github.com/cyeh015/gimu/issues
@@ -14,7 +14,7 @@ from collections import OrderedDict
14
14
 
15
15
  class WellData(dict):
16
16
  def __init__(self, *args, **kwargs):
17
- super().__init__(*args, **kwargs)
17
+ super().__init__(*args, **kwargs)
18
18
 
19
19
  def downhole_temperature(self, date_str):
20
20
  """ get direct access to data without fluff """
@@ -75,7 +75,7 @@ class DataJSON:
75
75
  self._cache[well_name] = data
76
76
  return data
77
77
 
78
- msg = '\n',join([
78
+ msg = '\n'.join([
79
79
  f"Well '{well_name}' not found in any of the data folders:",
80
80
  ] + [f" {f}" for f in self._data_folders])
81
81
  raise KeyError(msg)
@@ -0,0 +1,129 @@
1
+ """ handle GMF's modifier files that update model inputs with meta- parameters
2
+
3
+ - reads rocktype JSON and update model input
4
+ - reads upflow JSON and update model input
5
+ """
6
+
7
+ import json
8
+ import os
9
+ import sys
10
+
11
+ def compute_rocktypes(rocktype_json, warn=True):
12
+ """ compute the derived rocktype properties and update in place
13
+
14
+ if warn, will raise exception when rules are not followed:
15
+ - along modifier >= 1.0
16
+ - across modifier <= 1.0
17
+
18
+ Example entry in rocktype_json:
19
+ - base rocktype
20
+ "A0000": {
21
+ "permeability": [1e-11, 1e-11, 1e-12 ],
22
+ "porosity": [0.25 ]
23
+ },
24
+
25
+ - fault modified rocktype
26
+ "AA000": {
27
+ "base": ["A0000"],
28
+ "fault direction": [1],
29
+ "modifier": {
30
+ "along": [1],
31
+ "across": [1],
32
+ "vertical": [1],
33
+ "porosity": [1]
34
+ },
35
+ "permeability": [1e-11, 1e-11, 1e-12],
36
+ "porosity": [0.25]
37
+ },
38
+
39
+ - fault interesection rocktype
40
+ "SVU11": {
41
+ "base": ["S0011"],
42
+ "modifier": {
43
+ "k1": [2.5],
44
+ "k2": [0.4],
45
+ "k3": [5],
46
+ "porosity": [1]
47
+ },
48
+ "permeability": [2.5000000000000004e-15, 4.0000000000000004e-16, 5.000000000000001e-15],
49
+ "porosity": [0.1]
50
+ }
51
+
52
+ """
53
+ for rt_name, rt in rocktype_json.items():
54
+ if 'base' not in rt:
55
+ # base rocktype
56
+ pass
57
+ else:
58
+ if 'fault direction' in rt:
59
+ fault_dir = rt['fault direction'][0]
60
+ if float(rt['modifier']['along'][0]) < 1.0:
61
+ msg = f"Rocktype {rt_name} has fault modifier 'along' < 1.0"
62
+ if warn: raise Exception(msg)
63
+ else: print("Warning: " + msg)
64
+ if float(rt['modifier']['across'][0]) > 1.0:
65
+ msg = f"Rocktype {rt_name} has fault modifier 'across' > 1.0"
66
+ if warn: raise Exception(msg)
67
+ else: print("Warning: " + msg)
68
+ if fault_dir == 1:
69
+ k_modifier = [
70
+ float(rt['modifier']['along'][0]),
71
+ float(rt['modifier']['across'][0]),
72
+ float(rt['modifier']['vertical'][0]),
73
+ ]
74
+ elif fault_dir == 2:
75
+ k_modifier = [
76
+ float(rt['modifier']['across'][0]),
77
+ float(rt['modifier']['along'][0]),
78
+ float(rt['modifier']['vertical'][0]),
79
+ ]
80
+ else:
81
+ raise Exception(f"Fault direction {rt['fault direction'][0]} not 1 or 2 in rocktype {rt_name}")
82
+ else:
83
+ k_modifier = [
84
+ float(rt['modifier']['k1'][0]),
85
+ float(rt['modifier']['k2'][0]),
86
+ float(rt['modifier']['k3'][0]),
87
+ ]
88
+ # update permeability in place
89
+ if rt['base'][0] in rocktype_json:
90
+ rt['permeability'] = [k * m for k, m in zip(
91
+ rocktype_json[rt['base'][0]]['permeability'], k_modifier)]
92
+ rt['porosity'][0] = rocktype_json[rt['base'][0]]['porosity'][0] * rt['modifier']['porosity'][0]
93
+ else:
94
+ msg = f"Base rocktype {rt['base'][0]} not found for rocktype {rt_name}"
95
+ if warn:
96
+ raise Exception(msg)
97
+ else:
98
+ print("Warning: " + msg)
99
+ rt['error'] = msg
100
+
101
+
102
+ def update_waiwera_model_rocktypes(wjson, rtjson, skip_missing=True):
103
+ """ rtjson is loaded from the GMF modifier _rocktypes.json
104
+ """
105
+ for rt in wjson['rock']['types']:
106
+ if rt['name'] not in rtjson:
107
+ if skip_missing:
108
+ print(f"Rocktype {rt['name']} not found in _rocktypes.json... skipped")
109
+ continue
110
+ else:
111
+ raise Exception(f"Rocktype {rt['name']} not found in _rocktypes.json")
112
+ modifier = rtjson[rt['name']]
113
+ rt['permeability'] = modifier['permeability']
114
+ rt['porosity'] = modifier['porosity'][0]
115
+
116
+ def update_aut2_model_rocktypes(dat, rtjson, skip_missing=True):
117
+ """ rtjson is loaded from the GMF modifier _rocktypes.json
118
+ """
119
+ for rt in dat.grid.rocktypelist:
120
+ if rt.name not in rtjson:
121
+ if skip_missing:
122
+ print(f"Rocktype {rt.name} not found in _rocktypes.json... skipped")
123
+ continue
124
+ else:
125
+ raise Exception(f"Rocktype {rt.name} not found in _rocktypes.json")
126
+ modifier = rtjson[rt.name]
127
+ rt.permeability = modifier['permeability']
128
+ rt.porosity = modifier['porosity'][0]
129
+
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes