{
 "metadata": {
  "name": "",
  "signature": "sha256:8b62be1f41dd311c1ab38e8f1f5050fc85b3e25eb123d081120fb3bbfeaaa74a"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6 :\n",
      "The second law of\n",
      "thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.1 pg : 140"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "m = 5. \t    \t    \t#lbm\n",
      "P = 50. \t    \t\t#psia\n",
      "T = 500. + 460 \t\t\t#R\n",
      "\t\t\t\n",
      "# Calculations\n",
      "s1 = 0.4110 \t\t\t#B/lbm R\n",
      "s2 = 1.7887 \t\t\t#B/lbm R\n",
      "dS = m*(s2-s1)\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Change in entropy  =  %.3f B/R\"%(dS)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in entropy  =  6.888 B/R\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2 pg : 140"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "P = 20.          \t\t\t#psia\n",
      "T = 227.96+ 459.69 \t\t\t#R\n",
      "\t\t\t\n",
      "# Calculations\n",
      "sfg = 1.3962 \t\t\t#B/ R lbm\n",
      "Q = T*sfg\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"heat transfer  =  %.1f B/lbm\"%(Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "heat transfer  =  960.1 B/lbm\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.3 pg : 141"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables\n",
      "T1 = 100.+460 \t\t\t#R\n",
      "P1 = 15.    \t\t\t#psia\n",
      "P2 = 50. \t    \t\t#psia\n",
      "n = 1.3\n",
      "cp = 0.24\n",
      "\t\t\t\n",
      "# Calculations\n",
      "T2 = T1*(P2/P1)**((n-1)/n)\n",
      "dS = cp*math.log(T2/T1) - 53.35/778 *math.log(P2/P1) \n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Change in entropy  =  %.3f B/lbm R\"%(dS)\n",
      "\t\t\t#the answer given in textbook is wrong. Please check it using a calculator\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in entropy  =  -0.016 B/lbm R\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.4 pg : 141"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables\n",
      "T1 = 85.+460 \t\t\t#R\n",
      "T2 = T1\n",
      "cp = 0.24\n",
      "P2 = 15. \t\t\t#psia\n",
      "P1 = 30. \t\t\t#psia\n",
      "\t\t\t\n",
      "# Calculations\n",
      "dS = cp*math.log(T2/T1) - 53.35/778 *math.log(P2/P1)\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Change in entropy  =  %.4f B/lbm R\"%(dS)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in entropy  =  0.0475 B/lbm R\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5 pg : 142"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "Qh = -1000. \t\t\t#Btu\n",
      "Ql = 1000.   \t\t\t#Btu\n",
      "Th = 1460. \t    \t\t#R\n",
      "Tl = 960. \t\t    \t#R\n",
      "\t\t\t\n",
      "# Calculations\n",
      "Sh = Qh/Th\n",
      "Sl = Ql/Tl\n",
      "S = Sh+Sl\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Change in entropy of the universe  =  %.3f B/R\"%(S)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in entropy of the universe  =  0.357 B/R\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.6 pg : 143"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "h1 = 1416.4 \t\t\t#B/lbm\n",
      "s1 = 1.6842 \t\t\t#B/lbm R\n",
      "\t\t\t\n",
      "# Calculations\n",
      "s2 = s1\n",
      "P2 = 50. \t\t\t#psia\n",
      "T2 = 317.5 \t\t\t#F\n",
      "h2 = 1193.7\n",
      "W = h2-h1\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Work calculated  =  %.1f B/lbm\"%(W)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work calculated  =  -222.7 B/lbm\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}