{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5:Quantum Mechanics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.4,Page no:180"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration \n",
      "L= 1.0; #assuming Length L of box to be 1, this would not affect the probability\n",
      "x1=0.45; #lower bound\n",
      "x2=0.55; #upper bound\n",
      "\n",
      "from scipy.integrate import quad\n",
      "import math\n",
      "\n",
      "#Calculation \n",
      "def f(x):\n",
      "    y=(math.sin(n*(math.pi)*x))**2\n",
      "    return(y)\n",
      "n=1.0;\n",
      "I1=quad(f,x1,x2) #for ground state\n",
      "P1=(2/L*I1[0])\n",
      "n=2.0;\n",
      "I2=quad(f,x1,x2) #for ground state\n",
      "P2=(2/L*I2[0])\n",
      "\n",
      "\n",
      "\n",
      "#Result\n",
      "print\"The probability n ground state is: \",round(P1,3),\"=\",round(P1,3)*100,\"percent\"\n",
      "print\"The probability in first excited state is: \",round(P2,4),\"=\",round(P2,4)*100,\"percent\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The probability n ground state is:  0.198 = 19.8 percent\n",
        "The probability in first excited state is:  0.0065 = 0.65 percent\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.6,Page no:186"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "#Part (a)\n",
      "E1= 1.0 #energy of first electron, eV\n",
      "E2= 2.0  #energy of second electron, eV\n",
      "Eb= 10.0 #height of barrier, eV\n",
      "Wb= 0.50 #width of barrier, nm\n",
      "Wb= Wb* 10**(-9) #converting to m\n",
      "hbar= 1.054*10**(-34) #reduced Planck's conctaant, J.s\n",
      "Me= 9.1*10**(-31) #mass of electron, kg\n",
      "e= 1.6*10**(-19) #charge of an electron, J/eV\n",
      "import math\n",
      "#Calculation\n",
      "\n",
      "k2= (math.sqrt(2*(Me)*(Eb-E1)*(e)))/(hbar) #for 1.0 eV e-, m**(-1)\n",
      "k1= (math.sqrt(2*Me*(Eb-E2)*e))/hbar #for first electron, m**(-1)\n",
      "T1= math.exp((-2)*k2*Wb) #transmission probability for first electron\n",
      "T2= math.exp((-2)*k1*Wb) #for second electron\n",
      "print\"(A.)\\nTransmission probability for electrons with energy 1.0 eV is:%.2g\"%T1\n",
      "print\"Transmission probability for electrons with energy 2.0 eV is: %.2g\"%T2\n",
      "\n",
      "#Part (b)\n",
      "Wb= Wb*2; #Barrier width doubled\n",
      "T11= math.exp((-2)*k2*Wb) # changed transmission probability for first electron\n",
      "T22= math.exp((-2)*k1*Wb) #for second electron\n",
      "\n",
      "#Result\n",
      "print\"\\n\\n(B.):After the barrier width is doubled:\\n\"\n",
      "print\"Transmission probability for electrons with energy 1.0 eV is:%.2g\"%T11\n",
      "print\"Transmission probability for electrons with energy 2.0 eV is: %.2g\"%T22\n",
      "print\"\\n\\nNOTE:Calculation mistake in book in the calculation of k2,\\nit is wrongly written as 1.6e+10,\\nTHAT's Why a change in final answer\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(A.)\n",
        "Transmission probability for electrons with energy 1.0 eV is:2.1e-07\n",
        "Transmission probability for electrons with energy 2.0 eV is: 5.1e-07\n",
        "\n",
        "\n",
        "(B.):After the barrier width is doubled:\n",
        "\n",
        "Transmission probability for electrons with energy 1.0 eV is:4.6e-14\n",
        "Transmission probability for electrons with energy 2.0 eV is: 2.6e-13\n",
        "\n",
        "\n",
        "NOTE:Calculation mistake in book in the calculation of k2,\n",
        "it is wrongly written as 1.6e+10,\n",
        "THAT's Why a change in final answer\n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}