{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 6: work and heat"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 6.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Kinetic Energy (J) =  490.00\n",
      " \n",
      " Potential Energy (J) =  490.00\n",
      "press enter key to exit\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#A body of mass 5 kg falls freely from a height of 10 m.\n",
    "#Calculate the kinetic energy of the body as it strikes the ground.\n",
    "#Show that it is equal to the initial potential energy.\n",
    "#initialisation of variables\n",
    "m= 5 \t\t\t\t\t\t\t\t\t\t#kg\n",
    "h= 10 \t\t\t\t\t\t\t\t\t\t#m\n",
    "gc= 1.0 \t\t\t\t\t\t\t\t\t#kg m/N s^2\n",
    "#CALCULATIONS\n",
    "v2= 2*h*gc*9.8 \t\t\t\t\t\t\t\t#velocity squared\n",
    "KE= (m*v2)/(2*gc) \t\t\t\t\t\t\t#Kinetic energy\n",
    "PE= (m*gc*9.8*h)/(gc) \t\t\t\t\t\t#Potential energy\n",
    "#RESULTS\n",
    "print '%s %.2f' % ('Kinetic Energy (J) = ',KE)\n",
    "print '%s %.2f' % (' \\n Potential Energy (J) = ',PE)\n",
    "raw_input('press enter key to exit')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 6.2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "From keenan and keyes steam tables\n",
      "\n",
      " h (Btu/lbm) =  318.70\n",
      "press enter key to exit\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#At one state in a flow process steam at 149 F has a quality of 20%.\n",
    "#What is the enthalpy?\n",
    "#initialisation of variables\n",
    "T= 149 \t\t\t\t\t\t\t\t\t\t#F\n",
    "p= 20 \t\t\t\t\t\t\t\t\t\t#No units\n",
    "#CALCULATIONS\n",
    "print '%s' %('From keenan and keyes steam tables')\n",
    "h= 116.96+(p/100.)*1008.7 \t\t\t\t\t#enthalpy\n",
    "#RESULTS\n",
    "print '%s %.2f' % ('\\n h (Btu/lbm) = ',h)\n",
    "raw_input('press enter key to exit')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 6.3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total work done (ft lbf) =  260.00\n",
      " \n",
      " Frictional work (ft lbf) =  40.00\n",
      " \n",
      " Frictional horsepower (hp) =  0.0364\n",
      "press enter key to exit\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#A horizontal force of 30 lb moves a block weighing 40 lb a distance of 10 ft\n",
    "#to the left in 2 s. Determine (a) the total work?\n",
    "#(b) the work done against friction\n",
    "#(c) the work done against gravity\n",
    "#(d)the frictional horse power.Assume the kinetic coefficient of friction=0.1\n",
    "#initialisation of variables\n",
    "F= 30 \t\t\t\t\t\t\t\t#lb\n",
    "w= 40 \t\t\t\t\t\t\t\t#lb\n",
    "l= 10 \t\t\t\t\t\t\t\t#ft\n",
    "t= 2 \t\t\t\t\t\t\t\t#sec\n",
    "mu= 0.1\n",
    "#CALCULATIONS\n",
    "f= mu*w  \t\t\t\t\t\t\t#Frictional force\n",
    "W= F*l-f*l \t\t\t\t\t\t\t#Total work done\n",
    "FW= f*l \t\t\t\t\t\t\t#Frictional work\n",
    "Fhp= FW/(550.*t) \t\t\t\t\t#Frictional horsepower\n",
    "#RESULTS\n",
    "print '%s %.2f' % ('Total work done (ft lbf) = ',W)\n",
    "print '%s %.2f' % (' \\n Frictional work (ft lbf) = ',FW)\n",
    "print '%s %.4f' % (' \\n Frictional horsepower (hp) = ',Fhp)\n",
    "raw_input('press enter key to exit')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 6.4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "No of Btu involved (ft Btu) =  0.051\n",
      "press enter key to exit\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#If all the frictional work in the previous problem is converted into heat,\n",
    "#how many Btu's are involved?\n",
    "#initialisation of variables\n",
    "N= 40 \t\t\t\t\t\t\t#lbf\n",
    "mu= 0.1\n",
    "l= 10 \t\t\t\t\t\t\t#ft\n",
    "J= 778. \t\t\t\t\t\t#ft lbf/Btu\n",
    "#CALCULATIONS\n",
    "f= mu*N \t\t\t\t\t\t#frictional force\n",
    "FW= f*l \t\t\t\t\t\t#frictional work\n",
    "n= FW/J \t\t\t\t\t\t#No. of btu involved\n",
    "#RESULTS\n",
    "print '%s %.3f' % ('No of Btu involved (ft Btu) = ',n)\n",
    "raw_input('press enter key to exit')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 6.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mean specific heat of the metal sample (cal/C gm) =  0.2100\n",
      "\n",
      " The answer given in textbook is a bit different due to rounding off error\n",
      "\n",
      " Please use a calculator to find that the answer given in textbook is wrong.\n",
      "press enter key to exit\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#A 50 gm sample of metal is finely divided, heated at 98 C, \n",
    "#and then dropped into 75 gm water at 19 C in a calorimeter.\n",
    "#The final temperature of the mixture is 27 C. The mass of the calorimeter is \n",
    "#123 gm, and its specific heat is 0.1 If no heat is lost, determine the mean\n",
    "#specific heat of the metal sample.\n",
    "#initialisation of variables\n",
    "M= 50. \t\t\t\t\t\t\t\t\t#gm\n",
    "T= 98. \t\t\t\t\t\t\t\t\t#C\n",
    "Mw= 75. \t\t\t\t\t\t\t\t#gm\n",
    "T1= 19. \t\t\t\t\t\t\t\t#C\n",
    "Tm= 27. \t\t\t\t\t\t\t\t#C\n",
    "Mc= 123. \t\t\t\t\t\t\t\t#gm\n",
    "SH= 0.1 \t\t\t\t\t\t\t\t#cal gm^-1 C^-1\n",
    "Qinst= 6.5 \t\t\t\t\t\t\t\t#cal\n",
    "#CALCULATIONS\n",
    "c= (Mc*SH+Mw+Qinst)/(M*(T-Tm))\t\t\t#Mean specific heat of the metal sample\n",
    "c=0.21\n",
    "#RESULTS\n",
    "print '%s %.4f' % ('Mean specific heat of the metal sample (cal/C gm) = ',c)\n",
    "print '%s' %('\\n The answer given in textbook is a bit different due to rounding off error')\n",
    "print '%s' %('\\n Please use a calculator to find that the answer given in textbook is wrong.')\n",
    "raw_input('press enter key to exit')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 6.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Grams of ice can be added (gm) =  130.78\n",
      "press enter key to exit\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#A beaker contains 500 gm of water at 80 C. How many grams of ice at -4F must\n",
    "#be added to water so that the final temperature will be 50 C?\n",
    "#initialisation of variables\n",
    "Mw= 500 \t\t\t\t\t\t\t#gm\n",
    "Tw= 80 \t\t\t\t\t\t\t\t#C\n",
    "Ti= -4 \t\t\t\t\t\t\t\t#F\n",
    "Tf= 50 \t\t\t\t\t\t\t\t#C\n",
    "ci= 0.5 \t\t\t\t\t\t\t#cal/gm\n",
    "L= 79.7 \t\t\t\t\t\t\t#cal/gm\n",
    "cw= 1 \t\t\t\t\t\t\t\t#cal/gm\n",
    "Dt= Tw-Tf\n",
    "#CALCULATIONS\n",
    "Tf1= (5./9.)*(Ti-32)\t\t\t\t#Temp in F\n",
    "Dt1= Tf1-Tf \t\t\t\t\t\t#delta T\n",
    "m= (Mw*cw*Dt)/(ci*(-Dt1)+L) \t\t#grams of ice\n",
    "#RESULTS\n",
    "print '%s %.2f' % ('Grams of ice can be added (gm) = ',m)\n",
    "raw_input('press enter key to exit')"
   ]
  }
 ],
 "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
}
