# Code 01

Plot Planck's Law For Black Body Radiation And Compare It With Raleigh-Jeans Law At High And Low Temperature
Anamitra
python
a month ago
2.0 kB
6
Indexable
Never
BSC 6th Sem Python LNB
```import numpy as np
import scipy.constants as const
import matplotlib.pyplot as plt

plt.style.use('fivethirtyeight')
plt.rcParams['figure.figsize'] = (12, 10)

pi = const.pi  # Value Of Pi
h = const.h  # Planck's Constant
c = const.c  # Speed Of Light
k = const.k  # Boltzmann Constant

# Define Planck's Distribution Law For Black Body Radiation
def Plancks_law(lm,T):
return 8*pi*h*c / (lm**5 * (np.exp(h*c / (lm*k*T)) - 1))

# Define Rayleigh-Jeans Function
def Rayleigh_Jeans(lm,T):
return 8*pi*k*T/lm**4

lm = np.arange(100e-9, 30e-6, 5e-9)  # Wavelength In Meter
T = np.arange(300,3300,300)  # Temperature In Kelvin

# Planck's Distribution Law For Black Body Radiation
for i in range(len(T)):
plt.plot(lm*1e9, Plancks_law(lm,T[i]), label=f'T = {T[i]} K')
plt.legend(title='Temperature')
plt.xlabel("Wavelength (nm)")
plt.ylabel("Temperature in Kelvin")
plt.title("Planck's Distribution Law For Black Body Radiation")
plt.show()

# Compare Planck's Distribution Law With Raleigh-Jeans Law At Low Temperature
plt.plot(lm*1e9, Plancks_law(lm,300)*1e-3, color = 'teal', label="Planck's Law (T = 300 K)")
plt.plot(lm*1e9, Rayleigh_Jeans(lm,300)*1e-3, color = 'darksalmon', label="Rayleigh-Jeans Law (T = 300 K)")
plt.ylim(0,0.005)
plt.legend()
plt.xlabel("Wavelength (nm)")
plt.ylabel("Temperature in Kelvin")
plt.title("Compare Planck's Distribution Law With Raleigh-Jeans Law At Low Temperature", fontsize=17)
plt.show()

# Compare Planck's Distribution Law With Raleigh-Jeans Law At High Temperature
plt.plot(lm*1e9, Plancks_law(lm,3000)*1e-3, color = 'teal', label="Planck's Law (T = 3000 K)")
plt.plot(lm*1e9, Rayleigh_Jeans(lm,3000)*1e-3, color = 'darksalmon', label="Rayleigh-Jeans Law (T = 3000 K)")
plt.ylim(0,140)
plt.legend()
plt.xlabel("Wavelength (nm)")
plt.ylabel("Temperature in Kelvin")
plt.title("Compare Planck's Distribution Law With Raleigh-Jeans Law At High Temperature", fontsize=17)
plt.show()```