{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 2 Antenna Fundamentals"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.1 Calculation of Etheta"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Distance between point's is m 200 m\n",
      " the wavelength is  10 m\n",
      " the current element is  0.00030000000000000003 A/m\n",
      " Etheta value is V/m 0.2826\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "# Etheta = 60∗ pi ∗ I ( dl / lambda ) ∗ ( sin(theta) / r) where thetha = 90\n",
    "r =200;\n",
    "print ( \" Distance between point's is m\" ,r ,'m') \n",
    "lam =10;\n",
    "print ( \" the wavelength is \" , lam ,'m') ;\n",
    "idl =3*10**-4;\n",
    "print ( \" the current element is \" , idl ,\"A/m\") ;\n",
    "Etheta =60*3.14*3*10** -3/2\n",
    "print(\" Etheta value is V/m\",Etheta)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.2 Calculation of directive gain"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "radiation resistance is  72 ohm\n",
      "the Loss resistance is  8 ohm\n",
      "the power gain of antenna is  30\n",
      "the Directivity gain is  33.333333333333336\n",
      "the Directivity gain in db is given by  15.228787452803376\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#etta=Prad/Prad+Ploss=Rrad/Rrad+Rloss\n",
    "Rrad=72;\n",
    "print(\"radiation resistance is \",Rrad,\"ohm\");\n",
    "Rloss=8;\n",
    "ettar=72/(72+8);\n",
    "print(\"the Loss resistance is \",Rloss,\"ohm\");\n",
    "Gpmax=30;\n",
    "print(\"the power gain of antenna is \",Gpmax);\n",
    "Gdmax=Gpmax/ettar;\n",
    "Gdmax1=10 *math.log10(Gdmax);#in db\n",
    "print(\"the Directivity gain is \",Gdmax);\n",
    "print(\"the Directivity gain in db is given by \",Gdmax1);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.3 Radiation Resistance calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the elemental length is given by  0.1\n",
      "the radiation resistance is  7.895683520871488 ohm\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Rrad=80*pi^2*(dl/lambda)^2\n",
    "dl=0.1;\n",
    "print(\"the elemental length is given by \",dl);\n",
    "Rrad=80*(math.pi)**2*(0.1)**2;\n",
    "print(\"the radiation resistance is \",Rrad,\"ohm\");\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.4 Rms current calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the wavelength is  3.0 m\n",
      "the Radiated power is  100 W\n",
      "the elemental length is  0.01 m\n",
      "the Irms current is  106.76438151257656 A\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Prad=80*(pi)**2*(dl/lambda)*(Irms)**2;\n",
    "frequency=100*10**6;\n",
    "lamda=(3*10**8)/(100*10**6); #lamda=c/f;\n",
    "print(\"the wavelength is \",lamda,\"m\");\n",
    "Prad=100;\n",
    "print(\"the Radiated power is \",Prad,\"W\");\n",
    "dl=0.01;\n",
    "print(\"the elemental length is \",dl,\"m\");\n",
    "Irms2=(3/0.01)**2*100/(80*(math.pi)**2);\n",
    "Irms=math.sqrt(Irms2);\n",
    "print(\"the Irms current is \",Irms,\"A\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.5 Effective aperture calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the electric field is  0.05 V/m\n",
      "the average power is  3.315727981081154e-06 W\n",
      "the maximum effective aperture area is  0.603318250377074 m^2\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Pavg=0.5*|E|^2/etta0,Prmax=2*10^-6W,Aem=Prmax/Pavg\n",
    "\n",
    "E=50*10**-3;\n",
    "Etta0=120*(math.pi);\n",
    "print(\"the electric field is \",E,\"V/m\");\n",
    "Pavg=0.5*(50*10**-3)**2/(120*(math.pi));\n",
    "print(\"the average power is \",Pavg,\"W\");\n",
    "Aem=(2*10**-6)/(3.315*10**-6);\n",
    "print(\"the maximum effective aperture area is \",Aem,\"m^2\");\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.6 Aperture area calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The electric field is 5.000000e-02 V/m\n",
      "The average power is 3.31573e-06 W\n",
      "The maximum effective aperture area is 0.603318 m^2\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Pavg=0.5*|E|^2/etta0,Prmax=2*10^-6W,Aem=Prmax/Pavg\n",
    "\n",
    "E=50*10**-3;\n",
    "Etta0=120*(math.pi);\n",
    "print(\"The electric field is %e V/m\"%E);\n",
    "Pavg=0.5*(50*10**-3)**2/(120*(math.pi));\n",
    "print(\"The average power is %g W\"%Pavg);\n",
    "Aem=(2*10**-6)/(3.315*10**-6);\n",
    "print(\"The maximum effective aperture area is %g m^2\"%Aem);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.7 Transmitted power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The wavelength is 0.1 m\n",
      "The transmitter power is 36.8116 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#GT=GR=Antilog[GT or Gr(in db)/10]=31.622*10^3\n",
    "#1 mile=1609.35 m\n",
    "\n",
    "freq=3*10**9;\n",
    "d=48280.5;#30miles*1609.35\n",
    "lamda=(3*10**8)/(3*10**9);\n",
    "print(\"The wavelength is %g m\"%lamda);\n",
    "Pt=(10**-3)*((4*(math.pi)*48280.5)/0.1)**2*(1/(31.622*10**3)**2);#Pr=Pt(GR*GT*(lamda/4*pi*d)^2),Pr=1mW\n",
    "print(\"The transmitter power is %g W\"%Pt);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.8 Noise temperature calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "F is given by 1.2882\n",
      "Effective noise temperature is 83.578 K\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#T0=290k,room temperature\n",
    "\n",
    "F=1.2882;\n",
    "print(\"F is given by %g\"%F);\n",
    "Te=(1.2882-1)*290;#Te=(F-1)T0\n",
    "print(\"Effective noise temperature is %g K\"%Te);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.9 Average power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The average power is 0.365 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Etheta=60Im/r*(cos(pi/2cos(theta))/sin(theta));\n",
    "#theta=90\n",
    "#Pavg=Rrad*Irms^2;\n",
    "#Irms=Im/sqrt(2)\n",
    "\n",
    "Im=100*10**-3;\n",
    "r=100\n",
    "Etheta=(60*10**-3);\n",
    "H=(60*10**-3)/(120*(math.pi));\n",
    "Pavg=73*(10**-1/math.sqrt(2))**2;#Rrad=73ohm for half wave dipole\n",
    "print(\"The average power is %g W\"%Pavg);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.10 Average power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The average power is 22.9746 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Rrad=36.5ohm\n",
    "#Irms=Im/sqrt(2)\n",
    "\n",
    "Im=1.22;#on applying Kvl\n",
    "Pavg=36.5*(1.122/math.sqrt(2))**2;\n",
    "print(\"The average power is %g W\"%Pavg);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.11 power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiated Power is 0.157914 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Hphi=Im*dl*sin(theta)/(2*lamda*r);\n",
    "#for Hertzian Dipole\n",
    "\n",
    "Hphi=5*10**-6;\n",
    "lamda=1;#assume\n",
    "dl=0.04;\n",
    "Im=(5*10**-6)*2*(2*10**3)/(0.04);\n",
    "Irms=Im/(math.sqrt(2));\n",
    "Prad=80*(math.pi)**2*(0.04)**2*(Irms)**2;\n",
    "print(\"The radiated Power is %g W\"%Prad);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.12 Power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiated power is 0.144096 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#For Half wave Dipole\n",
    "#Hphi=Im/(2*pi*r)*cos(pi/2*cos(theta)/sin(theta))\n",
    "#Rrad=73 ohm\n",
    "\n",
    "Hphi=5*10**-6;\n",
    "r=2*10**3;\n",
    "Im=(5*10**-6)*(4*(math.pi)*10**3);\n",
    "Prad=73*(Im/math.sqrt(2))**2;\n",
    "print(\"The radiated power is %g W\"%Prad);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.13 power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiated power is 0.0720481 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#For quarter wave monopole\n",
    "#Rrad=36.5 ohm\n",
    "\n",
    "Im=20*(math.pi)*10**-3;#from previous problem\n",
    "Prad=36.5*((20*(math.pi)*10**-3)/math.sqrt(2))**2;\n",
    "print(\"The radiated power is %g W\"%Prad);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.14 Dipole length calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The length of the dipole antenna is 3 m\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#lamda=velocity/frequency\n",
    "\n",
    "frequency=50*10**6;\n",
    "lamda=3*10**8/frequency;\n",
    "leng=lamda/2;\n",
    "print(\"The length of the dipole antenna is %d m\"%leng);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.15 Current calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The current through the dipole is 0.0833333 A\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Etheta=60*Im*cos(pi/2*cos(theta)/sin(theta))/r\n",
    "\n",
    "r=500*10**3;\n",
    "Etheta=10*10**-6;\n",
    "Im=Etheta*r/60;\n",
    "print(\"The current through the dipole is %g A\"%Im);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.16 power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiated power is 3.04045 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#for half wave dipole\n",
    "\n",
    "Pavg=0.5*73*0.0833;#Rrad*Irms^2;Rrad=73 ohm\n",
    "print(\"The radiated power is %g W\"%Pavg);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.17 Directivity calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiated power is 0.38 W\n",
      "The directivity is 16.5347\n",
      "The directivity is 20.944\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#efficiency=Prad/Pinput\n",
    "#efficiency=0.95,Umax=0.5W/sr,D=Umax/[Prad/4*pi];\n",
    "\n",
    "#part (i)\n",
    "Pinput=0.4;\n",
    "n=0.95;\n",
    "Umax=0.5;\n",
    "Prad=n*Pinput;\n",
    "print(\"The radiated power is %g W\"%Prad);\n",
    "D=0.5/(0.38/(4*(math.pi)));\n",
    "print(\"The directivity is %g\"%D);\n",
    "\n",
    "#part(ii)\n",
    "Prad=0.3;\n",
    "D=0.5/(0.3/(4*(math.pi)));\n",
    "print(\"The directivity is %g\"%D);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.18 Efield calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiated power is 0.215286 W\n",
      "E2 = 2.11906e-07\n",
      "The field value is 0.000460332 V/m\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#for half wave dipole\n",
    "#on applying kvl\n",
    "\n",
    "Im=0.0768;\n",
    "Rrad=73;\n",
    "r=10**4;\n",
    "Prad=0.5*Rrad*Im**2;#Rrad=73 for half wave dipole\n",
    "print(\"The radiated power is %g W\"%Prad);\n",
    "Gd=1.6405#on taking antilog of Gd(in db)\n",
    "E4=Prad/(4*(math.pi)*r**2);\n",
    "E3=1.6405*E4;\n",
    "E2=E3*240*(math.pi);\n",
    "print(\"E2 = %g\"%E2);\n",
    "E=math.sqrt(E2);\n",
    "print(\"The field value is %g V/m\"%E);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.19 Power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The length of antenna is 1.5 m\n",
      "The power radiated is 22812.5 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#frequency=100 MHz\n",
    "\n",
    "frequency=100*10**6;\n",
    "lamda=3*10**8/frequency;\n",
    "leng=lamda/2;\n",
    "print(\"The length of antenna is %g m\"%leng);\n",
    "Rrad=73;\n",
    "Im=25;\n",
    "Prad=Rrad*0.5*Im**2;\n",
    "print(\"The power radiated is %g W\"%Prad);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.20 Radiation resistance calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiation resistance is 53.3333 ohm\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "Im=15;\n",
    "Prad=6*10**3;\n",
    "Rrad=Prad/(Im/math.sqrt(2))**2;\n",
    "print(\"The radiation resistance is %g ohm\"%Rrad);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.21 Directive gain calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiation efficiency is given by 0.9\n",
      "The directive gain is 17.6099\n",
      "The directive gain in db is 12.4576\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Gpmax=n*Gdmax\n",
    "#N=Rrad/Rrad+Rloss\n",
    "\n",
    "Rrad=72;\n",
    "Rloss=8;\n",
    "n=Rrad/(Rrad+Rloss);\n",
    "print(\"The radiation efficiency is given by %g\"%n);\n",
    "Gpmax=15.8489;#antilog(Gpmax/10);Gpmax=12db\n",
    "Gdmax=Gpmax/n;\n",
    "Gdmaxdb=10*math.log10(Gdmax);\n",
    "print(\"The directive gain is %g\"%Gdmax);\n",
    "print(\"The directive gain in db is %g\"%Gdmaxdb);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.22 Radiation efficiency calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Radiation resistance is 0.49348 ohm\n",
      "The Power radiated is 3855.31 W\n",
      "The radiation efficiency is 0.330423\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "dl=1/40;\n",
    "Im=125;\n",
    "Rloss=1;\n",
    "Rrad=80*(math.pi)**2*(dl)**2;\n",
    "print(\"The Radiation resistance is %g ohm\"%Rrad);\n",
    "Irms=Im/math.sqrt(2);\n",
    "Prad=Rrad*(Irms)**2;\n",
    "print(\"The Power radiated is %g W\"%Prad);\n",
    "n=Rrad/(Rrad+Rloss);\n",
    "print(\"The radiation efficiency is %g\"%n);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.23 Efield calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Electric field value is 0.194798 V/m\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#|E|^2=sqrt(60*Gd*Prad)/r;\n",
    "\n",
    "r=10**4;\n",
    "Gd=3.1622#antilog(5db/10)\n",
    "Prad=20*10**3;\n",
    "E=math.sqrt(60*Gd*Prad)/r;\n",
    "print(\"The Electric field value is %g V/m\"%E);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.24 Efield calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The electric field is 0.726865 V/m\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Gd=antilog(12db/10)\n",
    "\n",
    "Gd=15.85;\n",
    "Prad=5*10**3;\n",
    "r=3*10**3;\n",
    "E=math.sqrt(60*Gd*Prad)/r;\n",
    "print(\"The electric field is %g V/m\"%E);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.25 Radiation efficiency calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resistance of hertzian dipole is 0.374634 ohm\n",
      "The radiation efficiency is 0.272558 ohm\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#R=l*sqrt(pi*F*Uo*Sigma)/Sigma*2*pi*r\n",
    "\n",
    "L=2;\n",
    "r=1*10**-3;\n",
    "f=2*10**6;\n",
    "u=4*(math.pi)*10**-7;\n",
    "sig=5.7*10**6;\n",
    "R=math.sqrt((math.pi)*2*10**6*4*(math.pi)*10**-7/(5.7*10**6))*L/(2*(math.pi)*10**-3);\n",
    "print(\"The resistance of hertzian dipole is %g ohm\"%R);\n",
    "dl=2\n",
    "frequency=2*10**6;\n",
    "lamda=3*10**8/(frequency);\n",
    "Rrad=80*(math.pi)**2*(dl/lamda)**2;\n",
    "n=Rrad/(Rrad+R);\n",
    "print(\"The radiation efficiency is %g ohm\"%n);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.26 Radiation efficiency calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiation efficiency is 0.700551\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#half wave dipole\n",
    "\n",
    "dl=1/15;#assume lamda=1;\n",
    "Rloss=1.5;\n",
    "Rrad=80*(math.pi)**2*(1/15)**2;\n",
    "n=Rrad/(Rrad+Rloss);\n",
    "print(\"The radiation efficiency is %g\"%n);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.27 Voltage calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The voltage induced is 0.08 V\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Leff=Voc/E\n",
    "\n",
    "Leff=8;\n",
    "E=0.01;\n",
    "Voc=Leff*E;\n",
    "print(\"The voltage induced is %g V\"%Voc);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.28 Dipole length calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The length of the half wave dipole is 0.5 m\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Antenna Bandwidth=Operating Frequency/Q;\n",
    "\n",
    "Q=30;\n",
    "f=10*10**6;\n",
    "f0=f*Q;\n",
    "c=3*10**8;\n",
    "lamda=c/f0;\n",
    "leng=lamda/2;\n",
    "print(\"The length of the half wave dipole is %g m\"%leng);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.29 effective aperture calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The wavelength is 0.3 m\n",
      "The radiation resistance is 7.89568 ohm\n",
      "The antenna gain is given by 0.9\n",
      "The effective aperture is 0.010743 m^2\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#part a\n",
    "c=3*10**8;\n",
    "f=10**9;\n",
    "lamda=c/f;\n",
    "print(\"The wavelength is %g m\"%lamda);\n",
    "\n",
    "#part b\n",
    "dl=3*10**-2;\n",
    "Rrad=80*(math.pi)**2*(dl/lamda)**2;\n",
    "print(\"The radiation resistance is %g ohm\"%Rrad);\n",
    "\n",
    "#part c\n",
    "Gdmax=1.5#Gd=1.5sin^2(theta),where theta=90 for short dipole\n",
    "n=0.6;\n",
    "Gp=n*Gdmax;\n",
    "print(\"The antenna gain is given by %g\"%Gp);\n",
    "\n",
    "#part d\n",
    "Ae=1.5*(lamda)**2/(4*(math.pi));\n",
    "print(\"The effective aperture is %g m^2\"%Ae);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.30 Noise power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The power per unit bandwidth is 4.83e-22 W/hz\n",
      "The available noise power is 1.932e-15 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#P=k(Ta+Tr)B\n",
    "\n",
    "Ta=15;\n",
    "Tr=20;\n",
    "b=4*10**6;\n",
    "\n",
    "#part a\n",
    "k=1.38*10**-23;\n",
    "Pb=k*(Ta+Tr);\n",
    "print(\"The power per unit bandwidth is %g W/hz\"%Pb);\n",
    "\n",
    "#part b\n",
    "P=Pb*b;\n",
    "print(\"The available noise power is %g W\"%P);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.31 Tuning factor calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The tuning factor Q is 50\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Q=Fo/delf;\n",
    "\n",
    "f0=30*10**6;\n",
    "f=600*10**3;\n",
    "Q=f0/f;\n",
    "print(\"The tuning factor Q is %d\"%Q);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.32 Antenna gain calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The wavelength is 0.015 m\n",
      "The effective physical aperture is 1.16899 m^2\n",
      "The antenna gain is 35908.7\n",
      "The antenna gain in db is 45.552 db\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#part a\n",
    "c=3*10**8;\n",
    "frequency=20*10**9;\n",
    "lamda=c/frequency;\n",
    "print(\"The wavelength is %g m\"%lamda);\n",
    "\n",
    "#part b\n",
    "#Ae=G*(lamda)^2/4*pi\n",
    "r=0.61;\n",
    "Aep=(math.pi)*r**2;\n",
    "print(\"The effective physical aperture is %g m^2\"%Aep);\n",
    "Ae=0.55*Aep;\n",
    "Ga=(Ae*4*(math.pi))/(lamda)**2;\n",
    "Gdb=10*math.log10(Ga);\n",
    "print(\"The antenna gain is %g\"%Ga);\n",
    "print(\"The antenna gain in db is %g db\"%Gdb);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.33 Dipole length calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The length of half wave dipole is 5 m\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "f=30*10**6;\n",
    "c=3*10**8;\n",
    "lamda=c/f;\n",
    "leng=lamda/2;\n",
    "print(\"The length of half wave dipole is %d m\"%leng);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.34 Directive gain calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiation efficiency is 0.9\n",
      "The directive gain is 17.7778\n",
      "The directive gain in db is 12.4988 db\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "Rrad=72;\n",
    "Rloss=8;\n",
    "Gp=16;\n",
    "n=Rrad/(Rrad+Rloss);\n",
    "print(\"The radiation efficiency is %g\"%n);\n",
    "Gp=16;\n",
    "Gd=Gp/n;\n",
    "Gddb=10*math.log10(Gd);\n",
    "print(\"The directive gain is %g\"%Gd);\n",
    "print(\"The directive gain in db is %g db\"%Gddb);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.35 Power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiated power is 0.000192352 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "Gt=1.5;\n",
    "Gr=1.5;\n",
    "d=10;\n",
    "Pt=15;\n",
    "f=10**9;\n",
    "c=3*10**8;\n",
    "lamda=c/f;\n",
    "Pr=Pt*Gt*Gr*(lamda/(4*(math.pi)*d))**2;\n",
    "print(\"The radiated power is %g W\"%Pr);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2.36 Power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The wavelngth is 0.15 m\n",
      "The transmitted power is 1.57914 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "f=2*10**9;\n",
    "c=3*10**8;\n",
    "lamda=c/f;\n",
    "print(\"The wavelngth is %g m\"%lamda);\n",
    "\n",
    "#part b\n",
    "Pr=10**-12;\n",
    "Gt=200;\n",
    "Gr=200;\n",
    "d=3*10**6;\n",
    "Pt=((4*(math.pi)*d)/lamda)**2*(Pr/(Gt*Gr));\n",
    "print(\"The transmitted power is %g W\"%Pt);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.37 Gain calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The wavelength is 3 m\n",
      "The gain of receiver is 1.63586e+09\n",
      "The gain of receiver in db is 92.1374 db\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#part a\n",
    "c=3*10**8;\n",
    "f=100*10**6;\n",
    "lamda=c/f;\n",
    "print(\"The wavelength is %d m\"%lamda);\n",
    "\n",
    "#part b\n",
    "Gt=15.8489#antilog(12/10)\n",
    "Pt=10**-1;\n",
    "Pr=10**-9;\n",
    "d=384.4*10**6;#238857*1609.35\n",
    "Gr=(((4*(math.pi)*d)/lamda)**2*Pr)/(Pt*Gt);\n",
    "print(\"The gain of receiver is %g\"%Gr);\n",
    "Grdb=10*math.log10(Gr);\n",
    "print(\"The gain of receiver in db is %g db\"%Grdb);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.38 Bandwidth calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The bandwidth of antenna is 2.000000e+07 Hz\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "Q=15;\n",
    "lamda=1;\n",
    "c=3*10**8;\n",
    "f0=c/lamda;\n",
    "Bw=f0/Q;\n",
    "print(\"The bandwidth of antenna is %e Hz\"%Bw);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.39 Directive gain calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum directive gain is 1.63363\n",
      "The maximum directive gian in db is 2.13153 db\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Aemax=Gdmax*lamda^2/4*pi;\n",
    "\n",
    "Aemax=0.13;#assume lamda=1 for half wave dipole\n",
    "Gdmax=4*(math.pi)*Aemax;\n",
    "print(\"The maximum directive gain is %g\"%Gdmax);\n",
    "Gdmaxdb=10*math.log10(Gdmax);\n",
    "print(\"The maximum directive gian in db is %g db\"%Gdmaxdb);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.40 Radiated power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiated power is 0.007425 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "Rloss=1;\n",
    "Ra=73;\n",
    "Im=14.166*10**-3;#on applying kvl\n",
    "Prad=(Im/math.sqrt(2))**2*(Rloss+Ra);\n",
    "print(\"The radiated power is %g W\"%Prad);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.41 Average power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiated power is 50 W\n",
      "The electric field is given by 0.114676 V/m\n",
      "The average power is 1.74416e-05 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Etheta=n0Im/2pir*cos(pi/2 cos(theta)/sin(theta))\n",
    "\n",
    "Pin=100;\n",
    "n=0.5;\n",
    "r=500;\n",
    "Prad=n*Pin;\n",
    "print(\"The radiated power is %g W\"%Prad);\n",
    "Rrad=73;#for half wave dipole\n",
    "Im=math.sqrt((2*Prad)/Rrad);\n",
    "n0=120*(math.pi);\n",
    "Etheta=(math.cos((math.pi/2)*math.cos(math.pi/3))/math.sin(math.pi/3))*n0*(Im/(2*(math.pi)*r));\n",
    "print(\"The electric field is given by %g V/m\"%Etheta);\n",
    "Pavg=(0.5*(Etheta)**2)/(n0);\n",
    "print(\"The average power is %g W\"%Pavg);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.42 Radiation Power calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiated power is 2.31481e-05 W\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "Pt=15\n",
    "Aet=2.5;\n",
    "Aer=0.5;\n",
    "d=15*10**3;\n",
    "f=5*10**9;\n",
    "c=3*10**8;\n",
    "lamda=c/f;\n",
    "Pr=(Pt*Aet*Aer)/((d)**2*(lamda)**2);\n",
    "print(\"The radiated power is %g W\"%Pr);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.43 Directive gain calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum directive gain is 10\n",
      "The maximum directive gain in db is 10 db\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "n=10;\n",
    "d=0.25;\n",
    "lamda=1;#assume\n",
    "Gdmax=4*((n*d)/lamda);\n",
    "print(\"The maximum directive gain is %g\"%Gdmax);\n",
    "Gdmaxdb=10*math.log10(Gdmax);\n",
    "print(\"The maximum directive gain in db is %g db\"%Gdmaxdb);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.44 Radiation efficiency calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiation efficiency is 0.866667\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "Rrad=65;\n",
    "Rloss=10;\n",
    "n=Rrad/(Rrad+Rloss);\n",
    "print(\"The radiation efficiency is %g\"%n);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.45 Effective aperture calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The effective aperture is 0.010743 m^2\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Aem=Gdmax*lamda^2/4*pi;\n",
    "\n",
    "Gdmax=1.5;#for half wave dipole\n",
    "f=10**9;\n",
    "c=3*10**8;\n",
    "lamda=c/f;\n",
    "Aem=(Gdmax*(lamda)**2)/(4*(math.pi));\n",
    "print(\"The effective aperture is %g m^2\"%Aem);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.46 FBR ratio calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The front to back ratio is 6\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "Pdes=3*10**3;\n",
    "Popp=500;\n",
    "FBR=Pdes/Popp;\n",
    "print(\"The front to back ratio is %d\"%FBR);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.47 Radiation resistance calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The radiation resistance is 0.315827 ohm\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "dl=1/50;\n",
    "Rr=80*(math.pi)**2*(dl)**2;\n",
    "print(\"The radiation resistance is %g ohm\"%Rr);"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
