{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Yosioka and Kawasima (1955) Figure 2\nWith this example we want to recreate Figure 2 from the publication of\nYosioka and Kawasima (1955).\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "First, we need to get an instance of our solution class. In this case\n``osaft.yosioka1955.ARF()``. The steps are the same as in the earlier\nexamples.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nimport osaft\n\n# --------\n# Geometry\n# --------\n# Radius\nR_0 = 1e-6  # [m]\n\n# -----------------\n# Properties of Air\n# -----------------\n# Speed of sound\nc_air = 343  # [m/s]\n# Density\nrho_air = 1.225  # [kg/m^3]\n\n# -------------------\n# Properties of Water\n# -------------------\n# Speed of sound\nc_w = 1_498  # [m/s]\n# Density\nrho_w = 997  # [kg/m^3]\n\n# --------------------------------\n# Properties of the Acoustic Field\n# --------------------------------\n# Frequency\nf = 1e5  # [Hz]\n# Pressure\np_0 = 101_325  # [Pa]\n# Wave type\nwave_type = osaft.WaveType.TRAVELLING\n\n# Initializing Model Instance\nyosioka = osaft.yosioka1955.ARF(\n    f=f,\n    R_0=R_0,\n    rho_s=rho_air,\n    c_s=c_air,\n    rho_f=rho_w,\n    c_f=c_w,\n    p_0=p_0,\n    wave_type=wave_type,\n    bubble_solution=True,\n    small_particle=True,\n)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "For this example we are plotting the acoustic radiation for against\n\n\\begin{align}44x(R_0) = k_s * R_0 / \\sqrt{3 \\tilde{\\rho}}\\end{align}\n\nwhere $k_s$ is the wavenumber in the bubble, $R_0$ is the\nradius, and $\\tilde{\\rho}$ is the ratio of the\nparticle density and the fluid density. $x(R_0)$ is ranging between\n0 and 4. We, therefore, need to compute the values of $R_0$ takes,\nsuch that  $x(R_0)$ is in this range.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "x_values = np.linspace(0.01, 4, num=100)\nx_values = np.append(x_values, 1)\nx_values = np.sort(x_values)\n\nR_values = x_values * np.sqrt(3 * yosioka.rho_s / yosioka.rho_f) / yosioka.k_s"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Now that we have the values on the x-axis, we can plot the ARF. We pass\n``normalization_name = 'max'``. This will normalize the ARF w.r.t. the max\nvalue in the plot.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Plotting the acoustic radiation force with osaft\narf_plot = osaft.ARFPlot()\narf_plot.add_solutions(yosioka)\narf_plot.set_abscissa(x_values=R_values, attr_name=\"R_0\")\nfig, ax = arf_plot.plot_solutions(display_values=x_values, normalization=\"max\")\n\n# Finally, we manipulate the Axes object to make it more similar to the plot\n# in the paper.\n\n# adding a black vertical line at x = 1\nax.axvline(1, color=\"k\")\n\n# setting the x-axis ticks\nax.set_xticks([0, 1, 4])\n\n# setting y-axis limits and the ticks\nax.set_ylim(0, 0.04)\nax.set_yticks([0, 0.01, 0.02, 0.03, 0.04])\n\n# adding labels to both axis\nax.set_xlabel(r\"${k_s R_0}/{\\sqrt{3\\lambda}}$\")\n\n# displaying the plot\nfig.tight_layout()\nplt.show()\n\n# sphinx_gallery_thumbnail_number = -1"
      ]
    }
  ],
  "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
}