0% found this document useful (0 votes)
50 views3 pages

Physics Assignment by Programming

The document presents a Python script for calculating and plotting Planck's law in both wavelength and frequency forms. It defines constants such as Planck's constant and the speed of light, and includes functions to compute spectral radiance based on temperature. The script generates plots for specified temperature values, illustrating the relationship between spectral radiance, wavelength, and frequency.

Uploaded by

anaysixtysix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views3 pages

Physics Assignment by Programming

The document presents a Python script for calculating and plotting Planck's law in both wavelength and frequency forms. It defines constants such as Planck's constant and the speed of light, and includes functions to compute spectral radiance based on temperature. The script generates plots for specified temperature values, illustrating the relationship between spectral radiance, wavelength, and frequency.

Uploaded by

anaysixtysix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Physics Assignment by programming

# Constants

h = 6.62607015e-34 # Planck's constant (J·s)

c = 299792458 # Speed of light (m/s)

k = 1.380649e-23 # Boltzmann constant (J/K)

def planck_wavelength(lambd, T):

"""Planck's law in wavelength form"""

term1 = (2*h*c*2) / (lambd*5)

term2 = np.exp((h*c)/(lambd*k*T)) - 1

return term1 / term2

def planck_frequency(nu, T):

"""Planck's law in frequency form"""

term1 = (2*h*nu*3) / (c*2)

term2 = np.exp((h*nu)/(k*T)) - 1

return term1 / term2

# Wavelength range (in meters)

lambda_min = 1e-9 # 1 nm

lambda_max = 3e-6 # 3000 nm

wavelengths = np.linspace(lambda_min, lambda_max, 1000)

# Frequency range (in Hz)

nu_min = 1e12 # 1 THz

nu_max = 1e15 # 1000 THz

frequencies = np.linspace(nu_min, nu_max, 1000)


# Temperatures to plot (in Kelvin)

temperatures = [3000, 4000, 5000, 6000] # Example temperatures (like the Sun's surface)

# Plotting wavelength form

plt.figure(figsize=(12, 6))

plt.subplot(1, 2, 1)

for T in temperatures:

spectral_radiance = planck_wavelength(wavelengths, T)

plt.plot(wavelengths*1e9, spectral_radiance, label=f'T = {T} K')

plt.title("Planck's Law - Wavelength Form")

plt.xlabel('Wavelength (nm)')

plt.ylabel('Spectral Radiance (W·sr⁻¹·m⁻³)')

plt.legend()

plt.grid(True)

# Plotting frequency form

plt.subplot(1, 2, 2)

for T in temperatures:

spectral_radiance = planck_frequency(frequencies, T)

plt.plot(frequencies/1e12, spectral_radiance, label=f'T = {T} K')

plt.title("Planck's Law - Frequency Form")

plt.xlabel('Frequency (THz)')

plt.ylabel('Spectral Radiance (W·sr⁻¹·m⁻²·Hz⁻¹)')

plt.legend()

plt.grid(True)

plt.show()

You might also like