{
 "metadata": {
  "name": "",
  "signature": "sha256:9734f6fd136104d84e59a3bf0cf93b5573206727114793dcfbc73fa18b870ce6"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 14 : Two Port Networks"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.1  Page No : 276"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import Symbol\n",
      "\n",
      "s = Symbol('s');\n",
      "#Applying KVL equation to the two loops we get\n",
      "#V1 = 2*I1+s*(I1+I2)\n",
      "#V2 = 3*I2+s*(I1+I2)\n",
      "\n",
      "#On solving we get\n",
      "#(s+2)*I1+s*I2 = V1        (1)\");\n",
      "#s*I1+(s+3)*I2 = V2        (2)\");\n",
      "\n",
      "#The equations which contain Z parameters are\n",
      "#V1 = Z11*I1+Z12*I2\n",
      "#V2 = Z21*I1+Z22*I2\n",
      "\n",
      "#On comparing (1) and (2) with above equations\n",
      "Z11 = s+2;\n",
      "Z12 = s;\n",
      "Z21 = s;\n",
      "Z22 = s+3;\n",
      "\n",
      "print \"Z11 = \",Z11\n",
      "print \"Z12 = \",Z12\n",
      "print \"Z21 = \",Z21\n",
      "print \"Z22 = \",Z22\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Z11 =  s + 2\n",
        "Z12 =  s\n",
        "Z21 =  s\n",
        "Z22 =  s + 3\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.2  Page No : 278"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from sympy import Symbol\n",
      "\n",
      "s = Symbol('s')\n",
      "#Applying KVL equation to the two loops we get\n",
      "#V1 = 2*I1+s*(I1+I2)-I2\n",
      "#V2 = 3*I2+s*(I1+I2)\n",
      "\n",
      "#On solving we get\n",
      "#(s+2)*I1+(s-1)*I2 = V1    (1)\");\n",
      "#s*I1+(s+3)*I2 = V2        (2)\");\n",
      "\n",
      "#The equations which contain Z parameters are\n",
      "#V1 = Z11*I1+Z12*I2\n",
      "#V2 = Z21*I1+Z22*I2\n",
      "\n",
      "#On comparing (1) and (2) with above equations\n",
      "Z11 = s+2;\n",
      "Z12 = s-1;\n",
      "Z21 = s;\n",
      "Z22 = s+3;\n",
      "\n",
      "print \"Z11 = \",Z11\n",
      "print \"Z12 = \",Z12\n",
      "print \"Z21 = \",Z21\n",
      "print \"Z22 = \",Z22"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Z11 =  s + 2\n",
        "Z12 =  s - 1\n",
        "Z21 =  s\n",
        "Z22 =  s + 3\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.4  Page No : 282"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import Symbol\n",
      "\n",
      "\n",
      "s = Symbol('s')\n",
      "Ya = 3/(5*s+6);\n",
      "Yb = 2/(5*s+6);\n",
      "Yc = s/(5*s+6);\n",
      "\n",
      "#Writing KCL equations \n",
      "#I1 = (Ya+Yc)*V1-Yc*V2        (1)\")\n",
      "#I2 = -Yc*V1+(Yb+Yc)*V2       (2)\")\n",
      "\n",
      "#The equations which contain Y parameters are\n",
      "#I1 = Y11*V1+Y12*V2\n",
      "#I2 = Y21*V1+Y22*V2\n",
      "\n",
      "#On comparing (1) and (2) with above equations\n",
      "#Y11 = Ya+Yc\")\n",
      "#Y12 = -Yc = Y21\")\n",
      "#Y22 = Yb+Yc\")\n",
      "\n",
      "#Substituting Ya , Yb and Yc\n",
      "Y11 = Ya+Yc\n",
      "Y12 = -Yc\n",
      "Y21 = -Yc\n",
      "Y22 = Yb+Yc\n",
      "\n",
      "print \"Y11 = \",Y11\n",
      "print \"Y12 = \",Y12\n",
      "print \"Y21 = \",Y21\n",
      "print \"Y22 = \",Y22\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Y11 =  s/(5*s + 6) + 3/(5*s + 6)\n",
        "Y12 =  -s/(5*s + 6)\n",
        "Y21 =  -s/(5*s + 6)\n",
        "Y22 =  s/(5*s + 6) + 2/(5*s + 6)\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.6  Page No : 287"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import Symbol\n",
      "\n",
      "\n",
      "s = Symbol('s')\n",
      "#From example 14.4\n",
      "\n",
      "Y11 = (3 + s)/(5*s+6)\n",
      "Y12 = - s/(6 + 5*s)\n",
      "Y21 = - s/(6 + 5*s)\n",
      "Y22 = (2+s)/(6+5*s)   \n",
      "\n",
      "DYY = Y11*Y22-Y12*Y21\n",
      "\n",
      "Z11 = Y22/DYY;\n",
      "Z12 = -Y12/DYY;\n",
      "Z21 = -Y21/DYY;\n",
      "Z22 = Y11/DYY;\n",
      "\n",
      "print \"Z11 = \",Z11\n",
      "print \"Z12 = \",Z12\n",
      "print \"Z21 = \",Z21\n",
      "print \"Z22 = \",Z22"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Z11 =  (s + 2)/((5*s + 6)*(-s**2/(5*s + 6)**2 + (s + 2)*(s + 3)/(5*s + 6)**2))\n",
        "Z12 =  s/((5*s + 6)*(-s**2/(5*s + 6)**2 + (s + 2)*(s + 3)/(5*s + 6)**2))\n",
        "Z21 =  s/((5*s + 6)*(-s**2/(5*s + 6)**2 + (s + 2)*(s + 3)/(5*s + 6)**2))\n",
        "Z22 =  (s + 3)/((5*s + 6)*(-s**2/(5*s + 6)**2 + (s + 2)*(s + 3)/(5*s + 6)**2))\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.7  Page No : 288"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#From figure 14.9\n",
      "#V1 = 50*I1        (1)\");\n",
      "#I2 = 300*I1       (2)\");\n",
      "\n",
      "#The equations which contain h parameters are\n",
      "#V1 = h11*I1+h12*V2\n",
      "#I2 = h21*I1+h22*V2\n",
      "\n",
      "#On comparing (1) and (2) with above equations\n",
      "\n",
      "print \"h11 = %d\"%(50);\n",
      "print \"h12 = %d\"%(0);\n",
      "print \"h21 = %d\"%(300);\n",
      "print \"h22 = %d\"%(0);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "h11 = 50\n",
        "h12 = 0\n",
        "h21 = 300\n",
        "h22 = 0\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.8  Page No : 290"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#From figure 14.10\n",
      "#By inspection\n",
      "#V1 = 10**9*I1\n",
      "#V2 = 10(I2-10**-3*V1)\n",
      "\n",
      "\n",
      "#On solving we get\n",
      "#I1 = 10**-9*V1              (1)\");\n",
      "#V2 = 10*I2-10**-2*V1        (2)\");\n",
      "\n",
      "\n",
      "#The equations which contain g parameters are\n",
      "#I1 = g11*V1+g12*I2\n",
      "#V2 = g21*V1+g22*I2\n",
      "\n",
      "#On comparing (1) and (2) with above equations\n",
      "\n",
      "print \"g11 = %2.1e\"%(10**-9);\n",
      "print \"g12 = %d\"%(0);\n",
      "print \"g21 = %2.1e\"%(-10**-2);\n",
      "print \"g22 = %d\"%(10);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "g11 = 1.0e-09\n",
        "g12 = 0\n",
        "g21 = -1.0e-02\n",
        "g22 = 10\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.10  Page No : 292"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import Symbol\n",
      "\n",
      "s = Symbol('s')\n",
      "#Applying KVL equation to the two loops we get\n",
      "#V1 = 3*I1+3*(I1+I2)\n",
      "#V2 = 7*I1+3*(I1+I2)+2*I2\n",
      "\n",
      "#On solving we get\n",
      "#6*I1+3*I2 = V1         (1)\");\n",
      "#10*I1+5*I2 = V2        (2)\");\n",
      "\n",
      "#The equations which contain Z parameters are\n",
      "#V1 = Z11*I1+Z12*I2\n",
      "#V2 = Z21*I1+Z22*I2\n",
      "\n",
      "#On comparing (1) and (2) with above equations\n",
      "Z11 = 6;\n",
      "Z12 = 3;\n",
      "Z21 = 10;\n",
      "Z22 = 5;\n",
      "\n",
      "\n",
      "print \"Z11 = \",Z11\n",
      "print \"Z12 = \",Z12\n",
      "print \"Z21 = \",Z21\n",
      "print \"Z22 = \",Z22\n",
      "\n",
      "#As DZZ results in zero(0) therefore Y parameters are not defined \")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Z11 =  6\n",
        "Z12 =  3\n",
        "Z21 =  10\n",
        "Z22 =  5\n"
       ]
      }
     ],
     "prompt_number": 9
    }
   ],
   "metadata": {}
  }
 ]
}