{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 4: Defects in Crystals"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Example number 4.1, Page number 97"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fraction of vacancy sites at 1000 C is 8.4663 *10**-7\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",
    "T1=773;     #temperature(K)\n",
    "T2=1273;    #temperature(K)\n",
    "n=1*10**-10;       #fraction of vacancy sites\n",
    "\n",
    "#Calculations\n",
    "X=round(T1*math.log(n)/T2,3);\n",
    "x=math.exp(X);          #fraction of vacancy sites at 1000 C\n",
    "\n",
    "#Result\n",
    "print \"fraction of vacancy sites at 1000 C is\",round(x*10**7,4),\"*10**-7\"\n",
    "print \"answer varies due to rounding off errors\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 4.2, Page number 98"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "energy required is 1.971 eV\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration    \n",
    "T=273+25;     #temperature(K)\n",
    "m=4;      \n",
    "n=5*10**11;    #density(per m**3)\n",
    "V=(2*2.82*10**-10)**3;     #volume(m**3)\n",
    "kB=8.625*10**-5;\n",
    "\n",
    "#Calculations\n",
    "N=m/V;\n",
    "Ep=2*kB*T*math.log(N/n);\n",
    "\n",
    "#Result\n",
    "print \"energy required is\",round(Ep,3),\"eV\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 4.3, Page number 99"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ratio of frenkel defects is 2.802 *10**-3\n",
      "answer in the book is wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration    \n",
    "T1=273+20;     #temperature(K)\n",
    "T2=273+300;    #temperature(K)\n",
    "Ei=1.4;     #energy(eV)\n",
    "kB=8.625*10**-5;\n",
    "\n",
    "#Calculations\n",
    "x=(1/(2*T1))-(1/(2*T2));\n",
    "n=1/math.exp((Ei/(2.303*kB))*x);     #ratio of frenkel defects\n",
    "\n",
    "#Result\n",
    "print \"ratio of frenkel defects is\",round(n*10**3,3),\"*10**-3\"\n",
    "print \"answer in the book is wrong\""
   ]
  }
 ],
 "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.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}