Solution (source code)

= Solution

Assume an isolated, bound, nonrotating Newtonian gas cloud, negligible surface <pressure>, negligible magnetic and radiation stresses, no persistent bulk flow, and a stationary or time-averaged virialized state. The <stellar virial theorem> then reduces to
$$
3\int P(\mathbf x)\,dV+\Omega=0,
$$
where $\Omega<0$ is the total <gravitational potential energy>. Define the volume-averaged <pressure> $\overline P=V^{-1}\int P\,dV$ and average gravitational <energy density> $u_g=\Omega/V$. Hence
$$
\boxed{\overline P=-u_g/3.}
$$
Equivalently, for a nonrelativistic <monatomic gas>, the thermal <internal energy> $U=(3/2)\int P\,dV$ obeys $2U+\Omega=0$. This second derivation must not count the thermal motions again as a separate bulk <kinetic energy>. If the external <pressure> is $P_s$, the correct result is $\overline P-P_s=-u_g/3$; non-negligible bulk motion adds $2T_{\rm bulk}$ to the <virial theorem>. The initial sharp-edged $r^{-2}$ profile need not survive virialization; maintaining that profile hydrostatically to its edge would generally require a surface term.