{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#4: Electron Theory of Metals"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.1, Page number 4.28"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "energy difference is 1.81 *10**-37 J\n",
      "3/2*k*T = E2 = 3.62 *10**-37 J\n",
      "T = 1.75 *10**-14 K\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "m=9.1*10**-31;     #mass(kg)\n",
    "nx=ny=nz=1;\n",
    "n=6;\n",
    "a=1;     #edge(m)\n",
    "h=6.63*10**-34;     #planck's constant\n",
    "k=1.38\n",
    "#Calculation\n",
    "E1=h**2*(nx**2+ny**2+nz**2)/(8*m*a**2);\n",
    "E2=h**2*n/(8*m*a**2);\n",
    "E=E2-E1;               #energy difference(J)\n",
    "T=(2*E2*10**37)/(3*k*10**-23)\n",
    "#Result\n",
    "print \"energy difference is\",round(E*10**37,2),\"*10**-37 J\"\n",
    "print \"3/2*k*T = E2 =\",round(E2*10**37,2),\"*10**-37 J\"\n",
    "print \"T =\",round(T/10**23,2),\"*10**-14 K\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.2, Page number 4.28"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "temperature is 1261 K\n",
      "answer varies due to rounding off errors\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "y=1/100;    #percentage of probability\n",
    "x=0.5*1.6*10**-19;     #energy(J)\n",
    "k=1.38*10**-23;       #boltzmann constant\n",
    "\n",
    "#Calculation\n",
    "xbykT=math.log((1/y)-1);\n",
    "T=x/(k*xbykT);       #temperature(K)\n",
    "\n",
    "#Result\n",
    "print \"temperature is\",int(T),\"K\"\n",
    "print \"answer varies due to rounding off errors\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.3, Page number 4.29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fermi energy is 3.2 eV\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "d=970;    #density(kg/m**3)\n",
    "Na=6.02*10**26;    #avagadro number\n",
    "w=23;    #atomic weight\n",
    "m=9.1*10**-31;     #mass(kg)\n",
    "h=6.62*10**-34;     #planck's constant\n",
    "\n",
    "#Calculation\n",
    "N=d*Na/w;    #number of atoms/m**3\n",
    "x=h**2/(8*m);\n",
    "y=(3*N/math.pi)**(2/3);\n",
    "EF=x*y;     #fermi energy(J)\n",
    "\n",
    "#Result\n",
    "print \"fermi energy is\",round(EF/(1.6*10**-19),1),\"eV\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.4, Page number 4.29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "p(E) = 0.269\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "kT=1;\n",
    "E_EF=1;\n",
    "\n",
    "#Calculations\n",
    "p_E=1/(1+math.exp(E_EF/kT)) \n",
    "        \n",
    "#Result        \n",
    "print \"p(E) =\",round(p_E,3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.5, Page number 4.29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "N = 2.4 *10**26 states\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "from scipy.integrate import quad \n",
    "\n",
    "#Variable declarations\n",
    "m=9.1*10**-31\n",
    "h=6.626*10**-34\n",
    "Ef=3.1\n",
    "Ef1=Ef+0.02\n",
    "e=1.6*10**-19\n",
    "#Calculations\n",
    "def zintg(E):\n",
    "    return math.pi*((8*m)**(3/2))*(E**(1/2)*e**(3/2))/(2*(h**3))\n",
    "N=quad(zintg,Ef,Ef1)[0]\n",
    "\n",
    "#Result\n",
    "print\"N =\",round(N*10**-26,1),\"*10**26 states\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.6, Page number 4.30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "n = 8.5 *10**28 /m**3\n",
      "The drift speed Vd = 36.6 *10**-5 m/s\n",
      "The mean free collision time Tc = 2.087 *10**-14 seconds\n",
      "Mean free path = 3.34 *10**-8 m(answer varies due to rounding off errors)\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "N=6.023*10**26                   #Avagadro number\n",
    "D=8960                           #density  \n",
    "F_e=1                            #no.of free electrons per atom     \n",
    "W=63.54                          #Atomic weight\n",
    "i=10\n",
    "e=1.602*10**-19\n",
    "m=9.1*10**-31\n",
    "rho=2*10**-8\n",
    "Cbar=1.6*10**6                   #mean thermal velocity(m/s)\n",
    "\n",
    "#Calculations\n",
    "n=(N*D*F_e)/W\n",
    "A=math.pi*0.08**2*10**-4\n",
    "Vd=i/(A*n*e)                      #Drift speed\n",
    "Tc=m/(n*(e**2)*rho)\n",
    "lamda=Tc*Cbar\n",
    "\n",
    "#Result\n",
    "print\"n =\",round(n/10**28,1),\"*10**28 /m**3\"\n",
    "print\"The drift speed Vd =\",round(Vd*10**5,1),\"*10**-5 m/s\"\n",
    "print\"The mean free collision time Tc =\",round(Tc*10**14,3),\"*10**-14 seconds\"\n",
    "print\"Mean free path =\",round(lamda*10**8,2),\"*10**-8 m\"\"(answer varies due to rounding off errors)\" \n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.7, Page number 4.30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The mean free collision time = 4.8 *10**7 ohm**-1 m**-1\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "##Variable declaration\n",
    "n=8.5*10**28\n",
    "e=1.602*10**-19\n",
    "t=2*10**-14\n",
    "m=9.1*10**-31\n",
    "\n",
    "#Calculations\n",
    "Tc=n*(e**2)*t/m\n",
    "\n",
    "#Result\n",
    "print \"The mean free collision time =\",round(Tc/10**7,1),\"*10**7 ohm**-1 m**-1\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.8, Page number 4.31"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Relaxation time = 4.0 *10**-14 second\n",
      "Mobility = 7.0 *10**-3 m**2/volt-s\n",
      "Drift Velocity= 0.7 m/s\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "\n",
    "#Variable declaration\n",
    "e=1.6*10**-19\n",
    "E=1                    #(V/m)\n",
    "rho=1.54*10**-8\n",
    "n=5.8*10**28\n",
    "\n",
    "#Calculations\n",
    "T=m/(rho*n*e**2)\n",
    "Me=(e*T)/m\n",
    "Vd=Me*E\n",
    "\n",
    "#Result \n",
    "print\"Relaxation time =\",round(T*10**14),\"*10**-14 second\"\n",
    "print\"Mobility =\",round(Me*10**3),\"*10**-3 m**2/volt-s\"\n",
    "print\"Drift Velocity=\",round(Vd*100,1),\"m/s\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.9, Page number 4.31"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Temperature coefficient of resistivity,a = 5.7\n",
      "rho_973 = 5.51 *10**-8 ohm-m\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "\n",
    "##Variable declaration\n",
    "rho_r=0\n",
    "T=300\n",
    "rho=1.7*10**-18\n",
    "\n",
    "#Calculations \n",
    "a=rho/T\n",
    "rho_973=a*973\n",
    "\n",
    "#Results\n",
    "print\"Temperature coefficient of resistivity,a =\",round(a*10**21,1)\n",
    "print\"rho_973 =\",round(rho_973*10**18,2),\"*10**-8 ohm-m\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.10, Page number 4.31"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Increase in resistivity in copper = 0.54 *10**-8 ohm m\n",
      "Total resistivity of copper alloy = 2.04 *10**-8 ohm m\n",
      "The resistivity of alloy at 3K = 0.54 *10**-8 ohm m\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "\n",
    "##Variable declaration\n",
    "rho1=1.2*10**-8\n",
    "p1=0.4\n",
    "rho2=0.12*10**-8\n",
    "p2=0.5\n",
    "rho3=1.5*10**-8\n",
    "#Calculations\n",
    "R=(rho1*p1)+(rho2*p2)\n",
    "R_c=R+rho3\n",
    "\n",
    "#Results\n",
    "print\"Increase in resistivity in copper =\",round(R*10**8,2),\"*10**-8 ohm m\"\n",
    "print\"Total resistivity of copper alloy =\",round(R_c*10**8,2),\"*10**-8 ohm m\"\n",
    "print\"The resistivity of alloy at 3K =\",round(R*10**8,2),\"*10**-8 ohm m\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}