{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 7 Propagation of Radio Waves"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.1 Frequency calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum stable frequency is 1.76086e+07 Hz\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "fcr=11*10**6;\n",
    "D=1000;\n",
    "h=400;\n",
    "fmuf=fcr*math.sqrt(1+(D/(2*h))**2);\n",
    "print(\"The maximum stable frequency is %g Hz\"%fmuf);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.2 Usable frequency calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The critical frequency is 2.84605e+06 Hz\n",
      "The maximum usable frequency is 3.0287e+06 Hz\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "Nmax=10**11;\n",
    "phi=(math.pi)/9;\n",
    "fcr=math.sqrt(81*Nmax);\n",
    "print(\"The critical frequency is %g Hz\"%fcr);\n",
    "fmuf=fcr*(1/math.cos(phi));\n",
    "print(\"The maximum usable frequency is %g Hz\"%fmuf);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.3 Critical frequency calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The critical frequency is 6.00115e+06 Hz\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "D=2000;\n",
    "h=200;\n",
    "fmuf=30.6*10**6;\n",
    "fcr=fmuf/math.sqrt(1+(D/(2*h))**2);\n",
    "print(\"The critical frequency is %g Hz\"%fcr);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.4 Skip distance calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Nmax value is 2.34568e+11 /m^3\n",
      "The critical frequency is 4.3589e+06 Hz\n",
      "The skip distance is 1.65179e+06 m\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "n=0.9;\n",
    "fmuf=10*10**6;\n",
    "f=10*10**6;\n",
    "h=400*10**3;\n",
    "Nmax=(1-n**2)*f**2/81;\n",
    "print(\"The Nmax value is %g /m^3\"%Nmax);\n",
    "fcr=math.sqrt(81*Nmax);\n",
    "print(\"The critical frequency is %g Hz\"%fcr);\n",
    "Dskip=2*h*math.sqrt((fmuf/fcr)**2-1);\n",
    "print(\"The skip distance is %g m\"%Dskip);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.5 Efield calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The wavelength is 250 m\n",
      "The electric field is 0.101788 V/m\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "ht=150;\n",
    "hr=2;\n",
    "Is=9;\n",
    "d=40*10**3;\n",
    "f=1.2*10**6;\n",
    "c=3*10**8;\n",
    "lamda=c/f;\n",
    "print(\"The wavelength is %d m\"%lamda);\n",
    "E=120*(math.pi)*ht*hr*Is/(lamda*d);\n",
    "print(\"The electric field is %g V/m\"%E);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.6 Transmission height calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The height of transmission is 2.98243e+07 m\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "dmax=45*10**3;\n",
    "ht=(dmax/8.24)**2; #dmax=4.12[sqrt(ht)+sqrt(hr)];ht=hr;\n",
    "print(\"The height of transmission is %g m\"%ht);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.7 Nmax calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "fcre=2.5*10**6;\n",
    "fcrf=8.5*10**6;\n",
    "Nmaxe=(fcre)**2/81;\n",
    "Nmaxf=(fcrf)**2/81;\n",
    "print(\"The Nmax for e layer is %g /m^3\"%Nmaxe);\n",
    "print(\"The Nmax for f layer is %g /m^3\"%Nmaxf);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.8 Critical freq calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The critical frequencies are 14.2302Hz 16.8375Hz 11.0227Hz\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "Nmaxf1=2.5;\n",
    "Nmaxf2=3.5;\n",
    "Nmaxf3=1.5;#10^6*10^-6=1;\n",
    "fcr1=math.sqrt(81*Nmaxf1);\n",
    "fcr2=math.sqrt(81*Nmaxf2);\n",
    "fcr3=math.sqrt(81*Nmaxf3);\n",
    "print(\"The critical frequencies are %gHz %gHz %gHz\"%(fcr1,fcr2,fcr3));"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.9 Electron Density calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Nmax values are 2.5e+11 m^3 2.77778e+10 m^3\n",
      "The change in electron density is 2.22222e+11 m^3\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "fcr1=4.5*10**6;\n",
    "fcr2=1.5*10**6;\n",
    "Nmax1=(fcr1/9)**2;\n",
    "Nmax2=(fcr2/9)**2;\n",
    "print(\"The Nmax values are %g m^3 %g m^3\"%(Nmax1,Nmax2));\n",
    "Nmax=Nmax1-Nmax2;\n",
    "print(\"The change in electron density is %g m^3\"%Nmax);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.10 Frequency calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The frequency is 2.078461e+05 Hz\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "#Note:10^6 is the power and not 10^-6 as mentioned in book\n",
    "n=0.5;\n",
    "N=400*10**6;\n",
    "f=math.sqrt((81*N)/(1-n**2));\n",
    "print(\"The frequency is %e Hz\"%f);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.11 Critical freq calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The critical frequency is 1.200084e+07 Hz\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "D=1500;\n",
    "h=250;\n",
    "fmuf=37.95*10**6;\n",
    "fcr=fmuf/math.sqrt(1+(D/(2*h))**2);\n",
    "print(\"The critical frequency is %e Hz\"%fcr);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.12 Usable freq calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum usable frequency is 3.16475e+07 Hz\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "D=2500;\n",
    "h=200;\n",
    "fcr=5*10**6;\n",
    "fmuf=fcr*math.sqrt(1+(D/(2*h))**2);\n",
    "print(\"The maximum usable frequency is %g Hz\"%fmuf);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.13 virtual height calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The virtual height is given by 750000 m\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "T=5*10**-3;\n",
    "c=3*10**8;\n",
    "h=c*(T/2);\n",
    "print(\"The virtual height is given by %g m\"%h);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.14 LOS calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The line of sight distance is 46.6572 m\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "ht=40;\n",
    "hr=25;\n",
    "f=90*10**6;\n",
    "p=35;\n",
    "LOS=4.12*(math.sqrt(ht)+math.sqrt(hr));\n",
    "print(\"The line of sight distance is %g m\"%LOS);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.15 critical freq calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The critical frequency is 1.01025e+07 Hz\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "Nmax=1.26*10**12;\n",
    "fcr=math.sqrt(81*Nmax);\n",
    "print(\"The critical frequency is %g Hz\"%fcr)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.16 critical freq calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The critical frequency is 1.0022e+07 Hz\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "Nmax=1.24*10**12;\n",
    "fcr=math.sqrt(81*Nmax);\n",
    "print(\"The critical frequency is %g Hz\"%fcr);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.17 usable freq calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum usable frequency is 6.7082e+06 Hz\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "fcr=6*10**6;\n",
    "D=200*10**3;\n",
    "h=200*10**3;\n",
    "fmuf=fcr*math.sqrt(1+(D/(2*h))**2);\n",
    "print(\"The maximum usable frequency is %g Hz\"%fmuf);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.18 Range calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum range is 24.1419 miles\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import math\n",
    "\n",
    "ht=100;\n",
    "hr=50;\n",
    "d=1.4142*(math.sqrt(ht)+math.sqrt(hr));\n",
    "print(\"The maximum range is %g miles\"%d);"
   ]
  }
 ],
 "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
}
