Plotting Plank's Law
All bodies emit thermal rdiation at all temperatures. In the year 1900 Max Plank gave an expression to explain the energy distribution in the spectrum of Blackbody radiation. His formula for spectral energy density of radiation inside a blackbody cavity is given by:
`u(nu,T)dnu=(8pihnu^3)/c^3 1/(exp((hnu)/(kT))-1)dnu`.
Where, `k` is the Boltzmann constant, `c` is the speed of light in vacuum,`h` is the Plank's constant. Using `lambda=c/nu` we can write Plank's radiation law as:
`u(lambda,T)dlambda=(8 pi hc)/lambda^5 1/(exp((hc)/(lambdakT))-1)dlambda`.
Here,`u(lambda,T)` is the spectral energy density function with the units of energy per unit wavelength per unit volume. Our aim is to plot this function at different temperaturs. We shall do so by writing a fortran program to generate the values of `u(lambda,T)` at different λ and at different temperaturs. Then we shall plot the data so generated using gnuplot. Subsequently, we shall also plot it using scilab.
Program in Fortran 95
===================================================================================
Program to Plot Plank's Law of Blackbody radiation at different temperatures.
LANGUAGE :: FORTRAN 95
Compiler :: GNU Fortran
Program By:: G.R. Mohanty , www.numericalmethods.in
===================================================================================
PROGRAM PlankPlot
IMPLICIT NONE
INTEGER :: i
REAL :: c, k, T, h, dL, lambda
REAL, PARAMETER :: PI = 3.141592
REAL, DIMENSION (6) :: u
c = 3e8 ! speed of light
k = 1.38e-23 ! Boltzmann constant
h = 6.625e-34 ! Plank's constant
dL = 10e-8 ! Change in wavelength
lambda = 10e-9 ! initial wavelength
T = 200 ! Temperature in Kelvin
OPEN (UNIT=12,FILE='c:\\users\\user\\desktop\\plank.txt',STATUS='replace',ACTION='write')
DO
IF(lambda > 4e-5) EXIT
DO i = 1, 6 ,1
T = 200 + 50*i ! Temperature varies from 250 K to 500 K
! Calculate spectral radiance
u(i) = (8*PI*h*c)/((lambda**5)*(exp(h*c/(lambda*k*T))-1))
END DO
WRITE(12,*) lambda,(u(i),i=1,6) ! Write data to file
lambda = lambda + dL
END DO
CLOSE (UNIT=12)
END PROGRAM
---------------------OUTPUT-----------------------------------------
Click/tap here to view the file "plank.txt".
This file was plotted using the following GNUPLOT commands:
set title "Plank's radiation Law plotted at different temperatures" font "Cambria,12"
set ylabel "u (J/m^3 m)" font "Cambria,12"
set xlabel "Wavelength (m)" font "Cambria,12"
plot "plank.txt" u 1:2 w l lc "red" lw 3 title " 250 K",\
"" u 1:3 w l lc "orange" lw 3 title " 300 K",\
"" u 1:4 w l lc "yellow" lw 3 title " 350 K",\
"" u 1:5 w l lc "green" lw 3 title " 400 K",\
"" u 1:6 w l lc "blue" lw 3 title " 450 K",\
"" u 1:7 w l lc "purple" lw 3 title " 500 K"
Program in Scilab
===================================================================================
Program to Plot Plank's Law of Blackbody radiation at different temperatures.
LANGUAGE :: Scilab
Program By:: G.R. Mohanty , www.numericalmethods.in
===================================================================================
c = 3e8 // speed of light
k = 1.38e-23 //Boltzmann constant
T = 200 //Temperature in Kelvin
h = 6.625e-34 //Plank's constant
lambda = [10e-9:10e-8:4e-5] //Wavelength of the radiation
for j=1:1:6
T=200+50*j //Temperature varies between 250 K and 500 K
for i=1:1:length(lambda)
u(i,j) = (8*%pi*h*c)/((lambda(i)^5)*(exp(h*c/(lambda(i)*k*T))-1))
end
end
plot(lambda,u)
a = gca()
a.data_bounds = [1.000D-08,0;0.00004,6]
title ("Plank''s radiation Law plotted at different temperatures",'font_size',4,'font_style',3)
xlabel ('$Wavelength(\lambda)$','font_size',4)
ylabel ('$u(\lambda)$','font_size',4)
h1=legend('T = 250 K','T = 300 K','T = 350 K','T = 400 K','T = 450 K','T = 500 K')