{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 10 : Pumps compressors and turbines"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 10.1 page no : 362"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The efficiency of the pump is 0.729167\n"
     ]
    }
   ],
   "source": [
    "#Calculate the efficiency of a pump\n",
    "\n",
    "# variables\n",
    "Q=50.                           #gal/min\n",
    "P1=30.                          #psia 0r lbf/in**2\n",
    "P2=100.                         #psia 0r lbf/in**2\n",
    "dP=P2-P1                        #psia 0r lbf/in**2\n",
    "power=2.8                       #hp\n",
    "\n",
    "# calculation\n",
    "#1 ft = 12 in\n",
    "#1 hp.min = 33000 lbf.ft\n",
    "#1 gal = 231 in**3\n",
    "eta=(Q*dP/power)*(1/33000.0)*231*(1/12.0)           #dimentionless\n",
    "\n",
    "# result\n",
    "print \"The efficiency of the pump is %f\"%eta"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 10.2 page no : 366"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the maximum elevation above the lowest water level in sump at which pump inlet can be placed is 19.770533 ft\n"
     ]
    }
   ],
   "source": [
    "#Calculate the maximum elevation above the lowest water level in sump at which pump inlet can be placed\n",
    "\n",
    "# variables\n",
    "P1=3.72                  #psia 0r lbf/in**2\n",
    "P2=14.5                  #psia 0r lbf/in**2\n",
    "dP=P2-P1                 #psia 0r lbf/in**2\n",
    "rho=61.3                 #lbm/ft**3\n",
    "g=32.2                   #ft/s**2\n",
    "\n",
    "# calculation\n",
    "#1 ft = 12 in\n",
    "#1 lbf.s**2 = 32.2 lbm.ft\n",
    "h_loss=4                 #ft\n",
    "v=10                     #ft/s\n",
    "h_max=(dP/rho/g)*144*32.2-(v**2/2.0/g)-h_loss                    #ft\n",
    "\n",
    "# result\n",
    "print \"the maximum elevation above the lowest water level in sump at which pump inlet can be placed is %f ft\"%h_max"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 10.3 page no : 370"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The work required per pound mole for a 100 percent efficient isothermal compressor is 2415.724914  Btu/lbmol\n",
      "\n",
      "The work required per pound mole for a 100 percent efficient adiabatic compressor is 3417.499724  Btu/lbmol\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#Calculate the work requird per pound mole for a 100% efficient isothermal and adiabatic compressor\n",
    "import math\n",
    "\n",
    "# variables\n",
    "R=1.987                          #Btu/lbmol/R (universal gas constant)\n",
    "T=528.                           #R (Rankine temperature scale)\n",
    "ratio_P=10.                      #dimentionless\n",
    "\n",
    "# calculations and results\n",
    "#for isothermal compressor\n",
    "W1=R*T*math.log(ratio_P)         #Btu/lbmol\n",
    "print \"The work required per pound mole for a 100 percent efficient isothermal compressor is %f \"%W1,\"Btu/lbmol\\n\"\n",
    "\n",
    "#for adiabatic compressor\n",
    "gama=1.4#dimentionless\n",
    "W2=(gama/(gama-1))*R*T*(ratio_P**((gama-1)/gama)-1)#Btu/lbmol\n",
    "print \"The work required per pound mole for a 100 percent efficient adiabatic compressor is %f \"%W2,\"Btu/lbmol\\n\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 10.4 page no : 370"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The work required per pound mole for a 100 percent efficient adiabatic compressor is 2861.592127  Btu/lbmol\n"
     ]
    }
   ],
   "source": [
    "#Calculate the work requird per pound mole for a 100% efficient 2 stage adiabatic compressor\n",
    "\n",
    "# variables\n",
    "R=1.987                              #Btu/lbmol/R (universal gas constant)\n",
    "T=528.0                              #R (Rankine temperature scale)\n",
    "ratio_P1=3                           #dimentionless\n",
    "ratio_P2=10/3.0                      #dimentionless\n",
    "gama=1.4                             #dimentionless\n",
    "\n",
    "# calculation\n",
    "W=(gama/(gama-1))*R*T*((ratio_P1**((gama-1)/gama)-1)+(ratio_P2**((gama-1)/gama)-1))       #Btu/lbmol\n",
    "\n",
    "# result\n",
    "print \"The work required per pound mole for a 100 percent efficient adiabatic compressor is %f \"%W,\n",
    "print \"Btu/lbmol\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 10.5 page no : 373"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The pump head is 112.471747 ft\n"
     ]
    }
   ],
   "source": [
    "#Calculate the pump head\n",
    "import math\n",
    "\n",
    "# variables\n",
    "N=1750.                                       #rev/min\n",
    "#1 min 60 sec\n",
    "omega=2*(math.pi)*N/60                        #radians/sec\n",
    "Q=100.                                        #gal/min\n",
    "#1 gallon = 231 in**3\n",
    "#1 ft =12 in\n",
    "#1 min = 60 sec\n",
    "d_inlet = 2.067                               #ft\n",
    "\n",
    "# calculations\n",
    "A_inlet=(math.pi)/4.*(d_inlet**2)             #ft**2\n",
    "V1=(Q/A_inlet)*231/60.0/12.0                  #ft/s\n",
    "d_outlet = 1.61                               #ft\n",
    "A_outlet=(math.pi)/4*(d_outlet**2)            #ft**2\n",
    "V2=(Q/A_outlet)*231/60.0/12.0                 #ft/s\n",
    "g=32.2                                        #ft/s**2\n",
    "d_inner=0.086                                 #ft\n",
    "d_outer=0.336                                 #ft\n",
    "h=(omega)**2/g*((d_outer**2)-(d_inner)**2)+(V2**2-V1**2)/2./g               #ft\n",
    "\n",
    "#result\n",
    "print \"The pump head is %f ft\"%h"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 10.6 page no : 378"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The pump head is 2.734925 ft\n"
     ]
    }
   ],
   "source": [
    "#Calculate the pump head\n",
    "\n",
    "# variables\n",
    "rho=62.3                 #lbm/ft**3\n",
    "g=32.2                   #ft/s**2\n",
    "v=18.46                  #ft/s\n",
    "\n",
    "# calculation\n",
    "#1 lbf/s**2 = 32.2 lbm.ft\n",
    "h=1/(rho*g) * (v**2/2)*32.2              #ft\n",
    "\n",
    "# result\n",
    "print \"The pump head is %f ft\"%h"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 10.7 page no : 381"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the estimated pressure rise in the first stage of mutisatge centrifugal compressor is 8.865562 psia\n"
     ]
    }
   ],
   "source": [
    "#Calculate the estimated pressure rise in the first stage of mutisatge centrifugal compressor\n",
    "\n",
    "# variables\n",
    "rho=0.075                    #lbm/ft**3\n",
    "omega=1047.                  #rad/sec\n",
    "d=2.                         #ft\n",
    "\n",
    "# calculation\n",
    "dP=(1/2.0)*(rho)*(omega*d/2.0)**2/32.2/144.0                 #psia\n",
    "#1 lbf.s**2 = 32.2 lbm into feed\n",
    "#1 ft = 144 in**2\n",
    "\n",
    "# result\n",
    "print \"the estimated pressure rise in the first stage of mutisatge centrifugal compressor is %f psia\"%dP"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 10.8 page no : 383"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The efficiency of the compressor is 0.749243\n",
      "dT_real = 190 K\n",
      "dT_isentropic = 142 K\n"
     ]
    }
   ],
   "source": [
    "#Calculate the efficiency of a compressor and the change respective change in temperature\n",
    "\n",
    "# variables\n",
    "m=100.0                       #Kg/hr\n",
    "M=29.                         #gm/mol\n",
    "gama=1.4                      #dimentionless\n",
    "R=8.314                       #J/mol/K\n",
    "T=293.15                      #K\n",
    "ratio_P=4.                    #dimentionless\n",
    "\n",
    "# calculations\n",
    "Po=(m/M)*R*T*(gama/(gama-1))*((ratio_P)**((gama-1)/gama)-1)/3600.0              #kW\n",
    "P_real=5.3                    #kW\n",
    "eta=Po/P_real                 #dimentionless\n",
    "\n",
    "# result\n",
    "print \"The efficiency of the compressor is %f\"%eta\n",
    "Cp=29.1                       #J/mol/K\n",
    "dT_real=P_real*(M/m)*3600/Cp                      #K\n",
    "print \"dT_real = %d K\"%dT_real\n",
    "dT_isentropic=Po*(M/m)*3600/Cp                    #K\n",
    "print \"dT_isentropic = %d K\"%dT_isentropic"
   ]
  }
 ],
 "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
}
