A heat engine is a device (like the motor in a car) that produces macroscopic motion from heat. When people rub their hands together friction turns mechanical energy (the motion of our hands) into thermal energy (the hands get warmer). Heat engines do just the opposite; they take the energy from being warm (compared to the surroundings) and turn that into motion. Often this motion is turned into electricity with a generator.
Almost all of the energy that is harnessed for transportation and electricity comes from heat engines. Hot objects, even gases, have thermal energy that can be turned into something useful. Heat engines move energy from a hot place to a cold place and divert some of that energy into mechanical energy. Heat engines require a difference in temperature to function.
The study of thermodynamics was initially inspired by trying to get as much energy out of heat engines as possible. To this day, various fuels are used, like gasoline, coal, and uranium. All of these heat engines still operate under the limits imposed by the second law of thermodynamics. This means that various fuels are used to heat a gas and a large cold reservoir is needed in order to get rid of waste heat. Often, the waste heat goes into the atmosphere or a large body of water (the ocean, a lake, or a river).
Depending on the type of engine, different processes are employed, like igniting fuel through combustion (gasoline and coal), or using energy from nuclear processes to produce heat (uranium), but the end goal is the same: to turn the heat into work. The most familiar example of a heat engine is the engine of a car, but most power plants, like coal, natural gas, and nuclear, are also heat engines.
Internal combustion engines are the most common form of heat engines, as they are used in vehicles, boats, ships, airplanes, and trains. They are named as such because the fuel is ignited in order to do work inside the engine. The same fuel and air mixture is then emitted as exhaust. While this is most commonly done using a piston, it can also be done with a turbine.
Figure 1 is an example of an internal combustion engine. This particular type is called a four stroke engine, which is quite common in cars.
External heat engines are generally steam engines, and they differ from internal ones in that the heat source is separate from the gas that does work. These heat engines are usually called external combustion engines because combustion is occurring outside of the engine. For example, external combustion would be using a flame to heat water into steam, then using the steam to turn a turbine. This is different from internal combustion, like in a car engine, where the gasoline ignites inside a piston, does work, and then is expelled.
The efficiency of an engine is the percentage of energy input that the engine can convert to useful work. The equation for this is η = work output / energy input. The most efficient piston engines run at about 50% efficiency, and an average coal-fired power plant runs at around 33% efficiency. More recently built power plants are getting more than 40% efficiencies.
Smaller heat engines, like those in cars, have mechanical power outputs measured in terms of horsepower. Larger heat engines, like power plants, measure outputs in terms of MW. Of course the output can be measured in any units of power, such as watts.
The input of a heat engine is also a power, often measured in MW. With a power plant there is also an electric output power. In order to distinguish between the two powers, the thermal power (input power) is measured in megawatts thermal (MWt), while for electricity production the output power is measured in megawatts electric (MWe). For heat engines that provide motion instead of electricity, the output power would be mechanical power.
A heat engine has two byproducts: work and heat. The purpose of most engines is to produce work, and the heat is treated simply as waste. Cogeneration is using the waste heat for useful things. The heater in a car works using cogeneration - taking waste heat from the engine to heat air which warms up the cabin. This is why running a car's heater in winter has little effect on gas mileage, but running air conditioning in the summertime can cost an estimated 10-20% of a car's gas mileage.