{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#Chapter 1(A):Bonding in Solids"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 1.1, Page number 1.14"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-2*a/r**3 + 90*b/r**11\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "from sympy import Symbol\n",
    "from sympy import diff\n",
    "import numpy as np\n",
    "\n",
    "#Variable declaration\n",
    "n=1;\n",
    "m=9;\n",
    "a=Symbol('a')\n",
    "b=Symbol('b')\n",
    "r=Symbol('r')\n",
    "\n",
    "#Calculation\n",
    "y=(-a/(r**n))+(b/(r**m));\n",
    "y=diff(y,r);\n",
    "y=diff(y,r);\n",
    "\n",
    "#Result\n",
    "print y\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 1.1(Continued after differentiation)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "young's modulus is 157 GPa\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "a=7.68*10**-29;     \n",
    "r0=2.5*10**-10;    #radius(m)\n",
    "\n",
    "#Calculation\n",
    "b=a*(r0**8)/9;\n",
    "y=((-2*a*r0**8)+(90*b))/r0**11;    \n",
    "E=y/r0;           #young's modulus(Pa)\n",
    "\n",
    "#Result\n",
    "print \"young's modulus is\",int(E/10**9),\"GPa\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 1.2, Page number 1.15"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Effective charge = 0.72 *10**-29 coulomb\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declarations\n",
    "d=((1.98)*10**-29)*1/3;        #dipole moment\n",
    "b=(0.92);                      #bond length\n",
    "EC=d/(b*10**-10);              #Effective charge\n",
    "\n",
    "#Result\n",
    "print \"Effective charge =\",round((EC*10**19),2),\"*10**-29 coulomb\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 1.3, Page number 1.15"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cohesive energy = 668.9 *10**3 kJ/kmol\n",
      "#Answer varies due to rounding of numbers\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "A=1.748                 #Madelung Constant    \n",
    "N=6.02*10**26           #Avagadro Number\n",
    "e=1.6*10**-19\n",
    "n=9.5\n",
    "r=(0.324*10**-9)*10**3\n",
    "E=8.85*10**-12\n",
    "#Calculations\n",
    "U=((N*A*(e)**2)/(4*math.pi*E*r))*(1-1/n)       #Cohesive energy\n",
    "\n",
    "#Result\n",
    "print \"Cohesive energy =\",round(U/10**3,1),\"*10**3 kJ/kmol\"\n",
    "print \"#Answer varies due to rounding of numbers\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 1.4, Page number 1.15"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Coulomb energy = -2.88 eV\n",
      "Energy required = -1.88 eV\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "#variable declaration\n",
    "I=5;                       #Ionisation energy\n",
    "A=4;                       #Electron Affinity\n",
    "e=(1.6*10**-19)\n",
    "E=8.85*10**-12            #epsilon constant\n",
    "r=0.5*10**-19             #dist between A and B\n",
    "\n",
    "#Calculations\n",
    "C=-(e**2/(4*math.pi*E*r*e))/10**10    #Coulomb energy\n",
    "E_c=I-A+C                             #Energy required\n",
    "\n",
    "#Result\n",
    "print \"Coulomb energy =\",round(C,2),\"eV\"\n",
    "print \"Energy required =\",round(E_c,2),\"eV\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 1.5, Page number 1.16"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Energy required= 1.49 eV\n",
      "Distance of separation = 9.66 Angstrom\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "I=5.14;                    #Ionization energy\n",
    "A=3.65;                    #Electron Affinity\n",
    "e=(1.6*10**-19);\n",
    "E=8.85*10**-12; \n",
    "#calculations\n",
    "E_c=I-A                        #Energy required\n",
    "r=e**2/(4*math.pi*E*E_c*e)     #Distance of separation\n",
    "\n",
    "#Result\n",
    "print \"Energy required=\",E_c,\"eV\"\n",
    "print \"Distance of separation =\",round(r/10**-10,2),\"Angstrom\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 1.6, Page number 1.16"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Energy required= 1.49 eV\n",
      "Energy required = -6.1 eV\n",
      "Bond Energy = 4.61 eV\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration \n",
    "I=5.14;                    #Ionization energy\n",
    "A=3.65;                    #Electron Affinity\n",
    "e=(1.6*10**-19);\n",
    "E=8.85*10**-12; \n",
    "r=236*10**-12;\n",
    "\n",
    "#Calculations\n",
    "E_c=I-A                        #Energy required\n",
    "C=-(e**2/(4*math.pi*E*r*e))    #Potentential energy in eV\n",
    "BE=-(E_c+C)                    #Bond Energy\n",
    "#Result\n",
    "print \"Energy required=\",E_c,\"eV\"\n",
    "print \"Energy required =\",round(C,1),\"eV\"\n",
    "print \"Bond Energy =\",round(BE,2),\"eV\"\n",
    "\n"
   ]
  }
 ],
 "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
}