PV Diagrams
When a gas undergoes changes that will eventually return to its original state, it will go through a cycle of processes. The diagram below shows an ideal gas undergoing some processes.
The gas undergoes:
Isovolumetric changes between a and b, and c and d. You may see this written as isochoric changes in some books.
Isobaric changes between b and c, and d and a.
Let's analyse the changes and see what work gets done
From a to b, there is no work done as it is an isovolumetric change.
From b to c work is done by the gas as it expands. Work done is the area of the rectangle bcef = p_{2}(V_{2}  V_{1})
From c to d there is no work done as the change is isovolumetric.
From d to a work is done on the gas as it is compressed. Work done is the area of the rectangle adef = p_{1}(V_{2}  V_{1})
The overall work done is the difference between the two areas, i.e. the area of the rectangle abcd.
The pV diagram shows a cycle in which a fixed mass of an ideal gas is taken through the following processes: A to B isothermal compression, B to C expansion at constant pressure, C to A reduction in pressure at constant volume.
(a) Show that the compression in process A B is isothermal. (b) In which two of the three processes must heat be removed from the gas? (c) Calculate the work done by the gas during process B to C. (d) The cycle shown in the diagram involves 6.9 × 10.2 mol of gas. (i) At which point in the cycle is the temperature of the gas greatest? (ii) Calculate the temperature of the gas at this point. (AQA Past question) 
The cycle diagrams are sometimes called indicator diagrams and are widely used by engineers looking at the work that can be got from an engine. The diagram above is for an ideal gas, but there is a machine called a Stirling Engine that gives an indicator diagram that is very similar. Here is a picture of the Stirling Engine which was invented in 1816.
The Stirling Engine
At point A air is in the cylinder at a pressure of 1.0 x 10^{5} Pa and a temperature of 300 K. We always use absolute temperatures. We need to work out how many moles of gas there are in the cylinder.
Worked example Use the gas equation to find out how many moles there are in the cylinder at point A 
Answer pV = nRT
n = pV/RT = (1.0 × 10^{5} Pa × 0.0005 m^{3}) ÷ (8.3 J mol ^{1 }K^{1} × 300 K)
n = 0.0201 mol 
Use the graph above and the ideal gas equation to fill in the table below.

We can do an energy audit on the cycle. You are NOT expected to know about the molar heat capacity of a gas at constant volume, or the molar heat capacity of a gas at constant pressure. The table shows work done at various points about the cycle.
Point 
Heat supplied to gas (J) 
Work done on Gas (J) 
Increase in Internal energy (J) 
A 
125 
0 
125 
B 
700 
200 
500 
C 
375 
0 
375 
D 
350 
+100 
250 
We can describe what is happening:
A to B 125 J is supplied to the gas raising its temperature at constant volume.
B to C 700 J of heat is supplied, while the gas does 200 J of work on the surroundings.
C to D 375 J is extracted from the gas to cool it at constant volume.
D to A to return the gas to its starting point 100 J of work has to be done on the gas and 250 J are extracted from it so that the volume falls at constant pressure.
If we look at the indicator diagram, we can find the work done by the engine. It is the area of the pink rectangle.
What is the work done? 
Overall 825 J are supplied as heat, while 725 J are extracted as heat, and lost to heat the surroundings. Of the work done, only 100 J is useful work done.
Therefore we can write down the thermal efficiency:
Thermal efficiency = net work output ÷ heat input
Often we multiply the resulting fraction by 100 to give a percentage. It is impossible to get anything more than 100 % efficiency, as that means that we would be creating energy.
And we can't, so there!
What is the thermal efficiency of the engine above? 
Practical Efficiency
The thermal efficiency is not the actual efficiency of the engine. There will be frictional losses within the engine itself, reducing further the output available. The engineer can design the engine to be as efficient as possible:
by considering the theory of how the gases behave as they expand and contract;
by designing the engine so that friction is low, valves are gas tight, and that parts of the engine are manufactured with high precision. (Sloppy tolerances give rise to "slogger", which thwarts many attempts to increase efficiency.)
Although it is theoretically possible to get 60 % efficiency from a car engine, 30 % is more likely. Also an initially highly efficient engine will lose efficiency as it wears out.
Getting useful work from heat is remarkably difficult.
A single cylinder steam engine has an idealised indicator diagram as shown in Figure 1. Between A and B the cylinder is connected directly to a source of high pressure steam. Between C and D the cylinder is connected to the atmosphere.
Calculate the indicated power output of the engine when it is working at a rate such that one cycle takes 0.20 s. (AQA Past Question) 