{
 "metadata": {
  "name": "",
  "signature": "sha256:394dd92513e2eb48cf648e780d5cf6f538e689b0cc60f7f5f5099082361d1701"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 10 : Sinusoidal Steady state Circuit Analysis"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.4  Page No : 181"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from scipy.linalg import polar\n",
      "#Problem 10.4\")\n",
      "\n",
      "#For V1\n",
      "Ro1 = 25\n",
      "Theta1 = 143.13\n",
      "#For V1\n",
      "Ro2 = 11.2\n",
      "Theta2 = 26.57\n",
      "#We need to find V1/V2\n",
      "#Let V = V1/V2\n",
      "Vmag = (Ro1/Ro2) \n",
      "Vph = Theta1-Theta2\n",
      "x = Vmag*math.cos((Vph*math.pi)/180);\n",
      "y = Vmag*math.sin((Vph*math.pi)/180);\n",
      "z = complex(x,y)\n",
      "#Let V1+V2 = V12\n",
      "x1 = Ro1*math.cos((Theta1*math.pi)/180);\n",
      "y1 = Ro1*math.sin((Theta1*math.pi)/180);\n",
      "z1 = complex(x1,y1)\n",
      "x2 = Ro2*math.cos((Theta2*math.pi)/180);\n",
      "y2 = Ro2*math.sin((Theta2*math.pi)/180);\n",
      "z2 = complex(x2,y2)\n",
      "V12 = z1+z2\n",
      "print V12\n",
      "R,Theta =  polar([[V12]])\n",
      "print R,Theta\n",
      "\n",
      "# Results\n",
      "print \"V1/V2 = %0.2f+i*%3.2f V1+V2 = %3.2f%3.2f deg)\"%(x, y,R[0,0].real,Theta[0,0].real*180/math.pi)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(-9.98282132757+20.0096932306j)\n",
        "[[-0.44642546+0.89482083j]] [[ 22.36167581+0.j]]\n",
        "V1/V2 = -1.00+i*2.00 V1+V2 = -0.451281.23 deg)\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.5  Page No : 186"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#Problem 10.5\")\n",
      "\n",
      "# Given\n",
      "#Voltage is 100(45 deg)\")\n",
      "#Current is 5(15 deg)\")\n",
      "#For V\n",
      "Ro1 = 100\n",
      "Theta1 = 45\n",
      "#For I\n",
      "Ro2 = 5\n",
      "Theta2 = 15\n",
      "#We need to find V/I = Z\n",
      "\n",
      "Zmag = (Ro1/Ro2) \n",
      "Zph = Theta1-Theta2\n",
      "x = Zmag*math.cos((Zph*math.pi)/180);\n",
      "y = Zmag*math.sin((Zph*math.pi)/180);\n",
      "z = complex(x,y)\n",
      "#Let Y = 1/Z\n",
      "Ymag = (Ro2/Ro1) \n",
      "Yph = Theta2-Theta1\n",
      "x1 = Ymag*math.cos((Yph*math.pi)/180);\n",
      "y1 = Ymag*math.sin((Yph*math.pi)/180);\n",
      "z1 = complex(x1,y1)\n",
      "\n",
      "# Results\n",
      "print \"R = %3.2fohm XL = %3.2fH G = %0.3fS BL = %0.3fS\"%(x,y,x1,abs(y1));"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "R = 17.32ohm XL = 10.00H G = 0.000S BL = 0.000S\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.7  Page No : 187"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from scipy.linalg import polar\n",
      "#Problem 10.7\")\n",
      "\n",
      "print \"Voltage v1 = 5*math.cosw1*t\"\n",
      "print \"Voltage v2 = 10*math.cosw2*t+60\"\n",
      "#The circuit is modeled as\n",
      "#resistance is 10ohm and inducmath.tance is 5mH\")\n",
      "R = 10;\n",
      "L = 5*10**-3;\n",
      "#a)\")\n",
      "w1 = 2000;\n",
      "w2 = 2000;\n",
      "#Let Z be the impedance of the coil\n",
      "Z1 = R+1j*L*w1\n",
      "Z2 = R+1j*L*w2\n",
      "#Let V be phasor voltage between the terminals\n",
      "Vmag = 10;\n",
      "Vph = 60; \n",
      "x = Vmag*math.cos((Vph*math.pi)/180);\n",
      "y = Vmag*math.sin((Vph*math.pi)/180);\n",
      "z = complex(x,y)\n",
      "v = 5-z;\n",
      "#Let I be the current\n",
      "I = v/Z1\n",
      "R,Theta = polar([[I]])\n",
      "R = R[0,0].real\n",
      "Theta = Theta[0,0].real\n",
      "print \"i = %0.2f*math.cos%dt%d deg)\"%(R,w1,Theta*180/math.pi);\n",
      "\n",
      "#b)\")\n",
      "R = 10;L = 5*10**-3;\n",
      "w1 = 2000;w2 = 4000;\n",
      "#Let Z be the impedance of the coil\n",
      "Z1 = R+1j*L*w1\n",
      "Z2 = R+1j*L*w2\n",
      "V1 = 5;\n",
      "#By applying superposition i = i1-i2\n",
      "I1 = V1/Z1\n",
      "R,Theta = polar([[I1]])\n",
      "R = R[0,0].real\n",
      "Theta = Theta[0,0].real\n",
      "print \"i1 = %0.2f*math.cos%dt%d deg)\"%(R,w1,Theta*180/math.pi);\n",
      "V2mag = 10;V2ph = 60;\n",
      "I2 = z/Z2\n",
      "R1,Theta1 = polar([[I2]])\n",
      "R1 = R1[0,0].real\n",
      "Theta1 = Theta1[0,0].real\n",
      "print \"i2 = %0.2f*math.cos%dt%3.2f deg)\"%(R1,w2,Theta1*180/math.pi);\n",
      "#i = i1-i2\n",
      "print \"i = %0.2f*math.cos%dt%d deg)-%0.2f*math.cos%dt%3.2f deg)\"%(R,w1,Theta*180/math.pi,R1,w2,Theta1*180/math.pi)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage v1 = 5*math.cosw1*t\n",
        "Voltage v2 = 10*math.cosw2*t+60\n",
        "i = -0.71*math.cos2000t35 deg)\n",
        "i1 = 0.71*math.cos2000t20 deg)\n",
        "i2 = 1.00*math.cos4000t25.62 deg)\n",
        "i = 0.71*math.cos2000t20 deg)-1.00*math.cos4000t25.62 deg)\n"
       ]
      }
     ],
     "prompt_number": 27
    }
   ],
   "metadata": {}
  }
 ]
}