during which change of state does the thermal energy of a substance increase