Thermal Energy and States of Matter