{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "chapter 2: Satellite Orbits and Trajectories"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.1, page no-36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Declaration\n",
      "r1=6370.0        # Earth's Orbit in km\n",
      "r2=630.0         # Height of satellite from surface in km\n",
      "G=6.67*10**-11   # Gravitational constant inNm^2/kg^2\n",
      "M=5.98*10**24    # Mass of earth in kg\n",
      "\n",
      "#Calculation\n",
      "R=r1+r2\n",
      "v=math.sqrt(G*M/(R*10**3))\n",
      "\n",
      "#Result\n",
      "print(\"The velocity of sattelite %.2fkm/s\"%(math.floor(v/10)*10**-2))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of sattelite 7.54km/s\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.2, page no-37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Declaration\n",
      "A=45000.0    #Apogee in km\n",
      "P=7000.0     #Perigee in km\n",
      "\n",
      "\n",
      "#Calculation\n",
      "#(a)\n",
      "a=(A+P)/2\n",
      "#(b)\n",
      "e=(A-P)/(2*a)\n",
      "#(c)\n",
      "e=(math.floor(e*100))/100\n",
      "d=a*e\n",
      "\n",
      "#Result\n",
      "print(\"(a)\\nSemi-major axis of elliptical orbit is %d km\"%a)\n",
      "print(\"\\n(b)\\nEccentricity = %.2f\"%e)\n",
      "print(\"\\n(c)\\nThe distance between centre of earth and centre of ellipse is %d km \"%d)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)\n",
        "Semi-major axis of elliptical orbit is 26000 km\n",
        "\n",
        "(b)\n",
        "Eccentricity = 0.73\n",
        "\n",
        "(c)\n",
        "The distance between centre of earth and centre of ellipse is 18980 km \n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.3, page no-37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "ma=42000.0        # Major axis distance in Km\n",
      "P=8000.0          # Perigee distance in Km\n",
      "\n",
      "\n",
      "#Calculation\n",
      "A=ma-P\n",
      "e=(A-P)/ma\n",
      "\n",
      "#Result\n",
      "print(\"Apogee=%dkm\\n Eccentricity=%.2f\"%(A,e))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Apogee=34000km\n",
        " Eccentricity=0.62\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.4, page no-37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration\n",
      "e=0.6                #Eccentricity\n",
      "d=18000.0            #distance between earth's centre and centre of ellipse\n",
      "\n",
      "\n",
      "#Calculation\n",
      "a=d/e\n",
      "A=a*(1+e)\n",
      "P=a*(1-e)\n",
      "\n",
      "\n",
      "#Result\n",
      "print(\"Semi-major axis of elliptical orbit is %d km\\n Apogee distance=%dkm\\n Perigee distance=%dkm\"%(a,A,P))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Semi-major axis of elliptical orbit is 30000 km\n",
        " Apogee distance=48000km\n",
        " Perigee distance=12000km\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.5, page no-38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "AP_diff=30000.0   #difference between apogee and perigee in km\n",
      "AP_sum=62800.0    #Apogee+perigee\n",
      "\n",
      "\n",
      "#Calculation\n",
      "E=AP_diff/AP_sum\n",
      "\n",
      "\n",
      "#Result\n",
      "print(\"Orbit Eccentricity= %.3f\"%E)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Orbit Eccentricity= 0.478\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.6, page no-38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Variable Declaration\n",
      "R=7000.0*10**3       # sattelite orbit in m\n",
      "mu=39.8*10**13       # constant G*M in Nm^2/kg\n",
      "A=47000.0*10**3      # appogee distance in m\n",
      "P=7000.0*10**3       # perigee distance in m\n",
      "\n",
      "\n",
      "#Calculation\n",
      "v=math.sqrt(mu/R)\n",
      "a=(A+P)/2\n",
      "v1=math.sqrt(mu*((2/R)-(1/a)))\n",
      "\n",
      "\n",
      "#Result\n",
      "print(\"Velocity of satellite A at point X is v=%.2fkm/s\\nVelocity of satellite B at point X is V=%.3fkm/s\"%(v/1000,v1/1000))\n",
      "#value in book is different at 3rd decimal place."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity of satellite A at point X is v=7.54km/s\n",
        "Velocity of satellite B at point X is V=9.949km/s\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.7, page no-39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Declaration\n",
      "R=42000.0*10**3       #sattelite orbit in m\n",
      "mu=39.8*10**13        #constant G*M in Nm^2/kg\n",
      "A=42000.0*10**3       #appogee distance in m\n",
      "P=7000.0*10**3        #perigee distance in m\n",
      "\n",
      "#Calculation\n",
      "v=math.sqrt(mu/R)\n",
      "a=(A+P)/2\n",
      "v1=math.sqrt(mu*((2/R)-(1/a)))\n",
      "\n",
      "#Result\n",
      "print(\"Velocity of satellite A at point X is v=%.3fkm/s\\n Velocity of satellite B at point X is V=%.3fkm/s\"%(v/1000,v1/1000))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity of satellite A at point X is v=3.078km/s\n",
        " Velocity of satellite B at point X is V=1.645km/s\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.8, page no-40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Variable Declaration\n",
      "R=25000.0*10**3       #sattelite orbit in m\n",
      "mu=39.8*10**13        #constant G*M in Nm^2/kg\n",
      "A=43000.0*10**3       #appogee distance in m\n",
      "P=7000.0*10**3        #perigee distance in m\n",
      "\n",
      "#Calculation\n",
      "v=math.sqrt(mu/R)\n",
      "a=(A+P)/2\n",
      "v1=math.sqrt(mu*((2/R)-(1/a)))\n",
      "\n",
      "#Result\n",
      "print(\"Velocity of satellite A at point X is v=%.3fkm/s\\n Velocity of satellite B at point X is V=%.3fkm/s\"%(v/1000,v1/1000))\n",
      "#value in book is different at 3rd decimal place."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity of satellite A at point X is v=3.990km/s\n",
        " Velocity of satellite B at point X is V=3.990km/s\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.9, page no-40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Variable Declaration\n",
      "a=(50000.0/2)*10**3           #Semi-major axis in m\n",
      "mu=39.8*10**13                #constant G*M in Nm^2/kg\n",
      "\n",
      "\n",
      "#Calculation\n",
      "T=2*math.pi*math.sqrt((a**3)/mu) #math.pi gives variation in answer\n",
      "h=T/(60*60)\n",
      "x=T%3600\n",
      "m=x/60\n",
      "s=x%60\n",
      "\n",
      "#Result\n",
      "print(\"Orbital time period is given by, T = %dsec\\n\\t\\t\\t\\t    = %dh %dm %ds\"%(T,math.floor(h),math.floor(m),math.floor(s)))\n",
      "#value in book is different for seconds."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Orbital time period is given by, T = 39368sec\n",
        "\t\t\t\t    = 10h 56m 8s\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.10, page no-42"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "a1=18000.0*10**3           #Semi-major axis for first satellite in m\n",
      "a2=24000.0*10**3           #Semi-major axis f0r 2nd satellite in m\n",
      "\n",
      "#Calculation\n",
      "T2_by_T1=(a2/a1)**(3.0/2.0)\n",
      "\n",
      "#Result\n",
      "print(\"Orbital time period of sattelite 2 is %.2f times that of sattelite 1\"%T2_by_T1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Orbital time period of sattelite 2 is 1.54 times that of sattelite 1\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.11, page no-42"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Variable Declaration\n",
      "a=25000.0*10**3       #appogee distance in m\n",
      "b=18330.0*10**3       #perigee distance in m\n",
      "\n",
      "\n",
      "#Calculation\n",
      "e=(math.sqrt(a**2-b**2)/a)\n",
      "\n",
      "\n",
      "#Result\n",
      "print(\"Apogee distance  = a(1+e)= %dkm\\n Perigee distance = a(1-e)= %dkm\\n\"%(a*(1+e)/1000,math.ceil(a*(1-e)/1000)))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Apogee distance  = a(1+e)= 42000km\n",
        " Perigee distance = a(1-e)= 8000km\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.12, page no-43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "e=0.6                  # eccentricity of elliptical orbit\n",
      "a=0.97                 # area of shaded region\n",
      "b=2.17                 # Area of non-shaded region\n",
      "t=3                    # time taken by satellite to move from pt B to A\n",
      "\n",
      "\n",
      "#Calculation\n",
      "x=b/a\n",
      "y=x*t\n",
      "\n",
      "#Result\n",
      "print(\"Time taken by satellite to move from A to B is %.3f hours \"%y)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time taken by satellite to move from A to B is 6.711 hours \n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.13, page no-44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "A=42000.0            # Apogee in km\n",
      "P=8000.0             # Perigee in km\n",
      "v_p=9.142            # velocity at perigee point\n",
      "\n",
      "\n",
      "#Calculation\n",
      "v_a=v_p*P/A\n",
      "\n",
      "\n",
      "#Result\n",
      "print(\"Velocity at apogee = %.3f km/s\"%v_a)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity at apogee = 1.741 km/s\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.14, page no-44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Declaration\n",
      "theta=56.245      #angle made by direction of satellite with local horizontal\n",
      "d=16000.0         #distance of particular point\n",
      "P=8000.0          #Perigee in m\n",
      "v_p=9.142         #velocity at perigee point\n",
      "\n",
      "\n",
      "#Calculation\n",
      "v=(P*v_p)/(d*math.floor(math.cos(theta*math.pi/180)*1000)/1000)\n",
      "\n",
      "\n",
      "#Result\n",
      "print(\"The velocity of satellite at that particular point is %.3f km/s\"%v)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of satellite at that particular point is 8.236 km/s\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.16, page no-49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Variable Declaration\n",
      "A1=12000.0                 # first Apogee distance\n",
      "P=8000.0                   # Perigee distance\n",
      "v1=1.0                     # assume v1 as 1\n",
      "v2=1.2*v1                  # 20% higher than v1 \n",
      "\n",
      "\n",
      "#Calculation\n",
      "x=(v2/v1)**2\n",
      "k=(((1+(P/A1))/x)-1)\n",
      "k=math.floor(k*10**4)/10**4\n",
      "A2=P/k\n",
      "\n",
      "\n",
      "#Result\n",
      "print(\"A2 = %.0fkm\"%math.ceil(A2))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A2 = 50826km\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.17, page no-50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Variable Declaration\n",
      "vp=8.0         # horizontal velocity of satellite in km/s\n",
      "r=1620.0       # distance from earth's surface in km\n",
      "R=6380.0       # Earth's radius in km\n",
      "d=10000.0      # distance of point at which velocity to be calculated\n",
      "theta=30.0     # angle made by satellite with local horzon at that point\n",
      "\n",
      "\n",
      "#Calculation\n",
      "P=r+R\n",
      "v=(vp*P)/(d*math.cos(theta*math.pi/180))\n",
      "\n",
      "#Result\n",
      "print(\"v = %.2f km/s\"%v)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "v = 7.39 km/s\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.18, page no-50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Declaration\n",
      "r=620.0         # distance from earth's surface in km\n",
      "vp=8.0          # horizontal velocity of satelliteat 9000km height in km/s\n",
      "R=6380.0        # Earth's radius in km\n",
      "d=9000.0        # distance of point at which velocity to be calculated\n",
      "theta=30.0      # angle made by satellite with local horzon at that point\n",
      "mu=39.8*10**13  # Nm**2/kg\n",
      "\n",
      "\n",
      "#Calculation\n",
      "P=r+R\n",
      "m=vp*d*math.cos(theta*math.pi/180)/P    #m=sqrt((2mu/P)-[2mu/(A+P)])\n",
      "m=(m*10**3)**2\n",
      "x=(2*mu/(P*10**3))-m          #x=[2mu/(A+P)]\n",
      "x=math.floor(x/10**4)*10**4\n",
      "k=(2*mu)/x               #k=A+P\n",
      "k=math.ceil(k/10**4)*10**4\n",
      "A=k-(P*10**3)\n",
      "\n",
      "#Result\n",
      "print(\"A = %.0f km\"%(A/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A = 16170 km\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.19, page no-58"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "#variable declaration\n",
      "R=6380                  #Earth's radius in km\n",
      "T=86160                 #Orbital period of Geostationary satellite in km\n",
      "mu=39.8*10**13          #in Nm^2/k\n",
      "\n",
      "#calculations\n",
      "\n",
      "r=(T*math.sqrt(mu)/(2*math.pi))**(2.0/3.0) # Answer matches to the answer given in the book if value of pi is taken as 3.14 \n",
      "\n",
      "#Result\n",
      "print('Radius of satellite is, r = %.0f km'%(r/1000))\n",
      "print('Therefore, height of satellite orbit above earth surface is %.0f km '%((r/1000)-R))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Radius of satellite is, r = 42142 km\n",
        "Therefore, height of satellite orbit above earth surface is 35762 km \n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.20, page no-59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#variable declaration\n",
      "\n",
      "R=6380                  #radius of earth in km\n",
      "P=400                   #Perigee distance in km\n",
      "A=40000                 #Apogee distance in km\n",
      "mu=39.8*10**13          #in Nm^2/k\n",
      "\n",
      "#calculation\n",
      "\n",
      "a=(A+P+R+R)/2           #semi-major axis of the elliptical orbit\n",
      "\n",
      "T=(2*math.pi*(a*10**3)**(3.0/2.0))/math.sqrt(mu)\n",
      "\n",
      "h=T/(60*60)\n",
      "x=T%3600\n",
      "m=x/60\n",
      "s=x%60\n",
      "\n",
      "#Result\n",
      "print('T = %dsec\\n  = %dh %dm %ds\\n\\nThis approximately equal to 12 hour'%(T,math.floor(h),math.floor(m),math.floor(s)))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "T = 43158sec\n",
        "  = 11h 59m 18s\n",
        "\n",
        "This approximately equal to 12 hour\n"
       ]
      }
     ],
     "prompt_number": 34
    }
   ],
   "metadata": {}
  }
 ]
}