Solution (source code)

= Solution

For a monatomic <ideal gas>, write the thermal <energy> <density> as $u=3nk_BT/2$. At low <optical depth>, radiative loss uses an <astrophysical cooling function>, often written $\mathcal C=n_en_H\Lambda(T,Z)$, while $\mathcal H$ contains heating. At fixed <density> the net <radiative gas cooling time> is approximately $u/(\mathcal C-\mathcal H)$ when the denominator is positive; a cooling flow closer to constant <pressure> must include <enthalpy> and compressional work. Comparing this time with the <free-fall time of a uniform sphere> determines whether <pressure> can be lost during gravitational contraction.

Hot ionized gas cools by <bremsstrahlung> and <recombination>; <collisional excitation> followed by <photon> escape supplies atomic and metal-line cooling at lower <temperatures>. <molecular line cooling> through rotational or vibrational lines and <dust thermal emission> become important in cold dense gas. Abundances, <ionization> state, density-dependent collisional de-excitation, and <photon> trapping all change the cooling function. Optically thick gas requires <radiative transfer>, not a simple local density-squared loss law.

Heating comes from <photoionization>, <grain photoelectric heating> driven by ultraviolet light, <cosmic rays>, <shocks>, turbulent dissipation and compression. <photoionization heating> deposits the <photon> <energy> above the <ionization> threshold as electron <kinetic energy>. A <thermal equilibrium> satisfies $\mathcal H=\mathcal C$; its stability depends on how the net loss changes under the relevant <pressure> or <density> constraint, not merely on equality. Different stable balances permit a multiphase <interstellar medium>. Spectral-line ratios constrain <temperature> and <ionization>, but interpreting them requires <density> diagnostics, <interstellar extinction> corrections and a radiation-field model.