{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 19 : Economic Load Dispatch"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 19.1, Page No 643"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import numpy as np\n",
      "#initialisation of variables\n",
      "#dF1/dP1=.4*P1+40 per MWhr\n",
      "#dF2/dP2=.5*P1+30 per MWhr\n",
      "print(\"Two equations are :\")\n",
      "print(\"%.1f P1 %.1f P2 = %.1f\\n\" %(.4,-.5,-10))\n",
      "print(\"%.1f P1+ %.1fP2 = %.1f\\n\" %(1,1,180))\n",
      "A=[[.4,1],[-.5,1]]\n",
      "B=[-10,180]\n",
      "P1=88.89\n",
      "P2=91.11\n",
      "\n",
      "#Calculations\n",
      "F1=.2*(P1)**2 +40*P1+120\n",
      "F2=.25*(P2)**2+30*P2+150\n",
      "Total=F1+F2\t\t\t#Total cost\n",
      "print(\"(a)Cost of Generation=Rs %.2f /hr\\n\" %Total)\n",
      "P1=90\n",
      "P2=90\n",
      "F1=.2*(P1)**2 +40*P1+120\n",
      "F2=.25*(P2)**2+30*P2+150\n",
      "Total2=F1+F2\t\t#Total cost\n",
      "savings=Total2-Total\n",
      "\n",
      "#Results\n",
      "print(\"(b)Savings=Rs %.2f /hr\\n\" %savings)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Two equations are :\n",
        "0.4 P1 -0.5 P2 = -10.0\n",
        "\n",
        "1.0 P1+ 1.0P2 = 180.0\n",
        "\n",
        "(a)Cost of Generation=Rs 10214.44 /hr\n",
        "\n",
        "(b)Savings=Rs 0.56 /hr\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 19.2, Page No 643"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "pf=10.0/8     #penalty factor\n",
      "\n",
      "#Calculations\n",
      "cost=(.1*10+3)*pf\t\t#Cost of recieved power=dF1/dP1\n",
      "\n",
      "#Results\n",
      "print(\"Penalty Factor = %.1f\" %pf)\n",
      "print(\"Cost of recieved Power = Rs %.1f /MWhr\" %cost)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Penalty Factor = 1.2\n",
        "Cost of recieved Power = Rs 5.0 /MWhr\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 19.4, Page No 645"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "print(\"two equations are :\")\n",
      "print(\"%.3f P1 %.2f P2 = %.1f\" %(0.048,-.08,-2))\n",
      "print(\"%.1f P1+ %.1fP2 = %.1f\" %(1,1,50))\n",
      "\n",
      "#Calculations\n",
      "A=[[.048,-.08],[1,1]]\n",
      "B=[-2,50]\n",
      "P1=15.625\n",
      "P2=34.38\n",
      "F1=(.024*(P1)**2 +8*P1+80)*(10**6)\n",
      "F2=(.04*(P2)**2+6*P2+120)*(10**6)\n",
      "print(\"when load is 150MW , equations are: :\")\n",
      "print(\"%.3f P1 %.2f P2 = %.1f\" %(.048,-.08,-2))\n",
      "print(\"%.1f P1+ %.1fP2 = %.1f\" %(1,1,150))\n",
      "A=[[.048,-.08],[1,1]]\n",
      "B=[-2,150]\n",
      "P1=78.125\n",
      "P2=71.88\n",
      "f1=(.024*(P1)**2 +8*P1+80)*(10**6)\n",
      "f2=(.04*(P2)**2+6*P2+120)*(10**6)\n",
      "Total=(F1+F2+f1+f2)*12*2/(10**6)\n",
      "\n",
      "#Results\n",
      "print(\"Total cost=Rs. %.2f\" %(Total))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "two equations are :\n",
        "0.048 P1 -0.08 P2 = -2.0\n",
        "1.0 P1+ 1.0P2 = 50.0\n",
        "when load is 150MW , equations are: :\n",
        "0.048 P1 -0.08 P2 = -2.0\n",
        "1.0 P1+ 1.0P2 = 150.0\n",
        "Total cost=Rs. 52652.46\n"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}