In this notebook, a horizontal free-surface is implemented as an immersed boundary with the 1st-order P-SV formulation of the isotropic elastic wave equation.
# Load the signed distance function for the boundary geometryimport pickleimport matplotlib.pyplot as pltimport numpy as npdef read_sdf(surface):"""Unpickle an sdf""" fname ='sdfs/'+ surface +'.dat'withopen(fname, 'rb') as f: sdf = pickle.load(f)return sdf# Load the horizontal 2D sdfsdf = read_sdf('flat_surface_2d')# Load the staggered sdfssdf_x = read_sdf('flat_surface_2d_x')sdf_y = read_sdf('flat_surface_2d_y')sdf_xy = read_sdf('flat_surface_2d_xy')plt.imshow(sdf.data.T, origin='lower')plt.title("Boundary geometry SDF")plt.colorbar()plt.show()# It is a good idea to make sure your signed distance functions are aligned# Misaligned SDFs can result in considerable weirdnessplt.imshow(sdf_x.data.T-sdf.data.T, origin='lower')plt.title("Alignment check x")plt.colorbar()plt.show()plt.imshow(sdf_y.data.T-sdf.data.T, origin='lower')plt.title("Alignment check y")plt.colorbar()plt.show()plt.imshow(sdf_xy.data.T-sdf.data.T, origin='lower')plt.title("Alignment check xy")plt.colorbar()plt.show()
from schism import BoundaryGeometryimport sympy as spx, y = sdf.grid.dimensionsh_x = x.spacingh_y = y.spacingzero = sp.core.numbers.Zero()# Set cutoff for the velocity subgrids to zero# This means that any velocity point on the interior can be updated# This prevents over-extended extrapolations, as the velocity components do not have# zeroth-order boundary conditions imposed upon them# By default, this cutoff is 0.5 (half a grid spacing)cutoff = {(h_x/2, zero): 0., (zero, h_y/2): 0.}bg = BoundaryGeometry((sdf, sdf_x, sdf_y, sdf_xy), cutoff=cutoff)grid = bg.grid # Gets the grid from the signed distance functionprint(tuple(bg.interior_mask.keys()))
Operator `normals` ran in 0.01 s
((0, 0), (h_x/2, 0), (0, h_y/2), (h_x/2, h_y/2))
First one must define fields for particle velocity and the stress tensor. It is also necessary to define some material parameters used in the boundary conditions.
import devito as dvs_o =2tau = dv.TensorTimeFunction(name='tau', grid=grid, space_order=s_o, time_order=1)v = dv.VectorTimeFunction(name='v', grid=grid, space_order=s_o, time_order=1)# Material parametersrho =1.mu =0.25lam =0.5
Now to define the elastic free surface. This condition corresponds to the dot product of the stress tensor and the normal equalling zero.
Generating stencils for Derivative(tau_xx(t, x, y), x)
Generating stencils for Derivative(tau_xy(t, x + h_x/2, y + h_y/2), x)
Generating stencils for Derivative(v_x(t + dt, x + h_x/2, y), x)
Generating stencils for Derivative(v_y(t + dt, x, y + h_y/2), x)
Generating stencils for Derivative(tau_xy(t, x + h_x/2, y + h_y/2), y)
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Generating stencils for Derivative(tau_yy(t, x, y), y)
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
Generating stencils for Derivative(v_x(t + dt, x + h_x/2, y), y)
Generating stencils for Derivative(v_y(t + dt, x, y + h_y/2), y)
Operator `eval_coeffs` ran in 0.01 s
Operator `eval_coeffs` ran in 0.01 s
from examples.seismic import TimeAxis, RickerSourcec =1t0 =0.# Simulation starts a t=0tn =550.# Simulation last 0.5 seconds (500 ms)dt =0.5*5/c # Time step from grid spacingtime_range = TimeAxis(start=t0, stop=tn, step=dt)f0 =0.006# Source peak frequency is 16Hz (0.016 kHz)src = RickerSource(name='src', grid=grid, f0=f0, npoint=1, time_range=time_range)src.coordinates.data[0, 0] =500.src.coordinates.data[0, 1] =300.