{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#1: Bonding in Solids"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.1, Page number 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "bond energy is 3.84 eV\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "e=1.6*10**-19;      #charge(coulomb)\n",
    "epsilon0=8.85*10**-12;   \n",
    "r0=23.6*10**-10;    #equilibrium distance(m)\n",
    "I=5.14;    #ionisation energy(eV)\n",
    "EA=3.65;   #electron affinity(eV)\n",
    "N=8;     #born constant\n",
    "\n",
    "#Calculation\n",
    "x=1-(1/N);\n",
    "V=(e**2)*x/(4*e*math.pi*epsilon0*r0);   #potential(V)\n",
    "E=I-EA;        #net energy(eV)\n",
    "BE=round(V*10,2)-E;        #bond energy(eV)\n",
    "\n",
    "#Result\n",
    "print \"bond energy is\",BE,\"eV\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.2, Page number 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "compressibility is -25.1095 *10**14\n",
      "answer in the book is wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "e=1.6*10**-19;      #charge(coulomb)\n",
    "epsilon0=8.85*10**-12;   \n",
    "r0=0.41*10**-3;    #equilibrium distance(m)\n",
    "A=1.76;      #madelung constant\n",
    "n=0.5;       #repulsive exponent value\n",
    "\n",
    "#Calculation\n",
    "beta=72*math.pi*epsilon0*r0**4/(A*e**2*(n-1));    #compressibility\n",
    "\n",
    "#Result\n",
    "print \"compressibility is\",round(beta/10**14,4),\"*10**14\"\n",
    "print \"answer in the book is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.3, Page number 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cohesive energy is -3.065 eV\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "e=1.6*10**-19;      #charge(coulomb)\n",
    "epsilon0=8.85*10**-12;   \n",
    "r0=0.314*10**-9;    #equilibrium distance(m)\n",
    "A=1.75;      #madelung constant\n",
    "N=5.77;     #born constant\n",
    "I=4.1;    #ionisation energy(eV)\n",
    "EA=3.6;   #electron affinity(eV)\n",
    "\n",
    "#Calculation\n",
    "V=-A*e**2*((N-1)/N)/(4*e*math.pi*epsilon0*r0);\n",
    "PE=round(V,2)/2;    #potential energy per ion(eV)\n",
    "x=(I-EA)/2;\n",
    "CE=PE+x;   #cohesive energy(eV)\n",
    "\n",
    "#Result\n",
    "print \"cohesive energy is\",CE,\"eV\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.4, Page number 11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "binding energy is 665.0 *10**3 kJ/kmol\n",
      "answer in the book is wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration    \n",
    "N=6.02*10**26;           #Avagadro Number\n",
    "e=1.6*10**-19;      #charge(coulomb)\n",
    "epsilon0=8.85*10**-12;   \n",
    "r0=0.324*10**-9;    #equilibrium distance(m)\n",
    "A=1.75;      #madelung constant\n",
    "n=8.5;       #repulsive exponent value\n",
    "\n",
    "#Calculations\n",
    "U0=(A*e/(4*math.pi*epsilon0*r0))*(1-1//n);     \n",
    "U=round(U0,1)*N*e;      #binding energy(J/kmol)\n",
    "\n",
    "#Result\n",
    "print \"binding energy is\",round(U/10**6),\"*10**3 kJ/kmol\"\n",
    "print \"answer in the book is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.5, Page number 11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "density of CsClis 4.389 *10**3 kg/m**3\n",
      "answer in the book varies due to rounding off errors\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "rCs=0.165*10**-9;    #radius(m)\n",
    "rCl=0.181*10**-9;    #radius(m)\n",
    "MCs=133;    #atomic weight\n",
    "MCl=35.5;   #atomic weight\n",
    "N=6.02*10**26;           #Avagadro Number\n",
    "\n",
    "#Calculation\n",
    "a=2*(rCl+rCs)/math.sqrt(3);     #lattice constant(m)\n",
    "M=(MCs+MCl)/N;       #mass of 1 molecule(kg)\n",
    "V=a**3;    #volume of unit cell(m**3)\n",
    "rho=M/V;    #density of CsCl(kg/m**3)\n",
    "\n",
    "#Result\n",
    "print \"density of CsClis\",round(rho/10**3,3),\"*10**3 kg/m**3\"\n",
    "print \"answer in the book varies due to rounding off errors\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.6, Page number 12"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "effective charge is 0.72 *10**-19 coulomb\n",
      "answer given in the book is wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "dm=1.98*(10**-29)*(1/3);      #dipole moment\n",
    "l=0.92*10**-10;        #bond length(m)\n",
    "\n",
    "#Calculation\n",
    "ec=dm/l;        #effective charge(coulomb)\n",
    "\n",
    "#Result\n",
    "print \"effective charge is\",round(ec*10**19,2),\"*10**-19 coulomb\"\n",
    "print \"answer given in the book is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.7, Page number 12"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "energy required is -1.9 eV\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "e=1.6*10**-19;      #charge(coulomb)\n",
    "epsilon0=8.85*10**-12;   \n",
    "r=0.5*10**-9;    #distance(m)\n",
    "I=5;    #ionisation energy(eV)\n",
    "E=4;   #electron affinity(eV)\n",
    "\n",
    "#Calculation\n",
    "C=e**2/(4*math.pi*epsilon0*e*r);    #coulomb energy(eV)\n",
    "Er=I-E-C;    #energy required(eV)\n",
    "\n",
    "#Result\n",
    "print \"energy required is\",round(Er,1),\"eV\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.9, Page number 13"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "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",
    "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"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "young's modulus is 157 GPa\n"
     ]
    }
   ],
   "source": [
    "#since the values of a,b,r are declared as symbols in the above cell, it cannot be solved there. hence it is being solved here with the given variable declaration\n",
    "#importing modules\n",
    "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\""
   ]
  }
 ],
 "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
}
