{
 "metadata": {
  "name": "",
  "signature": "sha256:57afc22e72f8124575cf49b21448070d3e8a0ab91ff492996411fc02ec3e922d"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 13 : Unsteady-Flow Problems"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.1 Page No : 449"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#Initialization of variables\n",
      "ken = 0.5\n",
      "kex = 0.2\n",
      "f = 0.0018\n",
      "l = 10. \t#ft\n",
      "dia = 3. \t#in\n",
      "z1 = 8.\n",
      "z2 = 5.\n",
      "\t\n",
      "#calculations\n",
      "x1 = ken+kex+f*l*12/dia\n",
      "t = 35.5*2/3 *(z1**(3./2) - z2**(3./2))\n",
      "\t\n",
      "#Results\n",
      "print \"Time reqired  =  %.f s\"%(t)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time reqired  =  271 s\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.2 Page No : 451"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#Initialization of variables\n",
      "print (\"For steady state, dV/dt  = 0\")\n",
      "Q = 1600./449  #steady flow rate\n",
      "A2 = 0.1963\n",
      "g = 32.2\n",
      "rp2 = 2000.  #speed of rotation - rpm\n",
      "\t\n",
      "#calculations\n",
      "V2 = Q/A2\n",
      "hp1 = 32*V2**2 /(2*g) -50\n",
      "hp2 = hp1*(rp2/1650)**2\n",
      "hpf = 169. \t#ft\n",
      "Q = 4.1 \t#cfs\n",
      "\t\n",
      "#Results\n",
      "print \"Steady state flow rate  =  %.2f cfs\"%(Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For steady state, dV/dt  = 0\n",
        "Steady state flow rate  =  4.10 cfs\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.3 Page No : 455"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from numpy import *\n",
      "\t\n",
      "#Initialization of variables\n",
      "kl = 0.5\n",
      "f = 0.02\n",
      "L = 15. \t#length - m\n",
      "D = 0.1 \t#ft\n",
      "k = 3.5\n",
      "g = 9.81\n",
      "H = 2.\t#ft\n",
      "\t\n",
      "#calculations\n",
      "k = kl+f*L/D\n",
      "V0 = math.sqrt(2*g*H/(1+k))\n",
      "Q = array([0.25, 0.5, 0.75])\n",
      "V = V0*Q\n",
      "Vfun = (2.95+V)/(2.95-V)\n",
      "lnVfun = log(Vfun)\n",
      "t = 1.129*lnVfun\n",
      "\n",
      "print \"ln        t,s\"\n",
      "#Results\n",
      "for i in range(len(t)):\n",
      "    print \"%.3f     %.3f\"%(lnVfun[i],t[i])\n",
      "\n",
      "print (\"Similarly, it can be calculated for L = 150,1500 ft\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ln        t,s\n",
        "0.511     0.577\n",
        "1.100     1.242\n",
        "1.949     2.201\n",
        "Similarly, it can be calculated for L = 150,1500 ft\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.4 Page No : 462"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#Initialization of variables\n",
      "Q = 30. \t#cfs\n",
      "r = 2.  \t#ft\n",
      "cp = 3200.\n",
      "rho = 1.94\n",
      "Q2 = 10. \t#cfs\n",
      "z = 300. \t#ft\n",
      "\t\n",
      "#calculations\n",
      "V = Q/(math.pi*r**2)\n",
      "ph = rho*cp*V/144\n",
      "phd = 4000/cp /(2*r) *ph\n",
      "dV = (Q2-Q)/(math.pi*r**2)\n",
      "dph = -rho*cp*dV/144\n",
      "ph3 = rho*cp*V/3 /144\n",
      "ph4 = ph3*z*2/cp\n",
      "\t\n",
      "#Results\n",
      "print \"Water hammer pressure =  %.1f psi\"%(ph)\n",
      "print \" Water hammer pressure in case 2 =  %.1f psi\"%(phd)\n",
      "print \" Water hammer pressure in case 3 =  %.1f psi\"%(dph)\n",
      "print \" Pressure at valve in case 4  =  %.1f psi\"%(ph3)\n",
      "print \" Pressure at 300 ft from reservoir  =  %.2f psi\"%(ph4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Water hammer pressure =  102.9 psi\n",
        " Water hammer pressure in case 2 =  32.2 psi\n",
        " Water hammer pressure in case 3 =  68.6 psi\n",
        " Pressure at valve in case 4  =  34.3 psi\n",
        " Pressure at 300 ft from reservoir  =  6.43 psi\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}