The Demons that Haunted Maxwell

In this level-0 post, we take a look at some interesting thought experiments in thermodynamics, in particular the various incarnations of Maxwell’s demon. These were constructed as possible ways to subvert the second law of thermodynamics, and here we will talk about why they don’t.

Introduction

The mid-19th century was a boom time for physics in Europe. Great advances were being made in foundational areas, like electrodynamics and thermodynamics, which lead to the steam engine and the light bulb. Central to the construction and efficacy of heat engines was the developed (and developing) theory of thermodynamics, with its 4 laws. In this post, we will focus on the second law of thermodynamics, which states that any closed system cannot decrease its entropy. A famous thought experiment, originally by James Clark Maxwell, proposes that a “demon” could break the second law through several different means. Now we know that this is not true, and in this post, we will go through why this is so.

Entropy and Heat Engines

To understand Maxwell’s demon, we need to understand the law it is trying to break and thus to understand entropy. Entropy is an odd thing in the popular science discourse, since different people will give very different “definitions” of entropy. These explanations range from “entropy is a measure of disorder” to “entropy is a measure of how spread out energy is”. While these interpretations can be useful in certain situations, we will use a simple operational definition so that we may get to the main discussion.

Let’s say we have a box full of gas. The gas has some energy associated to it, and there are a couple of ways of increasing or decreasing the energy in the gas: we could add/remove thermal energy or we could add/remove mechanical energy by doing work on the gas (for example, by compressing the gas). This is summarized in the first law of thermodynamics,

\Delta E = Q + W ,

where Q is the energy from heat exchange, and W is the work done on the gas. The amount of energy gained from absorbing heat depends on the temperature of the gas, and crucially the entropy. A small amount of heat exchange generates a small amount of entropy change:

Q = T\Delta S.

For the purposes of this post, this and the second law are all we need to know about entropy. Let’s see a simple consequence of these two facts. Say we have a closed system consisting of two boxes, one at temperature T and the other at temperature 2T (we are using absolute temperature scales here, so 0 temperature is absolute zero, the coldest possible temperature). If these boxes are allowed to exchange a small amount of heat q, then we would have a corresponding change in entropy. If we say that the entropy of the hotter box is S_{h} and that of the colder box is S_{c}, then

\Delta S_{tot} = \Delta S_{h} + \Delta S_{c} = \frac{q}{2T} - \frac{q}{T} = -\frac{q}{2T}.

In the above equation, I chose q to be the heat transferred to the hotter box. We can see that transferring heat to the hotter box decreased the total entropy of the system, so the second law says this is impossible! Heat can only flow from a hot object to a cold object, just as everyday experience would tell us.

Now let’s talk a little bit about heat engines. In physics, we like to start as simple and idealized as possible before we add the more complicated and realistic stuff. This allows us to reduce a problem to its most fundamental parts. The physicist’s idealized model of a heat engine (everything from steam engines, diesel engines, Stirling engines, etc) is shown in the diagram below. It consists of three parts: a hot reservoir, a cold reservoir, and a black box that represents the internal components of the engine. In simplest terms, heat flows from the hot reservoir to the cold reservoir through the heat engine, and the heat engine can convert some of this heat into useful work.

A red rectangle sits at the top of the image, labelled T H for hot temperature. There is similar blue rectangle at the bottom labelled T C for cold temperature. In between the rectangles is a dotted rectangle labelled ENGINE. Arrows from the hot rectangle to the engine and from the engine to the cold rectangle represent heat flow, and an arrow coming out of the side of the engine represents the engine's output.
The physicist’s first approximation of a heat engine. Heat is transferred from the upper hot reservoir to the lower cold reservoir through the engine, which converts some of the energy into useful work.

Let’s analyze the efficiency of the heat engine using the second law of thermodynamics. The efficiency is the fraction of energy that the engine can convert into useful work. The energy coming in is Q_{in}, and the output of the engine is W, so the efficiency is

\varepsilon = \frac{W}{Q_{in}}=\frac{Q_{in}-Q_{out}}{Q_{in}} = 1-\frac{Q_{out}}{Q_{in}}.

I used a little trick there where I used the conservation of energy to write Q_{in}=W+Q_{out}, so that everything can be written in terms of the heat exchanges. This allows us to talk about the entropy change of the system. Since the engine has cycles, its entropy doesn’t change on average, so we can just focus on the entropy gained by the cold reservoir and lost by the hot reservoir.

\Delta S_{tot} = \frac{Q_{out}}{T_{C}} - \frac{Q_{in}}{T_{H}}

The second law says that the above change in entropy must be 0 or larger. The maximum efficiency of the engine comes from \Delta S=0 because the more work that is output from the engine, the less heat is transferred to the cold reservoir, which means a smaller change in entropy. Therefore the smallest change in entropy (0) corresponds to the largest output of the engine. When the change in entropy is 0, then the change in the entropy of each reservoir is the same size.

\frac{Q_{out}}{T_{C}} = \frac{Q_{in}}{T_{H}} \phantom{00}\Rightarrow\phantom{00} \frac{Q_{out}}{Q_{in}} = \frac{T_{C}}{T_{H}}

That allows us to write the maximum efficiency of a heat engine in terms of the temperatures of the two reservoirs:

\varepsilon = 1-\frac{T_{C}}{T_{H}}.

To get a really efficient heat engine, you need the cold reservoir to be much colder than the hot one. If we tried to run a heat engine off of the boxes in our previous example, we could only achieve a maximum of 50% efficiency! In particular, notice that the second law prevents the construction of a monothermal heat engine, that is one where there is really only one reservoir, so T_{C}=T_{H}. So you cannot just extract useful work from a single reservoir, regardless of the details of how the heat engine operates! This will be important to us soon.

Maxwell’s demon and Szilard’s refinement

We are now in a position to discuss Maxwell’s demon. Though to be clear, the concept of a supernatural demon isn’t strictly necessary here, the demon is really just any measuring device. In fact, Maxwell himself didn’t talk about demons, that was coined by Lord Kelvin, who seemed to be evoking the more neutral sort of demon from the ancient Greeks, rather than the evil spirits of the Abrahamic religions. Just thought I’d get that out of the way, since I will be using the standard term ‘demon’ all over this article. There are many equivalent Maxwell demon thought experiments, but we will start with just one. Suppose you have a box filled with a gas, a demon, and the demon has a partition that it can slide into the center of the box, splitting it into two (importantly, without needing to do any work on the gas). The demon, with its supernatural intellect can see the positions of all the particles of gas and knows their velocities. By moving the partition, the demon is able to let through specific gas particles from one side of the box to the other. The demon uses this power to let all the quickly moving particles to the left side of the box and all the slowly moving particles to the right side. Since temperature is related to the average speed of particles in a gas, the demon has separated a gas at one temperature into a hot gas and a cold gas without doing any work on the gas, violating the second law.

In the early 20th century, Hungarian physicist Leo Szilard refined Maxwell’s demon into the simplest possible model of a demon seemingly violating the 2nd law. This is called a Szilard engine, and it works like so: There is a single gas particle in a box, which is touching a reservoir so that everything stays at one temperature. The demon has a partition to split the box in half. Once this is done, the demon can look to see which side of the box the gas particle is on and place a piston in the other half so that, as the “gas” is allowed to expand, it pushes the piston, doing work. The demon can do this over and over again to extract as much energy as it wants out of the system. This is a heat engine that operates at one temperature, a monothermal heat engine. We argued just a moment ago that a monothermal heat engine should be 0% efficient by the second law, but this is clearly extracting some useful work. What is going on?

Animated gif. A box containing a gas particle is fitted with one pully on either side. Below each pulley, on the floor, is a weight. On top of the box, a demon inserts a partition into the center of the box, trapping the particle on the right half. The demon then connects the partition across the pulley to the weight on the right side. As the gas expands, the partition is pushed, lifting the weight off of the ground.
In a Szilard engine, the demon uses knowledge of the gas particle’s location to extract the work required to lift a weight.
Classical Szilard engine

We will start with the classical engine, that is the engine where we treat the gas molecule as a classical particle (no quantum mechanics allowed). The key to resolving this issue with the second law is to realize that we have applied it incorrectly in this case. We are looking that the gas as an isolated system, but that is clearly not the case! In particular, the demon is measuring the particles location. Any measurement, no matter how careful, requires an interaction between the measurer (the demon) and the system to be measured (the particle). Therefore, we need to consider the internal workings of a demon! Sounds complicated and dependent on the inner workings of supernatural creatures and measurement devices alike, but we can at least find out what the most efficient demon can do.

What’s important here is that the demon measures the particle’s location, and then uses that information to place a piston in the right orientation so that it may extract useful work from the particle. The most efficient demon would only need to know whether the particle is on the left or the right side of the box. We can think of the demon’s memory like 1-bit of memory on a computer. The bit is on if the particle is on the right side, off if the particle is on the left side. Importantly, the demon will have to erase the information once it is done using it in order to complete the engine cycle, so that the system returns to its starting configuration (otherwise it wouldn’t be much of a cycle would it).

In the 1960’s, around 100 years since Maxwell proposed his demon, Rolf Landauer was working at IBM and argued for a fundamental limit in computing related to erasing memories. In particular, he placed a lower bound on the amount of energy required to erase one bit of information. Amazingly, this bound was exactly the amount of work that is extracted from one cycle of the Szilard engine! So with Landauer’s principle, the second law is saved from Maxwell’s demon because all of the energy extracted from a cycle of the Szilard engine has to then be used to erase the demon’s memory.

Although I haven’t gone into the mathematical details, just this history explains the birth of the most incredible advances in physics and computing: information theory (and its relationship to thermodynamics). Until Szilard proposed his engine, physics was the domain of concrete objects and the interactions between them. But now the notion of information, before a subjective human concept, has been made precise and physical.

Quantum Demons

The previous discussion was all classical, so some may object, “hey! You can’t treat a single atom/molecule as a classical particle, this is very clearly the realm of quantum mechanics!” This is correct, of course. However, treating the problem quantum mechanically doesn’t change the basics or interpretation. To show what I mean, let’s go through the quantum version of the story.

The gas particle is now a quantum particle, meaning that it is represented not as a point in space, but as a wave function, which encodes all the information we could ever hope to know about the particle (i.e. the probabilities of all possible measurements that one could perform on the particle). The wave function is essentially the state of the particle, and in this set-up, we take the particle to be in a constant temperature state. The demon inserts a barrier into the box, chopping the wavefunction in half. Then, the demon measures the particle, and this is where things get funky. To properly model the problem, we should treat the demon also as a quantum object. So let’s talk about that for a second.

We can take the demon to have two possible states: the state where the demon has measured the particle to be on the left, and the one where the demon measured the particle to be on the right. Before measuring, the state of the demon in a “superposition” or combination of these left and right states, such that if we measured the demon, there would be a 50/50 chance of measuring the demon in the left or right state. Then, when we say that the demon “measures” the particle, we mean that the demon and particle interact in a very specific way. This interaction must “entangle” the demon and the particle states. When two quantum objects are entangled, it means that there is no way of thinking about them as separate objects. In this case, the demon+particle state is a superposition of (the demon and particle both in their left states) and (the demon and particle both in their right states). Don’t worry if this doesn’t fully make sense to you, hopefully the upcoming animation will help.

Animated gif. A box contains a quantum particle, represented by a blue curve called the wave function. On either side of the box, there is a small weight, and above the weights attached to the corners of the box are two pulleys. A demon stands on top of the box with a partition. The demon inserts the partition into the center of the box, splitting the wave function in two. Then, the demon looks in the box to measure which side the particle is on. The image splits into two semi-transparent copies on itself. On the left copy, the demon now has a leftward pointing arrow in its chest, and the box only contains a blue curve on the left half. On the right copy of the image, the demon has a rightward pointing arrow on its chest and the box contains only a wave function on its right half. On each side, the demon pulls string out of its back pocket and uses it to attach the partition across a pulley to the weight that is on the same side of the box as the wavefunction. As the demon copies watch, the wave function expands to fill the box, pushing the partition to the other side and lifting the weight. The two images merge showing that the wave function has returned to its initial state, but each copy of the demon is still semi-transparent.
The demon inserts the barrier and measures the particle. This causes the demon+particle system to become entangled. Each half of the demon+particle state goes through the same steps as the classical Szilard engine. However, once the particle expands back to its initial state, the energy produced must be used to return the demon to its initial state.

Okay, so the demon inserts the barrier and measures the particle. At this point, everything continues just like in the classical case. The demon uses the knowledge of the particles position to extract work just like before (albeit in this weird split-in-two way). When the particle expands to fill the rest of the box, it returns to its initial state. However, the demon does not. We need an extra step to complete the cycle, in which we return the demon to its initial ready-to-measure state. The issue with this is that it takes energy to change the demons state. How much? Well, at least as much energy as the demon was able to extract from the particle. Therefore, there is no engine and no violation of the 2nd law, even when you treat everything quantumly.

Conclusion

Maxwell’s demon is a great demonstration of why thought experiments are important. In testing the logical limits of our scientific theories, we can see when they break down, or better yet, entire new areas of physics to explore. Maxwell, while concerned about the former, really inspired the latter, eventually leading to entirely new fields of research, like quantum information theory. The second law of thermodynamics, meanwhile, has stood the test of time since then, even being extended to describe the physics of black holes and the cosmological horizon of our own universe. I’m sure such topics will appear in future posts (wink).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: