{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Acoustic equations for heterogeneous media" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We would like to model acoustic waves propagation through heterogeneous media, like non-homogeneous materials, layered media or any kind of interface, like walls. The materials in acoustic equations are modeled by the density and bulk modulus coefficients. The natural generalization of constant-coefficient acoustic equations is to have spatially dependent coefficients, so the equations take the form $q_t+A(x)q_x=0$. The explicit form is given by\n", "\n", "\\begin{align*}\n", " \\left[ \\begin{array}{c}\n", "p \\\\\n", "u \n", "\\end{array} \\right]_t\n", "+ \\left[ \\begin{array}{cc}\n", "0 & K(x) \\\\\n", "1/\\rho(x) & 0 \\\\\n", "\\end{array} \\right]\n", "\\left[ \\begin{array}{c}\n", "p \\\\\n", "u \\end{array} \\right]_x = 0,\n", "\\end{align*}\n", "\n", "with $p$ and $u$ the pressure and velocity and $\\rho(x)$ and $K(x)$ the spatially dependent density and bulk modulus of compressibility. Note this equation is in non-conservative form. An acoustics equation for heterogeneous media in conservative form can be derived in terms of the momentum and strain. However, that is a particular case of the elasticity equations, which are explored in detail in other sections of this book. Furthermore, it is convenient to use the pressure and velocity as variables since they are continuous at interfaces between materials, and they are also more physically intuitively. It is also important to recognize that more complicated systems emerging in applications might not be written in conservation form. Therefore, studying these problems might provide insight and algorithms on how to solve more complicated cases.\n", "\n", "We proceed to do the usual analysis. The eigenvalues of the coefficient matrix $A$ are $\\pm c(x)$, and the matrix of column eigenvalues is\n", "\n", "\\begin{align*}\n", "R(x) = \n", "\\left[ \\begin{array}{ccccc}\n", "-Z(x) & Z(x) \\\\\n", " 1 & 1 \\\\\n", "\\end{array} \\right].\n", "\\end{align*}\n", "\n", "where\n", "\n", "\\begin{align*}\n", "c(x) &= \\sqrt{\\frac{K(x)}{\\rho(x)}}, \\\\\n", "Z(x) &= \\rho(x) c(x) = \\sqrt{K(x)\\rho(x)}\n", "\\end{align*}\n", "\n", "are the spatially dependent sound speed and impedance.\n", "\n", "In order to solve these equations, we need to do a numerical discretization. Following the spirit of finite volume methods, we approximate $\\rho(x)$ and $K(x)$ by piecewise constant functions that are constant in any given grid cell. Therefore, if we can solve the Riemann problem across two given cells, we can extrapolate the solution to the whole grid using standard finite volume method techniques, see (LeVeque 2002). The Riemann problem to solve consists of the acoustic equations Riemann problem with discontinuous initial data and coefficients (discontinuous $\\rho$ and $K$). Once this problem is solved it can be used to approximate a continuous density varying material or other similar examples. As the value of $\\rho$ and $K$ is different on the left side than on the right side, the eigenvalues and eigenvectors are as follows. The eigenvalues will be given by the sound speed in each of the two mediums,\n", "\n", "\\begin{align}\n", "s_l = -c_l \\ \\ \\ \\ \\ s_r = c_r \\ \\ \\ \\ \\ \\mathrm{with:} \\ \\ \\ \\ \\ c_i = \\sqrt{\\frac{K_{i}}{\\rho_{i}}},\n", "\\label{eq:achetero}\n", "\\end{align}\n", "\n", "and the eigenvalues by the impedances of each medium as well, so we can write the matrix of column eigenvectors $R=[r_1, r_2]$ as,\n", "\n", "\\begin{align*}\n", "R = \n", "\\left[ \\begin{array}{ccccc}\n", "-Z_{l} & Z_{r} \\\\\n", " 1 & 1 \\\\\n", "\\end{array} \\right].\n", "\\end{align*}\n", "\n", "Once again, we only need to solve $\\mathbf{R} \\bar{\\alpha} = \\Delta \\bar{q}$, which yields the values\n", "of $\\alpha$\n", "\n", "\\begin{align*}\n", "\\alpha_1 = \\frac{-\\Delta p + Z_r\\Delta u}{Z_l + Z_r}, \\ \\ \\ \\ \\ \\\n", "\\alpha_2 = \\frac{\\Delta p + Z_l\\Delta u}{Z_l + Z_r}.\n", "\\end{align*}\n", "\n", "The middle state is again given simply by $q_m = q_\\ell + \\alpha_1 r_1 = q_r - \\alpha_2 r_2$." ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Interactive solution in the phase plane \n", "This interactive plots allows you to change all of the parameters, as well as the left and right density and bulk modulus so their influence in the phase plane solution can be obersved." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from ipywidgets import interact\n", "from ipywidgets import widgets\n", "from exact_solvers import acoustics, interactive_pplanes\n", "from utils import riemann_tools" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "deletable": true, "editable": true }, "outputs": [], "source": [ "# Initial states [pressure, velocity]\n", "ql = [25.0, 15.0]\n", "qr = [10.0,-15.0]\n", "# Acoustic eq. parameters [rho, bulk(K)]\n", "paramsl = [1.0, 0.5] \n", "paramsr = [5.0, 3.0]\n", "\n", "interactive_pplanes.acousticsInterface_interactive_phase_plane(ql,qr,paramsl,paramsr)" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "## Examples\n", "We will show some examples of where this Riemann problem becomes relevant. As in the previous case, we will begin by defining a function to do the interactive plotting for the different cases." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "deletable": true, "editable": true }, "outputs": [], "source": [ "def plot_heterogenous_riemann(ql, qr, auxl, auxr):\n", " ex_states, ex_speeds, reval = acoustics.exact_riemann_heterogenous(ql ,qr, auxl, auxr)\n", "\n", " plot_function = riemann_tools.make_plot_function(ex_states, ex_speeds, reval, layout='vertical',\n", " variable_names=['pressure', 'velocity'],\n", " aux=(np.array(auxl), np.array(auxr)),\n", " plot_chars=[acoustics.lambda1,\n", " acoustics.lambda2])\n", "\n", " return interact(plot_function, t=widgets.FloatSlider(value=0.0,min=0,max=1.0),\n", " which_char=widgets.Dropdown(options=[None,1,2],description='Show characteristics'));" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Problem 3: Shock tube with interface\n", "We repeat the shock tube problem for acoustics but now with two materials. The material properties in the acoustic equations are defined by the density and bulk modulus. Therefore, we can solve the acoustics Riemann problem for two materials by simply choosing different densities and bulk modulus and on the left and on the right. This Riemann problem is fundamental to model acoustic wave propagation across interfaces or heterogenous materials. Note the symmetry of the wave speeds is lost since the eigenvalues are the sound speed and the sound speed depends on the material, i.e. on the density and bulk modulus, like shown in equation (\\ref{eq:achetero}). Also note the characteristics bend when crossing the origin. This is a consequence of having differente materials on the left and right sides since different materials will yield different sound speeds." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "deletable": true, "editable": true }, "outputs": [], "source": [ "ql = np.array([5,0]) \n", "qr = np.array([1,0])\n", "rho = [1.0, 20.0] # left and right density\n", "bulk = [4.0, 15.0] # left and right bulk modulus\n", "plot_heterogenous_riemann(ql, qr, [rho[0],bulk[0]], [rho[1], bulk[1]]);" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "The solution in the phase plane is" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "deletable": true, "editable": true }, "outputs": [], "source": [ "ppplot_interface=interactive_pplanes.acousticsInterface_phase_plane_plot()\n", "ppplot_interface(ql[0],ql[1],qr[0],qr[1],rho[0],rho[1],bulk[0],bulk[1],ymin=-2,ymax=2)" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Problem 4: Acoustic propagation through a wall\n", "In a previous example, we showed the flow into a wall, which basically models the wall as a completely reflective surface. In most cases, this is a good approximation for the reflected waves; however, we could also ask what is the propagated acoustic wave through the wall. We can answer this question by using the air's bulk modulus and density in the right side and the wall's density and bulk modulus on the right. Air actually has density of $\\rho \\approx 1 kg/m^3$ and $K\\approx 100 kPa$, steel on the other hand has $\\rho\\approx 8000 kg/m^3$ and $K=160 GPa$. Considering the atmospheric pressure to be $p_{atm} = 101325 Pa$, and an acoustic wave hitting the steel at $340 m/s$, we have all the parameters. As expected you will notice the acoustic wave\n", "on the steel propagates extremely faster than in the air, which is around $5000 m/s$, around 14 times faster than in air." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "deletable": true, "editable": true }, "outputs": [], "source": [ "patm = 101325.0\n", "ql = np.array([patm,340]) \n", "qr = np.array([patm,0])\n", "rho = [1.0, 8000.0] # left and right density\n", "bulk = [100000.0, 160000000000.0] # left and right bulk modulus\n", "plot_heterogenous_riemann(ql, qr, [rho[0], bulk[0]], [rho[1],bulk[1]]);" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "deletable": true, "editable": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.13" } }, "nbformat": 4, "nbformat_minor": 2 }