{
 "metadata": {
  "name": "",
  "signature": "sha256:7e2f43e6e0f517c2aac74f69be1d132b3ab84b5c247c20e556eb69dbe9aedae5"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 12: Waveguides<h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 12.1, Page number: 557<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      " \n",
      "\n",
      "import scipy\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "a=2.5*10**-2     #in m\n",
      "b=1*10**-2       #in m\n",
      "c=0\n",
      "Ur=1             #relative permeability\n",
      "Er=4             #relative permittivity\n",
      "C=3*10**8        #speed of wave in m/s\n",
      "fc=0\n",
      "m=0\n",
      "n=0\n",
      "\n",
      "#Calculations\n",
      "\n",
      "while (fc*10**-9 < 15.1) :\n",
      "   fc = (C/(4*a))*scipy.sqrt(m**2+(a*n/b)**2)\n",
      "   if (( fc*10**-9) < 15.1) :\n",
      "       n=n+1\n",
      "   else:\n",
      "       print 'Maximum value of n is ',n-1\n",
      "\n",
      "nmax=n-1 \n",
      "fc=0\n",
      "m=0\n",
      "n=0\n",
      "while(fc*10**-9 < 15.1):\n",
      "   fc =(C/(4*a))*scipy.sqrt(m**2+(a*n/b)**2)\n",
      "   if((fc*10**-9) < 15.1):\n",
      "       m=m+1\n",
      "   else:\n",
      "      print 'Maximum value of m is ',m-1 \n",
      "\n",
      "mmax=m-1\n",
      "m=0\n",
      "while(m<mmax+1):\n",
      "    n=0\n",
      "    while(n<nmax+1):\n",
      "        p=(C/(4*a))*scipy.sqrt(m**2+(a*n/b)**2)\n",
      "        if((p*10**-9) < 15.1) :\n",
      "          print m,n,'transmission mode is possible'\n",
      "          print 'frequency is',round(p*10**-9,2),'GHz'\n",
      "        else:\n",
      "          print m,n,'transmission mode is not possible'\n",
      "        n=n+1\n",
      "    \n",
      "    m=m+1\n",
      "        "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum value of n is  2\n",
        "Maximum value of m is  5\n",
        "0 0 transmission mode is possible\n",
        "frequency is 0.0 GHz\n",
        "0 1 transmission mode is possible\n",
        "frequency is 7.5 GHz\n",
        "0 2 transmission mode is possible\n",
        "frequency is 15.0 GHz\n",
        "1 0 transmission mode is possible\n",
        "frequency is 3.0 GHz\n",
        "1 1 transmission mode is possible\n",
        "frequency is 8.08 GHz\n",
        "1 2 transmission mode is not possible\n",
        "2 0 transmission mode is possible\n",
        "frequency is 6.0 GHz\n",
        "2 1 transmission mode is possible\n",
        "frequency is 9.6 GHz\n",
        "2 2 transmission mode is not possible\n",
        "3 0 transmission mode is possible\n",
        "frequency is 9.0 GHz\n",
        "3 1 transmission mode is possible\n",
        "frequency is 11.72 GHz\n",
        "3 2 transmission mode is not possible\n",
        "4 0 transmission mode is possible\n",
        "frequency is 12.0 GHz\n",
        "4 1 transmission mode is possible\n",
        "frequency is 14.15 GHz\n",
        "4 2 transmission mode is not possible\n",
        "5 0 transmission mode is possible\n",
        "frequency is 15.0 GHz\n",
        "5 1 transmission mode is not possible\n",
        "5 2 transmission mode is not possible\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 12.3, Page number: 561<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import scipy\n",
      "import cmath\n",
      "from numpy import *\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "a=1.5*10**-2              #in m\n",
      "b=0.8*10**-2              #in m\n",
      "c=0\n",
      "Uo=4*scipy.pi*10**-7      #permeability of free space\n",
      "Ur=1                      #relative permeability\n",
      "Eo=10**-9/(36*scipy.pi)   #permittivity of free space\n",
      "Er=4                      #relative permittivity\n",
      "C=3*10**8                 #speed of light in m/s\n",
      "w=scipy.pi*10**11         #omega in rad/s\n",
      "m=1\n",
      "n=3\n",
      "u=C/2                     #speed of wave in m/s\n",
      "\n",
      "#Calculations\n",
      "\n",
      "f=w/(2*scipy.pi)                                #frequency of wave in Hz\n",
      "fc=u*((m*m)/(a*a)+(n*n)/(b*b))**0.5/2           #cutoff frequency in Hz\n",
      "B=w*scipy.sqrt(1-(fc/f)**2)/u                   #phase constant in rad/m\n",
      "eta=377/scipy.sqrt(Er)*scipy.sqrt(1-(fc/f)**2)  #intrinsic wave impedance in ohm\n",
      "\n",
      "#Results\n",
      "\n",
      "print 'The cutoff frequency =',round(fc*10**-9,2),'GHz'\n",
      "print 'The phase constant =',round(B,2),'rad/m'\n",
      "print 'The propagation constant =',round(B,2),'j /m'\n",
      "print 'The intrinsic wave impedance =',round(eta,1),'ohms'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The cutoff frequency = 28.57 GHz\n",
        "The phase constant = 1718.93 rad/m\n",
        "The propagation constant = 1718.93 j /m\n",
        "The intrinsic wave impedance = 154.7 ohms\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 12.4, Page number: 565<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import scipy\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "a=8.636*10**-2    #in m\n",
      "b=4.318*10**-2    #in m\n",
      "f=4*10**9         #in Hz\n",
      "u=3*10**8         #speed of wave in m/s\n",
      "\n",
      "#Calculations\n",
      "\n",
      "fc=u/(2*a)\n",
      "if(f>fc):\n",
      "    print 'As f>fc, TE10 mode will propogate'\n",
      "else:\n",
      "    print 'It will not propogate'\n",
      "\n",
      "Up=u/scipy.sqrt(1-(fc/f)**2)    #phase velocity in m/s\n",
      "Ug=u*u/Up                       #group velocity in m/s\n",
      "\n",
      "#Results\n",
      "\n",
      "print 'Phase velocity =',round(Up*10**-6,0),'Mm/s'\n",
      "print 'Group velocity =',round(Ug*10**-6,1),'Mm/s'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "As f>fc, TE10 mode will propogate\n",
        "Phase velocity = 333.0 Mm/s\n",
        "Group velocity = 270.2 Mm/s\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 12.5, Page number: 570<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "\n",
      "import scipy\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "f=10*10**9          #frequency of operation in Hz\n",
      "a=4*10**-2          #in m\n",
      "b=2*10**-2          #in m\n",
      "u=3*10**8           #velocity in m/s\n",
      "Pavg=2*10**-3       #average power in W\n",
      "\n",
      "#Calculations\n",
      "\n",
      "fc=u/(2*a)                      #cutoff frequency in Hz\n",
      "n=377/scipy.sqrt(1-(fc/f)**2)   #intrinsic wave impedance in ohms\n",
      "E=scipy.sqrt(4*n*Pavg/(a*b))    #peak value of electric field in V/m\n",
      "\n",
      "#Result\n",
      "\n",
      "print 'Peak value of electric field =',round(E,2),'V/m'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Peak value of electric field = 63.77 V/m\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 12.6, Page number: 571<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "\n",
      "import scipy\n",
      "\n",
      "#Variable declaration\n",
      "\n",
      "cc=5.8*10**7             #in S/m\n",
      "f=4.8*10**9              #in Hz\n",
      "c=10**-17                #in S/m\n",
      "Uo=4*scipy.pi*10**-7     #permeability of free space\n",
      "Eo=10**-9/(36*scipy.pi)  #permittivity of free space\n",
      "Er=2.55                  #relative permittivity\n",
      "z=60*10**-2              #in m\n",
      "l=4.2*10**-2             #in m\n",
      "b=2.6*10**-2             #in m\n",
      "P=1.2*10**3              #in W\n",
      "\n",
      "#Calculations\n",
      "\n",
      "n=377/scipy.sqrt(Er)\n",
      "u=3*10**8/scipy.sqrt(Er)\n",
      "fc=u/(2*l)\n",
      "ad=c*n/(2*scipy.sqrt(1-(fc/f)**2))\n",
      "Rs=scipy.sqrt(scipy.pi*f*Uo/cc)\n",
      "ac=2*Rs*(0.5+(b/l)*(fc/f)**2)/(b*n*scipy.sqrt(1-(fc/f)**2))\n",
      "a=ac\n",
      "Pd=P*(scipy.e**(2*a*z)-1)\n",
      "\n",
      "#Result\n",
      "\n",
      "print 'power dissipated =',round(Pd,3),'W'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "power dissipated = 6.096 W\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 12.8, Page number: 579<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "\n",
      "import scipy\n",
      "\n",
      "#Variable Declaration\n",
      "   \n",
      "a=5*10**-2              #in m\n",
      "b=4*10**-2              #in m\n",
      "c=10*10**-2             #in m\n",
      "C=5.8*10**7             #in mhos/m\n",
      "Uo=4*scipy.pi*10**-7    #permeability of free space\n",
      "u=3*10**8               #speed of wave in m/s\n",
      "\n",
      "#Calculations\n",
      "\n",
      "def f(m,n,p):\n",
      "    fr=scipy.sqrt((m/a)**2+(n/b)**2+(p/c)**2)*u/2     #resonant frequency in Hz\n",
      "    print round(fr*10**-9,3)\n",
      "    \n",
      "\n",
      "f101=3.35*10**9\n",
      "d=scipy.sqrt(1/(scipy.pi*f101*Uo*C))\n",
      "Q=(a*a+c*c)*a*b*c/(d*(2*b*(a**3+c**3)+a*c*(a*a+c*c))) #quality factor\n",
      "\n",
      "#Results\n",
      "\n",
      "print 'Thus the five lowest order modes in ascending order are '\n",
      "print 'TE101, frequency in GHz ='\n",
      "f(1,0,1)\n",
      "print 'TE011, frequency in GHz ='\n",
      "f(0,1,1)\n",
      "print 'TE102, frequency in GHz ='\n",
      "f(1,0,2)\n",
      "print 'TE110, frequency in GHz ='\n",
      "f(1,1,0)\n",
      "print 'TE111 or TM111, frequency in GHz ='\n",
      "f(1,1,1)\n",
      "print 'Quality factor =',round(Q,0)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thus the five lowest order modes in ascending order are \n",
        "TE101, frequency in GHz =\n",
        "3.354\n",
        "TE011, frequency in GHz =\n",
        "4.039\n",
        "TE102, frequency in GHz =\n",
        "4.243\n",
        "TE110, frequency in GHz =\n",
        "4.802\n",
        "TE111 or TM111, frequency in GHz =\n",
        "5.031\n",
        "Quality factor = 14358.0\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}