{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 9 : Second law of thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.1 pageno : 308"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "t2 = 300;\t\t\t#temperature of the math.sink in K\n",
      "n1 = 0.4;\t\t\t#efficiency of the engine\n",
      "n2 = 0.6;\t\t\t#efficiency of the engine\n",
      "\n",
      "# Calculations\n",
      "t1 = t2/(1-n1);\t\t\t#temperature of the source in K\n",
      "t3 = t2/(1-n2);\t\t\t#temperature of the source in K\n",
      "\n",
      "# Result\n",
      "print 'the temperature of the source when 0.4 efficiency is %3.2f K  \\\n",
      "\\nthe temperature of the source when 0.6 efficiency is %3.2f K'%(t1,t3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the temperature of the source when 0.4 efficiency is 500.00 K  \n",
        "the temperature of the source when 0.6 efficiency is 750.00 K\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.2 pageno : 308"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "t2 = 273.;\t\t\t#temperature of the math.sink in K\n",
      "t1 = 373.;\t\t\t#temperature of the source in K\n",
      "q1 = 840.;\t\t\t#heat supplied in joules\n",
      "j = 4.2;\t\t\t#joukes constant in erg/cal\n",
      "\n",
      "# Calculations\n",
      "w = (q1/t1)*(t1-t2);\t\t\t#work done in joules\n",
      "q2 = (q1/j)*(t2/t1);\t\t\t#heat rejected in calories\n",
      "n = 1-(t2/t1);\t\t\t#efficiency of the engine\n",
      "\n",
      "# Result\n",
      "print 'work done is %3.f j  \\\n",
      "\\nheat rejected is %3.f cal  \\\n",
      "\\nthe efficiency of the engine is %3.1f %%'%(w,q2,n*100)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "work done is 225 j  \n",
        "heat rejected is 146 cal  \n",
        "the efficiency of the engine is 26.8 %\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.3 pageno : 309"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "t1 = 90.;\t\t\t#temperature of the oxygen boils in K\n",
      "t2 = 20.;\t\t\t#temperature of the liquid hydrogen in K\n",
      "t3 = 300.;\t\t\t#temperature of the sink in K\n",
      "\n",
      "# Calculations\n",
      "n = (t1-t2)/t1;\t\t\t#efficiency of the engine\n",
      "t4 = t3/(1-n);\t\t\t#temperature of the source in K\n",
      "\n",
      "# Result\n",
      "print 'the efficiency of the engine is %3.2f  \\\n",
      "\\nthe temperature of the source is %3.2f K'%(n,t4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the efficiency of the engine is 0.78  \n",
        "the temperature of the source is 1350.00 K\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.4 pageno : 309"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "t1 = 373.;\t    \t    \t#temperature of the source in K\n",
      "t2 = 273.;\t\t    \t    #temperature of the sink in K\n",
      "w = 1200*10**5*980;\t\t\t#work done in ergs\n",
      "j = 4.18*10**7;\t\t    \t#joules constant in ergs/cal\n",
      "\n",
      "# Calculations\n",
      "q = (w/j)*(t1/(t1-t2));\t\t\t#heat added in cal\n",
      "\n",
      "# Result\n",
      "print 'the heat added is %3.2f cal'%(round(q,-1))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the heat added is 10490.00 cal\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.5 pageno : 309"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "t1 = 273.;\t\t\t#temperature of the source in K\n",
      "t2 = 290.;\t\t\t#temperature of the sink in K\n",
      "l = 8*10.**11;\t\t\t#latent of fusion in ergs/cal\n",
      "\n",
      "# Calculations\n",
      "n = (t2-t1)/t1;\t\t\t#efficiency of the engine\n",
      "w = n*l;\t\t\t#energy to be supplied in ergs\n",
      "\n",
      "# Result\n",
      "print 'efficiency of the engine is %.2f %%  \\\n",
      "\\nenergy to be supplied is %.3e ergs'%(n*100,w)\n",
      "print \"Note: answer in book are wrong please calculate manually.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "efficiency of the engine is 6.23 %  \n",
        "energy to be supplied is 4.982e+10 ergs\n",
        "Note: answer in book are wrong please calculate manually.\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.6 pageno : 309"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "t1 = 373;\t\t\t#temperature in K\n",
      "t2 = 273;\t\t\t#temperature of math.sink in K\n",
      "q = 10**4;\t\t\t#heat taken at higher temperature in cal\n",
      "j = 4.2*10**7;\t\t\t#joules consmath.tant in ergs/cal\n",
      "\n",
      "# Calculations\n",
      "w = q*j*(t1-t2)/t1;\t\t\t#work done in ergs\n",
      "\n",
      "# Result\n",
      "print 'work done is %.1e ergs'%(w)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "work done is 1.1e+11 ergs\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.7 page no : 310"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "# Variables\n",
      "p = 100*746/4.2;\t\t\t#power developed in cal/sec\n",
      "t1 = 300.;\t\t\t#temperature of the sink in K\n",
      "t2 = 500.\n",
      "\n",
      "# Calculations\n",
      "te = 1 - (t1/t2)\n",
      "Q1 = p * 100/40        # heat supplied\n",
      "Q2 = Q1 * 0.6\n",
      "\n",
      "\n",
      "# Result\n",
      "print \"Thermal efficiency = %.f %%\"%(te*100)\n",
      "print \"Power developed by the engine %.2f calories/sec\"%p\n",
      "print \"If Q1 heat supplied , Q1 = %.2e cal/sec\"%Q1\n",
      "print \"Q2 = %.2e cal/sec\"%Q2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency = 40 %\n",
        "Power developed by the engine 17761.90 calories/sec\n",
        "If Q1 heat supplied , Q1 = 4.44e+04 cal/sec\n",
        "Q2 = 2.66e+04 cal/sec\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.8 page no : 310"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "l = 964.8;\t\t\t#latent heat of steam in B.Th.U per lb\n",
      "q = 4*15*l*778;\t\t\t#heat developed in ft lbs\n",
      "w = 30000*60;\t\t\t#work done is ft lbs\n",
      "pv = 12*1.013*10**6*10**3 \n",
      "T = 600                # K\n",
      "\n",
      "# Calculations\n",
      "n = (w/q)*100;\t\t\t#efficiency of the engine\n",
      "p = 100-n;\t\t\t#percentage of heat wasted\n",
      "T2 = 600./(6**.4)\n",
      "R = pv/T\n",
      "W = R * (T - T2) * 2.303 * math.log10(6)\n",
      "e = 1 - (T2/T)\n",
      "# Result\n",
      "print \"Lowest temperature T2 = %.f K\"%T2\n",
      "print \"Work done W = %.2e ergs\"%W\n",
      "print \"Efficiency = %.1f %%\"%(e*100)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Lowest temperature T2 = 293 K\n",
        "Work done W = 1.11e+10 ergs\n",
        "Efficiency = 51.2 %\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.9 page no : 311"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "l=964.8;            #latent heat of steam in B.Th.U per lb\n",
      "q=4*15*l*778;       #heat developed in ft lbs\n",
      "w=33000*60;         #work done is ft lbs\n",
      "\n",
      "#CALCULATIONS\n",
      "n=(w/q)*100;       #efficiency of the engine\n",
      "p=100-n;          #percentage of heat wasted\n",
      "\n",
      "# Results\n",
      "print ('the percentage of the heat wasted is %3.2f'%p)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the percentage of the heat wasted is 95.60\n"
       ]
      }
     ],
     "prompt_number": 49
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.10 page no : 311"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "ip = 16.3*500*778/33000;\t\t\t# Variables power of the engine in HP\n",
      "me = 0.72;\t\t\t#mechanical efficiency of the engine\n",
      "bhp = 31;\t\t\t#brake horse power in b.h.p\n",
      "ihp = bhp/me;\t\t\t#indicated horse power in HP\n",
      "\n",
      "# Calculations\n",
      "i = ihp/ip;\t\t\t#indicated thermal efficiency\n",
      "\n",
      "# Result\n",
      "print 'the indicted thermal efficiency is %3.2f %%'%(i*100)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the indicted thermal efficiency is 22.41 %\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.11 pageno : 312"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "p = 200.;\t\t\t#horse power of steam engine in lbs coal per hour\n",
      "j = 770.;\t\t\t#joules constant in ft lbs per B.Th.U\n",
      "\n",
      "# Calculations\n",
      "w = 12500*p*j;\t\t\t#equivalent work in ft.lb.per.hr\n",
      "hp = w/(60*33000);\t\t\t#horse power\n",
      "\n",
      "# Result\n",
      "print 'horse power of the engine is %3.2f'%(hp)\n",
      "print \"Note : answer in book is wrong. Please check manually.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "horse power of the engine is 972.22\n",
        "Note : answer in book is wrong. Please check manually.\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.12 pageno  : 312"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "t1 = 340.;\t\t\t#temperature of the atmosphere in K\n",
      "t2 = 612.;\t\t\t#temperature of the compression stroke in K\n",
      "y = 1.39;\t\t\t#adiabatic expansion \n",
      "t3 = 2040.;\t\t\t#temperature after consmtant volume ignition in K\n",
      "\n",
      "# Calculations\n",
      "d = (t2/t1)**(1/(y-1))\t\t\t#density in gm/cc\n",
      "n = 1-(1/d)**(y-1);\t\t    \t#efficiency of the engine\n",
      "p = ((d)**(y))*(t3/t2);\t\t\t#maximum temperature of the temperature in atm\n",
      "\n",
      "# Result\n",
      "print 'the maximum pressure of the engine is %3.f atm'%(p)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the maximum pressure of the engine is  27 atm\n"
       ]
      }
     ],
     "prompt_number": 43
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.13 pageno : 313"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "t1 = 915;\t\t\t#temperature at the beggining in K\n",
      "t2 = 2040;\t\t\t#temperature at the end in K\n",
      "d = 12.6;\t\t\t#adiabatic expansion ratio\n",
      "y = 1.39;\t\t\t#coefficent of expansion\n",
      "\n",
      "# Calculations\n",
      "x = t2/t1                               \t\t\t#ratio temparatures\n",
      "n = 1-(1/d)**(y-1)*((x**y)-1)/(y*(x-1));\t\t\t#efficiency of the engine\n",
      "\n",
      "# Result\n",
      "print 'the efficiency of the engine is %3.3f'%(n)\n",
      "print \"Note : answer slighty different because of rounding error\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the efficiency of the engine is 0.566\n",
        "Note : answer slighty different because of rounding error\n"
       ]
      }
     ],
     "prompt_number": 40
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.14 pageno : 313"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "p1 = 15.;\t\t\t#intial pressure in lb/sq.inch\n",
      "dv = 15.;\t\t\t#ratio of intial to final volume\n",
      "t1 = 520.;\t\t\t#temperature at intial in K\n",
      "y = 1.4;\t\t\t#coefficient of expansion\n",
      "\n",
      "# Calculations\n",
      "p2 = p1*(dv)**(y);\t\t\t#final pressure in lb/sq.inch\n",
      "t2 = t1*(dv)**(y-1);\t\t\t#final temperatire in K\n",
      "\n",
      "# Result\n",
      "print 'the final pressure is %3.2f lb/sq.inch  \\\n",
      "\\nthe final temperature is %.f K'%(p2,t2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the final pressure is 664.69 lb/sq.inch  \n",
        "the final temperature is 1536 K\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}