{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 10: Electromagnetism"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.15, Page 10.42"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given \n",
      "n = 2000 # flux lines enter in given volume  in Vm\n",
      "n_ = 4000 # flux lines diverge from given volume in Vm\n",
      "e0 = 8.85e-12 # permittivity of space\n",
      "\n",
      "#Calculations\n",
      "fi = n_ - n\n",
      "q = e0 * fi\n",
      "\n",
      "#Result\n",
      "print 'The total charge within volume(in C) = ',q"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The total charge within volume(in C) =  1.77e-08\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.16, Page 10.42"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given \n",
      "n = 20000 # flux lines entering in given volume in Vm\n",
      "n_ = 45000 # flux lines entering out from given volume in Vm\n",
      "e0 = 8.85e-12 # permittivity of space\n",
      "\n",
      "#Calculations\n",
      "fi = n_ - n\n",
      "q = e0 * fi\n",
      "\n",
      "#Result\n",
      "print \"The total charge enclosed by closed surface is %.3e C\"%q"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The total charge enclosed by closed surface is 2.212e-07 C\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.17, Page 10.43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given \n",
      "q = 13.5e-6 # charge enclosed at the centre of cube in C\n",
      "l = 6 # length of the side of cube in cm\n",
      "e0 = 8.85e-12 # permittivity of space\n",
      "\n",
      "#Calculations\n",
      "fi = q / e0\n",
      "fi_ = fi / 6\n",
      "q = e0 * fi\n",
      "\n",
      "#Results\n",
      "print \"Electric flux through the whole volume of the cube is %.3e Nm^2/C\\nElectric flux through one face of the cube is %.2e Nm^2/C\"%(fi,fi_)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Electric flux through the whole volume of the cube is 1.525e+06 Nm^2/C\n",
        "Electric flux through one face of the cube is 2.54e+05 Nm^2/C\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.18, Page 10.43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given \n",
      "q = 11 # charge enclosed at the centre of cube in C\n",
      "l = 5 # length of the side of cube in cm\n",
      "e0 = 8.85e-12 # permittivity of space\n",
      "\n",
      "#Calculation\n",
      "fi_ = (q / e0) / 6\n",
      "\n",
      "#Result\n",
      "print \" Electric flux through each surface of the cube = %.2e Nm^2/C\"%fi_"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Electric flux through each surface of the cube = 2.07e+11 Nm^2/C\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.19, Page 10.43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "\n",
      "# Given \n",
      "q = 1e-8 # charge uniformly spread over metallic sphere in C\n",
      "r = .1 #radius of sphere in m\n",
      "d = 7 # distance of a point from centre of the sphere in cm\n",
      "d_ = .5 # distance of another point from centre of the sphere in m\n",
      "e0 = 8.85e-12 # permittivity of space\n",
      "\n",
      "#calculations\n",
      "E1 = (1 / (4 * pi * e0) * (q / r**2))\n",
      "E2 = 0 #because sphere is metallic\n",
      "E3 = (1 / (4 * pi * e0) * (q / d_**2))\n",
      "\n",
      "#Result\n",
      "print \"Electric field intensity-\\n(1) On the surface of the sphere = %.e N/C\\n(2) At first point = %d N/C\\n(3)At second point = %.2e N/C\"%(E1,E2,E3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Electric field intensity-\n",
        "(1) On the surface of the sphere = 9e+03 N/C\n",
        "(2) At first point = 0 N/C\n",
        "(3)At second point = 3.60e+02 N/C\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.20, Page 10.44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "\n",
      "# Given \n",
      "q = 1.6e-19 # charge on a proton in C\n",
      "d = 1e-10 # distance of a point from proton in m\n",
      "e0 = 8.85e-12 # permittivity of space\n",
      "\n",
      "#Calculation\n",
      "E = (1 / (4 * pi * e0)) * (q / d**2)\n",
      "\n",
      "#Result\n",
      "print \"Electric field = %.2e V/m\"%E"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Electric field = 1.44e+11 V/m\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.21, Page 10.44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given \n",
      "v = 1000 # potential through which alpha particle accelerated in V\n",
      "q = 3.2e-19 # charge on an alpha particle in C\n",
      "e0 = 8.85e-12 # electric permittivity of space\n",
      "\n",
      "#calculation\n",
      "E = q * v\n",
      "\n",
      "#Result\n",
      "print \"Energy gained by alpha particle = %.1e J\"%E"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Energy gained by alpha particle = 3.2e-16 J\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.22, Page 10.44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "\n",
      "# Given \n",
      "q = 1.6e-19 # charge on a proton in C\n",
      "d = 1e-10 # distance of a point from proton in m\n",
      "d_ = 2e-11 # distance of another point from proton in m\n",
      "e0 = 8.85e-12 # permittivity of space\n",
      "\n",
      "#calculations\n",
      "v = (1 / (4 * pi * e0)) * (q / d)#calculation for potential at first point\n",
      "E = -q * v#calculation for energy at first point in J\n",
      "delta_v = (1 / (4 * pi * e0)) * q * ((1 / d_) - (1 / d))#calculation for potential difference between points\n",
      "\n",
      "#Result\n",
      "print \"Potential energy at first point = %.1f eV\\nPotential difference between points = %.1f V\"%(E/q,delta_v)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Potential energy at first point = -14.4 eV\n",
        "Potential difference between points = 57.5 V\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.23, Page 10.45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi, ceil\n",
      "\n",
      "# Given \n",
      "q = 1.5e-6 # charge in C\n",
      "v = 30 # potential of a surface in V\n",
      "e0 = 8.85e-12 # permittivity of space\n",
      "\n",
      "#Calculation\n",
      "r = (1 / (4 * pi * e0)) * (q / v)\n",
      "\n",
      "#Result\n",
      "print \"Radius of equipotential surface = %d m\"%ceil(r)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Radius of equipotential surface = 450 m\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.24, Page 10.45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "\n",
      "# Given \n",
      "p = 3.8e26 # power radiated by sun in W\n",
      "r = 7e8 # radius of sun in m\n",
      "e0 = 8.85e-12 # permittivity of space\n",
      "\n",
      "#Calculation\n",
      "s = p / (4 * pi * r**2)\n",
      "\n",
      "#Result\n",
      "print \"The value of poynting vector at the surface of the sun = %.3e W/m^2\"%s"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of poynting vector at the surface of the sun = 6.171e+07 W/m^2\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.25, Page 10.45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Se = (2*4.2)/(60*10**-4)   #J/m^2-sec\n",
      "c = 3*10**8                #m/s\n",
      "res = 1.4*10**11           #m\n",
      "rs = 7*10**7               #W/m^2\n",
      "\n",
      "#Calculations\n",
      "Prad_e = Se/c\n",
      "Ss = Se*((res/rs)**2)\n",
      "Prad_s = Ss/c\n",
      "\n",
      "#Results\n",
      "print \"Radiation pressure at the surface of the earth =%.2e N/m^2\"%Prad_e\n",
      "print \"Radiation pressure at the surface of the sun =%.3e N/m^2\"%Prad_s"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Radiation pressure at the surface of the earth =4.67e-06 N/m^2\n",
        "Radiation pressure at the surface of the sun =1.867e+01 N/m^2\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.28, Page 10.47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "# Given \n",
      "s = 2 # energy received by the earth in cal/cm^2.min\n",
      "e0 = 8.85e-12 # electric permittivity of space\n",
      "mu0 = 1.2567e-6 # magnetic permittivity of space\n",
      "c = 3e8 # speed of light in meter/sec\n",
      "\n",
      "#calculations\n",
      "r = sqrt(mu0 / e0)\n",
      "P = s*4.2/(60*1e-4)\n",
      "E = sqrt(P*r)\n",
      "H = E/r\n",
      "\n",
      "#Result\n",
      "print \"Magnitude of electric field vector = %.1f v/m\\nMagnitude of magnetic field vector = %.3f A/m\"%(E * sqrt(2),H*sqrt(2))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Magnitude of electric field vector = 1027.2 v/m\n",
        "Magnitude of magnetic field vector = 2.726 A/m\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.29, Page 10.48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "# Given \n",
      "H = 1 # magnitude of magnetic field vector A/m\n",
      "e0 = 8.85e-12 # electric permittivity of space\n",
      "mu0 = 1.2567e-6 # magnetic permittivity of space\n",
      "c = 3e8 # speed of light in meter/sec\n",
      "\n",
      "#Calculations\n",
      "r = sqrt(mu0 / e0) # ratio of E,H\n",
      "E = H * r\n",
      "\n",
      "#Result\n",
      "print \"Magnitude of electric field vector = %.2f v/m.\"%E"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Magnitude of electric field vector = 376.83 v/m.\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.31, Page 10.48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt, pi\n",
      "\n",
      "# Given \n",
      "p = 1000 # power of lamp in W\n",
      "d = 2 # distance of a point from lamp in meter\n",
      "e0 = 8.85e-12 # electric permittivity of space\n",
      "mu0 = 1.2567e-6 # magnetic permittivity of space\n",
      "c = 3e8 # speed of light in meter/sec\n",
      "\n",
      "#Calculations\n",
      "s = p / (4 * pi * d**2) #calculation for \n",
      "r = sqrt(mu0 / e0) # ratio of E,H\n",
      "E = sqrt(s * r)#calculation for average value of intensity of electric field of radiation\n",
      "\n",
      "#Result\n",
      "print \"Average value of the intensity of electric field of radiation = %.2f v/m.\"%E"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Average value of the intensity of electric field of radiation = 86.58 v/m.\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.32, Page 10.49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "# Given \n",
      "k = 81 # relative permittivity of water \n",
      "c = 3e8 # speed of light in meter/sec\n",
      "\n",
      "#Calculations\n",
      "mu = sqrt(k)\n",
      "v = c / mu\n",
      "\n",
      "#Result\n",
      "print \"Refractive index of distilled water is %d \\nSpeed of light in water is %.2e m/sec\"%(mu,v)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Refractive index of distilled water is 9 \n",
        "Speed of light in water is 3.33e+07 m/sec\n"
       ]
      }
     ],
     "prompt_number": 5
    }
   ],
   "metadata": {}
  }
 ]
}