{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 12: Ultrasonics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 1, Page number 394"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fundamental frequency is 958.33 KHz\n",
      "answer in the book varies due to rounding off errors\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "v=5750;       #velocity(m/s)\n",
    "t=3*10**-3;        #thickness(m)\n",
    "\n",
    "#Calculation\n",
    "lamda=2*t;          #wavelength(m)\n",
    "f=v/lamda;      #fundamental frequency(Hz)\n",
    "\n",
    "#Result\n",
    "print \"fundamental frequency is\",round(f/10**3,2),\"KHz\"\n",
    "print \"answer in the book varies due to rounding off errors\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 2, Page number 394"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "natural frequency is 1365.0 KHz\n",
      "answer in the book varies due to rounding off errors\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "Y=7.9*10**10;       #youngs modulus(N/m**2)\n",
    "rho=2650;           #density(Kg/m**3)\n",
    "t=2*10**-3;         #thickness(m)\n",
    "\n",
    "#Calculation\n",
    "v=math.sqrt(Y/rho);    #velocity(m/s)\n",
    "lamda=2*t;          #wavelength(m)\n",
    "f=v/lamda;      #natural frequency(Hz)\n",
    "\n",
    "#Result\n",
    "print \"natural frequency is\",round(f/10**3),\"KHz\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 3, Page number 395"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pressure wave amplitude is 13.04 N/m**2\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "rho0=1.21;      #air density(kg/m**3)\n",
    "C=343;       #sound velocity(m/sec)\n",
    "f=500;       #frequency(Hz)\n",
    "A=10**-5;         #displacement amplitude(m)\n",
    "\n",
    "#Calculation\n",
    "omega=2*math.pi*f;       #angular frequency(Hz)\n",
    "Pe=rho0*C*omega*A;       #pressure wave amplitude(N/m**2)\n",
    "\n",
    "#Result\n",
    "print \"pressure wave amplitude is\",round(Pe,2),\"N/m**2\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 4, Page number 395"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ratio of pressure amplitudes is 58.0\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "Z1=1.43*10**6;      #value of constant in water(Rayls)\n",
    "Z2=425.7;      #value of constant in air(Rayls)\n",
    "\n",
    "#Calculation\n",
    "Pe1byPe2=math.sqrt(Z1/Z2);     #ratio of pressure amplitudes\n",
    "\n",
    "#Result\n",
    "print \"ratio of pressure amplitudes is\",round(Pe1byPe2)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
