#calculate the Angle required
#Initialization of variables
import math
l=0.71 *10**-8 #cm
n=200. #lines/cm
v=0.00145 #radian
#calculations
d=1/n
phi2=2*l/d +v**2
phi=math.sqrt(phi2)
#results
print '%s %.2e %s' %('Angle required =',phi,'radian')
#calculate the Interplanar distance
#Initialization of variables
import math
angle=37.25 #degrees
l=1.539 #A
n=1. #order
#calculations
d=n*l/(2*math.sin(angle/180.*math.pi))
#results
print '%s %.3f %s' %("Interplanar distance =",d,"A")
#calculate the ratio of radii
#Initialization of variables
import math
r1=math.sqrt(3.)
r2=1
#calculations
ratio=r1-r2
#results
print '%s %.3f' %('Ratio of radii =',ratio)
#calculate the Avagadro number
#Initialization of variables
d=2.64 #g/cc
l=4.016*10**-8 #cm
n=4
M=25.94 #g/mol
#calculations
m=d*l**3 /n
N0=M/m
#results
print '%s %.3e %s' %("Avagadro number =",N0," molecule/mol")
#calculate the angle required
#Initialization of variables
import math
import numpy
A=numpy.array([-1, -1, -1 ])
B=numpy.array([1, 1, -1])
#calculations
Ad=math.sqrt(1+1+1)
Bd=math.sqrt(1+1+1)
dot=numpy.dot(A,B) /(Ad*Bd)
theta=math.acos(dot) *180./math.pi
#results
print '%s %.2f %s' %("Angle =",theta," degrees")