in a general sense, the second law says that temperature differences between systems in contact with each other tend to even out and that work can be obtained from these non-equilibrium differences, but that loss of thermal energy occurs, when work is done and entropy increases. pressure, density and temperature differences in an isolated system, all tend to equalize if given the opportunity; density and pressure, but not temperature, are affected by gravity. a heat engine is a mechanical device that provides useful work from the difference in temperature of two bodies.