{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Plotting Particle Displacement In Sound Fields\n", "\n", "[back to overview page](index.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following is based on this Mathematica notebook: http://library.wolfram.com/infocenter/MathSource/780/" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "particles = 1000\n", "length = 2 # along x-axis\n", "width = 0.2 # along y-axis\n", "wavelength = 0.3 * length\n", "amplitude = 0.1 * wavelength" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "t = 0 # TODO: animation from 0 to 1" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x = np.random.uniform(0, length, particles)\n", "y = np.random.uniform(0, width, particles)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x += amplitude * np.sin((2 * np.pi / wavelength) * x - 2 * np.pi * t)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(12, 1))\n", "ax.scatter(x, y)\n", "ax.axis('equal')\n", "ax.axis('tight');" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## External Links\n", "\n", "Animation of 1D standing wave: http://www.acs.psu.edu/drussell/Demos/StandingWaves/StandingWaves.html\n", "\n", "Animation of 2D sound propagation: http://www.acs.psu.edu/drussell/Demos/rad2/mdq.html\n", "\n", "Another 1D animation: http://blog.soton.ac.uk/soundwaves/wave-basics/ways-of-showing-waves/\n", "\n", "Another 2D animation: http://blog.soton.ac.uk/soundwaves/wave-basics/point-sources-inverse-square-law/" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n",
" \n",
" \n",
" \n",
"
\n",
" To the extent possible under law,\n",
" the person who associated CC0\n",
" with this work has waived all copyright and related or neighboring\n",
" rights to this work.\n",
"