{
 "metadata": {
  "name": "",
  "signature": "sha256:efee43f3cff9fdca8c69d559c1c84e6f19cd4b3e6da3711c7567d0790f5b7290"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Ch-11, Hydro-Thermal Co-Ordination"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 11.2 Page 234"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given\n",
      "l1=700 ;t1=14 ;l2=500; t2=10\n",
      "ac=24 ;bc=0.02#variables of cost equation\n",
      "aw=6 ;bw=0.0025 #variables of watere quantity equation\n",
      "b22=0.0005 #loss coefficient\n",
      "r2=2.5\n",
      "from numpy import arange, mat\n",
      "lam=arange(1,40,0.001)\n",
      "gg=1; q=1\n",
      "for lam in arange(25,4,0.0010):\n",
      "    a=[2*bc, 0, 0, r2*bw*2+2*b22*lam]\n",
      "    b=[lam-ac ,lam-aw*r2]\n",
      "    p=inv(a)*b\n",
      "    g=round(p(1)+p(2))\n",
      "    l=round(l1+b22*p(2)**2)\n",
      "    lq=round(l2+b22*p(2)**2)\n",
      "    if g>=l:\n",
      "        print \"\\nfor load condition %dMW \\n then, \\n \\t lamda %f \\t p1=%fMW \\n \\t p2=%fMW \\t pl=%fMW\"%(l1,lam,p[0],p[1],2*b22*p[1])\n",
      "        break\n",
      "    #end\n",
      "#end\n",
      "for lam in arange(25,40,0.001):\n",
      "    a=mat([[2*bc ,0],[0, r2*bw*2+2*b22*lam]])\n",
      "    b=([[lam-ac] ,[lam-aw*r2]])\n",
      "    pq=(a**-1)*b\n",
      "    \n",
      "    g=round(pq[0]+pq[1])\n",
      "    lq=round(l2+b22*pq[1]**2)\n",
      "\n",
      "    if g>=lq:\n",
      "        print \"\\nfor load condition %dMW \\n then, \\n \\t lamda %f \\t p1=%fMW \\n \\t p2=%fMW \\t pl=%fMW\"%(l2,lam,pq[0],pq[1],2*b22*pq[1])\n",
      "        break\n",
      "    #end\n",
      "#end\n",
      "dwu=[(aw+bw*p)*p*t1+t2*(aw+bw*pq[1])*pq[1]]*3600\n",
      "doc=[(ac+bc*p)*p*t1+(ac+bc*pq[0])*pq[0]*t2]\n",
      "print \"\\ndaily water used %fm**3 \\ndaily operating cost of thermal plant Rs%f\"%(dwu[0],doc[0])\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "for load condition 500MW \n",
        " then, \n",
        " \t lamda 31.705000 \t p1=192.625000MW \n",
        " \t p2=377.898428MW \t pl=0.377898MW\n",
        "\n",
        "daily water used 26664.961210m**3 \n",
        "daily operating cost of thermal plant Rs55337.878125\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 11.3 Page "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "#given \n",
      "p=250#load\n",
      "rt=14 #run time\n",
      "t=24#total time\n",
      "ac=5 ;bc=8; cc=0.05 #variables of cost equation\n",
      "bw=30; cw=0.05 #variables of water per power\n",
      "qw=500#quantity of water\n",
      "lam=bc+cc*2*p #lambda\n",
      "a=-qw*(10**6)/(3600*rt)\n",
      "inn=sqrt(bw**2-4*cw*a)\n",
      "phh1=(-bw+inn)/(2*cw)#solution of quadratic equation\n",
      "phh2=(-bw-inn)/(2*cw)\n",
      "if phh1>0 :\n",
      "    r=lam/(bw+cw*phh1) \n",
      "    print \" hydro plant power is %fMW \\n the cost of water is %fRs.per hour/m**3/sec\"%(phh1,r) \n",
      "\n",
      "if phh2>0 :\n",
      "    r=lam/(bw+cw*phh2) \n",
      "    print \" hydro plant power is %fMW \\n the cost of water is %fRs.per hour/m**3/sec\"%(phh2,r) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " hydro plant power is 237.047484MW \n",
        " the cost of water is 0.788486Rs.per hour/m**3/sec\n"
       ]
      }
     ],
     "prompt_number": 11
    }
   ],
   "metadata": {}
  }
 ]
}