{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 12:Measurement of Non-Electrical Quantities"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.1,Page No:600"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Gf  = 2;                                 #guage factor \n",
    "a   = 100*10**6;                         #stress in N/m**2\n",
    "E   = 200*10**9;                         #elasticity of steel in N/m**2\n",
    "\n",
    "#calculation\n",
    "st     = (a/float(E));                        #strain\n",
    "x      = Gf*st;                              # change in guage resistance\n",
    "p      = (x)*100;                            #percentage change in resistance in %\n",
    "\n",
    "#result\n",
    "print\"percentage change in resistance %1.1f\"%p,\"%\";\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.4,Page No:631"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "water flow rate 0.0586 m**3/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "D1   = 200*10**-3;               # inlet horizontal venturimeter in m\n",
    "D2   = 100*10**-3;               #throat horizontal enturimeter in m\n",
    "h    = 220*10**-3;               #pressure in m\n",
    "Cd   = 0.98;                     #coefficient of discharge \n",
    "phg  = 13.6;                     #specific gravity of mercury\n",
    "p    = 1000;                     #density of water in kg/m**3\n",
    "g    = 9.81;                     #gravitational constant\n",
    "pw   = 1;                        #density of water in kg/m**3\n",
    "w    = 9.81; \n",
    "\n",
    "\n",
    "\n",
    "#calculation\n",
    "x    = (g)*(h)*(phg-pw)*1000;            #differential pressure  head in N/m**2\n",
    "a    = 1-((D2/float(D1))**4);            #velocity approach factor\n",
    "M    = 1/(float(math.sqrt(a)));           #velocity of approach\n",
    "b    = math.sqrt(((2*g)/(float(w*p)))*x);\n",
    "A2   = (math.pi/float(4))*((D2)**2);      #area in m**2\n",
    "Q    = Cd*M*A2*(b);                       #discharge through venturimeter in m**3/s\n",
    " \n",
    "#result\n",
    "print'water flow rate %3.4f'%Q,'m**3/s';    \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.5,Page No:631"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "rate of flow of oil 0.137850 m**3/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "D1    = 400*10**-3;                    #diameter at inlet in m\n",
    "D2    = 200*10**-3;                    #diameter at throat in m\n",
    "y     = 50*10**-3;                     #reading of differential manometer in m\n",
    "Shl   = 13.6;                          #specific gravity of mercury in U-tube \n",
    "Sp    = 0.7;                           #specific gravity of oil in U-tube \n",
    "h     = 0.92;\n",
    "\n",
    "#bernoulli's equation\n",
    "#p1/w +z1+V1**2=p2/w +z2+V2**2\n",
    "#solving we get h+(V1**2/2*g)-(V2**2/2*g)=0\n",
    "# calculations\n",
    "\n",
    "A1    =  (math.pi/float(4))*(D1**2);                   #area in m**2\n",
    "A2    =  (math.pi/4)*(D2**2);                          #area in m**2\n",
    "a     =  A2/float(A1);                                 #ratio of areas\n",
    "#V1 = a*V2;\n",
    "#h+(V1**2/2*g)*(1-(1/4))=0\n",
    "V2    =  math.sqrt((2*g*h)/(float(1-((a)**2))));     \n",
    "Q     =  A2*V2;                                         #rate of oil flow in m**3/s\n",
    "\n",
    "#result\n",
    "print'rate of flow of oil %f'%Q,'m**3/s';\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.6,Page No:633"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "difference in pressure head 4952.073 N/m**2\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Q    = 0.015;                          #rate of flow in m**3/s\n",
    "D0   = 100*10**-3;                     #diameter orifice in m\n",
    "D1   = 200*10**-3;                     #diameter of pipe in m\n",
    "Cc   =  0.6;                           #coefficient of contraction\n",
    "Cd   =  0.6;                           #coefficient  of discharge\n",
    "E    = 1;                              #thermal expansion factor\n",
    "g    = 9.81;                           #gravitational constant \n",
    "w    = 9810;\n",
    "\n",
    "#calculations\n",
    "A0 =  ((math.pi)/float(4))*(D0**2);               #area in m**2\n",
    "A1 =  ((math.pi)/float(4))*(D1**2);               #area in m**2\n",
    "a  =  (Cc*A0)/(float(A1));                        \n",
    "M  =  math.sqrt(1-((a)**2));\n",
    "K  =  Cd/float(M);\n",
    "x  =  ((Q/float(K*E*A0))**2);\n",
    "dp = (x*w/float(2*g));                          #difference in pressure head in N/m**2\n",
    "\n",
    "#result\n",
    "print'difference in pressure head %3.3f'%dp,'N/m**2';\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:12.7,Page No:633"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "discharge through the orifice 0.742 m**3/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "C0  = 0.6;                    #coefficient of orifice\n",
    "Cv  = 0.97;                   #coefficient of discharge\n",
    "Qv  =  1.2;                   #flow rate in m**3/s\n",
    "\n",
    "#calculations\n",
    "Q0  = (C0/Cv)*Qv;             #discharge through the orifice in m**3/s\n",
    "\n",
    "#result\n",
    "print'discharge through the orifice %3.3f'%Q0,'m**3/s'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:12.8,Page No:634"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "velocity of submarine 25.0 km/h\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Shl = 13.6;                #specific gravity of mercury\n",
    "Sl  = 1.025;               #specific gravity of sea water\n",
    "y   = 200*10**-3;          #reading in m\n",
    "g   = 9.81;                #constant\n",
    "\n",
    "#calculation\n",
    "x     = Shl/float(Sl);\n",
    "h     = (y*((x)-1));                       #head\n",
    "V     = math.sqrt(2*g*h);                  #velocity of submarine in km/h\n",
    "\n",
    "#result\n",
    "print'velocity of submarine %3.1f'%(V*(18/float(5))),'km/h';"
   ]
  }
 ],
 "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}