Numerical Methods

Comparing Plank's, Rayleigh-Jean's and Wien's Law of radiation

Comparing Plank's, Rayleigh-Jean's and Wien's Law of radiation
Plotting Plank's, Rayleigh-Jean's and Wien's Law of radiation
Program in Scilab
=========================================================================================
Program to Plot and compare Plank's Law, Rayleigh-Jeans' law and Wien's law of radiation. 
LANGUAGE :: Scilab 
Program By:: G.R. Mohanty , www.numericalmethods.in
=========================================================================================

c = 3e8                     // speed of light
k = 1.38e-23                //Boltzmann constant
T = 8000                     //Temperature in Kelvin
h = 6.625e-34               //Plank's constant
lambda = [10e-9:5e-9:2e-6] //Wavelength of the radiation

for i=1:1:length(lambda)
    u(i) = (8*%pi*h*c)/((lambda(i)^5)*(exp(h*c/(lambda(i)*k*T))-1)) //Plank's formula
    w(i) = (8*%pi*h*c)/((lambda(i)^5)*(exp(h*c/(lambda(i)*k*T))))   //Wien's formula
    rj(i) = (8*%pi*k*T)/(lambda(i)^4)                               //Rayleigh-Jeans' formula
end
    
plot(lambda,w,'g')
plot(lambda,u,'b')
plot(lambda,rj,'r')
a = gca()
a.data_bounds = [0,0;2e-6,7e6]
title ("T = 8000 K",'font_size',4,'font_style',3)
xlabel ('$\lambda(m)$','font_size',4)
ylabel ('$u(\lambda)$','font_size',4)
h1=legend('Wien','Plank','Rayleigh-Jeans')


Comparing Plank's, Rayleigh-Jean's and Wien's Law of radiation
Plotting Plank's, Rayleigh-Jean's and Wien's Law of radiation
Program in Fortran 95
=========================================================================================
Program to Plot and compare Plank's Law, Rayleigh-Jeans' law and Wien's law of radiation.  
LANGUAGE :: FORTRAN 95 
Compiler :: GNU Fortran
Program By:: G.R. Mohanty , www.numericalmethods.in
=========================================================================================
PROGRAM PlankRayleighWein
    IMPLICIT NONE
    REAL :: c, k, T, h, dL, u, w, rj, lambda
    REAL, PARAMETER :: PI = 3.141592
    c = 3e8             ! speed of light
    k = 1.38e-23        ! Boltzmann constant
    h = 6.625e-34       ! Plank's constant
    dL = 5e-9           ! Change in wavelength
    lambda = 10e-9      ! initial wavelength
    T = 8000            ! Temperature in Kelvin

    OPEN (UNIT=12,FILE='c:\\users\\user\\desktop\\plankrw.txt',STATUS='replace',ACTION='write')

    DO
        IF(lambda > 2e-6) EXIT
        u = (8*PI*h*c)/((lambda**5)*(exp(h*c/(lambda*k*T))-1))       ! Plank's formula
        w = (8*PI*h*c)/((lambda**5)*(exp(h*c/(lambda*k*T))))         ! Wien's formula
        rj= (8*PI*k*T)/(lambda**4)                                   ! Rayleigh-Jeans' formula
        WRITE(12,*) lambda,w,u,rj ! Write data to file
        lambda = lambda + dL
    END DO

    CLOSE (UNIT=12)
END PROGRAM

---------------------OUTPUT-----------------------------------------
Click/tap here to view the file "plankrw.txt".

This file was plotted using the following GNUPLOT commands:

set termoption dash
set yrange [0:7000000]
set title "T = 8000 K" font "Cambria,16"
set xlabel "Wavelength (m)" font "Cambria,15"
set ylabel "u (J/m^3 m)" font "Cambria,15" offset -2,0
set tics font "Cambria,11"
plot "plankrw.txt" u 1:2 w l lt 2 lw 2 lc "green" title "Wien",\
"" u 1:3 w l lt 1 lw 2 lc "blue" title "Plank",\
"" u 1:4 w l lt 3 lw 2 lc "red" title "Rayleigh-Jeans"