Entropy Part II (Building an Engine)

Posted by

The narrative of this blog post has been partially inspired by the seriously awesome episode of Love, Death and Robots: “Good Hunting”.

It is 1805. The world is changing. You can feel it in the air: smell of burned coal and sounds of metal parts and pistons clinking into each other. Just 30 years ago James Watt started mass producing his water pumping engine. Many similar machines pop out here and there, but they are still clunky and inefficient. Your contemporaries are trying to improve the existing engines by shooting trials and errors in the dark. You know better. You will apply the fundamental principles of physics to once and for all unravel what engines can and cannot do. You want to harness the true power of steam and propel humanity into a new age!

Your goal is to figure out a way to burn some coal, i.e. spent some energy in the form of heat, and have a box of gas perform the maximum possible amount of useful work, i.e. energy going towards making something move. Preferably, that “something” will move continuously in a circle, such that you can power the wheels of a locomotive or some other cool 19th century tech.

Now that your goal is clear, let’s break it into chunks. You want to understand:

  • How to describe the work done by or done on the gas?
  • How to describe the gas receiving or giving away heat?
  • What is the relation between total work done by the gas and total heat received when the gas undergoes a cyclic process?

We tackle these questions one by one in the following sections.

Describing Work

Imagine that your box is fully covered in a perfect thermal insulator so that no heat escapes or enters. The box is enclosed by a heavy lid (also perfectly insulating) that can slide without friction up an down the walls of the box. Take the gas to initially occupy volume $V_i$ at temperature $T_i$ and pressure $p_i$. If the outside pressure is $p_0$, the mass of the lid is $m$ and its area is $A$, then the lid will sit perfectly still if

$$\tag{1} p_i A = mg + p_0 A \,. \label{eq:lid_balance}$$

That formula simply says that the force pushing the lid up ($p_i A$) is exactly balanced by the weight of the lid ($mg$) plus the force pushing the lid down, provided by the atmospheric pressure ($p_0 A$). If, for some reason, the pressure of the gas starts changing the balance between the forces will be ruined and the lid will start moving. Now, the work done by the gas is defined as the force that the gas exerts on the lid multiplied by the distance that the lid travels. If the force changes its magnitude throughout the journey we get the equation

$$\tag{2} W = \int_{x_i}^{x_f} F(x) \, \text{d}x \,,$$

where $x_i$ and $x_f$ are the initial and final heights of the lid. This formula is not immediately useful, so lets improve upon it. We can express the force with which the gas pushes as $F(x) = p(x)A$, where $p(x)$ is the pressure of the gas when the lid is at height $x$. Using the fact that incremental change in height times the area is equal to the incremental change in the volume ($A \text{d}x = \text{d}V$) we can write the work done by the gas as

$$\tag{3} W = \int_{V_i}^{V_f}p(V) \, \text{d}V \,, \label{eq:work}$$

where $V_i$ and $V_f$ are the initial and final volume and we now view the pressure of the gas as a function of its volume.

Take a moment to appreciate what we have just learned. If for whatever reason the lid starts moving around (it might be you heat up the gas and the heavy lid is raised up or just push or pull on the lid yourself), the pressure and volume will change and you can plot the curve $p(V)$. Then, you can very easily determine the work done by the gas: its simply the area under that curve. Now, there is a convention that we should talk about. If the gas has expanded, then $V_f > V_i$: we say that the gas does work (green in Figure 1 left). However, if the gas has shrunk, then $V_f < V_i$: we say that work has been done on the gas (red in Figure 1 center). A curious possibility emerges: what if we somehow make the gas follow a clockwise closed curve on the so called p-V diagram (Figure 1 right)? On the upper leg of the journey we cover some green area (gas does work), while on the lower leg of the journey work is done on the gas and some, but, crucially, not all of the green area is swiped away (you can effectively think that red and green areas “cancel” each other). Remarkably, we are left with some remaining green area: the useful work performed by the gas. This smells a lot like an engine already: the gas can traverse many loops on the p-V diagram, and after each full loop it has done some amount of work, and returned to its initial state.

PV diagrams
Figure 1 The gas does work (left), work is done on the gas (center), the total work done for a closed loop (right).

Describing Heat

Pumping heat into the gas is easy to do in practice: take the insulating cover away and burn some coal nearby the walls of the box. Let’s denote the heat absorbed by the gas by $Q$. The temperature $T$ might change in this process, but how exactly are $Q$ and $T$ related? Turns out that the relationship involves $S$ — the entropy of the gas

$$\tag{4}Q = \int_{S_i}^{S_f} T(S) \, \text{d}S \,. \label{eq:heat}$$

If you wish you can view this formula as the definition of entropy. Notice how similar equations (\ref{eq:heat}) and (\ref{eq:work}) are: entropy is to temperature and heat what volume is to pressure and work. In both equations we relate somehow the interaction of the gas with the outside world ($W$ and $Q$) with some internal characteristics of the gas ($p$, $V$, $T$, and $S$). We can play the same game as on Figure 1, but on the so called T-S diagram. We agree that if $S_f>S_i$: the gas absorbs heat (yellow in Figure 2 left), and if $S_f < S_i$: the gas looses heat (blue in Figure 2 center). For a closed clockwise loop on the T-S diagram there is a total amount of heat absorbed (Figure 2 right), where again you can think of the yellow and blue regions “cancelling each other”.

TS diagrams
Figure 2 The gas absorbs heat (left), the gas loses heat (center), the total heat absorbed for a closed loop (right).

Relating Heat and Work

Now that you have separate descriptions of the input (heat added) and the output (work done) of your engine, the natural question to ask is: How are they related? Whatever happens to on the T-S diagram is intricately linked to whatever happens on the p-V diagram. In particular, a clockwise loop in one of them corresponds to a clockwise loop on the other and the shape of one of the loops is entirely determined by the other. To describe this relation we need two physical laws. The first one is one of the most fundamental laws of nature:

Energy is never lost or created; it is only converted from one type into another or hops from one system into another.

Think about your box of gas. When you burn some coal nearby, some heat $Q$ is released (remember that heat is just a type of energy). Assuming that all of the heat goes towards the gas and none is lost in the surroundings, then there are really only two ways in which that heat-type-energy can be spent: 1) raise the temperature of the gas (i.e. the heat-type-energy is spent into making the molecules of the gas jiggle and bounce of each other more intensely); 2) the gas does some work (i.e. the heat-type-energy is converted into work-type-energy and the gas lifts the heavy lid). In general, both of these things might happen in some, yet unknown to us, proportion, so we write

$$\tag{5} Q = \Delta E + W \,, \label{eq:1st_law}$$

where $Q$ is the heat absorbed by the gas, $W$ is the work done by the gas and $\Delta E$ is what we call the “change in the internal energy of the gas”. This simply means that the kinetic energy of the molecules has raised; they literally move faster as they randomly bounce off of each other. “Moving faster” is associated with higher temperature. Thus, we conclude that the internal energy of the gas is only a function of the temperature, and the change in the internal energy only depends on the change in the temperature. Experimentally, you can convince yourself that the precise relation between energy and temperature is

$$\tag{6} \Delta E = c_V n \Delta T \,, \quad c_V = \# R \,, \label{eq:internal_energy}$$

where $R = 8.3145 \, \text{J} \cdot \text{mol}^{-1} \cdot \text{K}^{-1} $ is a universal constant and $n$ is the number of moles (for example if you have $1$ liter of gas then $ n = 1/22.4 \, \text{mol}$), and $\#$ is a number that depends on the properties of the gas (for the type of gases we will consider $\# = 3/2$). Notice that the units work out as they should. On the right hand side we have energy measured in Joules ($ \text{J}$) and on the left hand side we have $ \text{J} \cdot \text{mol}^{-1} \cdot \text{K}^{-1} \cdot \text{mol} \cdot \text{K} = \text{J}$, where $ \text{K}$ stands for Kelvin — the sensible way to measure temperature.

Formula (\ref{eq:1st_law}) directly relates heat and work, so are we done? Well, not really, while formula (\ref{eq:1st_law}) is still very useful, it makes no mention to the p-V and T-S diagrams. In a way it is too generic, instead we want to be specific and describe our very own engine with its very concrete curves on the two diagrams. The key is in the so called the equation of state. It relates $T$, $p$ and $V$ and is a characteristic of the concrete gas that we use. The simplest possible example of such a relation is the one for a monoatomic ideal gas. That is a gas, made out of single atom molecules that bounce of each other perfectly elastically, like billiard balls where no energy is lost in each collision. A real world example of such a gas is hydrogen at not too wild pressure and temperature. In that case, you can experimentally find that

$$\tag{7}pV = nR T \,. \label{eq:ideal_gas}$$

This relation makes perfect intuitive sense: warm up the gas, while keeping the volume fixed and more pressure will build up. Or decide to keep the temperature fixed and enlarge the container, the pressure will drop.

Explain Your Engine to Your Neighbour

You have covered quite a lot of mileage in your quest for world domination, but you have not answered the question: what is an engine really capable of? Imagine marketing your engine to Joe the neighbor who has a small windmill, that he wants to power with your engine instead of relying on the caprice of the weather. He couldn’t care less about entropy, p-V or T-S diagrams. He only cares about how much wheat he can crush (work-type-energy released) with so and so amount of coal burned (heat-type-energy spent). And these are the answers that you are just about to give him. After one cycle of your engine the gas has returned to the initial temperature, pressure and volume. From (\ref{eq:internal_energy}) we see that there is no total change in the internal energy for that one cycle. Thus, we can write

$$\tag{8}Q = W \, \implies \, Q_{\text{in}} – Q_{\text{out}} = \oint p(V) \, \text{d}V \,,$$

where $Q_{\text{in}}$ is the heat we pump in by burning some coal, $Q_{\text{out}}$ is the heat that we allow to escape and the little circle on top of the integral is to remind us that we are just calculating the area inside the loop on the p-V diagram. Given $Q_{\text{in}}$ and $Q_{\text{out}}$ we want to make sure that the area inside the loop is the fattest possible so that we do the most amount of useful work. Naturally, we define the efficiency of the engine as the amount of useful work, divided by the amount of heat we pump in (or coal you burn)

$$\tag{9}\eta = \frac{W}{Q_{\text{in}}} = \frac{Q_{\text{in}} – Q_{\text{out}}}{Q_{\text{in}}} = 1 – \frac{Q_{\text{out}}}{Q_{\text{in}}} \,. \label{eq:efficiency}$$

Notice that $\eta = 1$ is a wishful scenario in which all of the heat we pump in gets converted to useful work. Unfortunately, we see that this scenario is impossible: to make a closed cycle on the p-V diagram, we have to make a closed cycle on the T-S diagram, and on the lower leg of that journey (Figure 2 right) some heat inevitably has to get lost to the environment. You can try to get smarty-pantsy and say that you will traverse the lower leg of the journey at zero temperature, but unfortunately the third law of thermodynamics will come bite you: it prohibits any system to reach exactly zero temperature in finite amount of steps. Nevermind trying to explain to Joe that he needs to also get himself a nuclear demagnetization refrigerator, and cool the gas to almost absolute zero!

An engine that converts all the input heat into useful work as an output is impossible.

A Formula for Change in Entropy

Before you get on to actually building your engine it will pay of to understand entropy a little better. Take the process on Figure 1 left. At each point on the curve, using (\ref{eq:ideal_gas}) you can determine the temperature at that instant. With a little bit of calculus trickery you can derive the entropy change when traversing from $(p_i, V_i, T_i)$ to $(p_f, V_f, T_f)$. The calculation goes as follows

$$\Delta S = \int \frac{\text{d}Q}{T} = \int \frac{\text{d}E + \text{d}W}{T} = \int \frac{c_V n \text{d} T + p \text{d}V}{T} = c_V n \int^{T_f}_{T_i} \frac{\text{d}T}{T} + nR \int^{V_f}_{V_i} \frac{\text{d}V}{V} \,,$$

where in the second equality we have used (\ref{eq:1st_law}), in the third equality we have used (\ref{eq:internal_energy}) and in the forth equality we have used (\ref{eq:ideal_gas}) and explicitly indicated the inital and final state of the gas. We can easily solve the above integral and upon using (\ref{eq:ideal_gas}) again we can express the total entropy change in three equivalent ways

$$\tag{10} \Delta S = n \, \ln \left[ \left( \frac{p_f}{p_i}\right)^{c_V} \left( \frac{V_f}{V_i}\right)^{c_p}\right] = n \, \ln \left[ \left( \frac{T_f}{T_i}\right)^{c_V} \left( \frac{V_f}{V_i}\right)^{R}\right] = n \, \ln \left[ \left( \frac{T_f}{T_i}\right)^{c_p} \left( \frac{p_f}{p_i}\right)^{-R}\right] \,, \label{eq:entropy}$$

where we have used the standard convention of defining a new constant

$$\tag{11} c_p = c_V + R \,.$$

Even if this calculation is a bit out of your league, you can still understand the final result. Say that you consider a process in which the volume stays the same ($V_f = V_i$), while the temperature and pressure double ($p_f = 2p_i$ and $T_f = 2T_i$). Then the entropy change is simply given by

$$\tag{12} \Delta S = c_V n \ln(2) \approx 0.386 \, \text{J} \cdot \text{K}^{-1} \,. $$

In this process, the entropy has increased. What if you, instead, you again keep the volume fixed, but decrease the pressure and temperature in half. In this case you get

$$\tag{13} \Delta S = c_V n \ln \left( \frac{1}{2} \right) \approx -0.386 \, \text{J} \cdot \text{K}^{-1} \,. $$

What, the entropy has decreased!? You immediately complain that you have heard that entropy can never decrease. Hold your horses, tiger. The correct statement is that the entropy of the whole universe can never decrease. The entropy of your local box of gas is very much allowed to do so. The price to pay is that the entropy somewhere else has increased more than that! We will explore this in far greater detail in another blog post.

It is important to realize that formula (\ref{eq:entropy}) doesn’t actually tell what what the entropy is as a function of the parameters of the gas ($p,V,T$) at any instant. It only tells you what is the change in entropy, when you change these parameters.

Pushing Nature to Her Limits

We already learned that efficiency of $\eta = 1$ is theoretically impossible. Nature has decided to not only forbid you from having a free lunch, but charge you extra just to keep you engine running. You sigh, abandon your naive dreams of perpetum mobile, and sit down to figure out what is the maximum possible efficiency you can squeeze out. The key is to consider the cycle in Figure 2 right. It is bounded by some maximal and minimal temperatures $T_{\text{max}}$ and $T_{\text{min}}$ that the gas can reach. In practice these temperatures are limited by the maximal temperature at which your coal can burn and the minimal temperature of whatever cooler you use to cool you engine (such as ice if it is winter and you have plenty of it around). Similarly, the curve is bounded by some minimal and maximal entropy $S_{\text{min}}$ and $S_{\text{max}}$. That you can easily see from (\ref{eq:entropy}): there is no way to have $\Delta S \to \infty$, since that will amount to making your container infinitely large, or trying to cranking up the pressure to infinity, which will simply make your container explode at some point. So what shape shall you choose that is contained within the rectangle formed by $T_\text{min}, T_\text{max}, S_\text{min}, S_\max$? You remember that the area inside the loop gives the total amount of heat absorbed by the gas in the cycle. This gives you a simple idea: if you squeeze in the maximum possible amount of heat absorbed, given the limitations, maybe that will also give you the maximum possible amount of useful work under those same limitations. So on the T-S diagram we choose the traverse a square, as in Figure 3 left. One can show that on the p-V diagram this corresponds to the funny looking shape on Figure Figure 3 right.

Carnot cycle
Figure 3 The shape on the T-S diagram which ensures maximal amount of heat absorbed (left), and the corresponding shape on the p-V diagram (right).

To achieve this cycle in practice, you sequentially do the following four processes:

  1. Get the gas in touch with a heater of temperature $T_H$ (that can be burning coal for example), and let the gas expand, while keeping its own temperature equal to $T_H$ throughout the whole process. On Figure 3 this is depicted by the red curves, indicating that the temperature doesn’t change and is equal to the temperature of the heater.
  2. At some point, remove the heater and thermally insulate the gas so that no heat can enter or escape. The momentum of the moving lid will keep it moving and the gas will expand a little bit more. In this process $p, V$ and $T$ will all change, but the entropy will stay the same (equal to $S_\max$). On Figure 3 that has being described by the black curves going downwards (I have not attempted to color code the temperature at each point of this process, you should imagine that it continuously changes from red to blue).
  3. Remove the insulator and now get the gas in touch with a cooler of temperature $T_C$ (that can be the ice you find in your back garden if it is winter). Let the gas contract, while keeping its temperature equal to $T_C$ throughout the whole process. On Figure 3 this is depicted by the blue curves, indicating that the temperature doesn’t change and is equal to the temperature of the cooler.
  4. Finally, again thermally insulate the gas. The momentum of the moving lid will keep it moving and the gas will contract back to the starting point. In this process $p, V$ and $T$ will all change, but the entropy will stay the same (equal to $S_\min$). On Figure 3 that has being described by the black curves going upwards, where again you should imagine that they are continuous changing in color from blue to red.

This whole fiasco has been described as a cartoon on Figure 4 to make it look more like an engine. In the middle container there is the gas. The left container is the heater: a slab of burning coal that is kept at temperature $T_H$ (red). The right container is the cooler: a block of ice that is kept at temperature $T_C$ (blue). The lid of the gas is connected to a wheel by a rod that makes the wheel rotate as the lid moves up and down. The solid black lines depict the thermal insulator: if the gas is fully enclosed by solid black lines no heat can leave or enter, and if one of the insulating walls has been removed heat can enter from the heater or escape into the cooler. Finally, the coloring of the gas is also supposed to indicate its temperature. For example, in process 2, the gas smoothly cools down from $T_H$ (red) to $T_C$ (blue).

Carnot engine
Figure 4 Your engine in action!

So, is this the engine you have been looking for: the theoretically most efficient one? One way to calculate the efficiency is to use $\eta = W / Q_\text{in}$. To get $W$ you should integrate to find the area enclosed by the loop on Figure 3 right, and to find $Q_\text{in}$ you should calculated as the area under the line $1$ on Figure 3 left, or simply count how many pieces of coal you burned, in one cycle. I, personally am not in the mood for integrating the weird shape on the p-V diagram, especially when there is an easier way. Looking at (\ref{eq:efficiency}) we see that we can easily obtain $\eta$ using $Q_\text{in} = T_H(
S_f – S_i)$ and $Q_\text{out} = T_C(S_f-S_i)$. So, finally we get

$$\tag{14} \eta_\text{max} = 1- \frac{T_H}{T_C} \,. $$

Turns out that this is indeed the maximum efficiency engine. A rigurous proof was provided by Sadi Carnot in 1824. His theorem states:

All heat engines operating between a hot and a cold reservoir are less efficient than a Carnot heat engine operating between the same reservoirs. Every Carnot heat engine between a pair of reservoirs is equally efficient, regardless of the working substance employed or the operation details.

That might very well be one of the most badass sounding theorems. Let me paraphrase: “Your engine might be good, but my engine is better. The only way you can have an engine as good as mine is to build another one of my engines…”

So did Carnot take over the world with the masterful theorem of his? Well, not really. Cholera took his life at only 36. Most of his academic writings were burned as they could have been contagious. His published book “Reflections on the Motive Power of Fire” would years later indeed help change the face of the world.