{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 21 : Compensation In Power Systems"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.1, Page No 683"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import numpy\n",
      "#initialisation of variables\n",
      "\n",
      "load1=complex(10,15)\t\t#load per phase(MVA)\n",
      "SCC=250.0/3\n",
      "V=11/math.sqrt(3)\n",
      "P=30\n",
      "Q=45\n",
      "Z=(11/math.sqrt(3))**2.0/(250.0/3)\t#Equivalent short circuit impedence\n",
      "\n",
      "#Calculations\n",
      "dsc=math.degrees(math.atan(5))\n",
      "R=.0949\n",
      "X=.4746\n",
      "#Using equation: V**2= (Vcosd+PR/V)**2 + (Vsind+QX/V)**2, we get \n",
      "y=numpy.polynomial.polynomial.polyval3d(51.7,0,-27.5,1)\n",
      "X=numpy.roots(y)\n",
      "V=5.046\n",
      "print(\"V=%.3f\" %V)\n",
      "dV=6.35-V\n",
      "Ssc=250\n",
      "#using expression ,a=dV/v=1(Pcos(dsc)+Qsin(dsc))/Ssc +j(Psin(dsc)-Qcos(dsc))/Ssc\n",
      "\n",
      "a=(P*math.cos(math.radians(dsc))+Q*math.sin(math.radians(dsc)))/Ssc +complex(P*math.sin(math.radians(dsc))-Q*math.cos(math.radians(dsc)))/Ssc\n",
      "\n",
      "#Results\n",
      "print(\"dV/V= %.2f \" %abs(a))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "V=5.046\n",
        "dV/V= 0.28 \n"
       ]
      }
     ],
     "prompt_number": 14
    }
   ],
   "metadata": {}
  }
 ]
}