Unlike ideal gases, the temperature of a real gas will change during a Joule expansion. At temperatures below their inversion temperature gases will cool during Joule expansion, while at higher temperatures they will heat up. The inversion temperature of a gas is typically much higher than room temperature; exceptions are helium, with an inversion temperature of about 40 K, and hydrogen, with an inversion temperature of about 200 K. Since the internal energy of the gas during Joule expansion is constant, cooling must be due to the conversion of internal kinetic energy to internal potential energy, with the opposite being the case for warming.
Intermolecular forces are repulsive at short range and attractive at long range (for example, see the Lennard-Jones potential). Since distances between gas molecules are large compared to molecular diameters, the energy of a gas is usually influenced mainly by the attractive part of the potential. As a result, expanding a gas usually increases the potential energy associated with intermolecular forces. Some textbooks say that for gases this must always be the case and that a Joule expansion must always produce cooling. When molecules are close together, however, repulsive interactions are much more important and it is thus possible to get an increase in temperature during a Joule expansion.
It is theoretically predicted that, at sufficiently high temperature, all gases will warm during a Joule expansion The reason is that at any moment, a very small number of molecules will be undergoing collisions; for those few molecules, repulsive forces will dominate and the potential energy will be positive. As the temperature rises, both the frequency of collisions and the energy involved in the collisions increase, so the positive potential energy associated with collisions increases strongly. If the temperature is high enough, that can make the total potential energy positive, in spite of the much larger number of molecules experiencing weak attractive interactions. When the potential energy is positive, a constant energy expansion reduces potential energy and increases kinetic energy, resulting in an increase in temperature. This behavior has only been observed for hydrogen and helium; which have very weak attractive interactions. For other gases this "Joule inversion temperature" appears to be extremely high.