# chapter3 :X-rays and compton effect¶

## example 3.1;page no:141¶

In :
#cal of Longest wavelength
#intiation of all variables
#given that
import math
d = 2.82 # crystal spacing in angstrom
n = 2 # order for longest passing wavelength
theta = 90 # angle for longest passing wavelength
print("Example 3.1,page no:141")
lamda = 2*d*math.sin(theta*math.pi/180)/n # Calculation of longest wavelength
print("Longest wavelength in angstrom:"),round(lamda,2)

Example 3.1,page no:141
Longest wavelength in angstrom: 2.82


## example 3.2;page no:142¶

In :
#cal of Angle at which second and third order bragg's
#intiation of all variables
#given that
import math
lamda = 0.3 # Wavelength in angstrom
d = 0.5 # crystal spacing in angstrom
n = 2. # order
m = 3. # order
print("Example 3.2,page no:142")
theta_n = math.asin(n*lamda/(2*d))*180/math.pi # Calculation of angle for order n
theta_m = math.asin(m*lamda/(2*d))*180/math.pi  # Calculation of angle for order m
print("Angle for nd order maxima in degree:"),round(theta_n,2)
print("Angle for rd order maxima in degree:"),round(theta_m,2)
# Answers in book are 40.97 degree and 72.29 degree which are due to wrong calculation

Example 3.2,page no:142
Angle for nd order maxima in degree: 36.87
Angle for rd order maxima in degree: 64.16


# example 3.3;page no:142¶

In :
#cal of Longest wavelength
#intiation of all variables
#given that
import math
d = 1.87 # crystal spacing in angstrom
n = 2 # order for longest passing wavelength
theta = 30 # angle for longest passing wavelength
print("Example 3.3,page no:142")
lamda = 2*d*math.sin(theta*math.pi/180)/n # Calculation of longest wavelength
print("Longest wavelength in angstrom:"),round(lamda,3)

Example 3.3,page no:142
Longest wavelength in angstrom: 0.935


## example 3.4;page no:143¶

In :
#cal of Crystal spacing
#intiation of all variables
#given that
import math
lamda = 3.6e-9 # Wavelength in cm
theta = 4.8 # glancing angle in degree
n = 1 # order
print("Example 3.4,page no:143")
d = n*lamda/(2*math.sin(theta*math.pi/180)) # calculation of crystal spacing in angstrom
print("Crystal spacing in angstrom in cm:"),round(d,10)

Example 3.4,page no:143
Crystal spacing in angstrom in cm: 2.15e-08


## example 3.5;page no:143¶

In :
#cal of Longest wavelength
#intiation of all variables
#given that
import math
d = 2.5 # crystal spacing in angstrom
n = 1 # order for longest passing wavelength
theta = 20 # angle for longest passing wavelength
print("Example 3.5,page no:143")
lamda = 2*d*math.sin(theta*math.pi/180)/n # Calculation of longest wavelength
print("Longest wavelength in angstrom:"),round(lamda,2)

Example 3.5,page no:143
Longest wavelength in angstrom: 1.71


## example 3.6;page no:144¶

In :
#cal of Longest wavelength
#intiation of all variables
#given that
import math
d = 2.5 # crystal spacing in angstrom
n = 1 # order for longest passing wavelength
theta = 90 # angle for longest passing wavelength
print("Example 3.6,page no:144")
lamda = 2*d*math.sin(theta*math.pi/180)/n # Calculation of longest wavelength
print("Longest wavelength is of angstrom:"),round(lamda)

Example 3.6,page no:144
Longest wavelength is of angstrom: 5.0


## example 3.7;page no:144¶

In :
#cal of Interatomic layer separation ratios in crystal
#intiation of all variables
#given that
import math
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 = 25#remainder minute part of angle for third angle
print("Example 3.7,page no:144")
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 :"),round(ratio_21,1),round(ratio_31,1)
print("Above relation shows that crystal is simple cubic crystal structure.")
print("therefore Interatomic layer separation ratios in crystal is 1:1.4:1.77")

Example 3.7,page no:144
Interatomic layer separation ratios in crystal are as 1 : 1.4 1.8
Above relation shows that crystal is simple cubic crystal structure.
therefore Interatomic layer separation ratios in crystal is 1:1.4:1.77


## example 3.8;page no:145¶

In :
#cal of possible spacing of this set of planes
#intiation of all variables
#given that
import math
lamda = 1.2 # wavelength in angstrom
theta_deg = 9. # angle fraction in degree
theta_min = 30. # Angle fraction in minute
print("Example 3.8,page no:145")
theta = theta_deg+theta_min/60 # Total angel
n1 =1
n2 =2
n3 =3
n4 =4
d1 = lamda/(n1*2*math.sin(theta*math.pi/180)) # Inter layer spacing
d2 = lamda/(n2*2*math.sin(theta*math.pi/180)) # Inter layer spacing
d3 = lamda/(n3*2*math.sin(theta*math.pi/180)) # Inter layer spacing
d4 = lamda/(n4*2*math.sin(theta*math.pi/180)) # Inter layer spacing
print("If order is then spacing in angstrom:"),round(d1,2),round(d2,2),round(d3,2),round(d4,2)

Example 3.8,page no:145
If order is then spacing in angstrom: 3.64 1.82 1.21 0.91


## example 3.9;page no:146¶

In :
#cal of Spacing of crystal
#intiation of all variables
#given that
import math
h = 6.62e-34 # Planks constant
m_e = 9.1e-31 # mass of electron in kg
e = 1.6e-19 # charge on electron in coulomb
v = 340 # Applied voltage in volt
n = 1 # order for longest passing wavelength
theta = 60 # angle for longest passing wavelength
print("Example 3.9,page no:146")
lamda= h/math.sqrt(2*m_e*e*v) # calculation of wavelength
d = n*lamda/(2*math.sin(theta*math.pi/180))# calculation of spacing of crystal
print("Spacing of crystal in angstrom:"),round(d*1e10,3)

Example 3.9,page no:146
Spacing of crystal in angstrom: 0.384


## example 3.10;page no:147¶

In :
#cal of Energy of recoiled electron
#intiation of all variables
#given that
import math
E = 100. # Energy of X ray beam in KeV
theta = 30. # Scattering angle in degree
m = 9.1e-31 # mass of electron in kg
c = 3.e8 # Speed of light in m/s
print("Example 3.10,page no:147")
E_rest = m*c**2/(1.6e-19*1e3) # Rest mass energy in KeV
k = 1/E + (1-math.cos(theta*math.pi/180))/(E_rest)
del_e = E - 1/k # Energy of recoiled electron
print("Energy of recoiled electron in KeV:"),round(del_e,2)
#cal of Energy of recoiled electron
#intiation of all variables
#given that
import math
E = 100. # Energy of X ray beam in KeV
theta = 30. # Scattering angle in degree
m = 9.1e-31 # mass of electron in kg
c = 3.e8 # Speed of light in m/s
print("Example 3.10,page no:147")
E_rest = m*c**2/(1.6e-19*1e3) # Rest mass energy in KeV
k = 1/E + (1-math.cos(theta*math.pi/180))/(E_rest)
del_e = E - 1/k # Energy of recoiled electron
print("Energy of recoiled electron in KeV:"),round(del_e,2)

Example 3.10,page no:147
Energy of recoiled electron in KeV: 2.55
Example 3.10,page no:147
Energy of recoiled electron in KeV: 2.55


## example 3.11;page no:148¶

In :
#cal of Wavelength shift
#intiation of all variables
#given that
import math
lamda = 1 #wavelength in angstrom
h = 6.62e-34 # Planks constant
m_e = 9.1e-31 # mass of electron in kg
c = 3e8 # speed of light in m/sec
theta = 90 # angle for longest passing wavelength
print("Example 3.11,page no:148")
d_lamda= h*(1-math.cos(theta*math.pi/180))/(m_e*c) # calculation of wavelength shift
print("Wavelength shift in angstrom:"),round(d_lamda*1e10,4)

Example 3.11,page no:148
Wavelength shift in angstrom: 0.0242


## example 3.12;page no:149¶

In :
#cal of Wavelength shift
#intiation of all variables
#given that
import math
lamda = 0.015 #wavelength in angstrom
h = 6.63e-34 # Planks constant
m_e = 9.1e-31 # mass of electron in kg
c = 3e8 # speed of light in m/sec
theta = 60 # angle for longest passing wavelength
print("Example 3.12,page no:149")
d_lamda= h*(1-math.cos(theta*math.pi/180))*1e10/(m_e*c) # calculation of wavelength shift in angstrom
lamda_n = lamda+d_lamda
print("Wavelength shift in angstrom:"),round(lamda_n,3)

Example 3.12,page no:149
Wavelength shift in angstrom: 0.027


## example 3.13;page no:150¶

In :
#cal of Wavelength shift and Energy of recoiled electron
#intiation of all variables
#given that
import math
lamda = 1 #wavelength in angstrom
h = 6.63e-34 # Planks constant
m_e = 9.1e-31 # mass of electron in kg
c = 3e8 # speed of light in m/sec
theta = 90 # angle for longest passing wavelength
print("Example 3.13,page no:150")
d_lamda= h*(1-math.cos(theta*math.pi/180))*1e10/(m_e*c) # calculation of wavelength shift in angstrom
lamda_n = lamda+d_lamda # Calculation of recoiled electron wavelength
d_E = h*c*(lamda_n-lamda)*1e10/(1.6e-19*lamda_n*lamda)# Calculation of recoiled electron energy in eV
print("Wavelength shift in angstrom:"),round(lamda_n,4)
print("Energy of recoiled electron in eV:"),round(d_E)

Example 3.13,page no:150
Wavelength shift in angstrom: 1.0243
Energy of recoiled electron in eV: 295.0


## example 3.14;page no:151¶

In :
#cal of wavelength shift and energy of recoiled electron
#intiation of all variables
#given that
lamda = 1 #let wavelength in angstrom
lamda_n = 2*lamda # recoiled electron wavelength
h = 6.63e-34 # Planks constant
m_e = 9.1e-31 # mass of electron in kg
c = 3e8 # speed of light in m/sec
theta = 90 # angle for longest passing wavelength
print("Example 3.14,page no:151")
lamda = h*1e10/(m_e*c) # calculation of wavelength in angstrom
E = h*c*1e10/(lamda*1.6e-19) # calculation of energy of electron
print("Wavelength shift in angstrom:"),round(lamda,4)
print("Energy of recoiled electron in KeV:"),round(E/1e3,2)

Example 3.14,page no:151
Wavelength shift in angstrom: 0.0243
Energy of recoiled electron in KeV: 511.88


## example 3.15;page no:152¶

In :
#cal of Fraction of energy lost by photon
#intiation of all variables
#given that
import math
lamda = 2 #wavelength in angstrom
h = 6.63e-34 # Planks constant
m_e = 9.1e-31 # mass of electron in kg
c = 3e8 # speed of light in m/sec
theta = 45 # scattering angle
print("Example 3.15,page no:152")
d_lamda= h*(1-math.cos(theta*math.pi/180))*1e10/(m_e*c) # calculation of wavelength shift in angstrom
lamda_n = lamda+d_lamda # Calculation of recoiled electron wavelength
f = d_lamda/lamda # Calculation of fraction of energy lost by photon
print("Fraction of energy lost by photon is:"),round(f,5)

Example 3.15,page no:152
Fraction of energy lost by photon is: 0.00356


## example 3.16;page no:153¶

In :
#cal of wavelength of scattered radiation
#intiation of all variables
#given that
import math
E_eV = 510 # Energy of gamma ray in keV
lamda = 2 #wavelength in angstrom
h = 6.63e-34 # Planks constant
m_e = 9.1e-31 # mass of electron in kg
c = 3e8 # speed of light in m/sec
theta = 90 # scattering angle in degree
print("Example 3.16,page no:153")
E_j = E_eV*1e3*1.6e-19 # Energy of gamma ray in Joule
lamda = h*c*1e10/E_j # Calculation of wavelength in angstrom
d_lamda= h*(1-math.cos(theta*math.pi/180))*1e10/(m_e*c) # calculation of wavelength shift in angstrom
lamda_n = lamda+d_lamda # Calculation of recoiled electron wavelength
print("Wavelength of scattered radiation in Angstrom:"),round(lamda_n,4)

Example 3.16,page no:153
Wavelength of scattered radiation in Angstrom: 0.0487


## example 3.17;page no:154¶

In :
#cal of Scattered wavelength and Energy of recoiled electron
#intiation of all variables
#given that
import math
lamda = 2 #wavelength in angstrom
h = 6.63e-34 # Planks constant
m_e = 9.1e-31 # mass of electron in kg
c = 3e8 # speed of light in m/sec
theta = 90 # angle for longest passing wavelength
print("Example 3.17,page no:154")
d_lamda= h*(1-math.cos(theta*math.pi/180))*1e10/(m_e*c) # calculation of wavelength shift in angstrom
lamda_n = lamda+d_lamda # Calculation of recoiled electron wavelength
d_E = h*c*(lamda_n-lamda)*1e10/(1.6e-19*lamda_n*lamda)# Calculation of recoiled electron energy in eV
print("Scattered wavelength in angstrom:"),round(lamda_n,4)
print("Energy of recoiled electron in eV:"),round(d_E,1)

Example 3.17,page no:154
Scattered wavelength in angstrom: 2.0243
Energy of recoiled electron in eV: 74.6


## example 3.18;page no:155¶

In :
#cal of Wavelength of scattered radiation and Energy of recoiled electron
#intiation of all variables
#given that
import math
E_eV = 510 # Energy of gamma ray in keV
h = 6.63e-34 # Planks constant
m_e = 9.1e-31 # mass of electron in kg
c = 3e8 # speed of light in m/sec
theta = 90 # scattering angle in degree
print("Example 3.18,page no:155")
E_j = E_eV*1e3*1.6e-19 # Energy of gamma ray in Joule
lamda = h*c/E_j # Calculation of wavelength in meter
d_lamda= h*(1-math.cos(theta*math.pi/180))*1e10/(m_e*c) # calculation of wavelength shift in angstrom
lamda_n = lamda+d_lamda/1e10 # Calculation of recoiled electron wavelength
d_E = h*c*(d_lamda/1e10)/(1.6e-19*lamda_n*lamda)# Calculation of recoiled electron energy in eV
psi= math.atan(1/(math.tan((theta*math.pi/180)/2)/(1+(h/(lamda*m_e*c)))))
phi_deg = 90 -psi*180/math.pi # Calculation of degree part of angle of recoiled electron
#phi_min = 60*(phi_deg - floor(phi_deg))# Calculation of minute part of angle of recoiled electron
print("Wavelength of scattered radiation in m:"),round(lamda_n,14)
print("Energy of recoiled electron in MeV:"),round(d_E/1e6,3)
#print("Recoiled electron angle in degree minute:"),round(phi_deg),round(phi_min)

Example 3.18,page no:155
Wavelength of scattered radiation in m: 4.87e-12
Energy of recoiled electron in MeV: 0.255


## example 3.19;page no:157¶

In :
#cal of Frequency after collision
#intiation of all variables
#given that
nu = 2e19 # initial frequency of X ray photon
h = 6.63e-34 # Planks constant
m_e = 9.1e-31 # mass of electron in kg
c = 3e8 # speed of light in m/sec
theta = 90 # scattering angle in degree
print("Example 3.19,page no:157")
d_lamda = h/(m_e*c) # calculation of wavelength shift
k = 1/nu + d_lamda/c
nu_1 = 1/k # Frequency after collision
nu_1 = (nu_1/1e18)*1e18 # rounding off
print("Frequency after collision in Hz:"),round(nu_1,19)

Example 3.19,page no:157
Frequency after collision in Hz: 1.72131147541e+19