---
title: Entropy and temperature
heading: What temperature is, and why heat flows from hot to cold
eyebrow: B11 · Lesson 2 · Entropy and temperature
xp: 40
---

::: hook
Put a hot heat sink against a cool one and energy flows until they reach the same temperature. Why that direction, and what is the temperature that ends up equal? The answer comes from counting. Two systems sharing energy can split it in many ways, and each split has a multiplicity: the product of the two systems' counts. The split that maximizes it wins, overwhelmingly, and the condition for that maximum defines temperature. The logarithm of the multiplicity is **entropy**, and the second law of thermodynamics is just the statement that systems end up in their most probable macrostate.
:::

::: play
- Two Einstein solids, A and B, with $N_A$ and $N_B$ oscillators, share q energy quanta. The curve is the probability of each split, $q_A$ in A and the rest in B, proportional to $g_A(q_A)g_B(q - q_A)$.
- The peak sits where the quanta per oscillator are equal in the two solids: that's where their temperatures match.
- Make the solids larger (scale) with the same proportions. The peak stays put but narrows: for a real object it's so narrow that the split is effectively fixed.
:::
:::

```sim plot
view: graph
x: f = 0..1
y: P = 0..1.05
slider: NA = 10..90 step 5 = 30
slider: s = 1..100 = 1 log
plot: exp(s*((f*300 + NA)*ln(f*300 + NA) - f*300*ln(f*300 + 0.0000001) + ((1 - f)*300 + 100 - NA)*ln((1 - f)*300 + 100 - NA) - (1 - f)*300*ln((1 - f)*300 + 0.0000001) - ((3*NA + NA)*ln(3*NA + NA) - 3*NA*ln(3*NA) + (300 - 3*NA + 100 - NA)*ln(300 - 3*NA + 100 - NA) - (300 - 3*NA)*ln(300 - 3*NA)))) | samples: 1500 | label: probability of the split ÷ largest
marker: f = NA/100 | label: equal quanta per oscillator
readout: oscillators in A of 100 = NA
readout: system size, times = s
```

::: predict
## One joule of heat flows from a 400 K body to a 300 K body. By what factor does the total number of accessible microstates change?

- [ ] It halves
- [ ] It doesn't change
- [ ] It doubles
- [x] It multiplies by about $10^{2.6 \times 10^{19}}$

::: reveal
$\Delta S = \frac{1\text{ J}}{300\text{ K}} - \frac{1\text{ J}}{400\text{ K}}$ = 8.3 × 10⁻⁴ J/K. Dividing by k gives $\Delta\ln g = 6.0 \times 10^{19}$, so g grows by a factor $e^{6.0 \times 10^{19}} = 10^{2.6 \times 10^{19}}$. The reverse flow would shrink it by the same factor. Heat flowing from cold to hot on its own breaks no law of mechanics, but it's so improbable that it never happens.
:::
:::

::: nameit
## Thermal contact

Two systems exchanging energy, with $U_A + U_B$ fixed, have total multiplicity $g_A(U_A)g_B(U_B)$. The most probable split maximizes $\ln g_A + \ln g_B$:

$$\frac{\partial\ln g_A}{\partial U_A} = \frac{\partial\ln g_B}{\partial U_B}$$

## Entropy and temperature

Define the **entropy** and the **temperature** by

$$S = k\ln g, \qquad \frac1T = \left(\frac{\partial S}{\partial U}\right)_{N, V}$$

with k = 1.381 × 10⁻²³ J/K = 86.17 µeV/K. Then equilibrium means equal temperatures. (Thermal physics texts often use the dimensionless σ = ln g and the energy τ = kT; they carry the same information.)

## The second law

If $T_A > T_B$, moving energy dU from A to B changes the total entropy by $dU\left(\frac{1}{T_B} - \frac{1}{T_A}\right) > 0$. So heat flows from hot to cold, total entropy rises, and it stops changing only when the temperatures are equal. Heat Q entering a body at temperature T raises its entropy by Q/T.

## The Einstein solid

N oscillators sharing q quanta of energy ε each have $g = \binom{q + N - 1}{q}$. For large N and q, Stirling gives $S/k \approx (q + N)\ln(q + N) - q\ln q - N\ln N$, and then $\frac1T = \frac{1}{\varepsilon}\frac{\partial S}{\partial q}$ gives

$$kT = \frac{\varepsilon}{\ln(1 + N/q)}$$
:::

::: example
## An Einstein solid has quanta of 10 meV and an average of one quantum per oscillator. What's its temperature?

::: solution
1. **Temperature from the quanta.** With one quantum per oscillator on average,
   $$\begin{aligned} kT &= \frac{0.010}{\ln 2} \\ &= 14.4\ \text{meV} \end{aligned}$$
2. **Convert to kelvin.**
   $$\begin{aligned} T &= \frac{0.0144}{86.17 \times 10^{-6}} \\ &= 167\ \text{K} \end{aligned}$$
3. **With 0.1 quanta per oscillator.**
   $$kT = \frac{0.010}{\ln 11}$$
   and T = 48 K: the fewer quanta per oscillator, the colder.

**Answer:** the solid is at about 167 K (kT = 14.4 meV).
:::
:::

::: example
## Find the entropy change when 1 J flows from 400 K to 300 K.

::: solution
1. **What each body does.** The hot body loses $\frac{1}{400}$ J/K and the cold one gains $\frac{1}{300}$ J/K.
2. **Net change.**
   $$\begin{aligned} \Delta S &= \frac{1}{300} - \frac{1}{400} \\ &= 8.3 \times 10^{-4}\ \text{J/K} \end{aligned}$$
3. **In units of k.** This is the natural log of the factor by which the number of microstates grows:
   $$\frac{\Delta S}{k} = 6.0 \times 10^{19}$$

**Answer:** the total entropy rises by $8.3 \times 10^{-4}$ J/K, or $6.0 \times 10^{19}$ in units of k.
:::
:::

::: example
## A 1 kg copper block (c = 385 J/(kg·K)) at 350 K is dropped into a lake at 290 K. What's the total entropy change?

::: solution
1. **The block.** Its temperature changes, so integrate:
   $$\begin{aligned} \Delta S_{block} &= mc\ln\frac{T_f}{T_i} \\ &= 385\ln\frac{290}{350} \\ &= -72.40\ \text{J/K} \end{aligned}$$
2. **Heat into the lake.**
   $$\begin{aligned} Q &= mc\,\Delta T \\ &= 385 \times 60 \\ &= 23\,100\ \text{J} \end{aligned}$$
3. **The lake.** It receives that heat at a fixed 290 K:
   $$\begin{aligned} \Delta S_{lake} &= \frac{23\,100}{290} \\ &= 79.66\ \text{J/K} \end{aligned}$$
4. **Total.**
   $$\begin{aligned} \Delta S &= -72.40 + 79.66 \\ &= +7.26\ \text{J/K} \end{aligned}$$
5. **Why it's positive.** The block loses entropy, but the lake gains more, because the heat arrives at the lake's lower temperature. Every real heat flow across a temperature difference ends with a positive total like this.

**Answer:** the total entropy rises by 7.26 J/K.
:::
:::

::: check
given: Q = 1 | 10 | 100; H = 350 | 500; L = 280 | 300
answer: Q/L - Q/H
unit: J/K
tolerance: 0.5%

## {Q} J of heat flows from a body at {H} K to one at {L} K. What's the total entropy change?

::: right
Right. $\frac{Q}{T_L} - \frac{Q}{T_H}$ = {answer} J/K.
:::

::: misses
- [Q/H - Q/L] That's negative; the flow from hot to cold raises the total entropy.
- [Q/L] Include the hot body's loss.
- [any] Not yet. Each body changes by ±Q/T.
:::
:::

::: check
given: e = 5 | 10 | 25; r = 0.1 | 0.5 | 2
answer: e/1000/(0.000086173*ln(1 + 1/r))
unit: K
tolerance: 0.5%

## An Einstein solid has quanta of {e} meV and {r} quanta per oscillator on average. What's its temperature?

::: right
Right. $kT = \frac{\varepsilon}{\ln(1 + N/q)}$ gives {answer} K.
:::

::: misses
- [e/1000/(0.000086173*ln(1 + r))] Use N/q, oscillators per quantum.
- [any] Not yet. k = 86.17 µeV/K.
:::
:::

::: check
given: g = 20 | 100 | 1000
answer: g*ln(10)*1.380649e-23
unit: J/K
tolerance: 0.5%

## A system has $10^{\given{g}}$ accessible microstates. What's its entropy?

::: right
Right. $S = k\ln g = k \times$ {g} ln 10 = {answer} J/K.
:::

::: misses
- [g*1.380649e-23] Use the natural log: ln 10 = 2.303.
- [any] Not yet. S = k ln g.
:::
:::

::: check
given: U = 0.01 | 0.1; S = 0.00002 | 0.0001
answer: U/S
unit: K
tolerance: 0.5%

## Adding {U} J to a system raises its entropy by {S} J/K. What's its temperature (assume the change is small)?

::: right
Right. $T = \frac{\Delta U}{\Delta S}$ = {answer} K.
:::

::: misses
- [S/U] Temperature is $\left(\frac{\partial S}{\partial U}\right)^{-1}$.
- [any] Not yet. $\frac1T = \frac{\partial S}{\partial U}$.
:::
:::

::: check
given: q = 300 | 1000; a = 20 | 30; b = 60 | 120
answer: q*a/(a + b)
tolerance: 0.5%

## Two Einstein solids with {a} and {b} oscillators share {q} quanta. At equilibrium, how many quanta does the first hold (most probable value, large-system limit)?

::: right
Right. Equal quanta per oscillator: $q\frac{N_A}{N_A + N_B}$ = {answer}.
:::

::: misses
- [q/2] The larger solid takes a larger share.
- [any] Not yet. Equal temperatures means equal q/N.
:::
:::

::: check
given: Q = 0.000001 | 0.001; T = 4 | 300
answer: Q/(1.380649e-23*T*ln(10))
tolerance: 0.5%

## A body at {T} K absorbs {Q} J. By what power of ten does its number of microstates grow?

::: right
Right. $\Delta\ln g = \frac{Q}{kT}$, so $\log_{10}$ grows by {answer}.
:::

::: misses
- [Q/(1.380649e-23*T)] That's the natural log; divide by ln 10.
- [any] Not yet. $\Delta S = Q/T$ and S = k ln g.
:::
:::

::: check
kind: parts
given: m = 0.1 | 1; c = 385 | 900; H = 350 | 400; L = 280 | 300

## A {m} kg block with specific heat {c} J/(kg·K) at {H} K is put in contact with a large reservoir at {L} K.

::: part
answer: m*c*ln(L/H)
unit: J/K
tolerance: 0.5%

### What's the block's entropy change?

::: misses
- [-m*c*(H - L)/L] The block's temperature changes as it cools; integrate $\frac{mc\,dT}{T}$.
- [any] $mc\ln\frac{T_f}{T_i}$.
:::
:::

::: part
answer: m*c*ln(L/H) + m*c*(H - L)/L
unit: J/K
tolerance: 0.5%

### What's the total entropy change?

::: misses
- [m*c*ln(L/H)] That's the block alone; add the reservoir's $\frac{Q}{T}$.
- [any] Add $\frac{mc(T_H - T_L)}{T_L}$.
:::
:::
:::

::: check
kind: derivation
vars: C = 1..1000, a = 200..400, b = 200..400

## Two bodies with the same heat capacity C, at temperatures a and b, are put in contact.

::: step
answer: (a + b)/2

### What's their final temperature?
:::

::: step
answer: C*ln((a + b)^2/(4*a*b))

### What's the total entropy change?
:::

::: right
Right. The arithmetic mean is never smaller than the geometric mean, so the total can't be negative, and it's zero only when the temperatures start equal.
:::
:::

::: explain
## Why does the condition for the most probable division of energy between two systems define a temperature?

::: model
When two systems share a fixed total energy, the number of microstates for a given split is the product of their separate counts. Moving a bit of energy from one to the other raises one count and lowers the other, and the product is largest where the fractional gain in one exactly balances the fractional loss in the other, that is, where $\frac{\partial\ln g}{\partial U}$ is the same for both. That quantity depends only on each system's own properties, and it's equal for any two systems that stop exchanging energy on average, which is exactly what we expect of temperature. Defining $\frac1T = k\frac{\partial\ln g}{\partial U}$ makes it agree with the thermometer scale, and it explains why energy flows toward the system where it adds the most microstates: the colder one.
:::
:::

::: practice

::: check
given: Q = 5 | 50; H = 400 | 600; L = 250 | 320
answer: Q/L - Q/H
unit: J/K
tolerance: 0.5%

## Entropy change for {Q} J flowing from {H} K to {L} K?

::: misses
- [any] $\frac{Q}{T_L} - \frac{Q}{T_H}$.
:::
:::

::: check
given: e = 8 | 40; r = 0.2 | 3
answer: e/1000/(0.000086173*ln(1 + 1/r))
unit: K
tolerance: 0.5%

## Einstein-solid temperature, ε = {e} meV, {r} quanta per oscillator?

::: misses
- [any] $kT = \frac{\varepsilon}{\ln(1 + N/q)}$.
:::
:::

::: check
given: g = 10 | 50 | 100 | 500 | 1000 | 5000
answer: g*ln(10)*1.380649e-23
unit: J/K
tolerance: 0.5%

## Entropy of $10^{\given{g}}$ microstates?

::: misses
- [any] $k\ln g$.
:::
:::
:::
