What is the actual energy content of the Sun?

So a while ago I did a little project where I grabbed a "standard solar model" from this paper, which gives me some information that's useful for actually making an estimate. (Unsurprisingly the link given to download the data has changed in the last ten years; I haven't sleuthed to see whether the data is still publicly available.)

  1. Only about 1.5% of the sun's mass is anything other than hydrogen and helium-4. This is true all the way out from the core to the surface. We'll assume that the sun contains only hydrogen and helium-4.

  2. All but the outermost 0.2% of the sun's mass (out to 90% of the sun's radius) is at a temperature $kT>54\,\mathrm{eV}$, which is the energy needed to turn $\mathrm{He^+}$ into $\mathrm{He^{2+}}$. (This energy is four times the Rydberg energy.) So somewhere above 99% of the sun's mass is completely ionized.

  3. The core temperature $kT\approx 1300\,\mathrm{eV}$ is much less than the electron mass, so the matter in the core is not relativistic.

  4. I'm going to assume that the electrons aren't degenerate; this tool (via this question) makes me think that's a pretty safe assumption for matter at the core with density $\rho \approx 150\,\mathrm{g/cm^3}$ and temperature $T \approx 10^7\,\mathrm K$.

In that case we can treat the core of the sun as a mixture of three non-interacting ideal gases, $\mathrm H^+$, $\mathrm{He}^{2+}$, and $\mathrm e^-$. As George Herold says, each ideal gas particle has mean kinetic energy $\frac32 kT$, so we'll want the number densities. The number density for hydrogen $n_\mathrm{H}$ is $$ n_\mathrm{H} = \rho f_\mathrm{H}/{\mu_\mathrm{H} } $$ where $\rho$ is the mass density, $f_\mathrm{H}$ is the hydrogen mass fraction, and $\mu_\mathrm{H} = 1\,\mathrm{gram/mole}$ is the atomic mass of hydrogen. You have a similar expression for helium (with $\mu_\mathrm{He} = 4\,\mathrm{gram/mole}$). The electron number density, thanks to complete ionization, is just $$ n_\mathrm{e} = n_\mathrm{H} + 2n_\mathrm{He}. $$ Here's a figure showing temperature, mass density, and composition from my source above and number density as computed here:enter image description here

Note that the horizontal scale (radius) is mass-weighted: you find about half the mass of the sun between 0.1 and 0.3 solar radii, so that interval takes up about half the horizontal axis. This is purely a visualization technique, so that your eye isn't distracted by the (relatively) cool, diffuse outer layers of the sun.

To find the total thermal energy density, we have to integrate. We find the thermal energy density $$ \epsilon = (n_\mathrm{H} + n_\mathrm{He} + n_\mathrm{e})\frac32 kT $$ and the volume of a thin shell at radius $r$ is $$ dV = 4\pi r^2 dr $$ This integral $\int\epsilon\, dV$ gives me a total stored kinetic energy $E=3.09\times10^{41}\,\mathrm{J}$, of which about 95% is contained within half the sun's radius.

Now, if the sun had uniform density you could estimate its gravitational potential energy, the energy that was released when all the pieces fell together, as $$ U_\text{uniform sphere} = -\frac35 \frac{GM_\text{sphere}^2}{R_\text{sphere}} = - 2.3\times10^{41}\,\mathrm J \text{ (uniformly dense sun)}. $$ That's pretty close to our stored heat! We can do a little bit better since we actually know the density profile of the sun, by finding the potential energy released as you lay down each spherical shell, $$ U = - \int_0^{M_\text{sun}} \frac{G M_\text{enclosed}(r)}{r} dM = -6.15\times10^{41}\,\mathrm{J}. $$ This gravitational self-energy is roughly twice the stored kinetic energy --- which a real astronomer would have predicted as a consequence of the virial theorem.


Fun, So you are asking about the thermal energy content of the sun?

If we assume that all the hydrogen is dissociated. (single atoms) Then each atom has three degrees of freedom and carriers 3/2 kT of energy.
So count up the number of atoms at each temperature.... That will work until the atoms ionize. Then there will be equal energy in all the electrons. (one from the H and two from He) (I'll leave all the messy details to you :^)