#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)
#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
#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)
#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)
#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)
#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)
#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")
#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)
#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)
#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)
#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)
#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)
#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)
#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)
#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)
#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)
#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)
#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)
#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)