from math import sqrt
#Variable Declaration
r=1.278*1e-8 ;#atomic radius in cm
M=63.5; #atomic weight
N=6.023*1e23; #avogadro number
n=4#for fcc n=4
#Calculations
a=4*r/(sqrt(2));
density=n*M/(N*a**3);#Density of copper
#Result
print 'Density of copper =',round(density,1),'g/cc'
#Variable Declaration
M=58.45;#atomic mass
N=6.02*1e23;#avogadro number
density=2.17*1e3 ; #in kg/m^3
n=4 #Nacl is FCC
#Calculation
a=(n*M/(N*density))**(1./3);#lattice constant
#Result
print 'lattice constant = ',round(a/1e-10,2),'A'
#incorrect answer in the textbook
#Variable Declaration
#let three intercepts are I1,I2,I3
I1=3;
I2=-2;
I3=3./2;
#let their reciprocals are I1_1,I2_1,I3_1
I1_1=1./I1;
I2_1=1./I2;
I3_1=1./I3;
#Calculations
#LCM of I1_1,I2_1,I3_1 are 6 .
#By multiply LCM with I1_1,I2_1,I3_1 we will get miller indices
LCM=6;
M_1=LCM*I1_1;
M_2=LCM*I2_1 ;
M_3=LCM*I3_1;
#Results
print 'Miller indices of plane are [',M_1,
print(M_2),
print(M_3),']'
from math import sqrt
#Variable Declaration
r=1.246 #in A
#Calculations & Results
a=4*r/sqrt(2)
d_200=a/sqrt(2**2+0**2+0**2)
print 'd200 = ',round(d_200,2),'A'
d_220=a/sqrt(2**2+2**2+0**2)
print 'd220 = ',d_220,'A'
d_111=a/sqrt(1**2+1**2+1**2)
print 'd111 = ',round(d_111,2),'A'
from math import acos,degrees
#Variable Declaration
h=1
k=1
l=1
h1=1
k1=1
l1=1
#Calculations
a=((h*h1)-(k*k1)+(l*l1))/(sqrt((h*h)+(k*k)+(l*l))*sqrt((h1*h1)+(k1*k1)+(l1*l1)));
#cosine angle=a so angle=cosine inverse of a
theta=degrees(acos(a));#angle between two planes
#Result
print 'angle between two planes =',round(theta,2),'degrees'
#Variable Declaration
a=2.9*1e-8; #in cm
M=55.85;#atomic mass
density=7.87 #in g/cc
N=6.023*1e23;
#Calculations
n=(a**3*N*density)/M;#Number of atoms per unit cell
#Result
print 'Number of atoms per unit cell =',round(n,3)
#Incorrect answer in the textbook
from math import sqrt
#Variable Declaration
M=55.85;#atomic mass
d=7.86 #density of iron in g/cc
N=6.023*1e23
n=2#BCC structure
#Calculations
a=((n*M)/(N*d))**(1./3);
r=(sqrt(3)*a)/4;#radius of iron atom
#Result
print 'radius of iron atom =',round(r/1e-10,3),'A'
#Incorrect answer in the textbook
from math import sqrt
#Variable Declaration
M=207.21;#atomic mass
d=11.34*1e3 #in kg/m^3
N=6.023*1e26 #in kg/m^3
n=4;#for FCC
#Calculations
a=((n*M)/(N*d))**(1./3);#lattice constant
r=(sqrt(2)*a)/4;#Atomic radius
#Result
print 'lattice constant =',round(a/1e-10,2),'A'
print 'Atomic radius =',round(r/1e-10,2),'A'
from math import sqrt,sin,degrees,radians,pi
#Variable Declaration
n=1;
theta=30;#angle in degree
lamda=1.75; #in A
h=1;
k=1;
l=1;
#Calculations
#d111=a/sqrt((h*h)+(k*k)+(l*l))
#2dsin(thita)=n*lamda
d=n*lamda/(2*sin(theta*pi/180))
a=sqrt(3)*d;#lattice constant
#Result
print "lattice constant =",round(a,3),'A'
#Variable Declaration
#let three intercepts are I1,I2,I3
I1=0.96;
I2=0.64;
I3=0.48;
#Calculations
#as they are ratios we will multiply by some some constants so that it will become integers
I1=6;
I2=4;
I3=3 ;
#let their reciprocals are I1_1,I2_1,I3_1
I1_1=1./I1;
I2_1=1./I2;
I3_1=1./I3;
#LCM of I1_1,I2_1,I3_1 are 12.
#By multiply LCM with I1_!,I2_1,I3_1 we will get miller indices
LCM=12;
M_1=LCM*I1_1;
M_2=LCM*I2_1 ;
M_3=LCM*I3_1;
#Results
print 'Miller indices of plane are [',M_1,
print(M_2),
print(M_3),']'