{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Acoustofluidics 2022: ARF Comparison\nIn this example, we reproduce the ARF comparison plot from the abstract book\nfor the conference Acoustofluidics 2022. We compute the ARF on a polystyrene\nparticle in a standing wave in water.\n\nWe start off by importing the library and defining all the necessary\nparameters.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nfrom matplotlib import pyplot as plt\n\nimport osaft\n\n# Frequency\nf = 5e6  # [Hz]\n# Radius\nR_0 = 1e-6  # [m]\n# Density and speed of sound of polystyrene\nrho_s = 1020  # [kg/m^3]\nc_s = 2_350  # [m/s]\n# Density and speed of sound of the fluid\nrho_f = 997  # [kg/m^3]\nc_f = 1_498  # [m/s]\n# Pressure amplitude\np_0 = 1e5  # [Pa]\n# Particle position\nd = osaft.pi / 4\n# Wave Type\nwave_type = osaft.WaveType.STANDING"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "For this example we compare three inviscid theories. The models by Yosioka &\nKawasima and the model by Gor'kov assume a fluid-like, compressible\nparticle. The latter model is restricted to the long-wavelength regime.\nThe model from Hasegawa & Yosioka assume a solid-elastic particle.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Model from Yosioka & Kawasima\nyosioka = osaft.yosioka1955.ARF(\n    f=f,\n    R_0=R_0,\n    rho_s=rho_s,\n    c_s=c_s,\n    rho_f=rho_f,\n    c_f=c_f,\n    p_0=p_0,\n    wave_type=wave_type,\n    position=d,\n)\n\n# Model from Gor'kov\ngorkov = osaft.gorkov1962.ARF(\n    f=f,\n    R_0=R_0,\n    rho_s=rho_s,\n    c_s=c_s,\n    rho_f=rho_f,\n    c_f=c_f,\n    p_0=p_0,\n    wave_type=wave_type,\n    position=d,\n)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Elastic properties of polystyrene for the model of Hasegawa & Yosioka are\nmatched to the compressibility of the other two models.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "nu_s = 0.4  # [-]\nE_s = 3 * (1 - 2 * nu_s) / yosioka.scatterer.kappa_f  # [Pa]\n\nhasegawa = osaft.hasegawa1969.ARF(\n    f=f,\n    R_0=R_0,\n    rho_s=rho_s,\n    E_s=E_s,\n    nu_s=nu_s,\n    rho_f=rho_f,\n    c_f=c_f,\n    p_0=p_0,\n    wave_type=wave_type,\n    position=d,\n)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Next, we plot the ARF according to the theories while changing the radius\nof the particle. For a more detailed explanation how this is done checkout\n`this example\n<sphx_glr_examples_publication_example_frontiers_hfe_in_water.py>`. For a\nsmall particle radius, the models are in good agreement. When the particle\nbecomes larger the model by Gor'kov is no longer valid.\nAlso the other two models are no longer in good agreement. The material model\nof the particle seems to strongly influence the ARF as higher order modes\nstart to contribute more significantly. To see an animation of these modes\ncheckout\n`this example\n<sphx_glr_examples_publication_example_af2022_presentation_scattering.py>`.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Changing the font size in Matplotlib\nplt.rcParams.update({\"font.size\": 8})\n\n# Getting a Figure, Axes instance with the right size\nfig, ax = plt.subplots(figsize=(3.7, 2.4))\n\n# Plot using the Axes object created above\narf_plot = osaft.ARFPlot(\"R_0\", np.linspace(1e-6, 50e-6, 100))\narf_plot.add_solutions(gorkov, yosioka, hasegawa)\narf_plot.plot_solutions(ax=ax)\n\n# Changing labels\nax.set_xlabel(\"$R_0$ [$\\\\mu m$]\")\nax.set_ylabel(\"$F^{rad}$ [$N$]\")\nax.set_xticks(\n    [1e-6, 1e-5, 2e-5, 3e-5, 4e-5, 5e-5],\n    labels=[1, 10, 20, 30, 40, 50],\n)\n\n# Adjust layout and display plot\nfig.tight_layout()\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
}