{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#1: Bonding in Solids"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.1, Page number 1.4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "net change in energy per mole is -296 kJ/mol\n",
      "answer varies due to rounding off errors\n",
      "since the net change in energy is negative, the A+B- molecule will be stable\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "e=1.602*10**-19;   #charge of electron(c)\n",
    "epsilon0=8.85*10**-12;    #permittivity(C/Nm)\n",
    "r=3*10**-10;     #seperation(m)\n",
    "N=6.022*10**20;\n",
    "Ea=502;     #ionisation energy of A(kJ/mol)\n",
    "Eb=-335;    #electron affinity for B(kJ/mol)\n",
    "\n",
    "#Calculation\n",
    "E=-e**2*N/(4*math.pi*epsilon0*r);    #electrostatic attraction(kJ/mol)\n",
    "nE=Ea+Eb+E;    #net change in energy per mole(kJ/mol)\n",
    "\n",
    "#Result\n",
    "print \"net change in energy per mole is\",int(nE),\"kJ/mol\"\n",
    "print \"answer varies due to rounding off errors\"\n",
    "print \"since the net change in energy is negative, the A+B- molecule will be stable\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.2, Page number 1.4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "energy required is 0.5 eV\n",
      "seperation is 2.88 nm\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "IPk=4.1;    #IP of K(eV)\n",
    "EACl=3.6;    #EA of Cl(eV)\n",
    "e=1.602*10**-19;   #charge of electron(c)\n",
    "onebyepsilon0=9*10**9;\n",
    "\n",
    "#Calculation\n",
    "deltaE=IPk-EACl;\n",
    "Ec=deltaE;      #energy required(eV)\n",
    "R=e*onebyepsilon0/deltaE;     #seperation(m)\n",
    "\n",
    "#Result\n",
    "print \"energy required is\",Ec,\"eV\"\n",
    "print \"seperation is\",round(R*10**9,2),\"nm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.3, Page number 1.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "bond energy is 4.61 eV\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "e=1.602*10**-19;   #charge of electron(c)\n",
    "epsilon0=8.85*10**-12;    #permittivity(C/Nm)\n",
    "r0=236*10**-12;     #seperation(m)\n",
    "N=6.022*10**20;\n",
    "IP=5.14;     #ionisation energy of A(kJ/mol)\n",
    "EA=3.65;    #electron affinity for B(kJ/mol)\n",
    "\n",
    "#Calculation\n",
    "Ue=-e**2/(4*math.pi*epsilon0*r0*e);    #potential energy(eV)\n",
    "BE=-Ue-IP+EA;      #bond energy(eV)\n",
    "\n",
    "#Result\n",
    "print \"bond energy is\",round(BE,2),\"eV\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.4, Page number 1.18"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cohesive energy is 7.965 eV\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "A=1.748;       #madelung constant\n",
    "n=9;     #born repulsive exponent\n",
    "e=1.602*10**-19;   #charge of electron(c)\n",
    "epsilon0=8.85*10**-12;    #permittivity(C/Nm)\n",
    "r0=0.281*10**-9;     #seperation(m)\n",
    "IE=5.14;     #ionisation energy of A(kJ/mol)\n",
    "EA=3.61;    #electron affinity for B(kJ/mol)\n",
    "\n",
    "#Calculation\n",
    "CE=A*e**2*(1-(1/n))/(4*math.pi*epsilon0*r0*e);      #cohesive energy(eV)\n",
    "\n",
    "#Result\n",
    "print \"cohesive energy is\",round(CE,3),\"eV\""
   ]
  }
 ],
 "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
}