{
 "metadata": {
  "name": "",
  "signature": "sha256:8e00413bfc7a32f9462043bc0306d2b727b39c9d5a7f565f60201529b83b4788"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6 : Microwave Components"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2  Page No : 200"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "Beeta = 34.3                   #in rad/m\n",
      "# S=[0,0.5*math.e**(%i*53.13);0.5*math.e**(%i*53.13),0];\n",
      "# S'=[0,0.5*math.e**(%i*53.13-x);0.5*math.e**(%i*53.13-x),0];\n",
      "#For S12& S21 to be real ,\n",
      "x = 53.5                       #in degrees\n",
      "\n",
      "#calculations\n",
      "x_rad = 53.5*math.pi/180\n",
      "l = x_rad/Beeta\n",
      "\n",
      "#---output---#\n",
      "print 'distance (in cm)=',round(l*100,4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "distance (in cm)= 2.7223\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.3  Page No : 205"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "D = 30                           #in dB\n",
      "VSWR = 1\n",
      "C = 10\n",
      "                                 #p1_p4 = p1/p4\n",
      "\n",
      "#calculations\n",
      "p1_p4 = 10**(C/-10)\n",
      "S_41 = round(math.sqrt(p1_p4),4)\n",
      "S_14 = S_41                     #As matched & lossless\n",
      "S_31 = round(S_41**2/10**(D/10),4)\n",
      "S_11 = round((VSWR-1)/(VSWR+1),4)\n",
      "S_22 = S_11\n",
      "S_44 = S_11\n",
      "S_33 = S_11\n",
      "S_21 = round(math.sqrt(1-0.1-10**-4),4)\n",
      "S_12 = S_21\n",
      "S_34 = round(math.sqrt(1-0.1-10**-4),4)\n",
      "S_43 = S_34\n",
      "S_24 = round(math.sqrt(1-0.1-S_34**2),4)\n",
      "S_42 = S_24\n",
      "S_23 = S_41\n",
      "S_32 = S_23\n",
      "S_13 = S_31\n",
      "S=[[S_11,S_12,S_13,S_14],[S_21,S_22,S_23,S_24],[S_31,S_32,S_33,S_34],[S_41,S_42,S_43,S_44]]\n",
      "\n",
      "\n",
      "\n",
      "#---output---#\n",
      "print 'Required Scattering Parameters are \\n', S\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Required Scattering Parameters are \n",
        "[[0.0, 0.9486, 0.0001, 0.3162], [0.9486, 0.0, 0.3162, 0.0126], [0.0001, 0.3162, 0.0, 0.9486], [0.3162, 0.0126, 0.9486, 0.0]]\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.4  Page No : 206"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "\n",
      "a_2 = 0\n",
      "a_3 = 0\n",
      "a_1 = 32                                            #in mW\n",
      "\n",
      "#calculations\n",
      "b_1 = (a_1/2**2)+(a_2/-2)+(a_3/math.sqrt(2))\n",
      "b_2 = (a_1/(-2)**2)+(a_2/-2)+(a_3/math.sqrt(2))\n",
      "b_3 = (a_1/2)+(a_2/math.sqrt(2))+(a_3/-math.sqrt(2))\n",
      "\n",
      "\n",
      "\n",
      "#---output---#\n",
      "print 'Power at port1(in mW)=',b_1\n",
      "print 'Power at port2(in mW) =',b_2\n",
      "print 'Power at port3(in mW) =',b_3\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power at port1(in mW)= 8.0\n",
        "Power at port2(in mW) = 8.0\n",
        "Power at port3(in mW) = 16.0\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5  Page No : 214"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "\n",
      "b_1 = 20\n",
      "b_2 = 20\n",
      "\n",
      "#calculations\n",
      "p_1 = abs((60-50)/(60+50))\n",
      "p_2 = abs((75-50)/(75+50))\n",
      "P_1 = b_1*(1-p_1**2)/2\n",
      "P_2 = b_2*(1-p_2**2)/2\n",
      "\n",
      "#---output---#\n",
      "print 'Power in port1 (in mW) =',round(P_1,4)\n",
      "print 'Power in port2 (in mW) =',P_2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power in port1 (in mW) = 10.0\n",
        "Power in port2 (in mW) = 10\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.6  Page No : 222"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "p_1 = 0.5\n",
      "p_2 = 0.6\n",
      "p_4 = 0.8\n",
      "b_1 = 0.6566\n",
      "b_2 = 0.7576\n",
      "b_3 = 0.6536\n",
      "b_4 = 0.00797\n",
      "\n",
      "#calculations\n",
      "a_1 = p_1*b_1\n",
      "a_2 = p_2*b_2\n",
      "a_3 = 1                               #in Watts\n",
      "a_4 = p_4*b_4\n",
      "\n",
      "\n",
      "#---output---#\n",
      "print 'Power at port 1(in W)=',round(b_1**2,4)\n",
      "print 'Power at port 2(in W)=',round(b_2**2,4)\n",
      "print 'Power at port 3(in W)=',round(b_3**2,4)\n",
      "print 'Power at port 4(in W)=',b_4**2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power at port 1(in W)= 0.4311\n",
        "Power at port 2(in W)= 0.574\n",
        "Power at port 3(in W)= 0.4272\n",
        "Power at port 4(in W)= 6.35209e-05\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.7  Page No : 227"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "In_loss = 0.5                         #in dB\n",
      "Isolation = 30                        #in dB\n",
      "S_11 = 0\n",
      "S_22 = 0\n",
      "\n",
      "#calculations\n",
      "S_21 = 10**(-In_loss/20) \n",
      "S_12 = 10**(-Isolation/20)\n",
      "S = [S_11,S_12,S_21,S_22]\n",
      "\n",
      "#output\n",
      "print 'Scattering matrix = [',\n",
      "for k in S:\n",
      "    print round(k,4),\",\" ,\n",
      "print ']'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Scattering matrix = [ 0.0 , 0.01 , 0.9441 , 0.0 , ]\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.9  Page No : 228"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "\n",
      "VSWR = 1\n",
      "In_loss = 0.5                                    #in dB\n",
      "Isolation = 20                                   #in dB\n",
      "\n",
      "#calculations\n",
      "S_12 = round(10**(-Isolation/20),4)\n",
      "S_21 = round(10**(-In_loss/20),4)\n",
      "S_23 = S_12\n",
      "S_31 = S_12\n",
      "S_32 = S_21\n",
      "S_13 = S_21\n",
      "p=round((VSWR-1)/(VSWR+1),4)\n",
      "S_11 = p\n",
      "S_22 = p\n",
      "S_33 = p\n",
      "S = [S_11,S_12,S_13],[S_21,S_22,S_23],[S_31,S_32,S_33]\n",
      "\n",
      "\n",
      "#---output---#\n",
      "print 'Scattering matrix =',S\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Scattering matrix = ([0.0, 0.1, 0.9441], [0.9441, 0.0, 0.1], [0.1, 0.9441, 0.0])\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.10  Page No : 232"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "In_loss = 0.5                       #insertion loss(in dB)\n",
      "C = 20                              #in dB\n",
      "D = 35                              #in dB\n",
      "Pi = 90                             #in Watts\n",
      "\n",
      "#calculations\n",
      "Pi_Pf = 10**(C/10)\n",
      "Pf = Pi/Pi_Pf\n",
      "Pf_Pb = 10**(D/10)\n",
      "Pb = Pf/Pf_Pb\n",
      "P_rec = (Pi-Pf-Pb)                                  #Power received (in Watts)\n",
      "P_rec_dB = 10*math.log(Pi/P_rec)/math.log(10)\n",
      "P_rec_eff = P_rec_dB-In_loss                        #Effective power received (in dB)\n",
      "\n",
      "\n",
      "#---output---#\n",
      "print 'Effective power received (in dB)=',round(P_rec_eff,4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Effective power received (in dB)= -0.5\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.11  Page No : 239"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "S_13 = 0.1\n",
      "S_14 = 0.05\n",
      "\n",
      "#calculations\n",
      "C = -20*math.log(S_13)/math.log(10)\n",
      "D = 20*math.log(S_13/S_14)/math.log(10)\n",
      "I = C+D\n",
      "\n",
      "#---output---#\n",
      "print 'Coupling (in dB) =',round(C,4)\n",
      "print 'Directivity (in dB)) =',round(D,4)\n",
      "print 'Isolation (in dB) =',round(I,4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Coupling (in dB) = 20.0\n",
        "Directivity (in dB)) = 6.0206\n",
        "Isolation (in dB) = 26.0206\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.12  Page No : 245"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "\n",
      "D=3                          #distance of seperation(in cm)\n",
      "\n",
      "\n",
      "#calculations\n",
      "w_l=2*D                      #wavelength\n",
      "d2_d1=2.5                    #d2-d1(in m)\n",
      "S=w_l/(math.pi*d2_d1*10**-1)\n",
      "\n",
      "#---output---#\n",
      "print 'VSWR =',round(S,4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "VSWR = 7.6394\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.13  Page No : 252"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "#---variables\n",
      "w_l=7.2                    #wavelength (in cm)\n",
      "x=10.5-9.3\n",
      "\n",
      "#calculations\n",
      "Phase_shift=(2*math.pi*x)/(w_l)\n",
      "\n",
      "#---output---#\n",
      "print 'Phase Shift (in degree) =',round(Phase_shift*180/math.pi,4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Phase Shift (in degree) = 60.0\n"
       ]
      }
     ],
     "prompt_number": 17
    }
   ],
   "metadata": {}
  }
 ]
}