The first law relates heat energy, work and the internal thermal energy of a system, and is essentially a statement of conservation of energy.

The second law of thermodynamics adds a restriction on the direction of thermodynamic processes.

One of the earliest statements of the second law, due to Rudolf Clausius is that:

**Heat cannot spontaneously flow from a cold object to a hot one, whereas the reverse, a spontaneous flow of heat from a hot object to a cold one, is possible.**

We should note that the first law

$\Delta E_{int}=Q-W$

would not prohibit such a process, so the second law adds something fundamentally new to our understanding of thermodynamics.

A heat engine is a system for turning temperature gradient between two thermal reservoirs in to mechanical work. We will consider heat engines that operate with a continuous cycle, which means that the system always returns to its initial state at the end of the cycle and there is no change in the internal energy.

The first law tells us that in the case

$Q_{H}=W+Q_{L}$

In writing this equation we have adopted a new sign convention, where all the heats and the work done are positive.

Some of the earliest engines were steam engines, though steam engines should not be thought of a historical relics, about 80% of the worlds electricity comes from steam turbines. The earliest “steam engine” the Aeolipile does not do very much work. To get work out of an engine one needs to design an efficient heat engine cycle.

The efficiency, $e$, of an engine is defined as the ratio of the work we get from the engine $W$ to the input heat $Q_{H}$

$e=\frac{W}{Q_{H}}$

As we know that

$Q_{H}=W+Q_{L}$

$e=\frac{W}{Q_{H}}=\frac{Q_{H}-Q_{L}}{Q_{H}}=1-\frac{Q_{L}}{Q_{H}}$

The lower the waste heat, the more efficient the engine, however the second law of thermodynamics prevents $Q_{L}$ being zero. Kelvin in fact stated the second law explicitly in those terms:

**No device is possible whose sole effect is to transform a given amount of heat directly in to work.**

To find the hypothetical maximum efficiency of a heat engine we can consider a cycle called the Carnot Cycle first proposed by Carnot.

The Carnot cycle is based entirely on reversible processes, this is not achievable in reality, it would require each process to be executed infinitely slowly so that the process can be considered as a continuous progression through equilibrium states. We can however consider the Carnot cycle as a theoretical ideal which can be approached.

There are 4 processes in the Carnot cycle, which we will consider as in terms of the expansion and compression of an ideal gas.

- From A to B. An isothermal expansion, in which an amount of heat $Q_{H}$ is added to the gas.
- From B to C. An adiabatic expansion, in which no heat is exchanged and the temperature of the gas is lowered.
- From C to D. An isothermal compression, in which an amount of heat $Q_{L}$ is removed from the gas.
- From D to A. An adiabatic compression, returning the system to it's original high temperature state.

The work done in the first isothermal process is

$W_{AB}=nRT_{H}\ln\frac{V_{B}}{V_{A}}$

and as the process is isothermal this means that the heat added is equal to the work done.

$Q_{H}=nRT_{H}\ln\frac{V_{B}}{V_{A}}$

The heat lost in in the second isothermal process will be

$Q_{L}=nRT_{L}\ln\frac{V_{C}}{V_{D}}$

For the adiabatic processes

$P_{B}V_{B}^{\gamma}=P_{C}V_{C}^{\gamma}$ and $P_{D}V_{D}^{\gamma}=P_{A}V_{A}^{\gamma}$

and from the ideal gas law

$\frac{P_{B}V_{B}}{T_{H}}=\frac{P_{C}V_{C}}{T_{L}}$ and $\frac{P_{D}V_{D}}{T_{L}}=\frac{P_{A}V_{A}}{T_{H}}$

These equations can be used to eliminate the temperatures and show that

$\frac{V_{B}}{V_{A}}=\frac{V_{C}}{V_{D}}$

which can be used with the equations for the isothermal processes to show that

$\frac{Q_{L}}{Q_{H}}=\frac{T_{L}}{T_{H}}$

making the efficiency

$e=1-\frac{T_{L}}{T_{H}}$

Carnot's theorem generalizes the result we just derived by stating:

All reversible engines operating between two constant temperatures $T_{H}$ and $T_{L}$ have the same efficiency.

$e_{ideal}=1-\frac{T_{L}}{T_{H}}$

Any irreversible engine operating between the same two fixed temperatures will have a lower efficiency.

A four stroke car engine runs on a cycle that can be approximated by the Otto Cycle

In this cycle neither AB or CD are isothermal, but are rather adiabatic processes. BC and DA can be considered to be isovolumetric.

As the heat input and exhaust cycles occur at constant volume $Q_{H}=nc_{V,m}(T_{C}-T_{B})$ and $Q_{L}=nc_{V,m}(T_{D}-T_{A})$

and the efficiency of an Otto cycle is

$e=1-\frac{Q_{L}}{Q_{H}}=1-\frac{T_{D}-T_{A}}{T_{C}-T_{B}}$

Using the fact for an adiabatic process $PV^{\gamma}=\mathrm{constant}$ and for an ideal gas $P=\frac{nrT}{V}$ it can be shown that

$T_{A}V_{A}^{\gamma - 1}=T_{B}V_{B}^{\gamma - 1}$ and $T_{C}V_{C}^{\gamma - 1}=T_{D}V_{D}^{\gamma - 1}$

which combined with the fact that $V_{C}=V_{B}$ and $V_{A}=V_{D}$ gives (after some manipulation!)

$e=1-(\frac{V_{A}}{V_{B}})^{1-\gamma}$

We can produce refrigeration only by doing work, to do otherwise would violate the second law of thermodynamics. We can achieve refrigeration by going around one of the cycles we discussed earlier in the opposite direction.

The coefficient of performance, $COP$, of a refrigerator is defined as the heat removed $Q_{L}$ divided by the work done $W$. As before we apply the first law $Q_{L}+W=Q_{H}$ so

$COP=\frac{Q_{L}}{W}=\frac{Q_{L}}{Q_{H}-Q_{L}}$

As with a heat engine we can consider the Carnot cycle to be the ideal case, which means that for an ideal refrigerator

$COP=\frac{T_{L}}{T_{H}-T_{L}}$

Most household refrigerators run on a vapor compression cycle. Let's pretend that the steps in this process can be approximated as those in the Carnot cycle, and recall that we are going around the cycle in the reverse direction to when we use it to produce work. In this approximation the stages of the cycle in which heat transfer occurs are isothermal, but in fact this is very much not the case, for a refrigerator to work we actually rely on these stages to convert the refrigerant from liquid to vapor in the evaporator (due to the $Q_{L}$ added to the refrigerant) and from vapor to liquid in the condenser (due to the $Q_{H}$ removed from the refrigerant). In the compressor we do work on the gas, in the expansion valve the gas does work (but less than the compressor does).

The same cycle is the basis of air conditioning, though in this case the heat is removed from inside the house and dumped outside.