A heat engine is a system that converts heat or thermal energy into mechanical energy. It does this by bringing a working substance from a higher temperature state to a lower temperature state. There are four main heat engine cycles: the Carnot cycle, Rankine cycle, Otto cycle, and Diesel cycle. The Carnot cycle involves reversible, isothermal expansion and compression processes. The Rankine cycle models steam engines and involves reversible expansion of steam in a turbine and condensation of steam in a condenser. The Otto and Diesel cycles involve compression, constant volume heat addition, and expansion processes to model gasoline and diesel engines.