import math
V=25*10**3 #potential difference in Volt
h=6.63*10**-34 #planck constant in joule-sec
c=3*10**8 #speed of light in m/sec
e=1.6*10**-19 #charge of electron in coulomb
theta=math.radians(15.8) #glancing angle for NaCl crystal for CuKa line
d=2.82 #for NaCl
lamda=2*d*math.sin(theta)
print "wavelength of CuKa line=",round(lamda,4),"Angstrom"
lamda_min=(h*c/(e*V))*10**10
print "wavelength of X-Ray photon at shortest limit=",round(lamda_min,4),"Angstrom"
theta_1=math.degrees(math.asin(lamda_min/(2*d)))
print "glancing angle for photons at the shortest wavelength limit=",round(theta_1,2),"degree"
import math
theta=math.radians(30) #glancing angle in radians
d=1.87 #spacing between lattice planes in angstrom
n=2 #for second order reflection
lamda=2*d*math.sin(theta)/n
print "wavelength of X-Rays=",lamda,"Angstrom"
import math
lamda=0.36*10**-8 #wavelength in cm
theta=math.radians(4.8)#glancing angle in radians
n=1 #for first order diffraction
d=n*lamda/(2*math.sin(theta))
print "interplanar separation of atomic planes in crystal=","{:.2e}".format(d),"cm"
import math
lamda=2.6*10**-10 #wavelength in meter
theta=math.radians(20) #in radians
n=2 #for second order diffraction
d=n*lamda/(2*math.sin(theta))
print "spacing constant of the crystal=",round(d*10**10,2),"Angstrom"
import math
d=2.82*10**-10 #spacing in meter
n=2 #for second order
sin_theta=1 #maximum value of sin(theta)
lamda_max=2*d*sin_theta/n
print "longest wavelength=",lamda_max*10**10,"Angstrom"
import math
lamda=0.842 #wavelength in angstrom
theta_1=8+(35./60) #1' = (1/60)º = 0.01666667º
theta_3=math.asin(round(3*math.sin(math.radians(theta_1)),2))
print "glancing angle for 3rd order reflection=",round(math.degrees(theta_3),1),"degree"
import math
lamda=0.97 #wavelength of first X-ray beam in angstrom
theta=math.radians(60) #angle of reflection in radians
n=3 #for third order reflection
d=n*lamda/(2*math.sin(theta))
n_1=1 #for first order reflection
theta_1=math.radians(30) #angle of reflection in radians
lamda_1=2*d*math.sin(theta_1)
print "wavelength of the second X-ray beam=",round(lamda_1,2),"Angstrom"
import math
lamda=0.30 #wavelength in angstrom
d=0.5 #lattice spacing in angstrom
n=2 #for second order diffraction
theta=math.asin(n*lamda/(2*d))
print "For second order maxima, angle=",round(math.degrees(theta),2),"degree"
n=3 #for third order diffraction
theta=math.asin(n*lamda/(2*d))
print "For third order maxima, angle=",round(math.degrees(theta),2),"degree"
import math
d=2.82*10**-8 #lattice spacing in cm
c=3*10**10 #speed of light in cm/sec
e=1.6*10**-19 #charge on electron in coulomb
v=9045 #voltage in volt
theta=math.radians(14)#angle in radians
n=1 #first order
lamda=2*d*math.sin(theta)/n
h=(e*v*lamda/c)*10**7 #since 1 joule=10**7 erg
print "h=","{:.2e}".format(h),"erg-sec"
import math
do=2.82 #lattice spacing in angstrom
theta=math.radians(10) #angle in radians
lamda=2*do*round(math.sin(theta),4)
print "wavelength=",round(lamda,4),"Angstrom"
import math
d=0.4086*10**-10 #lattice spacing in meter
h=6.6*10**-34 #planck constant in joule-sec
m=9.1*10**-31 #mass of electron in Kg
n=1 #first order
theta=math.radians(65) #glancing angle in radians
lamda=2*d*math.sin(theta)/n
print "wavelength=","{:.3e}".format(lamda),"m"
v=h/(m*lamda)
print "velocity of electron=","{:.3e}".format(v),"m/sec"
import math
h=6.62*10**-34 #planck constant in joule-sec
e=1.6*10**-19 #charge on electron in coulomb
m=9*10**-31 #mass of electron in Kg
v=344 #voltage in volt
n=1 #first order
theta=math.radians(60)#glancing angle in radians
lamda=h/math.sqrt(2*m*e*v)
d=n*lamda/(2*math.sin(theta))
print "spacing of the crystal=",round(d*10**10,2),"Angstrom"
import math
#given that
lamda=1.32*10**-10 #wavelength in meter
theta_deg=9 #angle fraction in degree
theta_min=30 #angle fraction in minute
theta =theta_deg+(theta_min/60.) # Total angle
for n in range(1,5):
d = lamda/(n*2*math.sin(theta*math.pi/180)) # Inter layer spacing
print "If order is %d then spacing is"%(n),"{:.2e}".format(d),"meter"
import math
# given that
theta1_deg = 5 # Absolut degree part of angle for first angle
theta1_min = 23# remainder minute part of angle for first angle
theta2_deg = 7 # Absolut degree part of angle for second angle
theta2_min = 37# remainder minute part of angle for second angle
theta3_deg = 9 # Absolut degree part of angle for third angle
theta3_min = 22# remainder minute part of angle for third angle
val1 = math.sin((theta1_deg+ theta1_min/60.)*math.pi/180)# Sin value for first angle
val2 = math.sin((theta2_deg+ theta2_min/60.)*math.pi/180) #Sin value for second angle
val3 = math.sin((theta3_deg+ theta3_min/60.)*math.pi/180)#Sin value for third angle
ratio_21 = val2/val1
ratio_31 = val3/val1
print "Interatomic layer separation ratios in crystal are as 1 : %f : %f"%(ratio_21,ratio_31)
print "Above relation shows that crystal has a simple cubic crystal structure."
import math
h=6.63*10**-34 #planck constant in joule-sec
c=3*10**8 #speed of light in m/sec
mo=9.1*10**-31 #mass of electron in Kg
theta=math.radians(180)#scattering angle in radians
d_lamda=h*(1-math.cos(theta))/(mo*c)
print "change in wavelength of photon=",round(d_lamda*10**10,4),"Angstrom"
import math
#given that
E=100. # Energy of X ray beam in KeV
theta=30 # Scattering angle in degree
mo=9.1*10**-31 # mass of electron in kg
c=3*10**8 # Speed of light in m/s
E_rest=(mo*c**2)/(1.6e-19*1e3) # Rest mass energy in KeV
k=(1/E)+ ((1-math.cos(math.radians(theta)))/(E_rest))
k=int(k*10000)*10**-4
del_e=E-1/k # Energy of recoiled electron
print "Energy of recoiled electrons is ",round(del_e,2),"KeV"
import math
#given that
lamda=1 # wavelength in angstrom
h=6.63*10**-34 # Planck's constant in joule-sec
mo=9.1*10**-31 # mass of electron in kg
c=3*10**8 # speed of light in m/sec
theta=90 # scattering angle in degree
d_lambda=h*(1-math.cos(math.radians(90)))/(mo*c) # calculation of compton shift
print "compton shift is ",round(d_lambda*1e10,4),"Angstrom"
import math
#given that
lamda=0.015 #wavelength in angstrom
h=6.63*10**-34 #Planks constant in joule-sec
mo=9.1*10**-31 #mass of electron in kg
c=3*10**8 #speed of light in m/sec
theta=60 #scattering angle in degree
d_lambda=h*(1-math.cos(theta*math.pi/180))*1e10/(mo*c)
lambda_n=lamda+d_lambda
print "Wavelength of the scattered X-ray is ",round(lambda_n,3),"Angstrom"
import math
#given that
lamda=1 # wavelength in angstrom
h=6.63*10**-34 # Planck's constant in joule-sec
mo=9.1*10**-31 # mass of electron in kg
c=3*10**8 # speed of light in m/sec
theta=90 # scattering angle in degree
d_lambda= h*(1-math.cos(math.radians(90)))*1e10/(mo*c) # calculation of wavelength shift in angstrom
lambda_n=lamda+d_lambda # Calculation of wavelength of scattered beam in angstrom
K_E=h*c*(lambda_n-lamda)*1e10/(1.6e-19*lambda_n*lamda)# Calculation of K.E of recoiled electron in eV
phi=math.atan(round((lamda/lambda_n),2))# calculation of Direction of the recoiled electron
print "Wavelength of the scattered beam is ",round(lambda_n,4),"Angstrom"
print "Kinetic Energy imparted to the recoiled electron is ",round(K_E),"eV"
print "Direction of the recoiled electron is ",round(math.degrees(phi),1),"degree"
import math
#given that
lamda=1 # wavelength in angstrom
h=6.63*10**-34 # Planck's constant in joule-sec
mo=9.1*10**-31 # mass of electron in kg
c=3*10**8 # speed of light in m/sec
theta=90 # scattering angle in degree
d_lambda= h*(1-math.cos(math.radians(90)))*1e10/(mo*c) # calculation of compton shift in angstrom
lambda_n=lamda+d_lambda # Calculation of wavelength of scattered beam in angstrom
K_E=h*c*(lambda_n-lamda)*1e10/(1.6e-19*lambda_n*lamda)# Calculation of K.E of recoiled electron in eV
print "Compton shift is ",round(d_lambda,4),"Angstrom"
print "Kinetic Energy imparted to the recoiled electron is ",round(K_E),"eV"
import math
h=6.63*10**-34 # Planck's constant in joule-sec
mo=9.1*10**-31 # mass of electron in kg
c=3*10**8 # speed of light in m/sec
E=0.88*10**6 #energy of gamma-rays in eV
theta=180 #scattering angle in degree for maximum energy of recoiled electron
lamda=h*c*10**10/(E*1.6*10**-19)
d_lamda_max=h*(1-math.cos(math.radians(theta)))*1e10/(mo*c)
lamda_n=lamda+d_lamda_max
K_E_max=h*c*d_lamda_max*1e10/(1.6e-19*lamda_n*lamda)
print "Maximum energy of compton recoil electrons is ",round(K_E_max*10**-6,3),"MeV"
import math
h=6.62*10**-34 # Planck's constant in joule-sec
mo=9.0*10**-31 # mass of electron in kg
c=3*10**8 # speed of light in m/sec
theta=90 # scattering angle in degree
lamda=h*(1-math.cos(math.radians(theta)))*1e10/(mo*c)
d_lamda=lamda # compton shift
E=h*c/(round(lamda,4)*1e-10)
print "Wavelength of incident photon is ",round(lamda,4),"Angstrom"
print "Energy of incident photon is ","{:.3e}".format(E),"joule"
import math
h=6.63*10**-34 # Planck's constant in joule-sec
mo=9.1*10**-31 # mass of electron in kg
c=3*10**8 # speed of light in m/sec
theta=90 # scattering angle in degree
d_lamda=h*(1-math.cos(math.radians(theta)))*1e10/(mo*c)
print "Percentage change in energy when photon is:"
#(a) for microwave photon
lamda=3*10**8 #wavelength of microwave photon in Angstrom
energy_change=d_lamda*100/(lamda+d_lamda)
print "A microwave photon= ","{:.1e}".format(energy_change),"%"
#(b) for visible light photon
lamda=5000 #wavelength of visible light photon in Angstrom
energy_change=d_lamda*100/(lamda+d_lamda)
print "A visible light photon= ","{:.2e}".format(energy_change),"%"
#(c) for X-ray photon
lamda=1 #wavelength of X-ray photon in Angstrom
energy_change=d_lamda*100/(lamda+d_lamda)
print "An X-ray photon= ",round(energy_change,1),"%"
#(d) for gamma-ray photon
lamda=0.0124 #wavelength of gamma-ray photon in Angstrom
energy_change=d_lamda*100/(lamda+d_lamda)
print "A gamma-ray photon= ",int(energy_change),"%"
print "Hence, the compton effect is dominant only in the gamma-ray region and shorter X-ray region.It is not observable in the visible region and microwave region"
import math
lamda=2 # wavelength in angstrom
h=6.62*10**-34 # Planck's constant in joule-sec
mo=9.1*10**-31 # mass of electron in kg
c=3*10**8 # speed of light in m/sec
theta=45 # scattering angle in degree
d_lamda=h*(1-math.cos(math.radians(theta)))*1e10/(mo*c)
lamda_n=lamda+d_lamda
f=d_lamda/lamda_n # Calculation of fraction of energy lost by photon
print "Fraction of energy lost by photon is ",round(f,4)
import math
C_W=0.0242 #compton wavelength of electron in Angstrom
theta=45 # scattering angle in degree
d_lamda=C_W*(1-math.cos(math.radians(theta)))
lamda= d_lamda
print "Wavelength= ",round(lamda,3),"Angstrom"
#answer is incomplete in book as only wavelength is calculated and no region is specified
print "Hence, such a photon lie in the Gamma-ray region of electromagnetic spectrum."
import math
h=6.6*10**-34 # Planck's constant in joule-sec
mo=9.1*10**-31 # mass of electron in kg
c=3*10**8 # speed of light in m/sec
E=510*10**3 # energy of gamma-rays in eV
theta=90 # scattering angle in degree
lamda=h*c/(E*1.6*10**-19)
d_lamda=h*(1-math.cos(math.radians(theta)))/(mo*c)
lamda_n=lamda+d_lamda
Er=h*c*d_lamda/(lamda_n*lamda)
phi=math.atan(lamda/lamda_n)
print "Wavelength of scattered radiation is ","{:.3e}".format(lamda_n),"meter"
print "Energy of recoil electron is ","{:.3e}".format(Er),"joule"
print "Direction of the recoil electron is ",round(degrees(phi),2),"degree"
import math
h=6.63*10**-34 # Planck's constant in joule-sec
mo=9.1*10**-31 # mass of electron in kg
c=3*10**8 # speed of light in m/sec
E=510*10**3 # energy of gamma-rays in eV
theta=90 # scattering angle in degree
lamda=h*c/(E*1.6*10**-19)
d_lamda=h*(1-math.cos(math.radians(theta)))/(mo*c)
lamda_n=lamda+d_lamda
print "Wavelength of scattered radiation is ",round(lamda_n*10**10,4),"Angstrom"
import math
h=6.62*10**-34 # Planck's constant in joule-sec
mo=9.1*10**-31 # mass of electron in kg
c=3*10**8 # speed of light in m/sec
theta=180 # scattering angle in degree for minimum energy of incident photon
lamda_max=h*(1-math.cos(math.radians(theta)))/(mo*c)
E_min=h*c/lamda_max
print "Minimum energy of incident photon is ",int(round(E_min/(1.6*10**-16))),"KeV"