snippet.stefan_boltzmannΒΆ

Stefan-Boltzmann relation

For black body, the integral of radiation spectrum will follow the stefan boltzmann relation. This should be confirmed.

''' Stefan-Boltzmann relation

For black body, the integral of radiation spectrum will follow
the stefan boltzmann relation.
This should be confirmed.
'''
import numpy as np
import scipy
import matplotlib.pyplot as plt

import irfpy.util.constant as k
import irfpy.util.planck as pl

def main():
    '''Main script'''

    temperature = 5800.
    bb = pl.BlackBodyMksa(temperature)   # A black body.

    wavelens = np.linspace(200, 4000, 3801) * 1e-9  # in m
    dwl = wavelens[1] - wavelens[0]  # in m

    spectral_radiance = bb.Blambda(wavelens) # in W/m2 m sr
    plt.plot(wavelens / 1e-9, spectral_radiance * 1e-9)
    plt.title('Black Body T=%g' % temperature)
    plt.xlabel('Wavelength, nm')
    plt.ylabel('Spectral radiance, W/m2 nm sr')

    ### Numerical integral in energy direction
    integral_radiance = (spectral_radiance * dwl).sum()
    ### In solid angle direction
    integral_radiance = np.pi * integral_radiance
    print('Integral Raidance (numerical) = %e W/m2' % integral_radiance)

    ### From Stefan-Boltzmann
    integral_radiance2 = k.stefan_boltzmann_constant * temperature ** 4
    print('Integral Raidance (formula)   = %e W/m2' % integral_radiance2)
    

if __name__ == "__main__":
    main()