Search
Black body radiation

Playing with Planck distribution

Let's use interactive Python code to get a feel for Planck distribution of black body radiation

%matplotlib notebook
import math
import numpy as np
import matplotlib.pyplot as plt
def planck_black_body(Lambda, T):
    """
    Lambda - radiation wavelength in nanometers
    T - temperature in Kelvins"""
    # Note: lambda is a keyword in Python so we need to capitalize it
    # Convert to meters
    l = Lambda*10e-9
    h = 6.626e-34
    c = 3e8
    k = 1.38e-23
    prefactor = 8 * math.pi * h * c / l**5
    hc_over_kT = h * c / k / T
    exponential = np.exp(hc_over_kT/ l)
    rho = prefactor / (exponential-1)
    return rho
    
    

Plotting the distribution

This is a markdown text Let's plot the Planck distribution for a specific temperature!

1) Try setting different temperatures

2) Identify the lambda for maximum for different temperatures.

  • What do you get for room temperature
  • What temperature do you need for the maximum to be in the visible region? (below 720 nm)
T1 = 298    # In Kelvins
T2 = 400
lambdas = np.arange(100, 5000., 100.)
plt.clf()
plt.plot(lambdas, planck_black_body(lambdas, T1), lambdas, planck_black_body(lambdas, T2))
#plt.axis([0, 10000, 0, 2])
plt.ylabel("Energy density")
plt.xlabel("Wavelength / nm")
plt.show()