How does gravity increase (or, at least, not-decrease) entropy?

I'm a total physics n00b (i.e. I only know the physics as taught in IT grades, and don't remember much of it), and was talking about entropy (initially, not with the physical implications). My friend talked about entropy and gravity and was not sure about the fact that entropy decreases with gravitationally bound systems.

I found this site telling that gravity actually increases the entropy, but "apparently proving" that gravity decreases it. Finally, in the final link where he will show the prove that gravitational systems do not decrease entropy, it shows this text:

So, you're wondering why gravity doesn't violate the 2nd law of thermodynamics, even though the entropy of a gas cloud decreases as it shrinks under its own gravitational pull? The answer is simple, but I'll just give you a hint. We've already seen that as it shrinks, it loses energy. The energy has to go somewhere. Where does it go? If you figure that out, you'll see that the total entropy is not actually decreasing - it's just leaving the gas cloud and going somehere else!

My question is: No, actually I cannot figure if out. Can someone help me to figure it out? (yes, perhaps it's a very simple answer but no, still don't get it).

Consider what happens to the total energy of the gas as it shrinks. By the virial theorem $K=-P/2, w$e can write the total energy $E$ of the gas cloud as $E=K+P=-P/2+P=P/2$. Additionally, according to equation (2) from the webpage, $P\sim -N^2/V^{1/3}$, so $E\sim -N^2/V^{1/3}$. Thus, as volume the volume decreases, the total energy becomes more and more negative, i.e., decreases.

Now, by conservation of energy, this energy must be going somewhere. One possibility is that you have gas particles escaping the cloud at high velocities kind of like they're "boiling" away, carrying energy and entropy away with them (this leads to some complications in the original derivation on the webpage since this would violate the assumptions required for the virial theorem to hold exactly, but you can see how it would work). Another way this can happen without gas particles actually escaping the system would be if the gas cloud somehow emitted radiation - the resulting radiation would also carry away energy and entropy.

In either case, the resulting flux of escaped gas particles and radiation in the space outside the cloud of gas will lead to some energy and entropy densities outside the volume of the gas cloud. For the second law of thermodynamics to hold, the total entropy of the cloud of gas and the rest of space must increase, i.e., the entropy contained in the escaped gas particles and radiation must exceed the decrease in entropy of the cloud of gas. A more thorough analysis of the entropy contained in the escaped gas particles and radiation will show that this is indeed the case, and thus the "object" whose entropy is increasing to compensate for the decrease in entropy of the cloud of gas is the rest of space.

Note that this is a highly simplified and not precisely correct argument, but as pointed out by Jàn in his answer, neither is Baez's original exposition on the webpage. I still think this captures the basic idea, and is probably what Baez was getting at.

• The equation (2) was derived based on the idea the system is a ball with uniform mass density. However, this is very unlikely configuration for gravitational system in virial equilibrium. Typically, such systems have centers of accumulation (see photos of globular clusters, galaxies). The argument is misconceived right from the start. – Ján Lalinský May 14 '15 at 20:49

The Baez article is strongly misleading in that it applies simplified concepts and arguments appropriate for gases with short-range interactions to a system with many particles interacting purely gravitationally.

Systems where short-range forces dominate (Lenard-Jones, van der Waals forces... ) such as rarified gases can be described in such simplified (thermodynamic) way where the system has volume, density and temperature.

Gravitationally bound systems in virial equilibrium typically have cluster(s) of accumulation with higher density of particles and as one gets farther from it(them), density of particles decreases (globular cluster, galaxy). As time goes, the system, even if in virial equilibirum, loses particles.

Thus gravitationally bound system has neither volume nor density. It cannot be in equilibrium, far less in thermodynamic equilibrium. It has no thermodynamic temperature.

2nd law of thermodynamics has implications for Clausius entropy. This entropy is defined via heat and temperature which have no convincing meaning for said gravitational systems. Thus "gravitational systems increase/decrease their entropy" is not even a meaningful statement, because it is not clear what the word entropy means.

2nd law is based on experience with water vapor, air, daily tangible materials. It is ungrounded to extrapolate it to systems like Solar system, globular cluster of stars or galaxy where no experiments with heat were ever made.