Thanks to the work of a 19th-century engineer named Sadi Carnot, you can apply the law of conservation of energy to measure the heat efficiency of an engine.
Given the amount of work a heat engine does and its efficiency, you can calculate how much heat goes in and how much comes out (along with a little help from the law of conservation of energy, which ties work, heat in, and heat out together). But why not create 100-percent efficient heat engines? Converting all the heat that goes into a heat engine into work would be nice, but the real world doesn’t work that way. Heat engines have some inevitable losses, such as through friction on the pistons in a steam engine.
Studying this problem, Carnot came to the conclusion that the best you can do, effectively, is to use an engine that has no such losses. If the engine experiences no losses, the system will return to the state it was in before the process took place. This is called a reversible process. For example, if a heat engine loses energy overcoming friction, it doesn’t have a reversible process, because it doesn’t end up in the same state when the process is complete. You have the most efficient heat engine when the engine operates reversibly.
Carnot’s principle says that no nonreversible engine can be as efficient as a reversible engine and that all reversible engines that work between the same two temperatures have the same efficiency. Here’s the kicker: A perfectly reversible engine doesn’t exist, so Carnot came up with an ideal one.
In the Carnot engine, the heat that comes from the heat source is supplied at a constant temperature Th. Meanwhile, the rejected heat goes into the heat sink, which is at a constant temperature Tc. Because the heat source and the heat sink are always at the same temperature, you can say that the ratio of the heat provided and rejected is the same as the ratio of those temperatures (expressed in kelvins):

And because the efficiency of a heat engine is

the efficiency of a Carnot engine is

This equation represents the maximum possible efficiency of a heat engine. You can’t do any better than that. And as the third law of thermodynamics states, you can’t reach absolute zero; therefore, Tc is never 0, so the efficiency is always 1 minus some number. You can never have a 100-percent efficient heat engine.
Applying the equation for maximum possible efficiency

is easy. For example, say that you come up with a terrific new invention: a Carnot engine that uses a balloon to connect the ground (27 degrees Celsius) as a heat source to the air at 33,000 feet (about –25 degrees Celsius), which you use as the heat sink. What’s the maximum efficiency you can get for your heat engine? After converting temperatures to kelvin, plugging in the numbers gives you

Your Carnot engine can be no more than 17.3 percent efficient — not too impressive. On the other hand, assume you can use the surface of the sun (about 5,800 kelvin) as the heat source and interstellar space (about 3.40 kelvin) as the heat sink (such is the stuff science-fiction stories are made of). You’d have quite a different story:

You get a theoretical efficiency for your Carnot engine — 99.9 percent.
Here’s another example. You’re in Hawaii, taking a well-deserved vacation with other hard-working physicists. The summer has been hot, and as you lounge on the beach, you read an article about the energy crisis caused by all those whirring air conditioners. You put down the paper as the happy physicists bobbing in the surf call to you, saying you should come in for a dip.
“How warm is it?” you ask.
“Very,” they say, bobbing up and down. “About 300 kelvin.”
Hmm, you think. If you could create a Carnot engine and use the surface of the ocean as the input heat source (300 kelvins) and the bottom of the ocean (about 7 degrees Celsius, or 280 kelvin) as the heat sink, what would the efficiency of such an engine be? And how much input heat would you need to supply the entire energy needs of the United States for one year

math to find the efficiency:

Hmm, 6.7 percent efficiency. So how much input heat would be needed to get

You know that Efficiency = W/Qh, so

Plugging in the numbers and doing the math yields

How much would taking that heat out of the top meter of the Pacific Ocean change its temperature by? Assume that the top meter of the Pacific Ocean contains about

The heat gained or lost is tied to temperature change by

so the temperature change would be

Plugging in the numbers and doing the math gives you a temperature change of

So if your Carnot engine were connected from the top of the Pacific Ocean to the bottom and sucked all its heat out of the top meter of the surface water, it’d lower the temperature of that top meter of water by 4.5 degrees Celsius to supply all the energy needs of the United States for one year.