Thermodynamics is the science of heat and energy and their relation.
It grew out of the study of gases and out of the engineering of
steam engines, which generate heat by burning something, then
transform that heat's energy into useful mechanical energy. The
science treats heat and energy as equivalent, distinguishing between
usable heat/energy versus relatively-evenly-distributed heat/energy
that cannot be transformed into mechanical energy in isolation, and
includes physical laws (laws of thermodynamics)
regarding the limits of transformations of such
heat/energy. The principles have been extended to chemical energy,
e.g., heat released or absorbed by chemical reactions.
Statistical mechanics models the underlying mechanism.