24 C Sumatra#

Authors: Kidus Teshome, Cian Wilson

Steady state implementation#

Preamble#

Set some path information.

import sys, os
basedir = ''
if "__file__" in globals(): basedir = os.path.dirname(__file__)
sys.path.append(os.path.join(basedir, os.path.pardir, os.path.pardir, os.path.pardir, 'python'))

Loading everything we need from sz_problem and also set our default plotting and output preferences.

import utils
from sz_problems.sz_params import allsz_params
from sz_problems.sz_slab import create_slab, plot_slab
from sz_problems.sz_geometry import create_sz_geometry
from sz_problems.sz_steady_dislcreep import SteadyDislSubductionProblem
import numpy as np
import dolfinx as df
import pyvista as pv
import pathlib
output_folder = pathlib.Path(os.path.join(basedir, "output"))
output_folder.mkdir(exist_ok=True, parents=True)
import hashlib
import zipfile
import requests

Parameters#

We first select the name and resolution scale, resscale of the model.

Resolution

By default the resolution is low to allow for a quick runtime and smaller website size. If sufficient computational resources are available set a lower resscale to get higher resolutions and results with sufficient accuracy.

name = "24_C_Sumatra"
resscale = 3.0

Then load the remaining parameters from the global suite.

szdict = allsz_params[name]
print("{}:".format(name))
print("{:<20} {:<10}".format('Key','Value'))
print("-"*85)
for k, v in allsz_params[name].items():
    if v is not None and k not in ['z0', 'z15']: print("{:<20} {}".format(k, v))
24_C_Sumatra:
Key                  Value     
-------------------------------------------------------------------------------------
coast_distance       230
extra_width          17.5
lc_depth             31
io_depth             178
uc_depth             15
dirname              24_C_Sumatra
As                   40.0
qs                   0.065
A                    54.8
sztype               continental
Vs                   40.0
xs                   [0, 60.6, 161.0, 265.0, 279.4, 282.6, 303.0, 389.0, 422.5]
ys                   [-6, -15.0, -31.0, -70.0, -80.0, -82.5, -100.0, -200.0, -240.0]

Any of these can be modified in the dictionary.

Several additional parameters can be modified, for details see the documentation for the SteadyDislSubductionProblem class.

SteadyDislSubductionProblem?

Setup#

Setup a slab.

slab = create_slab(szdict['xs'], szdict['ys'], resscale, szdict['lc_depth'])
_ = plot_slab(slab)
../../../_images/726b0cb848459278cbebfb389bfb3eef6a50b51315bb347b98ffc911a2d8de24.png

Create the subduction zome geometry around the slab.

geom = create_sz_geometry(slab, resscale, szdict['sztype'], szdict['io_depth'], szdict['extra_width'], 
                             szdict['coast_distance'], szdict['lc_depth'], szdict['uc_depth'])
_ = geom.plot()
../../../_images/07045efa690d83afa4bcb4e1a1f16d4ff598b9b5ba8f54e627d9329453ef553b.png

Finally, declare the SubductionZone problem class using the dictionary of parameters.

sz = SteadyDislSubductionProblem(geom, **szdict)

Solve#

Solve using a dislocation creep rheology and assuming a steady state.

sz.solve()
Iteration   Residual     Relative Residual
------------------------------------------
0           3614.71      1           
1           1389.2       0.384319    
2           92.4871      0.0255863   
3           46.6869      0.0129158   
4           19.9619      0.00552241  
5           9.04336      0.00250182  
6           4.66723      0.00129118  
7           2.92403      0.000808925 
8           2.12983      0.000589212 
9           1.64421      0.000454867 
10          1.28725      0.000356115 
11          1.01028      0.000279491 
12          0.791842     0.000219061 
13          0.620006     0.000171523 
14          0.485581     0.000134335 
15          0.380523     0.000105271 
16          0.298315     8.25281e-05 
17          0.233926     6.47151e-05 
18          0.183449     5.07508e-05 
19          0.143865     3.97998e-05 
20          0.112821     3.12117e-05 
21          0.0884768    2.44769e-05 
22          0.0693862    1.91955e-05 
23          0.0544166    1.50542e-05 
24          0.0426795    1.18072e-05 
25          0.0334776    9.26148e-06 
26          0.0262635    7.26573e-06 
27          0.0206079    5.70112e-06 
28          0.016174     4.47448e-06 

Plot#

Plot the solution.

plotter = pv.Plotter()
utils.plot.plot_scalar(sz.T_i, plotter=plotter, scale=sz.T0, gather=True, cmap='coolwarm', scalar_bar_args={'title': 'Temperature (deg C)', 'bold':True})
utils.plot.plot_vector_glyphs(sz.vw_i, plotter=plotter, gather=True, factor=0.1, color='k', scale=utils.mps_to_mmpyr(sz.v0))
utils.plot.plot_vector_glyphs(sz.vs_i, plotter=plotter, gather=True, factor=0.1, color='k', scale=utils.mps_to_mmpyr(sz.v0))
utils.plot.plot_geometry(geom, plotter=plotter, color='green', width=2)
utils.plot.plot_couplingdepth(slab, plotter=plotter, render_points_as_spheres=True, point_size=10.0, color='green')
utils.plot.plot_show(plotter)
utils.plot.plot_save(plotter, output_folder / "{}_ss_solution_resscale_{:.2f}.png".format(name, resscale))

Save it to disk so that it can be examined with other visualization software (e.g. Paraview).

filename = output_folder / "{}_ss_solution_resscale_{:.2f}.bp".format(name, resscale)
with df.io.VTXWriter(sz.mesh.comm, filename, [sz.T_i, sz.vs_i, sz.vw_i]) as vtx:
    vtx.write(0.0)
# zip the .bp folder so that it can be downloaded from Jupyter lab
zipfilename = filename.with_suffix(".zip")
!zip -r $zipfilename $filename
  adding: output/24_C_Sumatra_ss_solution_resscale_3.00.bp/ (stored 0%)
  adding: output/24_C_Sumatra_ss_solution_resscale_3.00.bp/mmd.0 (deflated 64%)
  adding: output/24_C_Sumatra_ss_solution_resscale_3.00.bp/profiling.json (deflated 62%)
  adding: output/24_C_Sumatra_ss_solution_resscale_3.00.bp/md.idx (deflated 59%)
  adding: output/24_C_Sumatra_ss_solution_resscale_3.00.bp/md.0 (deflated 75%)
  adding: output/24_C_Sumatra_ss_solution_resscale_3.00.bp/data.0
 (deflated 63%)

Comparison#

Compare to the published result from Wilson & van Keken, PEPS, 2023 (II) and van Keken & Wilson, PEPS, 2023 (III). The original models used in these papers are also available as open-source repositories on github and zenodo.

First download the minimal necessary data from zenodo and check it is the right version.

zipfilename = pathlib.Path(os.path.join(basedir, os.path.pardir, os.path.pardir, os.path.pardir, "data", "vankeken_wilson_peps_2023_TF_lowres_minimal.zip"))
if not zipfilename.is_file():
    zipfileurl = 'https://zenodo.org/records/13234021/files/vankeken_wilson_peps_2023_TF_lowres_minimal.zip'
    r = requests.get(zipfileurl, allow_redirects=True)
    open(zipfilename, 'wb').write(r.content)
assert hashlib.md5(open(zipfilename, 'rb').read()).hexdigest() == 'a8eca6220f9bee091e41a680d502fe0d'
tffilename = os.path.join('vankeken_wilson_peps_2023_TF_lowres_minimal', 'sz_suite_ss', szdict['dirname']+'_minres_2.00.vtu')
tffilepath = os.path.join(basedir, os.path.pardir, os.path.pardir, os.path.pardir, 'data')
with zipfile.ZipFile(zipfilename, 'r') as z:
    z.extract(tffilename, path=tffilepath)
fxgrid = utils.plot.grids_scalar(sz.T_i)[0]

tfgrid = pv.get_reader(os.path.join(tffilepath, tffilename)).read()

diffgrid = utils.plot.pv_diff(fxgrid, tfgrid, field_name_map={'T':'Temperature::PotentialTemperature'}, pass_point_data=True)
diffgrid.set_active_scalars('T')
plotter_diff = pv.Plotter()
clim = None
plotter_diff.add_mesh(diffgrid, cmap='coolwarm', clim=clim, scalar_bar_args={'title': 'Temperature Difference (deg C)', 'bold':True})
utils.plot.plot_geometry(geom, plotter=plotter_diff, color='green', width=2)
utils.plot.plot_couplingdepth(slab, plotter=plotter_diff, render_points_as_spheres=True, point_size=5.0, color='green')
plotter_diff.enable_parallel_projection()
plotter_diff.view_xy()
plotter_diff.show()
integrated_data = diffgrid.integrate_data()
error = integrated_data['T'][0]/integrated_data['Area'][0]
print("Average error = {}".format(error,))
assert np.abs(error) < 5
Average error = 0.20292256238453982