{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#4: Defects in Crystals"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.1, Page number 4.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ratio of vacancies is 1.082 *10**5\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "Ev=1;\n",
    "k=1.38*10**-23;     #boltzmann constant(J/K)\n",
    "e=1.6*10**-19;      #charge(eV)\n",
    "\n",
    "#Calculation\n",
    "r=Ev/(2.303*1000*k/e);      \n",
    "n=10**r;                #ratio of n1000/n500\n",
    "\n",
    "#Result\n",
    "print \"ratio of vacancies is\",round(n/10**5,3),\"*10**5\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.2, Page number 4.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "number of vacancies per atom at 350K is 0.5486 *10**-17\n",
      "number of vacancies per atom at 500K is 0.827 *10**-12\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "Ev=1.2;\n",
    "k=1.38*10**-23;     #boltzmann constant(J/K)\n",
    "e=1.6*10**-19;      #charge(eV)\n",
    "T1=350;    #temperature(K)\n",
    "T2=500;    #temperature(K)\n",
    "\n",
    "#Calculation\n",
    "x1=Ev/(2.303*k*T1/e);\n",
    "n1=1/(10**x1);     #number of vacancies per atom at 350K\n",
    "x2=Ev/(2.303*k*T2/e);\n",
    "n2=1/(10**x2);     #number of vacancies per atom at 500K\n",
    "\n",
    "#Result\n",
    "print \"number of vacancies per atom at 350K is\",round(n1*10**17,4),\"*10**-17\"\n",
    "print \"number of vacancies per atom at 500K is\",round(n2*10**12,3),\"*10**-12\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.3, Page number 4.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "average energy required is 1.971 eV\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "d=2.82*10**-10;    #distance(m)\n",
    "k=1.38*10**-23;     #boltzmann constant(J/K)\n",
    "e=1.6*10**-19;      #charge(eV)\n",
    "T=273+25;    #temperature(K)\n",
    "sd=5*10**11;    #schotky defects(per m**3)\n",
    "\n",
    "#Calculation\n",
    "V=(2*d)**3;    #volume of unit cell(m**3)\n",
    "N=4/V;    #density of ion pairs\n",
    "x=round(math.log10(N/sd),2);\n",
    "Es=2*(k/e)*T*2.303*x;       #average energy required(eV)\n",
    "\n",
    "#Result\n",
    "print \"average energy required is\",round(Es,3),\"eV\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 4.4, Page number 4.8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ratio of Frenkel defects is 1.125 *10**-6\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "T1=273+25;      #temperature(K)\n",
    "T2=273+350;     #temperature(K)\n",
    "Ef=1.35;     #energy(eV)\n",
    "k=8.625*10**-5;\n",
    "\n",
    "#Calculation\n",
    "x=(Ef/k)*((1/(2*T1))-(1/(2*T2)))/2.303;\n",
    "r=1/(10**round(x,3));      #ratio of Frenkel defects\n",
    "\n",
    "#Result\n",
    "print \"ratio of Frenkel defects is\",round(r*10**6,3),\"*10**-6\""
   ]
  }
 ],
 "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
}