{
 "metadata": {
  "name": "",
  "signature": "sha256:573d3c26bc06249cf2f9f4748e6d10f443e0ca37c6357e39541ace7a1534cbe6"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 15 : Mutual Inductance and Transformers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.4  Page No : 306"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#Example 15.4\")\n",
      "\n",
      "# Given\n",
      "#L1 = 0.1H L2 = 0.2H\")\n",
      "#i1 = 4A i2 = 10A\")\n",
      "L1 = 0.1;L2 = 0.2\n",
      "i1 = 4;i2 = 10;\n",
      "#The energy stored in coupled coils is\n",
      "#W = (L1*i1**2)/2+(L2*i2**2)/2+M*i1*i2\")\n",
      "\n",
      "#a)\")\n",
      "M = 0.1;\n",
      "W = (L1*i1**2)/2+(L2*i2**2)/2+M*i1*i2;\n",
      "print \"Total Energy in the coils = %3.2fJ\"%(W);\n",
      "\n",
      "#b)\")\n",
      "M = math.sqrt(2)/10;\n",
      "W = (L1*i1**2)/2+(L2*i2**2)/2+M*i1*i2;\n",
      "print \"Total Energy in the coils = %3.2fJ\"%(W);\n",
      "\n",
      "#c)\")\n",
      "M = -0.1;\n",
      "W = (L1*i1**2)/2+(L2*i2**2)/2+M*i1*i2;\n",
      "print \"Total Energy in the coils = %3.2fJ\"%(W);\n",
      "\n",
      "#a)\")\n",
      "M = -math.sqrt(2)/10;\n",
      "W = (L1*i1**2)/2+(L2*i2**2)/2+M*i1*i2;\n",
      "print \"Total Energy in the coils = %3.2fJ\"%(W);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total Energy in the coils = 14.80J\n",
        "Total Energy in the coils = 16.46J\n",
        "Total Energy in the coils = 6.80J\n",
        "Total Energy in the coils = 5.14J\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.7  Page No : 311"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from scipy.linalg import polar\n",
      "\n",
      "#Example 15.7\")\n",
      "\n",
      "# Given\n",
      "#N1 = 20 N2 = N3 = 10\")\n",
      "#I2 = 10(-53.13 deg) I3 = 10(-45 deg)\")\n",
      "N1 = 20;\n",
      "N2 = 10;\n",
      "N3 = 10;\n",
      "I2mag = 10;\n",
      "I2ph = -53.13;\n",
      "I3mag = 10;\n",
      "I3ph = -45;\n",
      "#From figure 15.14\n",
      "#N1*I1-N2*I2-N3*I3 = 0\")\n",
      "#Solving for I1\n",
      "Xmag = N2*I2mag \n",
      "Xph = I2ph\n",
      "x = Xmag*math.cos((Xph*math.pi)/180);\n",
      "y = Xmag*math.sin((Xph*math.pi)/180);\n",
      "z = complex(x,y)\n",
      "\n",
      "Ymag = N3*I3mag \n",
      "Yph = I3ph\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",
      "I1 = (z+z1)/N1\n",
      "R,Theta = polar([[I1]]);\n",
      "R = R[0][0].real\n",
      "Theta = Theta[0][0].real\n",
      "\n",
      "print \"I1 = %3.2f%3.2f deg) A\"%(R,(Theta*180)/math.pi);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "I1 = 0.66571.52 deg) A\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.8  Page No : 316"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from scipy.linalg import polar\n",
      "#Example 15.8\")\n",
      "\n",
      "# Given\n",
      "#L1 = 0.2H L2 = 0.1H\")\n",
      "#M = 0.1H R = 10ohm\")\n",
      "#v1 = 142.3*math.sin(100*t)\")\n",
      "L1 = 0.2;L2 = 0.1\n",
      "M = 0.1;R = 10;\n",
      "v1mag = 142.3;\n",
      "w = 100;\n",
      "#Let Input impedance be Z1 and can be calculated as\n",
      "#From the equations in 15.10\n",
      "#Z1 = 1j*w*L1+((M*w)**2)/(Z2+1j*w*L2)\")\n",
      "Z1 = 1j*w*L1+((M*w)**2)/(R+1j*w*L2)\n",
      "R,Theta = polar([[Z1]])\n",
      "R = R[0][0].real\n",
      "Theta = Theta[0][0].real\n",
      "\n",
      "#If I1 is the input current\n",
      "I1mag = v1mag/R\n",
      "I1ph = -(Theta*180)/math.pi\n",
      "#In time domain form\n",
      "print \"i1 = %3.1f*math.sin%d*t%3.1f deg) A)\"%(I1mag,w,I1ph);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i1 = 450.0*math.sin100*t-905.9 deg) A)\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.9  Page No : 318"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from sympy import Symbol\n",
      "\n",
      "s = Symbol('s')\n",
      "# Given\n",
      "#L1 = 0.2H L2 = 0.1H\")\n",
      "#M = 0.1H R = 10ohm\")\n",
      "#v1 = u(t) a unit step function\")\n",
      "L1 = 0.2;\n",
      "L2 = 0.1\n",
      "M = 0.1;\n",
      "R = 10;\n",
      "v1 = 1;\n",
      "w = 100;\n",
      "#Let Input impedance be Z1 and can be calculated as\n",
      "#From the equations in 15.10\n",
      "#Z1(s) = L1*s-((M*s)**2)/(R+L2*s)\")\n",
      "Z1 = L1*s-(((M*s)**2)/(R+L2*s))\n",
      "#Proper rearranging of co-efficients\n",
      "Num = Z1/0.01\n",
      "Den = Z1*100\n",
      "\n",
      "print \"Z1(s)\",Num/Den\n",
      "Y1 = 1./Z1\n",
      "print \"Y1(s)\",Den/Num\n",
      "\n",
      "#As the input is unit step function the value is 1V for t>0\n",
      "#In exponential form the value is represented as exp(s*t) with s = 0 as the pole of Y1(s)\n",
      "\n",
      "#Therefore forced response\n",
      "k = 1/L1;\n",
      "print \"Forced response i1,f = %d*t) A)\"%(k);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Z1(s) 1\n",
        "Y1(s) 1\n",
        "Forced response i1,f = 5*t) A)\n"
       ]
      }
     ],
     "prompt_number": 8
    }
   ],
   "metadata": {}
  }
 ]
}