{
 "metadata": {
  "name": "",
  "signature": "sha256:2d67a927dfb7c5a82b8b43df0005a44016d56976a1ce99d5ed2f07fea412a913"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter2-Energy Sources\n"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "## Example 2.1\n",
      "print('Example 2.1\\n\\n');\n",
      "print('Page No. 44\\n\\n');\n",
      "\n",
      "## given\n",
      "C= 35000.;## cost of boiler\n",
      "C_grant=.25;## Capital grant available from goverment\n",
      "E= -(C-(C_grant*C));## Net expenditure\n",
      "Fs= 15250.;## Fuel Saving\n",
      "r_i = 0.15;## interest\n",
      "r_t = 0.55;## tax\n",
      "\n",
      "a = ([0, E ,Fs ,0 ,E+Fs, r_i*(E+Fs) ,0 ])\n",
      "bal_1 = a[4]+a[5]-a[6]## Total Balance after 1st year\n",
      "\n",
      "c_all = 0.55;## capital allowance in 2nd year\n",
      "C_bal= (bal_1+0+Fs+(-(c_all*E)));## Cash Balance after 2nd year\n",
      "b = ([bal_1 ,0 ,Fs ,-(c_all*E) ,C_bal, r_i*C_bal, r_t*(Fs+(r_i*C_bal))]);\n",
      "bal_2 = b[4]+b[5]-b[6]##Total  Balance after 2nd year\n",
      "\n",
      "c = ([bal_2, 0 ,Fs ,0 ,bal_2+Fs ,r_i*(bal_2+Fs) ,r_t*(Fs+(r_i*(bal_2+Fs)))])\n",
      "bal_3= c[4]+c[5]-c[6]## Total  Balance after 3rd year\n",
      "\n",
      "if(bal_2>0):\n",
      "\tprint('Pay back period is of two year')\n",
      "else:\n",
      "    print('Pay back period is of three year')\n",
      "\n",
      "\n",
      "print'%s %.2f %s'%('Total saving at the end of second year is ',bal_2,' Pound\\n');\n",
      "print'%s %.2f %s'%('Total saving at the end of third year is ',bal_3,' Pound\\n');\n",
      "## Deviation in answer due to direct substitution\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Example 2.1\n",
        "\n",
        "\n",
        "Page No. 44\n",
        "\n",
        "\n",
        "Pay back period is of two year\n",
        "Total saving at the end of second year is  9800.03  Pound\n",
        "\n",
        "Total saving at the end of third year is  18353.41  Pound\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "## Example 2.2\n",
      "print('Example 2.2');\n",
      "print('Page No. 45');\n",
      "\n",
      "## given\n",
      "C= 35000.;## cost of boiler\n",
      "C_grant=0.;## Capital grant available from goverment\n",
      "E= -(C-(C_grant*C));## Net expenditure\n",
      "Fs= 15250.;## Fuel Saving\n",
      "r_i = 0.15;## interest\n",
      "r_t = 0.55;## tax\n",
      "\n",
      "a = ([0, E ,Fs ,0, E+Fs, r_i*(E+Fs) ,0 ])\n",
      "bal_1 = a[4]+a[5]-a[6]## Total  Balance after 1st year\n",
      "\n",
      "c_all = 0.55;## capital allowance in 2nd year\n",
      "C_bal= (bal_1+0+Fs+(-(c_all*E)));## Cash Balance after 2nd year\n",
      "b = ([bal_1 ,0 ,Fs ,-(c_all*E), C_bal ,r_i*C_bal, r_t*(Fs+(r_i*C_bal))]);\n",
      "bal_2 = b[4]+b[5]-b[6]##Total  Balance after 2nd year\n",
      "\n",
      "c = ([bal_2, 0 ,Fs ,0 ,bal_2+Fs, r_i*(bal_2+Fs) ,r_t*(Fs+(r_i*(bal_2+Fs)))])\n",
      "bal_3= c[4]+c[5]-c[6]## Total  Balance after 3rd year\n",
      "\n",
      "if(bal_2>0):\n",
      "\tprint('pay back period is of two year')\n",
      "else:\n",
      "\tprint('pay back period is of three year')\n",
      "\n",
      "\n",
      "print'%s %.2f %s'%('Total saving at the end of second year is ',bal_2,' Pound');\n",
      "print'%s %.2f %s'%('Total saving at the end of third year is ',bal_3,' Pound');\n",
      "## Deviation in answer due to direct substitution\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Example 2.2\n",
        "Page No. 45\n",
        "pay back period is of two year\n",
        "Total saving at the end of second year is  4195.66  Pound\n",
        "Total saving at the end of third year is  12370.74  Pound\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg46"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "## Example 2.3\n",
      "print('Example 2.3');\n",
      "print('Page No. 46');\n",
      "\n",
      "## given\n",
      "F= 350*10**3.;## fuel oils in gallons\n",
      "Ci= 5000.;## cost of insulation of tanks\n",
      "\n",
      "As= 7500.;##Annual Saving in Pound\n",
      "\n",
      "if(As> Ci):\n",
      "\tprint(\"The investment has a pay-back period of less than 1 year\");\n",
      "else:\n",
      "\tprint(\"The investment has not a pay-back period of less than 1 year\");\n",
      "    \n",
      "## Note- Since here pack back period is less than 1 year and the company is in profit so they can go with this fuel oil,\n",
      "## although it can be noted that there are more problems handling heavy fuels oils \n",
      "##and that the pay-back increases considerably the smaller the installation.\n",
      "##So the company can changeover from oil to coal as a fuel.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Example 2.3\n",
        "Page No. 46\n",
        "The investment has a pay-back period of less than 1 year\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex4-pg47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "## Example 2.4\n",
      "print('Example 2.4');\n",
      "print('Page No. 47');\n",
      "\n",
      "## given\n",
      "F1= 500.*10**3;## fuel oil in gallons\n",
      "F2= 500.*10**3;## coal in gallons in Pound\n",
      "C1= 165.*10**3;## cost of oil per year in Pound\n",
      "C2= 92.*10**3;## cost of an equivalent of coal in Pound\n",
      "Ce= 100.*10**3;## capital cost of extra handling eqiupment\n",
      "\n",
      "Cm= (Ce*0.2);## Maintenance , interest costs per year\n",
      "As= C1-C2;## Annual Saving in Pound\n",
      "print'%s %.2f %s'%('Annual Saving is ',As,' Pound')\n",
      "\n",
      "if((2*As)> Ce):\n",
      "\tprint(\"Replacing an obsolete boiler plant is considerable\");\n",
      "else:\n",
      "\tprint(\"Replacing an obsolete boiler plant is not considerble\");\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Example 2.4\n",
        "Page No. 47\n",
        "Annual Saving is  73000.00  Pound\n",
        "Replacing an obsolete boiler plant is considerable\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex5-pg49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "## Example 2.5\n",
      "print('Example 2.5\\n\\n');\n",
      "print('Page No. 49\\n\\n');\n",
      "\n",
      "## given\n",
      "F= 10.*10**3;## fuel oils in gallons\n",
      "Cs= 2200.;## cost of maintaining tanks per year in Pound\n",
      "Ci= 1850.;## cost of insulation of pipe in Pound\n",
      "\n",
      "As= (Cs*.85);##company saving is 85 per cent to the cost\n",
      "print'%s %.2f %s'%('Annual Saving on heating is ',As,'  Pound\\n')\n",
      "\n",
      "\n",
      "if(As> Ci):\n",
      "\tprint(\"The investment has a pay-back period of less than 1 year\");\n",
      "else:\n",
      "\tprint(\"The investment has not a pay-back period of less than 1 year\");\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Example 2.5\n",
        "\n",
        "\n",
        "Page No. 49\n",
        "\n",
        "\n",
        "Annual Saving on heating is  1870.00   Pound\n",
        "\n",
        "The investment has a pay-back period of less than 1 year\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex6-pg52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "## Example 2.6\n",
      "print('Example 2.6\\n\\n');\n",
      "print('Page No. 52\\n\\n');\n",
      "\n",
      "## given\n",
      "P1= 50.;## Dry saturated steam pressure in bar\n",
      "P2= 0.5;## condenser  pressure in bar\n",
      "\n",
      "##By using the steam tables saturation temperature is obtained at given pressures\n",
      "T1= 537.##The saturation temperatue in K at 50 bar\n",
      "T2= 306.##The saturation temperatue in K at 0.5 bar\n",
      "\n",
      "## For Carnot Cycle\n",
      "n=(1.-(T2/T1))*100.;\n",
      "print'%s %.2f %s'%('Efficiency percentage of Carnot Cycle is ',n,' \\n')\n",
      "\n",
      "\n",
      "## For Rankine Cycle\n",
      "## By usins steam tables, the total heat and the sensibles heat  and other remaining parameter has been calculated\n",
      "h1= 2794.*10**3;##the total heat in dry steam at 50 bar in J/kg\n",
      "d= 0.655;## dryness fraction \n",
      "h2= 1725.*10**3;## the entropy at state 2 in J/kg\n",
      "h3= 138.*10**3;## the sensible heat at 0.5 bar in J/kg\n",
      "Vf= 1.03*10**-3;## volume of fluid im m^3,calculated from steam table\n",
      "W= (Vf*(P1-P2))*10**5;## pump work in J/kg\n",
      "E=(((h1-h2)-(W))/((h1-h3)-(W)))*100.;\n",
      "print'%s %.2f %s'%('Efficiency percentage of Rankine Cycle is ',E,' \\n')\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Example 2.6\n",
        "\n",
        "\n",
        "Page No. 52\n",
        "\n",
        "\n",
        "Efficiency percentage of Carnot Cycle is  43.02  \n",
        "\n",
        "Efficiency percentage of Rankine Cycle is  40.13  \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}