diff options
Diffstat (limited to 'Applied_Physics_by_S._Mani_Naidu/Chapter3.ipynb')
-rw-r--r-- | Applied_Physics_by_S._Mani_Naidu/Chapter3.ipynb | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/Applied_Physics_by_S._Mani_Naidu/Chapter3.ipynb b/Applied_Physics_by_S._Mani_Naidu/Chapter3.ipynb index 1af94463..69e1a5ee 100644 --- a/Applied_Physics_by_S._Mani_Naidu/Chapter3.ipynb +++ b/Applied_Physics_by_S._Mani_Naidu/Chapter3.ipynb @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 1, "metadata": { "collapsed": false }, @@ -60,7 +60,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 2, "metadata": { "collapsed": false }, @@ -102,7 +102,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 3, "metadata": { "collapsed": false }, @@ -142,11 +142,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { - "collapsed": true + "collapsed": false }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ratio d100:d110:d111 is 1 *math.sqrt(6) : 1 *math.sqrt(3) : 1 *math.sqrt(2)\n" + ] + } + ], "source": [ "#importing modules\n", "import math\n", @@ -165,30 +173,37 @@ "a=1; #assume\n", "\n", "#Calculation\n", - "d100=a/math.sqrt(h1**2+k1**2+l1**2); #spacing(nm)\n", + "d100=a/math.sqrt(h1**2+k1**2+l1**2); #spacing(nm) \n", "d110=a/math.sqrt(h2**2+k2**2+l2**2); #spacing(nm)\n", "d111=a/math.sqrt(h3**2+k3**2+l3**2); #spacing(nm)\n", + "x=int(1/d100)**2;\n", + "y=int((1/d110)**2);\n", + "z=int(round((1/d111)**2)); #taking squares of the value of spacing since lcm function doesnt work on square root\n", "\n", - "def lcm(x, y):\n", - " if x > y:\n", - " greater = x\n", - " else:\n", + "def lcm(y, z):\n", + " if y > z:\n", " greater = y\n", + " else:\n", + " greater = z\n", " while(True):\n", - " if((greater % x == 0) and (greater % y == 0)):\n", + " if((greater % y == 0) and (greater % z == 0)):\n", " lcm = greater\n", " break\n", " greater += 1\n", " \n", " return lcm\n", "\n", - "lcm=lcm(1/d110,1/d111);\n", - "d100=d100*lcm;\n", - "d110=d110*lcm;\n", - "d111=d111*lcm; #ratio d100:d110:d111\n", + "l=lcm(y,z);\n", + "l=math.sqrt(l);\n", + "d1=d100*l;\n", + "d10=d110*l;\n", + "d11=d111*l; #ratio d100:d110:d111\n", + "d1=int(d1/math.sqrt(6));\n", + "d10=int(round(d10/math.sqrt(3)));\n", + "d11=int(d11/math.sqrt(2));\n", "\n", "#Result\n", - "print \"ratio d100:d110:d111 is\",d100/math.sqrt(6),\"*math.sqrt(6)\",d110/math.sqrt(3),\"*math.sqrt(3)\",d111/math.sqrt(2),\"*math.sqrt(2)\"" + "print \"ratio d100:d110:d111 is\",d1,\"*math.sqrt(6) :\",d10,\"*math.sqrt(3) :\",d11,\"*math.sqrt(2)\"" ] }, { @@ -200,11 +215,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "collapsed": false }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "lattice parameter is 3.522 angstrom\n" + ] + } + ], "source": [ "#importing modules\n", "import math\n", @@ -235,7 +258,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 1, "metadata": { "collapsed": false }, |