---
title: Free energy, pressure and the thermodynamic identity
heading: Energy against entropy, settled at fixed temperature
eyebrow: B11 · Lesson 4 · Free energy, pressure and the thermodynamic identity
xp: 45
---

::: hook
A system in contact with a reservoir doesn't simply minimize its energy, or the electrons in a semiconductor would all sit at the bottom of the valence band and crystals would have no defects. It doesn't simply maximize its entropy either. It minimizes a compromise, the **Helmholtz free energy** F = U − TS: energy costs, entropy pays, and temperature sets the exchange rate. That's why a silicon wafer at diffusion temperature holds a definite concentration of vacancies, why a stretched rubber band pulls back, and why every thermodynamic quantity can be read off one function, $F = -kT\ln Z$.
:::

::: play
- A two-level system (splitting Δ) in contact with a reservoir. The curves show, in units of Δ, its average energy U, its free energy F, and TS = U − F, against temperature.
- At low T, F ≈ U ≈ 0: energy wins and the system sits in its ground state. At high T the entropy term takes over; S approaches k ln 2, the entropy of two equally likely states.
- F always lies below U, and its slope is −S: entropy is how fast the free energy falls with temperature.
:::
:::

```sim plot
view: graph
x: T = 1..1500 K
y: E = -2..0.6
slider: D = 10..200 step 5 = 50 meV
plot: 1/(exp(D/(0.086173*T)) + 1) | label: U ÷ Δ
plot: -0.086173*T/D*ln(1 + exp(-D/(0.086173*T))) | label: F ÷ Δ
plot: 1/(exp(D/(0.086173*T)) + 1) + 0.086173*T/D*ln(1 + exp(-D/(0.086173*T))) | dashed | label: TS ÷ Δ
readout: S/k at 300 K = ln(1 + exp(-D/25.852)) + D/25.852/(exp(D/25.852) + 1)
readout: ln 2 = 0.693147
```

::: predict
## A crystal can lower its energy by having no vacancies at all. Why does a real crystal at 1100 °C have some?

- [ ] Vacancies lower the energy
- [x] Each vacancy costs energy but adds a great deal of entropy, so a small concentration minimizes F
- [ ] They're frozen in from the melt
- [ ] Pressure creates them

::: reveal
Placing n vacancies among N sites can be done $\binom{N}{n}$ ways, so the entropy gain from the first few is enormous while each costs a fixed energy $E_v$. Minimizing $F = nE_v - kT\ln\binom{N}{n}$ gives $\frac nN \approx e^{-E_v/kT}$. In silicon, with $E_v \approx 3.6$ eV, that's about $6 \times 10^{-14}$ at 1100 °C, a few billion vacancies per cm³, and they're how dopants diffuse.
:::
:::

::: nameit
## The thermodynamic identity

For a system whose energy depends on its entropy and volume,

$$dU = T\,dS - p\,dV$$

which defines the pressure as $p = -\left(\frac{\partial U}{\partial V}\right)_S$. Other work terms join in the same way: $+\mu\,dN$ for particles (lesson 16), $+V\,dQ$ for charge on a capacitor, $+f\,dx$ for a stretched spring.

## Helmholtz free energy

$$F = U - TS = -kT\ln Z, \qquad dF = -S\,dT - p\,dV$$

so

$$S = -\left(\frac{\partial F}{\partial T}\right)_V, \qquad p = -\left(\frac{\partial F}{\partial V}\right)_T, \qquad U = F + TS$$

At fixed T and V, a system in contact with a reservoir settles where F is smallest. That's the second law again: minimizing F is the same as maximizing the combined entropy of system plus reservoir.

## Entropic forces

When the energy doesn't change but the entropy does, the force comes from the entropy alone: $f = -\frac{\partial F}{\partial x} = T\frac{\partial S}{\partial x}$. A chain of N freely jointed links of length a, stretched by x, has $S \approx S_0 - \frac{kx^2}{2Na^2}$, so it pulls back with $f = \frac{kTx}{Na^2}$, stiffer when hotter. Rubber bands and DNA molecules behave this way; so does the pressure of an ideal gas, $p = \frac{NkT}{V}$.

## Independent parts

Since Z multiplies for independent parts, F adds. A two-level system has $F = -kT\ln(1 + e^{-\Delta/kT})$; N of them, N times that.
:::

::: example
## Find F and S for a two-level system with Δ = 50 meV at 300 K.

::: solution
1. **Gap over kT.**
   $$\frac{\Delta}{kT} = 1.934$$
2. **Free energy.**
   $$\begin{aligned} F &= -25.85\ln(1 + e^{-1.934}) \\ &= -3.49\ \text{meV} \end{aligned}$$
3. **Average energy.**
   $$\begin{aligned} U &= \frac{50}{e^{1.934} + 1} \\ &= 6.31\ \text{meV} \end{aligned}$$
4. **Entropy.** $S = \frac{U - F}{T}$, which in units of k is
   $$\begin{aligned} \frac{S}{k} &= \frac{6.31 + 3.49}{25.85} \\ &= 0.379 \end{aligned}$$
   about half the high-temperature limit ln 2 = 0.693.

**Answer:** F = −3.49 meV and S = 0.379k.
:::
:::

::: example
## A chain of 100 links, each 0.5 nm, is held stretched by 0.1 µm at 300 K. What force does it exert?

::: solution
1. **Entropic spring force.**
   $$\begin{aligned} f &= \frac{kTx}{Na^2} \\ &= \frac{4.14 \times 10^{-21} \times 10^{-7}}{100 \times 2.5 \times 10^{-19}} \\ &= 1.7 \times 10^{-11}\ \text{N} \\ &= 17\ \text{pN} \end{aligned}$$
2. **What that scale means.** That's the scale optical tweezers measure on single molecules, and it comes entirely from entropy.

**Answer:** the chain pulls with about 17 pN.
:::
:::

::: example
## A quantum oscillator has ħω = 25 meV. At 300 K, find its free energy, its average energy (both above the zero point) and its entropy.

::: solution
1. **Quantum over kT.** kT = 25.85 meV, so
   $$\begin{aligned} x &= \frac{\hbar\omega}{kT} \\ &= 0.967 \end{aligned}$$
2. **Partition function.** Above the zero point the levels are nħω, so
   $$Z = \frac{1}{1 - e^{-x}}$$
3. **Free energy.**
   $$\begin{aligned} F &= kT\ln(1 - e^{-x}) \\ &= 25.85 \times \ln 0.6198 \\ &= -12.37\ \text{meV} \end{aligned}$$
4. **Average energy.** This is an average of 0.613 quanta:
   $$\begin{aligned} U &= \frac{\hbar\omega}{e^x - 1} \\ &= \frac{25}{1.630} \\ &= 15.34\ \text{meV} \end{aligned}$$
5. **Entropy.** $S = \frac{U - F}{T}$, or in units of k,
   $$\begin{aligned} \frac{S}{k} &= \frac{15.34 + 12.37}{25.85} \\ &= 1.07 \end{aligned}$$
6. **Why F is negative.** The free energy is negative even though every energy is positive: F counts the many states the oscillator can wander among, and at this temperature that entropy term wins.

**Answer:** F = −12.37 meV, U = 15.34 meV and S = 1.07k.
:::
:::

::: check
given: D = 20 | 50 | 100; T = 100 | 300 | 600
answer: -0.086173*T*ln(1 + exp(-D/(0.086173*T)))
unit: meV
tolerance: 0.5%

## What's the free energy of a two-level system (states at 0 and {D} meV) at {T} K?

::: right
Right. $-kT\ln(1 + e^{-\Delta/kT})$ = {answer} meV.
:::

::: misses
- [D/(exp(D/(0.086173*T)) + 1)] That's U; F = U − TS is lower.
- [any] Not yet. F = −kT ln Z.
:::
:::

::: check
given: D = 20 | 50 | 100; T = 100 | 300 | 450
answer: ln(1 + exp(-D/(0.086173*T))) + D/(0.086173*T)/(exp(D/(0.086173*T)) + 1)
tolerance: 0.5%

## Same two-level system, {D} meV at {T} K: what's its entropy in units of k?

::: right
Right. $\frac{U - F}{kT}$ = {answer}.
:::

::: misses
- [ln(2)] That's the high-temperature limit.
- [any] Not yet. S = (U − F)/T.
:::
:::

::: check
given: E = 2.5 | 3.6 | 4.5; T = 1100 | 1400
answer: exp(-E/(0.000086173*T))
tolerance: 1%

## Vacancies cost {E} eV each. What fraction of sites are vacant at {T} K?

::: right
Right. $\frac nN \approx e^{-E_v/kT}$ = {answer}.
:::

::: misses
- [exp(-E/(0.000086173*T))*2] There's no factor of 2: minimize $nE_v - kT\ln\binom Nn$.
- [any] Not yet. Minimize F over n.
:::
:::

::: check
given: N = 50 | 200; a = 0.4 | 1; x = 20 | 80; T = 300 | 310
answer: 1.380649e-23*T*x*1e-9/(N*(a*1e-9)^2)*1e12
unit: pN
tolerance: 0.5%

## A freely jointed chain of {N} links of {a} nm is stretched by {x} nm at {T} K. What force does it exert?

::: right
Right. $\frac{kTx}{Na^2}$ = {answer} pN.
:::

::: misses
- [1.380649e-23*T*x*1e-9/(N*a*1e-9)*1e12] The mean square length is $Na^2$.
- [any] Not yet. $f = T\frac{\partial S}{\partial x}$.
:::
:::

::: check
given: n = 1e19 | 2.5e19; T = 77 | 300
answer: n*1e6*1.380649e-23*T
unit: Pa
tolerance: 0.5%

## A gas has {n} molecules per cm³ at {T} K. What's its pressure?

::: right
Right. p = nkT = {answer} Pa.
:::

::: misses
- [n*1.380649e-23*T] Convert cm⁻³ to m⁻³.
- [any] Not yet. $p = -\partial F/\partial V = NkT/V$.
:::
:::

::: check
kind: choice

## At fixed temperature and volume, a system in contact with a reservoir ends up where

- [ ] its energy is smallest
- [ ] its own entropy is largest
- [x] its free energy F = U − TS is smallest
- [ ] its pressure is zero

::: misses
- [1] That ignores entropy; real crystals have vacancies, gases fill their containers.
- [2] That ignores the reservoir's entropy, which falls when the system takes energy.
- [4] Pressure is whatever $-\partial F/\partial V$ gives.
:::
:::

::: check
kind: parts
given: D = 20 | 50; g = 2 | 4; T = 150 | 300

## A system has one state at 0 and {g} states at {D} meV, at {T} K.

::: part
answer: -0.086173*T*ln(1 + g*exp(-D/(0.086173*T)))
unit: meV
tolerance: 0.5%

### What's its free energy?

::: misses
- [-0.086173*T*ln(1 + exp(-D/(0.086173*T)))] Count all g upper states in Z.
- [any] $F = -kT\ln Z$.
:::
:::

::: part
answer: D*g*exp(-D/(0.086173*T))/(1 + g*exp(-D/(0.086173*T)))
unit: meV
tolerance: 0.5%

### What's its average energy?

::: misses
- [any] The upper level's share times its energy.
:::
:::

::: part
answer: (D*g*exp(-D/(0.086173*T))/(1 + g*exp(-D/(0.086173*T))))/(0.086173*T) + ln(1 + g*exp(-D/(0.086173*T)))
tolerance: 0.5%

### What's its entropy, in units of k?

::: misses
- [any] $\frac{S}{k} = \frac{U - F}{kT}$.
:::
:::
:::

::: check
kind: derivation
vars: E = 0.5..4, T = 300..1500

## N sites hold n vacancies, each costing E (eV). The free energy is $F = nE - kT\ln\binom{N}{n}$.

::: step
answer: exp(-E/(0.000086173*T))

### Setting dF/dn = E − kT ln((N − n)/n) = 0, what's n/(N − n)?
:::

::: step
answer: 1/(1 + exp(E/(0.000086173*T)))

### So what fraction n/N of sites is vacant?
:::

::: right
Right. When vacancies are rare, $N - n \approx N$ and the fraction is just the Boltzmann factor $e^{-E/kT}$.
:::
:::

::: explain
## Why does a system in contact with a reservoir minimize F = U − TS rather than its own energy?

::: model
The quantity that must be maximized is the total entropy of system plus reservoir. If the system gains energy U, the reservoir loses it and its entropy falls by U/T, while the system's own entropy is S. So the total entropy, apart from a constant, is $S - U/T = -\frac{U - TS}{T}$, and maximizing it at fixed T means minimizing F. Low energy is favored because it leaves more entropy in the reservoir; high entropy in the system is favored too, and the temperature sets how much energy one unit of entropy is worth. At low temperature energy wins, and at high temperature entropy does.
:::
:::

::: practice

::: check
given: D = 30 | 150; T = 200 | 800
answer: -0.086173*T*ln(1 + exp(-D/(0.086173*T)))
unit: meV
tolerance: 0.5%

## F of a two-level system, {D} meV at {T} K?

::: misses
- [any] $-kT\ln(1 + e^{-\Delta/kT})$.
:::
:::

::: check
given: E = 2 | 4; T = 900 | 1500
answer: exp(-E/(0.000086173*T))
tolerance: 1%

## Vacancy fraction, {E} eV at {T} K?

::: misses
- [any] $e^{-E_v/kT}$.
:::
:::

::: check
given: n = 3e18 | 5e19; T = 4 | 500
answer: n*1e6*1.380649e-23*T
unit: Pa
tolerance: 0.5%

## Pressure of {n} cm⁻³ at {T} K?

::: misses
- [any] nkT.
:::
:::
:::
