{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Acoustofluidics 2022: Plotting the Scattering Field\nThis example is from the presentation at the Acoustofluidics 2022 conference\nand shows how to plot the scattered pressure field and the mode shape of a\npolystyrene particle suspended in water and subjected to a 5MHz-standing wave.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "We import ``osaft`` and initialise the model with parameters of the\npolystyrene particle, water, and the acoustic field.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from matplotlib import pyplot as plt\n\nimport osaft\n\nhasegawa = osaft.hasegawa1969.ScatteringField(\n    f=5e6,\n    R_0=1e-6,\n    rho_s=1020,\n    E_s=3.4e9,\n    nu_s=0.4,\n    rho_f=1498,\n    c_f=997,\n    p_0=1e5,\n    wave_type=osaft.WaveType.STANDING,\n    position=osaft.pi / 4,\n)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "We generate the particle animation for the small 1-micron particle. It can\nbe seen how its motion is dominated by the dipole mode.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "plot_particle_small = osaft.ParticleWireframePlot(hasegawa)\nanim_particle_small = plot_particle_small.animate()\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Also the scattered pressure field is dominated by the contribution of\nthe dipole mode.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "plot_fluid_small = osaft.FluidScatteringPlot(hasegawa, r_max=5 * hasegawa.R_0)\nanim_fluid_small = plot_fluid_small.animate_pressure(incident=False)\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "We increase the particle radius and we animate the particle motion of the\n50-micron particle analogously to the small particle.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "hasegawa.R_0 = 50e-6\n\nplot_particle_large = osaft.ParticleWireframePlot(hasegawa)\nanim_fluid_large = plot_particle_large.animate()\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "For the large particle both particle motion and scattered pressure field\nare dominated by the quadrupole mode, i.e. a mode neglected in most\ntheories only considering the long-wavelength limit.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "plot_fluid_large = osaft.FluidScatteringPlot(hasegawa, r_max=5 * hasegawa.R_0)\nanim_particle_large = plot_fluid_large.animate_pressure(incident=False)\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.9.15"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}