\n",
"

"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"

\n",
"\n",
"

\n",
" Computational Seismology

\n",
" Lamb's problem

\n",
" \n", "\n", "\n", "\n", "

\n", "\n", "---\n", "\n", "This notebook is part of the supplementary material \n", "to [Computational Seismology: A Practical Introduction](https://global.oup.com/academic/product/computational-seismology-9780198717416?cc=de&lang=en&#), \n", "Oxford University Press, 2016.\n", "\n", "##### Authors:\n", "* David Vargas ([@dvargas](https://github.com/davofis))\n", "* Heiner Igel ([@heinerigel](https://github.com/heinerigel))\n", "\n", "(Based on the original code by Lane Johnson)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Basic Equations\n", "\n", "The fundamental analytical solution to the three-dimensional Lamb’s problem, the problem of determining the elastic disturbance resulting from a point force in a homogeneous half space, is implemented in this Ipython notebook. This solution provides fundamental information used as benchmark for comparison with entirely numerical solutions. A setup of the fundamental problem is illustrated below. The figure on the right hand side is published in [1] (Figure 1. System of coordinates)\n", "\n", "\n", "\n", "\n", "\n", "

\n", "\n", "Simulations of 3D elastic wave propagation need to be validated by the use of analytical solutions. In order to evaluate how healthy a numerical solution is, one may recreate conditions for which analytical solutions exist with the aim of reproducing and compare the different results.\n", "\n", "We which to find the displacement wavefield $\\mathbf{u}(\\mathbf{x},t)$ at some distance $\\mathbf{x}$ from a seismic source with $ \\mathbf{F} = f_1\\mathbf{\\hat{x}_1} + f_2\\mathbf{\\hat{x}_2} + f_3\\mathbf{\\hat{x}_3}$.\n", "\n", "For a uniform elastic material and a Cartesian co-ordinate system the equation for the conservation of linear momentum can be written\n", "\n", "\\begin{align*}\n", "\\rho(x) \\frac{\\partial^2}{\\partial t^2} \\mathbf{u(\\mathbf{x},t)} = (\\lambda + \\mu)\\nabla(\\nabla\\mathbf{u(\\mathbf{x},t)}) + \\mu\\nabla^2 \\mathbf{u(\\mathbf{x},t)} + \\mathbf{f(\\mathbf{x},t)}\n", "\\end{align*}\n", "\n", "We will consider the case where the source function is localized in both time and space\n", "\n", "\\begin{align*}\n", "\\mathbf{f(\\mathbf{x},t)} = (f_1\\mathbf{\\hat{x}_1} + f_2\\mathbf{\\hat{x}_2} + f_3\\mathbf{\\hat{x}_3})\\delta(x_1 - x^{'}_{1})\\delta(x_2 - x^{'}_{2})\\delta(x_3 - x^{'}_{3})\\delta(t - t^{'})\n", "\\end{align*}\n", "\n", "For such a source we will refer to the displacement solution as a Green’s function, and use the standard notation\n", "\n", "\\begin{align*}\n", "\\mathbf{u(\\mathbf{x},t)} = g_1(\\mathbf{x},t;\\mathbf{x^{'}},t^{'})\\mathbf{\\hat{x}_1} + g_2(\\mathbf{x},t;\\mathbf{x^{'}},t^{'})\\mathbf{\\hat{x}_2} + g_3(\\mathbf{x},t;\\mathbf{x^{'}},t^{'})\\mathbf{\\hat{x}_3}\n", "\\end{align*}\n", "\n", "The complete solution is found after applying the Laplace transform to the elastic wave equation, implementing the stress-free boundary condition, defining some transformations, and performing some algebraic manoeuvres. Then, the Green's function at the free surface is given:\n", "\n", "\\begin{align*}\n", "\\begin{split}\n", "\\mathbf{G}(x_1,x_2,0,t;0,0,x^{'}_{3},0) & = \\dfrac{1}{\\pi^2\\mu r} \\dfrac{\\partial}{\\partial t}\\int_{0}^{((t/r)^2 - \\alpha^{-2})^{1/2}}\\mathbf{H}(t-r/\\alpha)\\mathbb{R}[\\eta_\\alpha\\sigma^{-1}((t/r)^2 - \\alpha^{-2} - p^2)^{-1/2}\\mathbf{M}(q,p,0,t,x^{'}_{3})\\mathbf{F}] dp \\\\\n", " & + \\dfrac{1}{\\pi^2\\mu r} \\dfrac{\\partial}{\\partial t}\\int_{0}^{p_2}\\mathbf{H}(t-t_2)\\mathbb{R}[\\eta_\\beta\\sigma^{-1}((t/r)^2 - \\beta^{-2} - p^2)^{-1/2}\\mathbf{N}(q,p,0,t,x^{'}_{3})\\mathbf{F}] dp\n", "\\end{split}\n", "\\end{align*}\n", "\n", "Details on the involved terms are found in the original paper [2]. The Green's $\\mathbf{G}$ function consist of three components of displacement evolving from the application of three components of force $\\mathbf{F}$. If we assume that each component of $\\mathbf{F}$ provokes three components of displacement, then $\\mathbf{G}$ is composed by nine independent components that correspond one to one to the matrices $\\mathbf{M}$ and $\\mathbf{N}$. Without losing generality it is shown that among them four are equal zero, and we end up only with five possible components. \n", "\n", "\n", " [1] Eduardo Kausel - Lamb's problem at its simplest, 2012

\n", " \n", "\n", " [2] Lane R. Johnson - Green’s Function for Lamb’s Problem, 1974

\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "code_folding": [ 0 ] }, "outputs": [], "source": [ "# Import all necessary libraries, this is a configuration step for the exercise.\n", "# Please run it before the simulation code!\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import os\n", "from ricker import ricker\n", "\n", "# Show the plots in the Notebook.\n", "plt.switch_backend(\"nbagg\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "code_folding": [ 0 ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[01m\u001b[Kcanhfs.for:88:31:\u001b[m\u001b[K\r\n", "\r\n", " CALL ROMS (K, NG, DI, P, DP, DD, EPS, NOR)\r\n", " \u001b[01;35m\u001b[K1\u001b[m\u001b[K\r\n", "\u001b[01;35m\u001b[KWarning:\u001b[m\u001b[K Actual argument contains too few elements for dummy argument '\u001b[01m\u001b[Ky\u001b[m\u001b[K' (12/20) at (1) [\u001b[01;35m\u001b[K-Wargument-mismatch\u001b[m\u001b[K]\r\n", "\u001b[01m\u001b[Kcanhfs.for:115:31:\u001b[m\u001b[K\r\n", "\r\n", " CALL ROMS1(K, NG, DI, P, DP, DD, EPS, NOR)\r\n", " \u001b[01;35m\u001b[K1\u001b[m\u001b[K\r\n", "\u001b[01;35m\u001b[KWarning:\u001b[m\u001b[K Actual argument contains too few elements for dummy argument '\u001b[01m\u001b[Ky\u001b[m\u001b[K' (12/20) at (1) [\u001b[01;35m\u001b[K-Wargument-mismatch\u001b[m\u001b[K]\r\n", "\u001b[01m\u001b[Kcanhfs.for:218:31:\u001b[m\u001b[K\r\n", "\r\n", " CALL ROMS (K, NG, DI, S, DS, DD, EPS, NOR)\r\n", " \u001b[01;35m\u001b[K1\u001b[m\u001b[K\r\n", "\u001b[01;35m\u001b[KWarning:\u001b[m\u001b[K Actual argument contains too few elements for dummy argument '\u001b[01m\u001b[Ky\u001b[m\u001b[K' (12/20) at (1) [\u001b[01;35m\u001b[K-Wargument-mismatch\u001b[m\u001b[K]\r\n", "\u001b[01m\u001b[Kcanhfs.for:252:31:\u001b[m\u001b[K\r\n", "\r\n", " CALL ROMS1(K, NG, DI, S, DS, DD, EPS, NOR)\r\n", " \u001b[01;35m\u001b[K1\u001b[m\u001b[K\r\n", "\u001b[01;35m\u001b[KWarning:\u001b[m\u001b[K Actual argument contains too few elements for dummy argument '\u001b[01m\u001b[Ky\u001b[m\u001b[K' (12/20) at (1) [\u001b[01;35m\u001b[K-Wargument-mismatch\u001b[m\u001b[K]\r\n" ] } ], "source": [ "# Compile the source code (needs gfortran!)\n", "!rm -rf lamb.exe output.txt\n", "!gfortran canhfs.for -fcheck=all -o lamb.exe" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Calling the original FORTRAN code" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Initialization of setup:\n", "# Figure 4 in Lane R. Johnson - Green’s Function for Lamb’s Problem, 1974\n", "# is reproduced when the following parameters are given\n", "# -----------------------------------------------------------------------------\n", "r = 10.0 # km\n", "vp = 8.0 # P-wave velocity km/s\n", "vs = 4.62 # s-wave velocity km/s\n", "rho = 3.3 # Density kg/m^3 \n", "nt = 512 # Number of time steps\n", "dt = 0.01 # Time step s\n", "h = 0.2 # Source position km (0.01 to reproduce Fig 2.16 of the book)\n", "ti = 0.0 # Initial time s\n", "\n", "var = [vp, vs, rho, nt, dt, h, r, ti]\n", "\n", "# -----------------------------------------------------------------------------\n", "# Execute fortran code\n", "# -----------------------------------------------------------------------------\n", "with open('input.txt', 'w') as f:\n", " for i in var:\n", " print(i, file=f, end=' ') # Write input for fortran code\n", "\n", "f.close()\n", "\n", "os.system(\"./lamb.exe\") # Code execution\n", "\n", "# -----------------------------------------------------------------------------\n", "# Load the solution\n", "# -----------------------------------------------------------------------------\n", "G = np.genfromtxt('output.txt')\n", "\n", "u_rx = G[:,0] # Radial displacement owing to horizontal load\n", "u_tx = G[:,1] # Tangential displacement due to horizontal load\n", "u_zx = G[:,2] # Vertical displacement owing to horizontal load\n", "\n", "u_rz = G[:,3] # Radial displacement owing to a vertical load\n", "u_zz = G[:,4] # Vertical displacement owing to vertical load\n", "\n", "t = np.linspace(dt, nt*dt, nt) # Time axis\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Visualization of the Green's function" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "code_folding": [ 0 ] }, "outputs": [ { "data": { "text/plain": [ "