from __future__ import division
from math import sqrt
#Given data
r = 1.278 # in angstrum
At = 63.5 # atomic weight
N_A = 6.023*10**23 # Avagadro number
a = (4*r)/sqrt(2) # in angstrum
a = a * 10**-10 # in m
m = At/N_A # in gm
m = m * 10**-3 # in kg
V = (a**3) # in m**3
n = 4 # number of atoms present in one unit cell of Cu
rho = (m*n)/V # in kg/m**3
print "The density of crystal = %0.f kg/m**3 " %rho
from math import sin, pi
#Given data
lembda = 1.539 # in angstrum
theta = 22.5 # in degree
n = 1 # first order
# n*lembda = 2*d*sind(theta)
d = lembda/(2*sin(theta*pi/180)) # in angstrum
print "The interplaner distance = %0.2f angstrum " %d
#Given data
n = 2 # second order
d = 0.4 # in nm
d = d * 10**-9 # in m
theta = 16.8/2 # in degree
# n*lembda = 2*d*sind(theta) (using Bragg's equation)
lembda = (2*d*sin(theta*pi/180))/n # in m
lembda = lembda * 10**10 # in angstrum
print "The wavelength of x-rays = %0.3f angstrum " %lembda
# Given data
a= 3.15 # in angstrum
a= a*10**-10 # in m
theta= 20.2 # in degree
n= 1 # first order
d= a/2**(1/2) # d110 for BCC crystal
# n*lembda = 2*d*sind(theta) (using Bragg's equation)
lembda = (2*d*sin(theta*pi/180))/n # in m
lembda = lembda * 10**10 # in angstrum
print "The wavelength of x-rays = %0.2f angstrum " %lembda