Thermal energy is the energy contained within a system that is responsible for its temperature. It refers to the kinetic energy of vibrating and colliding atoms in a substance. When the particles in a substance are moving quickly, the object or system has more thermal energy. Thermal energy can be produced by adding heat to a substance, which makes its particles move faster and bump into each other. The hotter the substance, the more its particles move, and the higher its thermal energy.
In the context of mechanics problems, thermal energy plays a role in ensuring conservation of energy. Almost every transfer of energy that takes place in real-world physical systems does so with efficiency less than 100% and results in some thermal energy. This energy is usually in the form of low-level thermal energy, which represents the end of the road of energy transfer. No further useful work is possible, and it is only possible to extract work when there is a temperature difference.
Thermal energy is also a form of potential energy, and the sensible heat as well as the energy carried by a heat flow can be referred to as thermal energy.