from sympy import Symbol
R=Symbol('R')
a=2*R*round(math.sqrt(2),2)
V=a**3
print"Volume is",V," m**3"
print"which is also equal to 16*sqrt(2)*R**3"
n=4
R=1 #say
a=2*R*math.sqrt(2)
Vc=a**3
Vs=n*4*math.pi*R**3/3.0
APF=Vs/Vc
print"Atomic packing fraction is",round(APF,2)
R=1.28*10**-8 #Atomic radius in cm
A_Cu=63.5 #Atomic wt of copper
n=4 #For FCC
Na=6.023*10**23 #Avogadro no.
a=2*R*math.sqrt(2)
Vc=a**3
den=n*A_Cu/(Vc*Na)
print"Density is ",round(den,2),"g/cm**3"
a=1/2.0
b=1
c=0
x=[2*a,2*b,2*c]
print"The intercept for the given plane is",x
du=1
dv=1
dw=1
u=(2*du-dv)/3.0
v=(2*dv-du)/3.0
t=-(u+v)
w=dw
x=[3*u,3*v,3*t,3*w]
print"The indices for the given directions are",x
a=-1
b=1/2.0
l=0 #Reciprocal of infinity
m=1/a
n=1/b
x=[l,m,n]
print"The intercept for the given plane is",x
h=1 #Reciprocal of intersection point
k=-1
l=1
i=-(h+k)
x=[h,k,i,l]
print"The indices of plane are",x
a=0.2866 #Lattice parameter in nm
h=2
k=2
l=0
import math
d_hkl=a/(math.sqrt(h**2+k**2+l**2))
lam=0.1790 #Wavelength in nm
n=1
theta=math.asin(n*lam/(2*d_hkl))
print"(a)Interplanar spacing is ",round(d_hkl,4),"nm"
print"(b)Diffraction angle is ",round(2*theta*(180/math.pi),1),"degree"