{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 12: The Cylindrical Antenna and the Moment Method (MM)<h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 12-12.1, Page number: 472<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "import numpy as np\n",
      "\n",
      "#Variable declaration\n",
      "N = 3        #Piecewise sinusoidal dipole modes (unitless)\n",
      "l = 1/10.0     #Dipole length (lambda)\n",
      "z11_exact = 0.4935 - 3454j #Exact impedence vector(ohm)\n",
      "z11_apprx = 0.4944 - 3426j #approximate impedence vector(ohm)\n",
      "z12_exact = 0.4935 + 1753j  #Exact impedence vector(ohm)\n",
      "z12_apprx =  0.4945 + 1576j #approximate impedence vector(ohm)\n",
      "z13_exact = 0.4935 + 129.9j #Exact impedence vector(ohm)\n",
      "z13_apprx =  0.4885 + 132.2j #approximate impedence vector(ohm)\n",
      "\n",
      "#Calculations\n",
      "N2 = N + 1  #Number of equal segments (unitless)\n",
      "d = l/4     #Length of each segment (lambda)\n",
      "Rmn = 20*(2*pi*d)**2   #Real part of elements of Z-matrix, Zmn (VA)\n",
      "zmat_apprx = np.array([[(z11_apprx+z13_apprx), z12_apprx],\n",
      "                        [2*z12_apprx, z11_apprx]])\n",
      "                        #Z(impedence) matrix    (unitless)\n",
      "vmat = np.array([0,1])  #Voltage matrix (unitless)\n",
      "i1,i2 = np.linalg.solve(zmat_apprx,vmat)    #Current matrix (unitless)\n",
      "i_ratio = i2/i1         #Current ratio  (unitless)\n",
      "zin = vmat[1]/i2        #Input impedence (ohm)\n",
      "\n",
      "\n",
      "zmat_exact = np.array([[(z11_exact+z13_exact), z12_exact],\n",
      "                        [2*z12_exact, z11_exact]])\n",
      "i1_e,i2_e = np.linalg.solve(zmat_exact,vmat)    #Current matrix (unitless)\n",
      "i_ratio_exact = i2_e/i1_e         #Current ratio  (unitless)\n",
      "zin_exact = vmat[1]/i2_e        #Input impedence (ohm)\n",
      "\n",
      "\n",
      "#Result\n",
      "print \"The current ratio is \", np.around(i_ratio,4)\n",
      "print \"This is nearly equal to 1.9,\" \\\n",
      "                \"indicating a nearly triangular current distribution\"\n",
      "print \"The input impdence is \", np.around(zin,3), \"ohm using approximate values\"\n",
      "print \"The input impedence is \", np.around(zin_exact,3), \"ohm using exact values\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The current ratio is  (2.09+0.0013j)\n",
        "This is nearly equal to 1.9,indicating a nearly triangular current distribution\n",
        "The input impdence is  (1.891-1917.848j) ohm using approximate values\n",
        "The input impedence is  (2.083-1605.074j) ohm using exact values\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 12-12.2, Page number: 473<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import tan, pi\n",
      "import numpy as np\n",
      "\n",
      "#Variable declaration\n",
      "z_load = 2.083 + 1605j    #conjugate matched load (ohm)\n",
      "e0 = 1.0                      #Electric field magnitude (unitless)\n",
      "l = 1/10.0                    #length of dipole (lambda)\n",
      "imag = 0+1j                 #Imaginary number \n",
      "\n",
      "z11_exact = 0.4935 - 3454j #Exact impedence vector(ohm)\n",
      "z11_apprx = 0.4944 - 3426j #approximate impedence vector(ohm)\n",
      "z12_exact = 0.4935 + 1753j  #Exact impedence vector(ohm)\n",
      "z12_apprx =  0.4945 + 1576j #approximate impedence vector(ohm)\n",
      "z13_exact = 0.4935 + 129.9j #Exact impedence vector(ohm)\n",
      "z13_apprx =  0.4885 + 132.2j #approximate impedence vector(ohm)\n",
      "\n",
      "#Calculation\n",
      "d = l/4     #Length of each segment (lambda)\n",
      "vm = (2*e0/(2*pi))*tan(2*pi*d/2)    #Voltage vector (VA)\n",
      "z22 = z11_exact + z_load        #Impedence matrix for loaded dipole (VA)\n",
      "zmat_exact = np.array([[(z11_exact+z13_exact), z12_exact],\n",
      "                        [2*z12_exact, z22]])\n",
      "                        #Z(impedence) matrix    (unitless)\n",
      "vmat = np.array([vm,vm])  #Voltage matrix (unitless)\n",
      "i1,i2 = np.linalg.solve(zmat_exact,vmat)    #Current matrix (unitless)\n",
      "i3 = i1         #Current vector (unitless)\n",
      "\n",
      "e_zn = (60*tan(2*pi*d/2))*imag      #Free space electric field (V/m)\n",
      "\n",
      "e_s = i1*e_zn + i2*e_zn + i3*e_zn         #Scattered field (V/m)\n",
      "\n",
      "sigma = 4*pi*(abs(e_s)**2)/(abs(e0)**2) #Radar Cross section (lambda**2)\n",
      "\n",
      "#Result\n",
      "print \"The radar cross section using exact values of Z matrix is\", round(sigma,4),\\\n",
      "                                                    \"lambda^2\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The radar cross section using exact values of Z matrix is 0.1805 lambda^2\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 12-12.3, Page number: 475<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "\n",
      "#Variable declaration\n",
      "z11_exact = 2-1921j         #Exact impedence vector (ohm)\n",
      "z12_exact = 1.9971-325.1j   #Exact impedence vector (ohm)\n",
      "\n",
      "z11_apprx = 1.9739-1992j    #Approximate impedence vector (ohm)\n",
      "z12_apprx = 1.9739-232.8j   #Approximate impedence vector (ohm)\n",
      "\n",
      "vmat = np.array([1,0])\n",
      "\n",
      "#Calculations\n",
      "zmat_exact = np.array([[z11_apprx, z12_apprx],\n",
      "                        [z12_apprx, z11_apprx]])    \n",
      "                        #Impedence matrix (unitless)\n",
      "i1,i2 = np.linalg.solve(zmat_exact,vmat)\n",
      "                        #Current matrix (unitless)\n",
      "zin = 1/i1\n",
      "\n",
      "#Result\n",
      "print \"The input impedence for order N = 2 is\", np.around(zin,3), \"ohm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The input impedence for order N = 2 is (1.539-1964.795j) ohm\n"
       ]
      }
     ],
     "prompt_number": 4
    }
   ],
   "metadata": {}
  }
 ]
}