{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 5:Conductivity of Metals and Superconductivity"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.1,Page No:5.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "velocity=1.17e-07 m/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "d       = 2*10**-3;                 #diameter in m \n",
    "I       = 5*10**-3;                 #current in A\n",
    "e       = 1.6*10**-19;              #charge of electron in coulombs \n",
    "a       = 3.61*10**-10;             #side of cube in m\n",
    "N       = 4;                       #number of atoms in per unit cell\n",
    " \n",
    " \n",
    "#formula\n",
    "#J=n*v*e\n",
    "\n",
    "#calculation\n",
    "r       = d/float(2);                #radius in m\n",
    "n       = N/float(a**3);             #number of atoms per unit volume in atoms/m**3\n",
    "A       = math.pi*(r**2);            #area in m**2\n",
    "J       = I/float(A);                #current density in Amp/m**2\n",
    "v       = J/float(n*e);              #average drift velocity in m/s\n",
    "\n",
    "#result\n",
    "print'velocity=%3.2e'%v,'m/s';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.2,Page No:5.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "velocity=1.06e-03 m/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "I       = 6;                    #current in A\n",
    "d       = 1*10**-3;             #diameter in m\n",
    "n       = 4.5*10**28;           #electrons available in electron/m**3\n",
    "e      = 1.6*10**-19;           #charge of  electron  in coulombs\n",
    "\n",
    "\n",
    "#calculation\n",
    "r     = d/float(2);               #radius in m\n",
    "A     = math.pi*(r**2);           #area in m**2\n",
    "J     = I/float(A);               #current density in A/m**3\n",
    "vd    = J/float(n*e);             #density in m/s\n",
    " \n",
    " \n",
    "#result\n",
    "print'velocity=%3.2e'%vd,'m/s';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.3,Page No:5.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "velocity=4.80e-06 m/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "V       = 63.5;             #atomic weight in kg\n",
    "d       = 8.92*10**3;        #density of copper in kg/m**3\n",
    "r       = 0.7*10**-3;        #radius in m\n",
    "I       = 10;               #current in A\n",
    "e       = 1.6*10**-19;          #charge of electronin coulomb\n",
    "h       = 6.02*10**28;          #planck's constant in (m**2)*kg/s\n",
    "\n",
    "\n",
    "#calculation\n",
    "A        = math.pi*(r**2);          # area in m**2\n",
    "N        = h*d;\n",
    "n        = N/float(V);\n",
    "J        = I/float(A);              #current density in m/s\n",
    "vd       = J/float(n*e);            #drift velocity in m/s\n",
    "\n",
    "#result\n",
    "print'velocity=%2.2e'%vd,'m/s';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.4,Page No:5.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "restivity=1.82e-08 ohm m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "R        = 0.182;             #resistance in ohm\n",
    "l       = 1;                  #length in m\n",
    "A       = 0.1*10**-6;         #area in m**2\n",
    "\n",
    "#formula \n",
    "#R=(p*l)/A\n",
    "\n",
    "#calculation\n",
    "p      = (R*A)/float(l);              #resistivity in ohm m\n",
    "\n",
    "\n",
    "#result\n",
    "print'restivity=%3.2e'%p,'ohm m';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.5,Page No:5.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "velocity=0.7 m/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "n        = 5.8*10**28;                 #number of silver electrons in electrond/m**3\n",
    "p        = 1.45*10**-8;                #resistivity in ohm m\n",
    "E        = 10**2;                      #electric field in V/m\n",
    "e        = 1.6*10**-19; \n",
    "\n",
    "\n",
    "#formula\n",
    "#sigma  = n*e*u \n",
    "#sigma=p\n",
    "#calculation\n",
    "u       = 1/float(n*e*p);\n",
    "vd      = u*E;                    #drift velocity in m/s\n",
    "\n",
    "#result\n",
    "print'velocity=%3.1f'%vd,'m/s';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.6,Page No:5.8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "density=7.25e-03 m**2.V**-1.s**-1\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "W           = 107.9;               #atomic weight in amu(atomic mass unit)\n",
    "p           = 10.5*10**3;           #density in kg/m**3\n",
    "sigma       =6.8*10**7;            #conductivity in ohm**-1.m**-1\n",
    "e           =1.6*10**-19;          #charge of electron in coulombs\n",
    "N           = 6.02*10**26;         #avagadro number in mol**-1\n",
    " \n",
    "\n",
    "#calculation\n",
    "n       = (N*p)/float(W);              #number of atoms per unit volume \n",
    "u      = sigma/float(n*e);          #density of electron in m**2.V**-1.s**-1\n",
    "\n",
    "\n",
    "#result\n",
    "print'density=%3.2e'%u,'m**2.V**-1.s**-1';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.7,Page No:5.8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time=2.51e-14 s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "#for common metal copper\n",
    "n           = 8.5*10**28;               #number of atoms in m**-3\n",
    "sigma       = 6*10**7;                  #sigma  in ohm**-1 m**-1\n",
    "m           = 9.1*10**-31;              #mass of electron in kilogram\n",
    "e           = 1.6*10**-19;              #charge of electron in coulombs\n",
    "\n",
    "#calculation\n",
    "t  = (m*sigma)/float(n*(e**2));       #relaxation time in s\n",
    "\n",
    "#result\n",
    "print'time=%3.2e'%t,'s';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.9,Page No:5.14"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "thermal conductivity=1.6731  W/m-K\n",
      " Note: calculation mistake in textbook in calculating K as T value is taken 325 instead of 3.25\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "t       = 3.0*10**-14;              #time in s\n",
    "n       = 2.5*10**22;               #in electrons per m**3\n",
    "m       = 9.1*10**-31;              #mass of electron in kilograms\n",
    "e       = 1.6*10**-19;              #charge of electron in coulombs\n",
    "T       = 3.25;                     #temperature in K\n",
    "\n",
    "\n",
    "#formula\n",
    "#K/(sigma*T)=2.44*10**-8   from wiedemann Franz law\n",
    "#calculation\n",
    "sigma    = (n*(e**2)*t)/float(m*10**-6);             #conductivity in m**3\n",
    "K        = (2.44*10**-8)*sigma*T;                    #thermalconductivity in W/m-K\n",
    "\n",
    "\n",
    "#result\n",
    "print'thermal conductivity=%3.4f '%K,'W/m-K';\n",
    "print' Note: calculation mistake in textbook in calculating K as T value is taken 325 instead of 3.25';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.10,Page No:5.20"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "energy diefference=1.13e+02 eV\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "a       = 10**-10;                   #one dimension in m\n",
    "m       = 9.1*10**-31;               #mass of kg\n",
    "h       = 6.62*10**-34;              #planck's constant in joule-s\n",
    "\n",
    "\n",
    "#formula\n",
    "#En   = ((n**2)*(h**2))/float(8*m*(a**2))\n",
    "#calculation\n",
    "E1      = (h**2)/float(8*m*(a**2));           #energy in J\n",
    "E2      = (4*(h**2))/float(8*m*(a**2));       #energy in J\n",
    "dE       = (3*(h**2))/float(8*m*(a**2));      #energy diefference in J \n",
    "x        = dE/float(1.6*10**-19);      #energy diefference in eV\n",
    "\n",
    "#result\n",
    "print'energy diefference=%3.2e'%x,'eV';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.11,Page No:5.20"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fermi energy=3.16 eV\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "N         =6.02*10**23;            #avagadro number in atoms /mole\n",
    "h        = 6.63*10**-34;            #planck's constant in joule-s\n",
    "m        = 9.11*10**-31;            #mass in kg\n",
    "M        = 23;                      #atomic weight in grams /mole\n",
    "p        = 0.971;                   #density in gram/cm**3\n",
    "\n",
    "\n",
    "#formula \n",
    "#x=N/V=(N*p)/M\n",
    "#calculation\n",
    "x       = (N*p)/float(M);\n",
    "x1      = x*10**6;\n",
    "eF      = (((h**2)/float(2*m)))*(((3*x1)/(8*math.pi))**(2/float(3)));       #Fermi energy\n",
    "eF1     = (eF)/float(1.6*10**-19);\n",
    "\n",
    "#result\n",
    "print'fermi energy=%3.2f'%eF1,'eV';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.12,Page No:5.21"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fermi energy =3.16 eV\n",
      "fermi velocity =1.05e+06 m/s\n",
      "femi temperature =3.66e+04 K\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "x       = 2.54*10**28;           #number of electrons in per m**2\n",
    "h       = 6.63*10**-34;          # planck's constant in joule-s\n",
    "m       = 9.11*10**-31;          # mass in kg\n",
    "p       = 0.971;                 #density in grams/cm**3\n",
    "k       = 1.38*10**-23;\n",
    " \n",
    "\n",
    "#calculation\n",
    "#x       = (N*p)/float(M);\n",
    "eF      = (((h**2)/(2*m)))*(((3*x)/float(8*math.pi))**(2/float(3))); \n",
    "eF1     = (eF)/float(1.6*10**-19);                                  #Fermi energy in eV\n",
    "vF      = math.sqrt((2*eF)/float(m));                               #fermi velocity in m/s\n",
    "TF      = eF/float(k);                                             #fermi temperature in K\n",
    "  \n",
    "\n",
    "#result\n",
    "print'fermi energy =%3.2f'%eF1,'eV';\n",
    "print'fermi velocity =%3.2e'%vF,'m/s';\n",
    "print'femi temperature =%3.2e'%TF,'K';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.13,Page No:5.21"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fermi energy = 11 eV\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "M      = 65.4;              #atomic weight\n",
    "p      = 7.13;              #density in g/cm**3\n",
    "h      = 6.62*10**-34;      # planck's constant in joules-s\n",
    "m      = 7.7*10**-31;       # mass\n",
    "v      = 6.02*10**23;       #avagadros number in atoms/gram-atom\n",
    "\n",
    "\n",
    "#calculation\n",
    "#x =N/V\n",
    "V      = M/float(p);                                                        #volume of one atom in cm**3\n",
    "n      = v/float(V);                                                        # number of Zn atoms in volume v\n",
    "x      = 2*n*(10**6);                                                        #number of free electrons in unit volume iper m**2\n",
    "eF     = ((h**2)/float(2*m))*(((3*x)/float(8*math.pi))**(2/float(3)));        # fermi energy in J\n",
    "eF1    = eF/float(1.6*(10**-19));\n",
    "\n",
    "\n",
    "#result\n",
    "print'fermi energy =%3.2d'%eF1,'eV';\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.14,Page No:5.22"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "number of electrons per unit volume =4e+28 m**-3\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "eF     = 4.27;             #fermi energy in eV\n",
    "m      = 9.11*10**-31;      # mass of electron in kg\n",
    "h      = 6.63*10**-34;      # planck's constant J.s\n",
    "\n",
    "\n",
    "#formula\n",
    "#x= N/V\n",
    "#calculation\n",
    "eF1    = eF*1.6*10**-19;                                                   #fermi energy in eV                \n",
    "x      = (((2*m*eF1)/float(h**2))**(3/float(2)))*((8*math.pi)/float(3));    #number of electrons per unit volume\n",
    "\n",
    "\n",
    "#result\n",
    "print'number of electrons per unit volume =%4.00e'%x,'m**-3';\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Example 5.15,Page No:5.23"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "electron density  for a metal =1.47e+28 m**-3\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "eF1       = 4.70;             # fermi energy in eV\n",
    "eF2       = 2.20;             #fermi energy in eV\n",
    "x1        = 4.6*10**28;        # electron density of lithium per m**3\n",
    "\n",
    "\n",
    "#formula\n",
    "#N/V = (((2*m*eF1)/(h**2))**(3/2))*((8*math.pi)/3);\n",
    "#N/V = k*(eF**3/2)\n",
    "#N/V = x\n",
    "#calculation\n",
    "x2      = x1*((eF2/float(eF1))**(3/float(2)));            #electron density for metal in per m**3\n",
    "\n",
    "\n",
    "#result\n",
    "print'electron density  for a metal =%4.2e'%x2,'m**-3';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Example 5.16,Page No:5.24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "average energy =3.24 eV\n",
      "temperature =2.50e+04 K\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "eF      = 5.4;                         #fermi energy in eV\n",
    "k       = 1.38*10**-23;                 # k in joule/K\n",
    "\n",
    "\n",
    "#calculation\n",
    "e0      = (3*eF)/float(5);                           #average energy in eV\n",
    "T       = (e0*(1.6*10**-19)*2)/float(3*k);           #temperature in K\n",
    " \n",
    "\n",
    "#result\n",
    "print'average energy =%3.2f'%e0,'eV';\n",
    "print'temperature =%3.2e'%T,'K';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.17,Page No:5.25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "average energy =9.0 eV\n",
      "speed =1.78e+06 m/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "EF        = 15;                     #fermi energy  in eV\n",
    "m         = 9.1*10**-31;            #mass of electron in kilogarams\n",
    "\n",
    "\n",
    "#calculation\n",
    "E0        = (3*EF)/float(5);                                     #average energy en eV\n",
    "v         = math.sqrt((2*E0*1.6*10**-19)/float(m));              #speed of electron in m/s\n",
    "\n",
    "\n",
    "#result\n",
    "print'average energy =%3.1f'%E0,'eV';\n",
    "print'speed =%3.2e'%v,'m/s';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.18,Page No:5.25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "average energy =4.50 eV\n",
      " speed =1.26e+06 m/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "EF        = 7.5;                     #fermi energy  in eV\n",
    "m         = 9.1*10**-31;            #mass of electron in kilograms\n",
    "\n",
    "#calculation\n",
    "E0        = (3*EF)/float(5);             #average energy en eV\n",
    "v         = math.sqrt((2*E0*1.6*10**-19)/float(m));       #speed in m\n",
    "\n",
    "#result\n",
    "print'average energy =%3.2f'%E0,'eV';\n",
    "print' speed =%3.2e'%v,'m/s';\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.19,Page No:5.25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "energy=3.12 eV\n",
      " speed= =1.05e+06 m/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "m     = 9.1*10**-31;       #mass of electron in kg\n",
    "h     = 6.62*10**-34;      #planck's constant in (m**2)*kg/s\n",
    "#formula\n",
    "#x=N/V\n",
    "x      = 2.5*10**28;\n",
    "\n",
    "#calculation\n",
    "EF       = ((h**2)/float(8*(math.pi**2)*m))*((3*(math.pi**2)*x)**(2/float(3)));      #fermi energy in J\n",
    "EF1      = EF/float(1.6*10**-19);                                                    #fermi energy in eV\n",
    "vF       = (h/float(2*m*math.pi))*((3*(math.pi**2)*x)**(1/float(3)));                #fermi velocity in m/s\n",
    "\n",
    "\n",
    "#result\n",
    "print'energy=%3.2f'%EF1,'eV';\n",
    "print' speed= =%3.2e'%vF,'m/s';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.20,Page No:5.29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "efficiency =99.998163  %\n",
      "voltage drop =1.8 %\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Ps      = 10**7;                 #power in W\n",
    "V      = 33*10**3;               #power transmitted in W\n",
    "R      = 2;                      #resistance in ohm\n",
    " \n",
    "#calculation\n",
    "I      = Ps/float(V);                    #current in A\n",
    "Pd     = (I**2*R)/float(1000);           #power lost in feeder in kW   \n",
    "n      = ((Ps-Pd)/float(Ps))*100;        #efficiency in %\n",
    "v      = I*R;                            #voltage drop in V\n",
    "Vd     = (v/float(V))*100;              #percentage voltage drop\n",
    " \n",
    "#result\n",
    "print'efficiency =%0f '%n,'%';\n",
    "print'voltage drop =%3.1f'%Vd,'%';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.21,Page No:5.36"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "aCu,Fe = -13.8 uV/°C\n",
      " bCu,Fe = 0.042 uV/(°C)**2\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "a1   = 2.76;               #a1 in uv/°C\n",
    "a2   = 16.6;              #a2 in uv/°C\n",
    "b1   = 0.012;              #b1 in uv/°C\n",
    "b2   = -0.03;              #b2 in uv/°C\n",
    "\n",
    "#calculation\n",
    "#aFe,Pb   =a1 \n",
    "#aCu,Pb   = a2\n",
    "#bCu,Fe   = b1\n",
    "#bFe,Pb   = b2\n",
    "\n",
    "#calculation\n",
    "a3    = a1-a2;              #a3 in uv/°C\n",
    "b3    = b1-b2;              #b3 in uv/(°C)**2\n",
    "\n",
    "#result\n",
    "print'aCu,Fe = %3.1f'%a3,'uV/°C';\n",
    "print' bCu,Fe = %3.3f'%b3,'uV/(°C)**2';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.23,Page No:5.37"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "neutral temperature =225  °C\n",
      "temperature of inversin = 450  °C\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "a       = 15;              #a in uv/°C\n",
    "b       = -1/float(30);              #b in uv/°C\n",
    "\n",
    "#E = at+bt^2\n",
    "#dE/dT =a+2*b*t\n",
    "#t=tn\n",
    "#dE/dT =0\n",
    "#calculation\n",
    "tn     = -(a/float(2*(b)))               #neutral temperature in °C\n",
    "#t1+t2  = 2*t2;\n",
    "t2    = 2*tn               #inversion temperature in °C\n",
    " \n",
    "#result\n",
    "print'neutral temperature =%3.2d '%tn,'°C';\n",
    "print'temperature of inversin = %3.2d '%t2,'°C';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.24,Page No:5.37"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "resistivity of alloy =4.4533 uΩ-cm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "p2        =  2.75;         #resistivity of alloy 1 percent of Ni in uΩ-cm\n",
    "p1        =  1.42;         #resistivity of pure copper in uΩ-cm\n",
    "p3        = 1.98;          #resistivity of alloy 3 percent of silver in uΩ-cm\n",
    " \n",
    "#p(Ni+Cu) =p1\n",
    "#pCu =p2\n",
    "#p(Cu+silver)=p3\n",
    "#calculation\n",
    "pNi        = p2-p1;\n",
    "p4         = (p3-p1)/float(3);\n",
    "palloy     = p1+(2*pNi)+(2*p4);        #resistivity of alloy 2 percent of silver and 2 percent of nickel in uΩ-cm\n",
    " \n",
    "#result\n",
    "print'resistivity of alloy =%3.4f'%palloy,'uΩ-cm';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.25,Page No:5.41"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "transition temperature =4.174 K\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "M1       = 202;           #mass number\n",
    "M2       = 200;          # mass number\n",
    "Tc1      = 4.153;       # temperature in K\n",
    "alpha    = 0.5;\n",
    " \n",
    "\n",
    "#formula\n",
    "#m**alpha*(Tc)= conatant\n",
    "#calculation\n",
    "Tc2    = ((M1**alpha)*Tc1)/float(M2**alpha);     #transition temperature in K\n",
    " \n",
    "\n",
    "#result\n",
    "print'transition temperature =%3.3f'%Tc2,'K';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.26,Page No:5.41"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "critical temperature =1.92 K\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaraion\n",
    "Tc1      = 2.1;                    #temperature in K\n",
    "M1       = 26.91;                  #mass number \n",
    "M2       = 32.13;                  #mass number \n",
    "\n",
    "\n",
    "#formula\n",
    "#Tc*(M1**2) = constant\n",
    "#calculation\n",
    "Tc2        = (Tc1*(M1**(1/float(2))))/float(M2**(1/float(2)));       #critical temperature in K\n",
    "\n",
    "\n",
    "#result\n",
    "print'critical temperature =%3.2f'%Tc2,'K';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.27,Page No:5.42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "transition temperature =14.67 K\n",
      "critical field  =1.70e+06 A/m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Hc1        =  1.41*10**5;       #critical fields in amp/m\n",
    "Hc2        = 4.205*10**5;       # critical fields in amp/m\n",
    "T1         = 14.1;              #temperature in K\n",
    "T2         = 12.9;              # temperature in K\n",
    "T3         = 4.2;               #temperature in K\n",
    " \n",
    "\n",
    "#formula\n",
    "#Hcn =Hc*((1-((T/Tc)**4)))\n",
    "#calculation\n",
    "Tc        =(((((Hc2*(T1**2))-(Hc1*(T2**2)))/float(Hc2-Hc1)))**(1/float(2)));          #temperature in K\n",
    "Hc0       = Hc1/float(1-((T1/float(Tc))**2));                                         #critical field in A/m\n",
    "Hc2       = Hc0*(1-(T3/float(Tc))**2);                                                #critical field in A/m\n",
    "\n",
    "\n",
    "#result\n",
    "print'transition temperature =%3.2f'%Tc,'K';\n",
    "print'critical field  =%3.2e'%Hc2,'A/m';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.28,Page No:5.43"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "critical field =4.8751e+05 A/m\n",
      " Note: calculation mistake in texttbook in calculating Hc\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Hc0        = 700000;       #critical field at 0 K\n",
    "T          = 4;            #temperature in K\n",
    "Tc         = 7.26;         #temperature in K\n",
    " \n",
    " \n",
    "#calculation\n",
    "Hc    = Hc0*(1-(T/float(Tc))**2);    #critical field n A/m\n",
    "\n",
    "\n",
    "#result\n",
    "print'critical field =%3.4e'%Hc,'A/m';\n",
    "print' Note: calculation mistake in texttbook in calculating Hc';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.29,Page No:5.44"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "critical current =153.15 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Hc0        = 8*10**4;       #critical field \n",
    "T          = 4.5;          #temperature in K\n",
    "Tc         = 7.2;          #temperature in K\n",
    "D          = 1*10**-3;      #diameter in m\n",
    "\n",
    " \n",
    "#calculation\n",
    "Hc    = Hc0*(1-(T/float(Tc))**2);\n",
    "r     = D/float(2);                #radius in m\n",
    "Ic     = 2*math.pi*r*Hc;           #critical current in A\n",
    "\n",
    "#result\n",
    "print'critical current =%3.2f'%Ic,'A';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.30,Page No:5.44"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "critical field =0.0217 tesla\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Hc0        = 0.0306;       #critical field at 0 K\n",
    "T          = 2;           #temperature in K\n",
    "Tc         = 3.7;         #temperature in K\n",
    " \n",
    " \n",
    "#calculation\n",
    "Hc    = Hc0*(1-(T/float(Tc))**2);     #critical field in tesla\n",
    "\n",
    "\n",
    "#result\n",
    "print'critical field =%3.4f'%Hc,'tesla';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.31,Page No:5.44"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "transition temperature =16.00 K\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "HcT        = 1.5*10**5;     # critical field for niobium at 0 K\n",
    "Hc0        = 2*10**5;       # critical field for nobium at 0 K\n",
    "T          = 8;             # temperature in K\n",
    " \n",
    "\n",
    "#calculation\n",
    "Tc     = T/((1-(HcT/float(Hc0)))**0.5);     #transition temperature in K\n",
    " \n",
    "\n",
    "#result\n",
    "print'transition temperature =%3.2f'%Tc,'K';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.32,Page No:5.45"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "transition temperature =14.47  K\n",
      " critical field  =2.50  T\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Hc1        =  0.176;       #critical fields\n",
    "Hc2        = 0.528;        #critical fields\n",
    "T1         = 14;           #temperature in K\n",
    "T2         = 13;           #temperature in K\n",
    "T3         = 4.2;          #temperature in K\n",
    "\n",
    "#formula\n",
    "#Hcn =Hc*((1-((T/Tc)**4)))\n",
    "#calculation\n",
    "Tc     =(((((Hc2*(T1**2))-(Hc1*(T2**2)))/float(Hc2-Hc1)))**(1/float(2)));  #transition temperature in K\n",
    "Hc0    = Hc1/(1-((T1/float(Tc))**2));          #critical field in T\n",
    "Hc2    = Hc0*(1-((T3/float(Tc))**2));          #critical field in T\n",
    "\n",
    "\n",
    "#result\n",
    "print'transition temperature =%3.2f '%Tc,'K';\n",
    "print' critical field  =%3.2f '%Hc2,'T';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.33,Page No:5.46"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "critical current =99.274328 A\n",
      "Note: calculation mistake in textbook in calculation of I\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Hc         = 7900;                                  #magnetic field in A/m\n",
    "r          = 2.0*10**-3;                            #radius of super condutor in m\n",
    " \n",
    " \n",
    "#calculation\n",
    "I          = 2*math.pi*r*Hc;                          #critical current in A\n",
    " \n",
    "#result\n",
    "print'critical current =%4f'%I,'A';\n",
    "print'Note: calculation mistake in textbook in calculation of I';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.34,Page No:5.46"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "current =137  Amp\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "d           = 10**-3;           #diameter in m\n",
    "Bc          = 0.0548;           # Bc in T\n",
    " \n",
    " \n",
    "#calculation\n",
    "u0          = 4*math.pi*10**-7;                 #permiability m**2\n",
    "r           = d/float(2);                       #radius in m\n",
    "Ic          = (2*math.pi*r*Bc)/float(u0);       #current in Amp\n",
    "\n",
    "#result\n",
    "print'current =%3.2d '%Ic,'Amp';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.35,Page No:5.52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "penetration depth=11.33 nm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "D          =8.5*10**3;               #density in kg/m**3\n",
    "W          =93;                      #atomic weight \n",
    "m          =9.1*10**-31;             #mass of electron in kilograms\n",
    "e          =2*1.6*10**-19;           #charge of electron in coulombs\n",
    "N          =6.023*10**26;            #avagadro number in (lb-mol)−1\n",
    "\n",
    "\n",
    "#calculation\n",
    "u0         =4*math.pi*10**-7;\n",
    "ns         =(D*N)/float(W);                         #in per m**3\n",
    "lamdaL     =(m/float(u0*ns*e**2))**(1/float(2));    #London's penetration depth in nm\n",
    "\n",
    "#result\n",
    "print'penetration depth=%3.2f'%(lamdaL*10**9),'nm';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.36,Page No:5.52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "penetration depth=467.9 Å\n",
      " Note: calculation mistake in textbook in calculating lamdaT\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Tc     =7.2;                  #temperature in K\n",
    "lamda  =380;                  #penetration depth in Å\n",
    "T      =5.5;                  #temperature in K\n",
    " \n",
    "\n",
    "#calculation\n",
    "\n",
    "lamdaT=lamda*((1-((T/float(Tc))**4))**(-1/float(2)));     #penetration depth in Å\n",
    " \n",
    "#result\n",
    "print'penetration depth=%3.1f'%lamdaT,'Å';\n",
    "print' Note: calculation mistake in textbook in calculating lamdaT';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.37,Page No:5.53"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "critical temperature =8.48  K\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "lamda1      = 16;         #penetration depth in nm\n",
    "lamda2      = 96;         #penetration depth in nm\n",
    "T1          = 2.18;       #temperature in K\n",
    "T2          = 8.1;        # temperature in K\n",
    "\n",
    "#formula\n",
    "#lamdaT =lamda0*((1-((T/Tc)**4))**(-1/4))\n",
    "#calculation\n",
    "Tc          = ((((lamda2*(T2**4))-(lamda1*(T1**4)))/float(lamda2-lamda1))**(1/float(4)));   #critical temperature in K\n",
    "\n",
    "\n",
    "#result\n",
    "print'critical temperature =%3.2f '%Tc,'K';\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.38,Page No:5.55"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "wavelength=0.41 mm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Eg      =30.5*1.6*10**-23;       #energy gap in eV\n",
    "h       =6.6*10**-34;           #planck's constant in (m**2)*kg/s\n",
    "c       =3.0*10**8;             #velocity of light in m\n",
    " \n",
    "\n",
    "#formula\n",
    "#Eg=h*v\n",
    "#calculation\n",
    "v       = Eg/float(h);                #velocity in m\n",
    "lamda   = c/float(v);               #wavelength in m\n",
    "\n",
    "#result\n",
    "print'wavelength=%2.2f'%(lamda*10**3),'mm';\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.39,Page No:5.55"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "region of electromagnetic spectrum=1.14e-03 m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "k  =1.38*10**-23;\n",
    "Tc  =4.2;                  #tempetrature in K\n",
    "h  =6.6*10**-34;           #planck's constant in (m**2)*kg/s\n",
    "c  =3*10**8;               # velocity of light in m\n",
    " \n",
    " \n",
    "#calculation\n",
    "Eg      = (3*k*Tc);            #energy gap in eV\n",
    "lamda   = h*c/float(Eg);       #wavelngth in m\n",
    "\n",
    "#result\n",
    "print'region of electromagnetic spectrum=%3.2e'%lamda,'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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}