{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3 - Temperature and Heat"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - Pg 33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the mass of water required per pound of iron \n",
      "import math\n",
      "#Initialization of variables\n",
      "T1=500 #F\n",
      "T2=100 #F\n",
      "Tf=75 #F\n",
      "cpi=0.120 #B/lb F\n",
      "cpw=1.0 #B/lb F\n",
      "#calculations\n",
      "Qw=1*cpw*(T2-Tf)\n",
      "Qi=-1*cpi*(T2-T1)\n",
      "mw=Qi/Qw\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Mass of water = \",mw,\"lb water/lb iron\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass of water =  1.92 lb water/lb iron\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - Pg 34"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the net heat transferred\n",
      "import math\n",
      "import scipy\n",
      "from scipy import integrate\n",
      "#Initialization of variables\n",
      "m=5 #lb\n",
      "T1=1540+460  #R\n",
      "T2=540+460  #R\n",
      "#calculations\n",
      "def q(T):\n",
      "\tcp=m*(0.248+0.448*math.pow(10,-8) *T*T)\n",
      "\treturn cp;\n",
      "\n",
      "Q=scipy.integrate.quad(q,T1,T2)\n",
      "#results\n",
      "print '%s %d %s' %(\"Heat transferred =\",Q[0],\"Btu\")\n",
      "print '%s' %(\"The answer is a bit different due to rounding off error in textbook\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat transferred = -1292 Btu\n",
        "The answer is a bit different due to rounding off error in textbook\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - Pg 36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the heat required for the process\n",
      "#Initialization of variables\n",
      "Tm=235 #F\n",
      "Tb=832 #F\n",
      "T=70 #F\n",
      "cps=0.18 #B/lb F\n",
      "cpl=0.235 #B/lb F\n",
      "Lf=15.8 #B/lb\n",
      "Lv=120 #B/lb\n",
      "m=10 #lb\n",
      "#calculations\n",
      "Qa=m*cps*(Tm-T)\n",
      "Qb=m*Lf\n",
      "Qc=m*cpl*(Tb-Tm)\n",
      "Qd=m*Lv\n",
      "Q=Qa+Qb+Qc+Qd\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Heat required =\",Q,\"Btu\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat required = 3057.9 Btu\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4 - Pg 36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the mass of ice required for the process\n",
      "#Initialization of variables\n",
      "T1=22 #F\n",
      "T2=32 #F\n",
      "T3=40 #F\n",
      "T4=70 #F\n",
      "cps=0.501 #B/lb F\n",
      "cpw=1 #B/lb F\n",
      "Lf=143.3 #B/lb\n",
      "m=40 #lb\n",
      "#calculations\n",
      "Qa=cps*(T2-T1)\n",
      "Qb=Lf\n",
      "Qc=cpw*(T3-T2)\n",
      "Qd=m*cpw*(T3-T4)\n",
      "mi=-Qd/(Qa+Qb+Qc)\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Mass of ice required  =\",mi,\"lb ice\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass of ice required  = 7.68 lb ice\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5 - Pg 37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the extra mass of ice required\n",
      "#Initialization of variables\n",
      "T1=22 #F\n",
      "T2=32 #F\n",
      "T3=40 #F\n",
      "T4=70 #F\n",
      "cps=0.501 #B/lb F\n",
      "cpw=1 #B/lb F\n",
      "Lf=143.3 #B/lb\n",
      "m=40 #lb\n",
      "cp=0.092\n",
      "mc=10\n",
      "#calculations\n",
      "Qa=cps*(T2-T1)\n",
      "Qb=Lf\n",
      "Qc=cpw*(T3-T2)\n",
      "Qe=mc*cp*(T3-T4)\n",
      "mi=-Qe/(Qa+Qb+Qc)\n",
      "#results\n",
      "print '%s %.3f %s' %(\"Extra Mass of ice required  =\",mi,\"lb ice\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Extra Mass of ice required  = 0.177 lb ice\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}