LTE

Local Thermodynamic Equilibrium

class LTEpy.lte.Boltzmann_Factor(temp, atom)

Class for calculating Boltzmann Factor between two energy levels of a given atom.

temp

temperature in K

Type:

float

atom (

obj: LTEpy.atom.Atom):

Properties:

bfact (:obj: ‘np.array’): Boltzmann factors of each energy level pfunc (float): Partition function using all energy levels provided.

property bfact

Boltzmann factor

Calculate Boltzmann factor for each energy level.

Returns:

Boltzmann factor

Return type:

_bfact (np.array)

\[\beta(n, T) = \exp \bigg(\frac{-E_n}{k_B T}\bigg)\]
draw_bfact(ax, levmin=None, levmax=None, color=None)

Draw the Boltzmann factors

Plot the Boltzmann factors for each energy level at a fixed temperature, and return the line handle.

Parameters:
  • levmin (float or None) – Lowest level to plot.

  • levman (float or None) – Highest level to plot.

Returns:

obj:’matplotlib.Line2D.Line’: Line handle

property pfunc

Partition Function

Calculate the partition function, the sum of all the Boltzmann factors, using all levels belonging to the atom.

Parameters:

temp (float) – Temperature in Kelvin.

\[\sum_n \beta(n, T)\]
plot_bfact(levmin=None, levmax=None)

Plot the Boltzmann factor

Plot the Boltzmann factor for each energy level at a fixed temperature.

Parameters:
  • levmin (float or None) – Lowest level to plot.

  • levman (float or None) – Highest level to plot.

Returns:

Matplotlib figure :obj:’matplotlib.Line2D.Line’: Line handle

Return type:

matplotlib.pyplot.Figure

set_temp(temp)

Set temperature.

Change the temperature of this Boltzmann_Factor LTE object and reset _bfact.

Parameters:

temp (float) – Temperature in K.

class LTEpy.lte.Maxwell_Boltzmann(temp, mass)

Maxwell-Boltzmann Distribution.

Class for calculating the Maxwell-Boltzmann Distribution for a system in Local Thermodynamic Equilibrium, given a particle mass.

Parameters:
  • temp (float) – Temperature in K.

  • mass (float) – Particle mass in AMU.

compute_maxwell_boltzmann(speed)

Maxwell-Boltzmann speed distribution.

Compute the probabilty density of a particle with a given mass having a given speed.

\[f(v) = \bigg(\frac{m}{2 \pi k T}\bigg)^{3/2} 4 \pi v^2 e^{-m v^2 / 2 k T}\]
Parameters:

speed (float or np.array) – Speed in cm/s.

Returns:

Probability density s/cm

Return type:

float or np.array

plot_fv(speed_1, speed_2, N_speed=500, lw=1, ax=None, **ax_kwargs)

Plot the Maxwell-Boltzmann Distribution.

Plot the distributino of particle speeds defined by the Maxwell-Boltzmann Distribution between two speeds.

Parameters:
  • speed_1 (float) – First speed in cm/s.

  • speed_2 (float) – Second speed in cm/s.

  • N_speed (int, optional) – Number of speed points to plot. Defaults to 500.

  • lw (int, optional) – Plot line width. Defaults to 1.

  • ax (matplotlib.pyplot.Axes, optional) – Matplotlib axis for plotting. Defaults to None.

  • **ax_kwargs – Keyword arguments passed to matplotlib.pyplot.Axes object.

Returns:

Matplotlib axis

Return type:

matplotlib.pyplot.Axes

set_mass(mass)

Set mass.

Change the mass of this Maxwell-Boltzmann LTE object.

Parameters:

mass (float) – Mass in AMU.

set_temp(temp)

Set temperature.

Change the temperature of this Maxwell-Boltzmann LTE object.

Parameters:

temp (float) – Temperature in K.

class LTEpy.lte.Planck(temp)

Planck’s Law.

Class for calculating Planck’s Law for a blackbody in Local Thermodynamic Equilibrium (either in wavelength or frequency).

Parameters:

temp (float) – Temperature in K.

compute_B_lambda(wl)

Spectral radiance in wavelength space.

Calculate the spectral radiance (or specific intensity) \(B_\lambda\) for a given wavelength.

\[B_\lambda(T) = \frac{2 h c^2}{\lambda^5} \frac{1}{e^{h c / \lambda k T} - 1}\]
Parameters:

wl (float or np.array) – Wavelength in cm.

Returns:

Spectral radiance in erg/s/cm^2/sr/nm.

Return type:

float or np.array

compute_B_nu(nu)

Spectral radiance in frequency space.

Calculate the spectral radiance (or specific intensity) \(B_\nu\) for a given frequency in cgs units.

\[B_\nu(T) = \frac{2 h \nu^3}{c^2} \frac{1}{e^{h \nu / k T} - 1}\]
Parameters:

nu (float or np.array) – Frequency in Hz.

Returns:

Spectral radiance in erg/s/cm^2/sr/Hz.

Return type:

float or np.array

compute_lambda_max()

Wien’s Displacement Law.

Calculate the wavelength of maximum spectral radiance \(\lambda_{max}\) from Wien’s Law in cm.

\[\lambda_{max} = \frac{b}{T}\]
Returns:

Peak wavelength in cm.

Return type:

float

plot_B_lambda(wl_1, wl_2, N_wl=500, lw=1, log_scale=True, ax=None, **ax_kwargs)

Plot spectral radiance in wavelength space.

Plot the spectral radiance \(B_\lambda\) between two wavelengths.

Parameters:
  • wl_1 (float) – First wavelength in nm.

  • wl_2 (float) – Second wavelength in nm.

  • N_wl (int, optional) – Number of wavelength points to plot. Defaults to 500.

  • lw (int, optional) – Plot line width. Defaults to 1.

  • log_scale (bool, optional) – Option to plot with a log scale. Defaults to True.

  • ax (matplotlib.pyplot.Axes, optional) – Matplotlib axis for plotting. Defaults to None.

  • **ax_kwargs – Keyword arguments passed to matplotlib.pyplot.Axes object.

Returns:

Matplotlib axis

Return type:

matplotlib.pyplot.Axes

plot_B_nu(nu_1, nu_2, N_nu=500, lw=1, log_scale=True, ax=None, **ax_kwargs)

Plot spectral radiance in frequency space.

Plot the spectral radiance \(B_\nu\) between two frequencies.

Parameters:
  • nu_1 (float) – First frequency in Hz.

  • nu_2 (float) – Second frequency in Hz.

  • N_nu (int, optional) – Number of frequency points to plot. Defaults to 500.

  • lw (int, optional) – Plot line width. Defaults to 1.

  • log_scale (bool, optional) – Option to plot with a log scale. Defaults to True.

  • ax (matplotlib.pyplot.Axes, optional) – Matplotlib axis for plotting. Defaults to None.

  • **ax_kwargs – Keyword arguments passed to matplotlib.pyplot.Axes object.

Returns:

Matplotlib axis

Return type:

matplotlib.pyplot.Axes

plot_lambda_max(ax, **vline_kwargs)

Plot peak wavelength.

Plot a vertical line at the peak wavelength \(\lambda_{max}\) in nm according to Wien’s Law.

Parameters:
  • ax (matplotlib.pyplot.Axes) – Matplotlib axis for plotting.

  • **vline_kwargs – Keyword arguments passed to matplotlib.pyplot.axvline

set_temp(temp)

Set temperature.

Change the temperature of this Planck LTE object.

Parameters:

temp (float) – Temperature in K.