 We've been illustrating the concept of isothermal expansion and contraction using a one-dimensional single-atom gas model. An obvious simplification is that we treat the fixed and moving walls, as well as the heat reservoir, as ideal, incidentally hard solid structures. In reality, they would be made of atoms, and we are neglecting the kinetic interactions between the atoms of the gas and the atoms of these structures. For example, we assume there is no transfer of heat between the gas and the moving wall. The actual physics of a gas-solid interface is more like this conceptual simulation. The blue balls represent atoms of the solid, which, in addition to collisional forces, are also subject to elastic forces, trying to keep them in their equilibrium positions in the crystal lattice. The red balls represent gas atoms subject only to collisional forces. All kinetic energy is originally contained in the red atoms. As time goes on, atomic collisions transfer energy from the gas to the solid until their temperatures reach equilibrium. So, when we illustrate a piston system and claim that the gray regions, the piston and cylinder walls, are thermally insulated, that can't be rigorously true in any real system. We're developing an idealized model to help us understand ultimate theoretical thermodynamic limits. A real system might approach these limits with a design that reduces thermal transfer between the gas and the gray regions to small amounts, possibly by using materials with small heat capacity. But no real system will ever reach the theoretical limits. With that in mind, let's consider the work done in isothermal expansion or compression. The gas volume equals the piston cross-sectional area A times the gas height X. The force on the piston is the gas pressure P times the area A. From the ideal gas law, the pressure is the number of gas atoms N times Boltzmann's constant K times the temperature T divided by the volume. The force is then NKT over X. When the piston moves a distance delta X, the work done is approximately F times delta X. Approximately, because the force changes with X. If delta X is very small, this change is very small. If the piston travels a large distance from X1 to X2, we have the process illustrated in this graph. The orange curve shows the force as a function of position X. For a small displacement delta X, the work done is approximately the area of one of the blue rectangles, F times delta X. We add all these areas to get the total work done in moving from X1 to X2. As delta X gets smaller, the area of the blue rectangles more closely approximates the exact work, which is the area under the orange curve. The calculation of this area is called integration, and we write that the work done on the environment equals NKT times the integral from X1 to X2 of dx over X. This equals NKT times the natural logarithm of X2 over X1. Instead of expanding from X1 to X2, we can push down on the piston and compress the gas from X2 back to X1. The same expression now represents the work done on the system. Everything returns to its original state, leaving no trace of the expansion compression cycle. We say that isothermal expansion and compression are reversible. We now have enough theory to design a simple but useful heat engine based on the so-called Sterling cycle. We start with the piston in position X1. The gas is maximally compressed and in contact with a hot reservoir at temperature Th. The gas undergoes isothermal expansion until the piston position is X2. During this, the gas exerts a varying force F on the piston. The resulting work done on the environment is NKT hot times natural log of X2 over X1. The gas temperature doesn't change, so the gas's internal energy remains constant. By the first law, therefore, an amount of energy in the form of heat equal to this work must flow from the hot reservoir to the gas. We now replace the hot reservoir with a cold reservoir at temperature Th. The gas cools to this temperature and its pressure decreases proportionally. Exerting a force on the piston, we isothermally compress the gas until the piston returns to its original position X1. The work done on the system is NKT cold times natural logarithm of X2 over X1. By the first law, this energy in the form of work must be converted to energy in the form of heat, which is transferred to the cold reservoir. The cycle is now complete. We can replace the cold reservoir with the hot reservoir and repeat the cycle for as many times as desired. Because expansion occurs at high temperature and pressure, and compression occurs at low temperature and pressure, the work done on the environment during expansion is larger than the work done on the system during compression. So, a net amount of work, NKT hot minus T cold times natural log of X2 over X1 is produced by the engine. We can plot the evolution of the state of the system on a PV diagram. The first leg of the cycle is the isothermal expansion at temperature T hot. This takes us from state one to state two along an isothermal curve. As volume increases, pressure decreases according to the ideal gas law. In the second leg of the cycle, the gas is cooled, the pressure drops accordingly, and we move to the second isothermal curve at temperature T cold. This takes the system from state two to state three. The third leg of the cycle is isothermal compression at temperature T cold. This takes us from state three to state four. As the volume decreases, the pressure increases. The final leg of the cycle is the reheating of the gas to temperature T hot. This increases the pressure and takes us from state four back to state one. During the transition from state one to state two, heat energy QS is delivered to the system and converted to work WE delivered to the environment. Both equal to NK T hot natural log X2 over X1. The cooling from state two to state three transfers heat from the gas to the environment, specifically the cold reservoir. This heat QE equals the heat capacity of the gas three halves NK times the temperature change T hot minus T cold. During the transition from state three to state four, work WS is done on the system and converted to heat QE transferred to the environment, specifically the cold reservoir, equal to NK T cold natural log X2 over X1. Finally, warming the gas to bring the system back to state one requires heat QS to be transferred from the hot reservoir to the system, equal to three halves NK T hot minus T cold. The area under the curve between states one and two is the work done on the environment. The area under the curve between states three and four is the work done on the system. The difference is the area between the curves and this represents the network produced by the engine. The theoretical sterling cycle we've just developed is an ideal that can only be approximated by a practical design. A popular implementation for demonstration purposes is the gamma type sterling engine. Here's a conceptual schematic. The heat reservoirs are implemented by two metal plates, a cold one on top and a hot one on bottom. If the cold plate is isolated by a displacer, the enclosed air is primarily in contact with the hot plate. The resulting higher pressure pushes the piston upward doing work on the environment. Moving the displacer to isolate the hot plate leaves the air primarily in contact with the cold plate. The resulting lower pressure allows the piston to be pushed downward with less work than was produced on the upward stroke. The network output by the engine can be used to turn the flywheel. Placing one of these toy sterling engines over a cup of hot water warms the bottom plate. As the flywheel turns you can see the large gray displacer moving between the hot and cold plates and the small white piston delivering a net positive amount of energy to the flywheel causing it to accelerate.