The engine idea
A heat engine is any device that turns heat into useful work by running a working substance around a cycle. Every one of them, from a steam turbine to a car engine, does the same three things: it draws heat Q_H from a hot reservoir, converts part of it into work W, and dumps the leftover heat Q_C into a cold reservoir. The reservoirs are just anything big enough to give or take heat without changing temperature — a furnace, the atmosphere, a river.
The first law applied to a full cycle (ΔU = 0): the useful work out is simply the heat taken in from the hot reservoir minus the heat dumped to the cold one.
Efficiency: how much do you get out?
The thermal efficiency \eta answers the engineer's only real question: of the expensive heat you paid for, what fraction came back as work? It is the efficiency you would quote on a spec sheet, always a number between 0 and 1.
Efficiency is work out divided by heat in. Equivalently it is one minus the fraction of heat that gets wasted to the cold reservoir.
Worked example. An engine absorbs 2000 J from its hot reservoir each cycle and exhausts 1500 J to the cold reservoir. Then the work out is W = 2000 - 1500 = 500\text{ J}, and the efficiency is
Only a quarter of the heat became work; the other three-quarters was dumped as waste heat. Typical car engines manage only about 25–35%.
The catch: the second law
Why not just build an engine with Q_C = 0 — one that turns all the heat into work and wastes nothing? Efficiency would be 100%. Every experiment ever tried says you cannot, and that impossibility is one face of the second law of thermodynamics. In the Kelvin–Planck wording: *no cyclic engine can take heat from a single reservoir and convert it entirely into work.* There must always be a colder place to dump waste heat.
Run it backwards: refrigerators and heat pumps
Trace the engine's cycle the other way and heat flows the 'wrong' direction — from cold to hot — but only if you pay for it with work. That is a refrigerator: work W goes in, heat Q_C is pulled out of the cold interior, and Q_H = Q_C + W is dumped into the warm room behind it. The Clausius wording of the second law captures why you must pay: *heat never flows spontaneously from a colder body to a hotter one.*
A heat pump is exactly the same machine judged by its other output: instead of the cold you extract, you value the heat Q_H it delivers to your warm house. We rate these by a coefficient of performance (COP) — the benefit divided by the work you paid — which is happily greater than 1, because you are moving heat, not making it.
A fridge's COP counts the heat removed per unit work; a heat pump's counts the heat delivered — and it is always exactly one more, since the work itself also ends up as heat in the warm side.