In thermodynamics and engineering, a heat engine is a system that converts heat or thermal energy to mechanical energy, which can then be used to do mechanical work.