If the temperature of a body changes then it must have gained or lost energy. If fact the temperature of a body is a measure of the random kinetic energy, also called thermal energy of the molecules or atoms that make up the body. The molecules of a material may move in a variety of ways. They may rotate, move in space (translational), move as a whole or independently of one another, or vibrate about a fixed point. The heat energy of a material is only a measure of the random motion of a molecule in all its different forms – rotational, translational and vibrational. The body may be moving as a whole in space but this does not contribute to the heat energy of the body this this motion is not random motion of the molecules of the body but of the body as a whole.
The average kinetic energy of the molecules of any substance is independent of the material, of the molecular mass of the material, its density, shape... For a gas mad up of atoms the average kinetic energy of the atoms is given by the simple expressionThe expression gets more complicated as the complexity of the material increases but remains independent of those things mentioned.
In fact the temperature is not the only measure of the amount of energy in a material. There also exists potential energy between the atoms and molecules that make up the material. The atoms and molecules attract each other on average. Energy is required to prise the atoms apart from each other. Atoms and molecules in the solid state have the least energy. As the solid is heated, the average kinetic energy increases. There comes a point however when the average kinetic energy becomes big enough so that the structure of the solid material breaks down. Molecules and atoms become free to move and the solid melts. The melting of a material is not a single event – many bonds between molecules must be broken for a material to melt and each broken bond demands an energy input.
When the material is melted and becomes a liquid, though there are not fixed bonds between the atoms of the liquid, there still exist attractive forces between atoms and molecules that make up the liquid. These have the effect of keeping the atoms and molecules almost as close together as the atoms and molecules of the solid.
Heating the liquid increases the average kinetic energy of the liquid molecules. Heating the liquid sufficiently gives the molecules enough energy to overcome the attractive forces between them and the other liquid molecules. The material becomes a gas. The forces between the molecules of a gas are very weak, and the gas molecules are much further apart than for a liquid or solid – maybe ten times further.