Plot Planck's law for Black Body radiation and compare it with Wein's Law and Raleigh-Jeans Law at high temperature (room temperature) and low temperature using Python
INPUT:-
#SAYANTAN DATTA / 6TH SEM / ROLL-074
#DATE - 08-04-2022
import numpy as np
import matplotlib.pyplot as plt
h=6.626e-34
k=1.38e-23
pi=3.14159
c=3e8
l1=float(input("Enter the value of lower wavelength = "))
l2=float(input("Enter the value of higher wavelength = "))
lw0=float(input("Give an upper limit of wavelength value for Wiens = "))
lr0=float(input("Give the lower limit of wavelength value for Rayleigh Jeans = "))
T1=float(input("Give the first value of temperature in Kelvin = "))
T2=float(input("Give the second value of temperature in Kelvin = "))
T3=float(input("Give the third value of temperature in Kelvin = "))
l=np.linspace(l1,l2,1000)
lw=np.linspace(l1,lw0,1000)
lr=np.linspace(lr0,l2,1000)
def p(l,T):
y=h*c/(l*k*T)
x=np.exp(y)
return (8*pi*h*c)/((l**5)*(x-1))
def w(lw,T):
y=h*c/(lw*k*T)
x=np.exp(y)
return (8*pi*h*c)/((lw**5)*x)
def r(lr,T):
return 8*pi*k*T/(lr**4)
plt.plot(l,p(l,T1),"m",label="PLanck Law Plot at "+str(T1)+"K")
plt.plot(lw,w(lw,T1),"c",ls="--",label="Wiens Law Plot at "+str(T1)+"K")
plt.plot(lr,r(lr,T1),"r",ls="--",label="Rayleight Jeans Law Plot at "+str(T1)+"K")
plt.xlabel("Wavelength in mtr")
plt.ylabel("Energy Density (arbitrary units)")
plt.title("Energy Density vs Wavelength at "+str(T1)+"K")
plt.legend()
plt.grid()
plt.savefig("T1.png")
plt.show()
plt.plot(l,p(l,T2),"m",label="PLanck Radiation Law Plot at "+str(T2)+"K")
plt.plot(lw,w(lw,T2),"c",ls="--",label="Wiens Law Plot at "+str(T2)+"K")
plt.plot(lr,r(lr,T2),"r",ls="--",label="Rayleight Jeans Law Plot at "+str(T2)+"K")
plt.xlabel("Wavelength in mtr")
plt.ylabel("Energy Density (arbitrary units)")
plt.title("Energy Density vs Wavelength at "+str(T2)+"K")
plt.legend()
plt.grid()
plt.savefig("T2.png")
plt.show()
plt.plot(l,p(l,T3),"m",label="PLanck Law Plot at "+str(T3)+"K")
plt.plot(lw,w(lw,T3),"c",ls="--",label="Wiens Law Plot at "+str(T3)+"K")
plt.plot(lr,r(lr,T3),"r",ls="--",label="Rayleight Jeans Law Plot at "+str(T3)+"K")
plt.xlabel("Wavelength in mtr")
plt.ylabel("Energy Density (arbitrary units)")
plt.title("Energy Density vs Wavelength at "+str(T3)+"K")
plt.legend()
plt.grid()
plt.savefig("T3.png")
plt.show()
OUTPUT:-
Enter the value of lower wavelength = 0.1e-6
Enter the value of higher wavelength = 0.00004
Give an upper limit of wavelength value for Wiens = 2e-5
Give the lower limit of wavelength value for Rayleigh Jeans = 2e-5
Give the first value of temperature in Kelvin = 200
Give the second value of temperature in Kelvin = 273
Give the third value of temperature in Kelvin = 315
To get the best result use Spyder 5.0 or IDLE.
Do not use Pydroid 3 to run this, you will face some error there of their own as yours.
Contact me using Contact Form from side bar if any doubt is there.
THANK YOU...
©SAYANTAN DATTA, 2023, PHYSICS
Comments
Post a Comment