{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Frontiers: PS Particle in Water\n\nThis example corresponds to section 3.1 in\n`our publication <CitingOsaft>`.\nIn this example we compute the acoustic radiation force (ARF) on a polystyrene\nparticle suspended in water subjected to a plane standing wave. We compare\nthe theories from Yosioka & Kawasima (1955), Gor'kov (1962), and Settnes &\nBruus (2012).\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "As always we start off by importing the nececassry Python modules. For this\nexample we are only going to need the osaft library.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import osaft"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "The next step is to define the properties for our example,\nthese include the material properties, the properties of the acoustic field,\nand the radius of the particle. In the osaft library we are always\nassuming SI-units.\n\nThe wave type is set using the ``osaft.WaveType`` enum. Currently, there are\ntwo options:\n``osaft.WaveType.STANDING`` and ``osaft.WaveType.TRAVELLING`` for a plane\nstanding wave and a plane travelling wave, respectively.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# --------\n# Geometry\n# --------\n# Radius\nR_0 = 1e-6  # [m]\n\n# -------------------\n# Properties of Water\n# -------------------\n# Speed of sound\nc_f = 1_498  # [m/s]\n# Density\nrho_f = 997  # [kg/m^3]\n# Viscosity at 25 degC\neta_w = 0.89e-3  # [Pa s]\n\n# -------------------------\n# Properties of Polystyrene\n# -------------------------\n# Speed of sound\nc_s = 2350  # [m/s]\n# Density\nrho_s = 1020  # [kg/m^3]\n\n# --------------------------------\n# Properties of the Acoustic Field\n# --------------------------------\n# Frequency\nf = 1e5  # [Hz]\n# Pressure\np_0 = 1e5  # [Pa]\n# Wave type\nwave_type = osaft.WaveType.STANDING\n# Position of the particle in the field\nposition = osaft.pi / 4  # [rad]"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Once all properties are defined we can initialize the solution classes.\nIn this example, we use the classes ``osaft.yosioka1955.ARF()``,\n``osaft.gorkov1962.ARF()``, and ``osaft.settnes2012.ARF()``.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "yosioka = 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=position,\n)\n\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=position,\n)\n\nsettnes = osaft.settnes2012.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    eta_f=eta_w,\n    p_0=p_0,\n    wave_type=wave_type,\n    position=position,\n)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Now we want to make sure that the solutions from Gor'kov and Settnes &\nBruus are actually applicable. These theories assume a small particle\ncompared to the acoustic wavelength\n\n\\begin{align}\\end{align}\n k_\\mathrm{f} \\cdot R_0 \\ll 1\n\nWe evaluate this expression using osaft\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "print(f\"{yosioka.k_f * yosioka.R_0 = :.4f}\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "And indeed, we were able to confirm that this is the case.\n\nFinally, we compute the acoustic radiation force for all models by calling\nthe ``compute_arf()`` method on all instances.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "print(f\"{yosioka.compute_arf() = :.3e}\")\nprint(f\"{gorkov.compute_arf() = :.3e}\")\nprint(f\"{settnes.compute_arf() = :.3e}\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "We have found that all solutions are in excellent agreement.\n\n"
      ]
    }
  ],
  "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
}