{
 "metadata": {
  "name": "Chapter5"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": "Crystal Physics"
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example number 5.1, Page number 149"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#To calculate the Miller indices\n\n#Calculation\n#The plane has intercepts a,2b,3c along 3 crystal axes\n#lattice points are r = pa+qb+sc\n#therefore p = 1 q = 2 s = 3\n#miller indices are [1/p,1/q,1/s]\n\n#Result\nprint \"lattice points are p = 1 q = 2 s = 3\"\nprint \"miller indices are [1/p,1/q,1/s] or [1,1/2,1/3] or [6,3,2]\"",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "lattice points are p = 1 q = 2 s = 3\nmiller indices are [1/p,1/q,1/s] or [1,1/2,1/3] or [6,3,2]\n"
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example number 5.2, Page number 150"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#To calculate the density of Si\n\n#importing modules\nimport math\n\n#Variable declaration\nn = 8;          #number of atoms per cell\na = 5.43*10**-8;       #lattice constant(cm)\nw = 28.1;              #atomic weight(gm)\nN = 6.02*10**23;       #avagadro number\n\n#Calculation\nac = n/(a**3);         #atomic concentration(atoms/cm**3)\nd = ac*w/N;            #density of Si(g/cm**3)\nd=math.ceil(d*10**3)/10**3;   #rounding off to 3 decimals\n\n#Result\nprint \"density of Si is\",d,\"g/cm**3\"",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "density of Si is 2.333 g/cm**3\n"
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example number 5.3, Page number 151"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#To calculate the surface density of atoms\n\n#importing modules\nimport math\nfrom __future__ import division\n\n#Variable declaration\na = 5;       #lattice constant(Angstrom)\n\n#Calculation\na = a*10**-10;         #lattice constant(m)\n#to calculate the planar concentration, only equilateral triangular region is considered of length a*math.sqrt(2) and height a*math.sqrt(3/2)\nl = a*math.sqrt(2);           #length of face diagonal(m)\nh = a*math.sqrt(3/2);         #height of triangle(m)\nA = l*h/2;                    #area of shaded portion(m**2)\n#every atom at the corner contributes 1/6 to this area.\nn111 = (3/6)*(1/A);           #planar concentration(atoms/m**2)\n\n#Result\nprint \"surface density of atoms is\",n111,\"atoms/m**2\"",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "surface density of atoms is 2.30940107676e+18 atoms/m**2\n"
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example number 5.4, Page number 152"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#To calculate the spacing of planes\n\n#importing modules\nimport math\n\n#Variable declaration\na = 4.049;       #lattice constant(Angstrom)\nh = 2;\nk = 2;\nl = 0;           #miller indices of(2 2 0)\n\n#Calculation\nd = a/math.sqrt(h**2+k**2+l**2);        #spacing of planes(Angstrom)\nd=math.ceil(d*10**3)/10**3;   #rounding off to 3 decimals\n\n#Result\nprint \"spacing of planes is\",d,\"Angstrom\"",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "spacing of planes is 1.432 Angstrom\n"
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example number 5.5, Page number 152"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#To calculate the size of unit cell\n\n#importing modules\nimport math\n\n#Variable declaration\nd110 = 2.03;       #distance between planes(Angstrom)\nh = 1;\nk = 1;\nl = 0;           #miller indices of(1 1 0)\n\n#Calculation\na = d110*math.sqrt(h**2+k**2+l**2);        #size of unit cell(Angstrom)\na=math.ceil(a*10**3)/10**3;   #rounding off to 3 decimals\n\n#Result\nprint \"size of unit cell is\",a,\"Angstrom\"",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "size of unit cell is 2.871 Angstrom\n"
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example number 5.6, Page number 152"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#To calculate the spacing of planes\n\n#importing modules\nimport math\n\n#Variable declaration\na = 5.64;       #lattice constant(Angstrom)\nh1 = 1;\nk1 = 0;\nl1 = 0;           #miller indices of(1 0 0)\nh2 = 1;\nk2 = 1;\nl2 = 0;           #miller indices of(1 1 0)\nh3 = 1;\nk3 = 1;\nl3 = 1;           #miller indices of(1 1 1)\n\n#Calculation\nd100 = a/math.sqrt(h1**2+k1**2+l1**2);        #spacing of planes[100](Angstrom)\nd110 = a/math.sqrt(h2**2+k2**2+l2**2);        #spacing of planes[110](Angstrom)\nd111 = a/math.sqrt(h3**2+k3**2+l3**2);        #spacing of planes[111](Angstrom)\nd111=math.ceil(d111*10**2)/10**2;   #rounding off to 2 decimals\n\n#Result\nprint \"spacing of plane [100] is\",d100,\"Angstrom\"\nprint \"spacing of plane [110] is\",round(d110),\"Angstrom\"\nprint \"spacing of plane [111] is\",d111,\"Angstrom\"",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "spacing of plane [100] is 5.64 Angstrom\nspacing of plane [110] is 4.0 Angstrom\nspacing of plane [111] is 3.26 Angstrom\n"
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example number 5.7, Page number 153"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#To calculate the volume of unit cell\n\n#importing modules\nimport math\n\n#Variable declaration\nr = 1.605;         #radius of atom(Angstrom)\n\n\n#Calculation\nr = r*10**-10;      #radius of atom(m)\na = 2*r;        #size of unit cell(m)\nc = a*math.sqrt(8/3);\nV = 3*math.sqrt(3)*a**2*c/2;       #volume of unit cell(m**3)\n\n#Result\nprint \"volume of unit cell is\",V,\"m**3\"",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "volume of unit cell is 1.40330266432e-28 m**3\n"
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "",
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}