{
 "metadata": {
  "name": "",
  "signature": "sha256:71218a03a9605d3f7a7341594baa7c6aaf03b045951699482ae5c6da5c0be5f7"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 2: Pressure<h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2.1, Page Number: 116<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "\n",
      "x=10000.0*10.0            #equivalnt to 10kg/cm^2\n",
      "\n",
      "#result\n",
      "print('(a)\\n 10kg/cm^2 = %.0f mmWG' %x)\n",
      "\n",
      "#(b)\n",
      "\n",
      "#variable declaration\n",
      "onemm_Hg=13.546                #pressure  of 1 mm Hg\n",
      "\n",
      "#calculation\n",
      "y=10.0**5/onemm_Hg\n",
      "y=y/10.0**3\n",
      "\n",
      "#result\n",
      "print('\\n(b)\\n10kg/cm^2 = 10^5 mmWG = %.2f * 10^3 mmHg' %y)\n",
      "\n",
      "#(c)\n",
      "\n",
      "#variable declaration\n",
      "onebar=1.03                   # 1 Bar presssure in kg/cm^2\n",
      "#calculation\n",
      "z=10.0/onebar\n",
      "\n",
      "#result\n",
      "print('\\n(c)\\n10kg/cm^2 = %.2f bars' %z)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)\n",
        " 10kg/cm^2 = 100000 mmWG\n",
        "\n",
        "(b)\n",
        "10kg/cm^2 = 10^5 mmWG = 7.38 * 10^3 mmHg\n",
        "\n",
        "(c)\n",
        "10kg/cm^2 = 9.71 bars"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2.2, Page Number: 116<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#(a)\n",
      "\n",
      "#variable Declaration\n",
      "gamm=1000.0               # density of water\n",
      "d=35.0                    # depth of water \n",
      "dens_Hg=13.546            # density of Hg\n",
      "\n",
      "#calculation\n",
      "press_in_kg_cm=gamm*d*10**-4\n",
      "press_in_mmHg=gamm*d/dens_Hg\n",
      "press_in_mmHg=press_in_mmHg/10**3\n",
      "\n",
      "#result\n",
      "print('(a)\\nThe pressure at depth of %d meters in a water tank=%.1f kg/cm^2 = %.2f*10^3 mmHg'%(d, press_in_kg_cm, press_in_mmHg))\n",
      "\n",
      "#(b)\n",
      "\n",
      "#varible declaration\n",
      "press_atm=1.03            #atmospheric pressure\n",
      "\n",
      "#calculation\n",
      "abspress=press_in_kg_cm+press_atm\n",
      "abspress_mmHg=press_in_mmHg*1000.0+760.0\n",
      "abspress_mmHg=abspress_mmHg/1000.0\n",
      "\n",
      "#result\n",
      "print('\\n(b)\\nAbsolute Pressure= %.2f kg/cm^2 Abs = %.2f*10^3 mmHg Abs'%(abspress, abspress_mmHg))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)\n",
        "The pressure at depth of 35 meters in a water tank=3.5 kg/cm^2 = 2.58*10^3 mmHg\n",
        "\n",
        "(b)\n",
        "Absolute Pressure= 4.53 kg/cm^2 Abs = 3.34*10^3 mmHg Abs"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2.3, Page Number:116<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#varible declaration\n",
      "egp=260.0                  # equivalent gauge pressure\n",
      "\n",
      "#calculation\n",
      "abspress=760.0-egp\n",
      "\n",
      "#result\n",
      "print('Absolute Presssure = %d mmHg' %abspress)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Absolute Presssure = 500 mmHg"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2.4,Page Number:117<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#(a)\n",
      "\n",
      "#variable declaration\n",
      "p_diff=500.0                #pressure difference in mmHg\n",
      "\n",
      "#calculations\n",
      "pdiff=p_diff*13.546/10000\n",
      "\n",
      "#Result\n",
      "print('(a)\\np1-p2 = %.3f kg/cm^2' %pdiff)\n",
      "\n",
      "\n",
      "#(b)\n",
      "\n",
      "#variable declaration\n",
      "p1=6770.0                  # Gauge pressure in mmWG\n",
      "p_atm=10300.0              # atmospheric pressure \n",
      "\n",
      "#calculation\n",
      "abs_p1=p1+p_atm\n",
      "\n",
      "#result\n",
      "print('\\n(b)If p2 is open to atmosphere:\\nAbsolute Pressure P1 = %d mmWG abs.' %abs_p1)\n",
      "\n",
      "#(c)\n",
      "\n",
      "#variable declaration\n",
      "P1=500.0                 #mmHg absolute pressure\n",
      "\n",
      "#calculations\n",
      "P1_gauge=P1-760.0\n",
      "\n",
      "#result\n",
      "print('\\n(c)If p2 is evacuated and sealed:\\np1= %d mmHg gauge Pressure' %P1_gauge)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)\n",
        "p1-p2 = 0.677 kg/cm^2\n",
        "\n",
        "(b)If p2 is open to atmosphere:\n",
        "Absolute Pressure P1 = 17070 mmWG abs.\n",
        "\n",
        "(c)If p2 is evacuated and sealed:\n",
        "p1= -260 mmHg gauge Pressure"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2.5, Page Number: 117<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#variable declaration\n",
      "spe_grav_water=1.0             # specific gravity of water\n",
      "\n",
      "#calculation\n",
      "spe_grav_X=spe_grav_water*100.0/50.0\n",
      "wt_dens_water=1000.0\n",
      "wt_dens_X=wt_dens_water*2.0\n",
      "\n",
      "#result\n",
      "print('Weight Density of X = %d kg/m^3' %wt_dens_X)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Weight Density of X = 2000 kg/m^3"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2.6, Page Number: 117<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#variable declaration\n",
      "A=1.0/20.0                      # Area ratio\n",
      "p_diff=1500.0                   # pressure difference in mmWG\n",
      "\n",
      "#result\n",
      "print('(a)\\nAs Delta_h=A2/A1*h << h and normally negligible for well type manometer')\n",
      "print('hence, p1-p2 = h = %d =111 mmHg' %p_diff)\n",
      "print('\\n(b)\\nh measured above the oriinal reference will be half of H, i.e. 111/2=55.5 mmHg')\n",
      "print('(Since area of both legs are same)')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)\n",
        "As Delta_h=A2/A1*h << h and normally negligible for well type manometer\n",
        "hence, p1-p2 = h = 1500 =111 mmHg\n",
        "\n",
        "(b)\n",
        "h measured above the oriinal reference will be half of H, i.e. 111/2=55.5 mmHg\n",
        "(Since area of both legs are same)"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2.7, Page Number: 119<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "print('1 kg/cm^2 = 10 mWG\\n')\n",
      "\n",
      "#(a)\n",
      "\n",
      "#variable declaration\n",
      "press=10+2              #pressure read by the gauge\n",
      "\n",
      "#result\n",
      "print('\\n(a)Bourdon Gauge is mounted 20 meters below water line:')\n",
      "print('\\nPressure read by the Gauge = %d kg/cm^2'%press)\n",
      "\n",
      "\n",
      "#(b)\n",
      "\n",
      "#variable declaration\n",
      "press2=10-3            #pressure read by the gauge\n",
      "\n",
      "#result\n",
      "print('\\n\\n(b)Bourdon Gauge is located 30 meters above the water line:')\n",
      "print('\\nPressure read by the Gauge = %d kg/cm^2'%press2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1 kg/cm^2 = 10 mWG\n",
        "\n",
        "\n",
        "(a)Bourdon Gauge is mounted 20 meters below water line:\n",
        "\n",
        "Pressure read by the Gauge = 12 kg/cm^2\n",
        "\n",
        "\n",
        "(b)Bourdon Gauge is located 30 meters above the water line:\n",
        "\n",
        "Pressure read by the Gauge = 7 kg/cm^2"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2.8, Page Number: 120<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#Variable declaration\n",
      "dens_water=1000.0                 # water Density\n",
      "h1=125.0                          # height1 mm\n",
      "h2=250.0                          # height2 mm\n",
      "d2=h1*dens_water/h2\n",
      "\n",
      "#result\n",
      "\n",
      "#a\n",
      "print('(a)\\nDensity of Liquid = %d kg/m^3' %d2)\n",
      "print('\\nSpecific Density of the liquid = %.1f' %(h1/h2))\n",
      "\n",
      "#(b)\n",
      "print('\\n\\n(b)\\nIf Values of water and liquid interchanged:\\n')\n",
      "d3=h2*dens_water/h1\n",
      "print('\\nDensity of Liquid = %d kg/m^3' %d3)\n",
      "print('\\nSpecific Density of the liquid = %.1f' %(h2/h1))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)\n",
        "Density of Liquid = 500 kg/m^3\n",
        "\n",
        "Specific Density of the liquid = 0.5\n",
        "\n",
        "\n",
        "(b)\n",
        "If Values of water and liquid interchanged:\n",
        "\n",
        "\n",
        "Density of Liquid = 2000 kg/m^3\n",
        "\n",
        "Specific Density of the liquid = 2.0"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2.9, Page Number: 120<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math\n",
      "#variable Declaration\n",
      "R=120.0                        #resistance\n",
      "l=122.0                        #length\n",
      "a=0.1                          #area\n",
      "R1=140.0                       #resistance in ohm\n",
      "\n",
      "#calculation\n",
      "rho=R*a/l\n",
      "l1=math.sqrt(R1*a*l/rho)\n",
      "l1=round(l1,0)\n",
      "\n",
      "#Result\n",
      "print('Length l1 = %d meters' %l1)\n",
      "A1=a*l/l1\n",
      "print('\\nArea A1 = %.4f mm^2' %A1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Length l1 = 132 meters\n",
        "\n",
        "Area A1 = 0.0924 mm^2"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2.10, Page Number: 121<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "c=0.57                   #Constant\n",
      "\n",
      "#(a)\n",
      "\n",
      "#variable declaration\n",
      "d=0.1                    #distance between plates\n",
      "di1=100.0                #Dielectric constant\n",
      "di2=1000.0               #Dielectric constant\n",
      "\n",
      "#calculation\n",
      "c1=c*di1*10.0/d\n",
      "c1=round(c1,0)\n",
      "\n",
      "#result\n",
      "print('(a)\\nC1=%d pf' %c1)\n",
      "\n",
      "\n",
      "#(b)\n",
      "\n",
      "#calculation\n",
      "c2=c*di2*10/d\n",
      "\n",
      "#result\n",
      "print('\\n(b)\\nC2=%d pf' %c2)\n",
      "\n",
      "\n",
      "#(c)\n",
      "\n",
      "#calculation\n",
      "ds=0.09\n",
      "c11=c*di1*10/ds\n",
      "c12=c*di2*10/ds\n",
      "\n",
      "#result\n",
      "print('\\n(c)\\nC1 = %.1f pf\\nC2 = %d pf'%(c11,c12))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)\n",
        "C1=5700 pf\n",
        "\n",
        "(b)\n",
        "C2=57000 pf\n",
        "\n",
        "(c)\n",
        "C1 = 6333.3 pf\n",
        "C2 = 63333 pf"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2.11, Page Number: 121<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#variable Declaration\n",
      "A=1.0                       #area\n",
      "p1=10.0                     #pressure\n",
      "\n",
      "#calculation\n",
      "W1=A*p1\n",
      "\n",
      "#Result\n",
      "print('W1 = %d kg' %W1)\n",
      "print('\\nWith the 4 standard weights of 10kg, 20kg, 30kg and 40kg')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "W1 = 10 kg\n",
        "\n",
        "With the 4 standard weights of 10kg, 20kg, 30kg and 40kg"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2.12, Page Number: 122<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#varable declaration\n",
      "p1=10**-2                 #pressure in torr\n",
      "h1=20.0                   #height in mm\n",
      "\n",
      "#xalculation\n",
      "K=p1/h1**2\n",
      "p2=K*30**2\n",
      "p2=p2*100.0\n",
      "\n",
      "#Result\n",
      "print('The unknown pressure p2 = %.2f * 10^-2 torr' %p2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The unknown pressure p2 = 2.25 * 10^-2 torr"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}