{
 "metadata": {
  "name": "",
  "signature": "sha256:4900eeee12d5add487271b429c0cbafd110530ef7f850ea37e0c5905f6da1030"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Ch-12 : Microwave Measurements"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 649 Example 12.1"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "#Given\n",
      "Is=0.1*(10**-6)  #A\n",
      "Pi=0  #dBm\n",
      "Cs=0.1*(10**-12)  #F\n",
      "Ls=2*(10**-9) \n",
      "Cj=0.15*(10**-12)  #F\n",
      "Rs=10  #ohm\n",
      "T=293  #K\n",
      "nktbye=25*(10**-3)  #V\n",
      "\n",
      "#Rj\n",
      "Rj=(nktbye/Is) \n",
      "print 'Rj:' ,Rj/1000,'Kohm'\n",
      "\n",
      "#Bi\n",
      "Bi=nktbye/2 \n",
      "Bii=Bi*1000 \n",
      "print 'Bi:' ,Bii,'A/W'\n",
      "\n",
      "#Bv\n",
      "Bv=Rj*Bii \n",
      "print 'Bv:',Bv, 'V/W'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rj: 250.0 Kohm\n",
        "Bi: 12.5 A/W\n",
        "Bv: 3125000.0 V/W\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 650 Example 12.2"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log10 \n",
      "#Given\n",
      "vswr=4 \n",
      "\n",
      "modT=(vswr-1)/(vswr+1) \n",
      "Lm=-10*log10(1-(modT*modT))  #dB\n",
      "print 'Mismatch Loss:' ,Lm,'dB'\n",
      "\n",
      "#Sensitivity reduces by a factor\n",
      "Bvd=(1-(modT*modT)) \n",
      "Bvdp=Bvd*100 \n",
      "print 'Voltge sensitivity reduces by:' ,Bvdp,'%'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mismatch Loss: -0.0 dB\n",
        "Voltge sensitivity reduces by: 100 %\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 650 Example 12.3"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt , pi\n",
      "#Given\n",
      "f=10e9  #Hz\n",
      "c=3e10  #cm/s\n",
      "a=4  #cm\n",
      "s=0.1  #cm\n",
      "lmb=c/f  #cm\n",
      "lmbg=lmb/(sqrt(1-((lmb/(2*a))**2))) \n",
      "vswr=lmbg/(pi*s) \n",
      "print 'VSWR: %0.3f'%vswr\n",
      "\n",
      "#Answer in book for lmbg is given as 3.49 but it should be 3.23 and hence the answer will be 10.3"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "VSWR: 10.301\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 651 Example 12.4"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "delx=3.5  #cm\n",
      "s=0.25  #cm\n",
      "\n",
      "lmbg=2*delx \n",
      "vswr=lmbg/(pi*s) \n",
      "print 'VSWR: %0.3f'%vswr"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "VSWR: 8.913\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 651 Example 12.5"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "vswr=2 \n",
      "Pin=4.5e-3  #W\n",
      "\n",
      "modT=(vswr-1)/(vswr+1) \n",
      "#Power reflected,\n",
      "Pr=(modT**2)*Pin \n",
      "#As coupler samples only 1/1000th power\n",
      "Prr=Pr*1000 \n",
      "print 'Reflected Power:' ,Prr,'W'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reflected Power: 0.5 W\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 652 Example 12.6"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import tan\n",
      "#Given\n",
      "Z0=50  #ohm\n",
      "p=2.4 \n",
      "L=0.313 \n",
      "x=2*pi*L \n",
      "y=tan(x) \n",
      "\n",
      "Zl=(Z0*(1+(p*p*1J)))/(p+(p*1J)) \n",
      "T=(Zl-Z0)/(Zl+Z0) \n",
      "p=sqrt(((T.real))**2+((T.imag))**2) \n",
      "print 'Reflection coefficient: %0.3f'%p"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reflection coefficient: 0.412\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 652 Example 12.7"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "Zl=25+25*1J  #ohm\n",
      "Z0=50  #ohm\n",
      "\n",
      "T=(Zl-Z0)/(Zl+Z0) \n",
      "p=sqrt(((T.real))**2+((T.imag))**2) \n",
      "print 'Reflection coefficient: %0.3f'%p\n",
      "\n",
      "vswrr=(1+p)/(1-p) \n",
      "print 'VSWR: %0.3f'%vswrr\n",
      "\n",
      "#Fraction of power delivered\n",
      "Pd=1-(p**2) \n",
      "Pdp=Pd*100 \n",
      "\n",
      "print 'Fraction of power delivered:',Pdp, '%'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reflection coefficient: 0.447\n",
        "VSWR: 2.618\n",
        "Fraction of power delivered: 80.0 %\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 653 Example 12.8"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "d=2.4 #cm\n",
      "lmbc=1.8 \n",
      "c=3*10**10  #cm/s\n",
      "\n",
      "lmbg=2*d \n",
      "lmb=(lmbg*lmbc)/(sqrt(lmbg**2+lmbc**2)) \n",
      "#Operating frequency\n",
      "f=c/lmb \n",
      "print 'Operating frequency: %0.3f'%(f/10**9),'GHz'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Operating frequency: 17.800 GHz\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 653 Example 12.9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import mat\n",
      "#Given\n",
      "p=1.5 \n",
      "IsL=1  #dB\n",
      "InL=30  #dB\n",
      "\n",
      "S21=10**(-IsL/20) \n",
      "\n",
      "#Assuming tgree ports to be identical\n",
      "S32=S21 \n",
      "S13=S21 \n",
      "\n",
      "#Isolations are also the same\n",
      "S31=10**(-InL/20) \n",
      "S23=S31 \n",
      "S12=S31 \n",
      "\n",
      "#Refelction coefficients are also the same\n",
      "T=(p-1)/(p+1) \n",
      "S11=T \n",
      "S22=T \n",
      "S33=T \n",
      "\n",
      "S=mat([[S11, S12, S13], [S21, S22, S23], [S31, S32, S33] ])\n",
      "print 'Matrix is:\\n' ,S"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Matrix is:\n",
        "[[ 0.2         0.03162278  0.89125094]\n",
        " [ 0.89125094  0.2         0.03162278]\n",
        " [ 0.03162278  0.89125094  0.2       ]]\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 654 Example 12.10"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "R1=10.6  #GHz\n",
      "R2=8.30  #GHz\n",
      "Q0=8200 \n",
      "Q0d=890 \n",
      "\n",
      "Er=(R1/R2)**2 \n",
      "print 'Dielectric constant %0.3f'%Er\n",
      "\n",
      "Qd=(Q0-Q0d)/(Q0*Q0d) \n",
      "print 'Loss tangent of dielectric' ,Qd"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Dielectric constant 1.631\n",
        "Loss tangent of dielectric 0\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 654 Example 12.11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "l0=0.15  #cm\n",
      "lmbg=2*2.24  #cm\n",
      "le=1.14  #cm\n",
      "a=2.286  #cm\n",
      "d=2 \n",
      "\n",
      "B0=(2*pi)/lmbg \n",
      "x=tan(B0*l0)/(B0*l0) \n",
      "#Also\n",
      "x1=(l0*x)/le \n",
      "#Correct value seems to be\n",
      "Bele=2.786 \n",
      "e1=((((a/pi)**2)*(Bele/le)**2)+1) \n",
      "e2=(((2*a)/lmbg)**2)+1 \n",
      "Er=e1/e2 \n",
      "print 'Er: %0.3f'%Er\n",
      "\n",
      "\n",
      "#Answer in book for Er is given as 2.062 but it should be 2.038"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Er: 2.039\n"
       ]
      }
     ],
     "prompt_number": 14
    }
   ],
   "metadata": {}
  }
 ]
}