-->

Etiquetas

The Blackbody Radiation and the Cosmic Microwave Background (CMB) in Python: part I

The Blackbody Radiation and the Cosmic Microwave Background (CMB) in Python: part I

Author: Eduardo Martín Calleja
This post is the first in a series of two in which we will examine, with the help of the Python language, the features of the blackbody radiation. In a second part, we will apply it to the particular case of the spectrum of the cosmic microwave background (CMB).
The study of the properties of celestial bodies, such as its color or luminosity, needs the concept of an ideal radiation emitter known as a "blackbody". The stars radiate energy that depends on its temperature and the length of the radiation wavelength, and the blackbody emission law can be considered as a first approximation of the characteristics of this radiation. For this reason I will show in this post how to build with Python the curves of radiation of a blackbody at different temperatures, which will also constitute a good exercise to practice with the use of physical units with the "quantities" Python package, which was the subject of a previous post.
As usual, this entry has been written entirely using the amazing IPython Notebook.

Imports and references

In [1]:
%matplotlib inline

from __future__ import division

import quantities as pq
import numpy as np
import matplotlib.pyplot as plt

# This IPython magic generates a table with version information
# https://github.com/jrjohansson/version_information
%load_ext version_information
%version_information numpy, matplotlib, quantities
Out[1]:
SoftwareVersion
Python2.7.9 64bit [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
IPython2.3.1
OSLinux 3.13.0 45 generic x86_64 with debian jessie sid
numpy1.9.1
matplotlib1.4.2
quantities0.10.1
Sat Feb 21 00:33:52 2015 CET
You can check out the Planck's law in the wikipedia

Blackbody Radiation

The Plank equation represents the intensity of the radiation from a blackbody as a function of the wavelength. There is a curve for each blackbody temperature. Its form is:
\[ B_\lambda(T) = \frac{2hc^2}{\lambda^5} \frac{1}{e^\frac{hc}{\lambda k_B T} -1}\]
\(B\) is the spectral radiance, defined as the power emitted per unit area within a unit solid angle normal to the area, per unit of wavelength. The letter B is commonly used instead of the letter I with generically designates intensities, to emphasize that we are specifically referring to a "blackbody". Its units, assuming that we measure the wavelengths in namometers, will be: \(W m ^ {⁻2} nm ^ {-1} sr ^ {⁻1} \), \(sr\) being the unit of solid angle "steradian".
The formula above uses the following constants:
  • \(k_B\) is the Boltzmann constant
  • \(h\) is the Plank constant
which, in the Python package quantities are defined as:
In [2]:
print repr(pq.constants.Planck_constant)
print repr(pq.constants.Boltzmann_constant)
UnitConstant('Planck_constant', 6.62606896e-34 * s*J, 'h')
UnitConstant('Boltzmann_constant', 1.3806504e-23 * J/K, 'k')

Let's define a function that will calculate the spectral radiance according to the previous Plank law:
In [3]:
def B(wl,T):
    '''wl is an array of wavelengths with units of length
    T is a temperature in Kelvin
    the result is an array of s.r. with units W/(m**2 * nm * sr)
    '''
    I = 2 * pq.constants.h * (pq.c)**2 / wl**5 *  \
        1 / (np.exp((pq.constants.h*pq.c \
        / (wl*pq.constants.k*T)).simplified)-1)
    return I.rescale(pq.watt/(pq.m**2 * pq.nm *pq.sr))
We will check the correct operation of the function with an example:
In [4]:
B( 5000 *pq.angstrom, 5780 *pq.K)
Out[4]:
array(26421.629609697076) * W/(m**2*nm*sr)
We will then use this function to plot the blackbody radiation curves for four temperatures:
In [5]:
T1 = 4000 * pq.Kelvin
T2 = 5000 * pq.Kelvin
T3 = 6000 * pq.Kelvin
T4 = 7000 * pq.Kelvin
We will draw the curves with the Python Matplotlib plot() function
In [6]:
wl = np.arange(10,2000,10) * pq.nm
fig, ax = plt.subplots(figsize=(12, 8))
ax.plot(wl, B(wl,T4), label='7000K')
ax.plot(wl, B(wl,T3), label='6000K')
ax.plot(wl, B(wl,T2), label='5000K')
ax.plot(wl, B(wl,T1), label='4000K')
ax.legend()
ax.set_title('Blackbody radiation')
ax.title.set_fontsize(20)
ax.set_xlabel('wavelength in nm')
ax.xaxis.label.set_fontsize(15)
ax.set_ylabel('spectral radiance $(W m^{-2}nm^{-1}sr^{-1})$')
ax.yaxis.label.set_fontsize(15)
ax.axvspan(0,400,facecolor = 'violet',alpha = 0.6)
ax.axvspan(400,700, facecolor='yellow', alpha = 0.5)
ax.axvspan(700,2000, facecolor ='red', alpha = 0.3)
ax.text(150,6e4, 'UV', fontsize=30, color = 'b')
ax.text(1200,6e4, 'IR', fontsize=30, color = 'r')
ax.text(420,6e4, 'VISIBLE', fontsize=20, color = 'green');
The previous figure shows crearly that, as the blackbody temperature rises, the maximum of the emitted intensity will correspond to wavelengths increasingly shorter, i.e., higher frequencies, most energetic photons, entering this maximum, starting from 7000K, in the ultraviolet region. This fact is expressed mathematically by the Wien law.

Wien law

The maximum wavelength \(\lambda_{max} \) which emits a black body is given by:
\[ \lambda_{max} = \frac{b}{T} \]
Being \(b\) the Wien constant, whose value is given by:
In [7]:
print repr(pq.constants.b)
UnitConstant('Wien_wavelength_displacement_law_constant', 0.0028977685 * m*K, 'b')

Here are some examples:
The star Betelgeuse, in the constellation of Orion, has a surface temperature of 3600K. If we consider it in a first approximation as a blackbody, at what wavelength present its spectrum a maximum of radiation?
In [8]:
l_max = pq.constants.b/(3600 * pq.K)
print '%d Angstrom' %l_max.rescale(pq.angstrom)
8049 Angstrom

I.e., the radiation of Betelgeuse will reach its peak in the infrared region
The Wien law can also be used to estimate the temperature of a star from its spectrum (always with the approach of assuming a model of black body radiation):
In [9]:
# Suppose that the radiation from a star has its maximum intensity at 400 nm

lmax  = 400 * pq.nm

T = pq.constants.b / lmax

print "Its effective temperature will be: %d K" %T.simplified
Its effective temperature will be: 7244 K

Stefan–Boltzmann law

The Stefan-Boltzmann law is another important consequence of the Plank's radiation law. It indicates that the value of the total energy radiated per unit area and unit of time in all wavelengths, is proportional to the fourth power of the temperature.
The total energy radiated by a blackbody per unit area and unit time in all wavelengths is known as emissive power, and it is given by:
\[ E = \sigma T^4 \]
E is measured in \(W/m^2\)
\(\sigma\) is called the Stefan-Boltzmann constant, and its value is:
In [10]:
print pq.constants.sigma, '=', pq.constants.sigma.simplified
1 sigma (Stefan_Boltzmann_constant) = 5.6704e-08 kg/(s**3*K**4)

A related concept is that of the intrinsic brightness of a star, L, defined as the total energy radiated by the star in a unit of time. If the radius of the star is R and its surface temperature is T, it will be given by:
\[L = 4 \pi R^2 E = 4 \pi R^2 \sigma T^4 \]
The above formula could be in principle used to calculate the temperature of the star once known its brightness. However stars are not perfect blackbodies, although some approach more than others. For this reason it is used the concept of effective temperature, which is the temperature that would have a blackbody whose brightness was the same as the star. This effective temperature can be considered an approximation of the actual temperature of the surface of the star. Here is an example:
The brightness of the Sun is: \(3.839 \times 10 ^ {26} W\). What will be its effective temperature?
In [11]:
# We will need the value of the radius of the Sun:
sun_radius = 695000000.0 * pq.m

l_sun = 3.839e26 * pq.watt

temp_sun = (l_sun/(4 * np.pi * sun_radius**2 * pq.constants.sigma))**(1./4)
print temp_sun.simplified
5779.04712292 K

Well, we wll stop now at this point to make the entry not too long. In my next post I will apply the above to study the radiation spectrum of the cosmic microwave background (CMB) with the help of the Python language.

1 comentario: