|
3 | 3 | from gempy.plot._visualization_2d import PlotData2D
|
4 | 4 | import numpy as np
|
5 | 5 | import os
|
| 6 | +import itertools as it |
6 | 7 |
|
7 | 8 |
|
8 | 9 | def export_geomap2geotiff(path, geo_model, geo_map=None, geotiff_filepath=None):
|
@@ -135,6 +136,147 @@ def export_moose_input(geo_model, path=None, filename='geo_model_units_moose_inp
|
135 | 136 |
|
136 | 137 | print("Successfully exported geological model as moose input to "+path)
|
137 | 138 |
|
| 139 | +def export_shemat_suite_input_file(geo_model, path: str=None, filename: str='geo_model_SHEMAT_input'): |
| 140 | + """ |
| 141 | + Method to export a 3D geological model as SHEMAT-Suite input-file for a conductive HT-simulation. |
| 142 | +
|
| 143 | + Args: |
| 144 | + path (str): Filepath for the exported input file (default './') |
| 145 | + filename (str): name of exported input file (default 'geo_model_SHEMAT_input') |
| 146 | + """ |
| 147 | + # get model dimensions |
| 148 | + nx, ny, nz = geo_model.grid.regular_grid.resolution |
| 149 | + xmin, xmax, ymin, ymax, zmin, zmax = geo_model.solutions.grid.regular_grid.extent |
| 150 | + |
| 151 | + delx = (xmax - xmin)/nx |
| 152 | + dely = (ymax - ymin)/ny |
| 153 | + delz = (zmax - zmin)/nz |
| 154 | + |
| 155 | + # get unit IDs and restructure them |
| 156 | + ids = np.round(geo_model.solutions.lith_block) |
| 157 | + ids = ids.astype(int) |
| 158 | + |
| 159 | + liths = ids.reshape((nx, ny, nz)) |
| 160 | + liths = liths.flatten('F') |
| 161 | + |
| 162 | + # group litho in space-saving way |
| 163 | + sequence = [len(list(group)) for key, group in it.groupby(liths)] |
| 164 | + unit_id = [key for key, group in it.groupby(liths)] |
| 165 | + combined = ["%s*%s" % (pair) for pair in zip(sequence,unit_id)] |
| 166 | + |
| 167 | + combined_string = " ".join(combined) |
| 168 | + |
| 169 | + # get number of units and set units string |
| 170 | + units = geo_model.surfaces.df[['surface', 'id']] |
| 171 | + |
| 172 | + unitstring = "" |
| 173 | + for index, rows in units.iterrows(): |
| 174 | + unitstring += f"0.01d-10 1.d0 1.d0 1.e-14 1.e-10 1.d0 1.d0 3.74 0. 2077074. 10 2e-3 !{rows['surface']} \n" |
| 175 | + |
| 176 | + # input file as f-string |
| 177 | + fstring = f"""!==========>>>>> INFO |
| 178 | +# Title |
| 179 | +{filename} |
| 180 | +
|
| 181 | +# linfo |
| 182 | +1 2 1 1 |
| 183 | +
|
| 184 | +# runmode |
| 185 | +1 |
| 186 | +
|
| 187 | +# timestep control |
| 188 | +0 |
| 189 | +1 1 0 0 |
| 190 | +
|
| 191 | +# tunit |
| 192 | +1 |
| 193 | + |
| 194 | +# time periods, records=1 |
| 195 | +0 60000000 200 lin |
| 196 | + |
| 197 | +# output times, records=10 |
| 198 | +1 |
| 199 | +6000000 |
| 200 | +12000000 |
| 201 | +18000000 |
| 202 | +24000000 |
| 203 | +30000000 |
| 204 | +36000000 |
| 205 | +42000000 |
| 206 | +48000000 |
| 207 | +54000000 |
| 208 | + |
| 209 | +# file output: hdf vtk |
| 210 | +
|
| 211 | +# active temp |
| 212 | +
|
| 213 | +# PROPS=bas |
| 214 | +
|
| 215 | +# USER=none |
| 216 | +
|
| 217 | +
|
| 218 | +# grid |
| 219 | +{nx} {ny} {nz} |
| 220 | +
|
| 221 | +# delx |
| 222 | +{nx}*{delx} |
| 223 | +
|
| 224 | +# dely |
| 225 | +{ny}*{dely} |
| 226 | +
|
| 227 | +# delz |
| 228 | +{nz}*{delz} |
| 229 | +
|
| 230 | +!==========>>>>> NONLINEAR SOLVER |
| 231 | +# nlsolve |
| 232 | +50 0 |
| 233 | +
|
| 234 | +!==========>>>>> FLOW |
| 235 | +# lsolvef (linear solver control) |
| 236 | +1.d-12 64 500 |
| 237 | +# nliterf (nonlinear iteration control) |
| 238 | +1.0d-10 1.0 |
| 239 | +
|
| 240 | +!==========>>>>> TEMPERATURE |
| 241 | +# lsolvet (linear solver control) |
| 242 | +1.d-12 64 500 |
| 243 | +# nlitert (nonlinear iteration control) |
| 244 | +1.0d-10 1.0 |
| 245 | +
|
| 246 | +!==========>>>>> INITIAL VALUES |
| 247 | +# temp init |
| 248 | +{nx*ny*nz}*15.0d0 |
| 249 | +
|
| 250 | +# head init |
| 251 | +{nx*ny*nz}*7500 |
| 252 | +
|
| 253 | +!==========>>>>> UNIT DESCRIPTION |
| 254 | +!! |
| 255 | +# units |
| 256 | +{unitstring} |
| 257 | +
|
| 258 | +!==========>>>>> define boundary properties |
| 259 | +# temp bcd, simple=top, value=init |
| 260 | +
|
| 261 | +# temp bcn, simple=base, error=ignore |
| 262 | +{nx*ny}*0.06 |
| 263 | +
|
| 264 | +# uindex |
| 265 | +{combined_string}""" |
| 266 | + |
| 267 | + if not path: |
| 268 | + path = './' |
| 269 | + if not os.path.exists(path): |
| 270 | + os.makedirs(path) |
| 271 | + |
| 272 | + f = open(path+filename, 'w+') |
| 273 | + |
| 274 | + f.write(fstring) |
| 275 | + f.close() |
| 276 | + |
| 277 | + print("Successfully exported geological model as SHEMAT-Suite input to "+path) |
| 278 | + |
| 279 | + |
138 | 280 | def export_pflotran_input(geo_model, path=None, filename='pflotran.ugi'):
|
139 | 281 | """
|
140 | 282 | Method to export a 3D geological model as PFLOTRAN implicit unstructured grid
|
@@ -245,10 +387,11 @@ def export_flac3D_input(geo_model, path=None, filename='geomodel.f3grid'):
|
245 | 387 | vertices, elements, groups = __build_vertices_elements_groups__(geo_model)
|
246 | 388 |
|
247 | 389 | #open output file
|
248 |
| - if not path: |
249 |
| - path = './' |
250 |
| - if not os.path.exists(path): |
251 |
| - os.makedirs(path) |
| 390 | + #if not path: |
| 391 | + # path = './' |
| 392 | + #if not os.path.exists(path): |
| 393 | + # os.makedirs(path) |
| 394 | + |
252 | 395 | out = open(path+filename, 'w')
|
253 | 396 |
|
254 | 397 | #write gridpoints
|
|
0 commit comments