# Fundamental thermodynamic relation

Template:Laws of thermodynamics
In thermodynamics, the **fundamental thermodynamic relation** is a mathematical summation of the first law of thermodynamics and the second law of thermodynamics subsumed into a single concise mathematical statement as shown below:

- <math>dE= T dS - P dV\,</math>

Here, *E* is internal energy, *T* is temperature, *S* is entropy, *P* is pressure, and *V* is volume.

## Thermodynamic derivation

Starting from the first law:

- <math>dE = dQ - dW\,</math>

From the second law we have for a reversible process:

- <math>dS = dQ/T\,</math>

Hence:

- <math>dQ = TdS\,</math>

By substituting this into the first law, we have:

- <math>dE = TdS - dW\,</math>

Letting dW be reversible pressure-volume work, we have:

- <math>dU = T dS - P dV\,</math>

This has been derived in the case of reversible changes. However, since U, S and V are thermodynamic functions of state, the above relation holds also for non-reversible changes. If the system has more external variables than just the volume that can change and if the numbers of particles in the system can also change, the fundamental thermodynamic relation generalizes to:

- <math>dE = T dS - \sum_{i}X_{i}dx_{i} + \sum_{j}\mu_{j}dN_{j}\,</math>

Here the <math>X_{i}</math> are the generalized forces corresponding to the external variables <math>x_{i}</math>. The <math>\mu_{j}</math> are the chemical potentials corresponding to particles of type j.

## Derivation using the microcanonical ensemble

The above derivation can be criticized on the grounds that it merely defines a partitioning of the change in internal energy in heat and work in terms of the entropy. As long as we don't define the entropy in terms of the fundamental properties of the system, the fundamental law of thermodynamics is vacuous.

The entropy of an isolated system containing an amount of energy of <math></math>is defined as:

- <math>S = k \log\left[\Omega\left(E\right)\right]\,</math>

where <math>\Omega\left(E\right)</math> is the number of quantum states in a small interval between <math>E</math> and <math>E +\delta E</math>. Here <math>\delta E</math> is a macroscopically small energy interval that is kept fixed. Strictly speaking this means that the entropy depends on the choice of <math>\delta E</math>. However, in the thermodynamic limit (i.e. in the limit of infinitely large system size), the specific entropy (entropy per unit volume or per unit mass) does not depend on <math>\delta E</math>. The entropy is thus a measure of the uncertainty about exactly which quantum state the system is in, given that we know its energy to be in some interval of size <math>\delta E</math>.

The fundamental assumption of statistical mechanics is that all the <math>\Omega\left(E\right)</math> states are equally likely. This allows us to extract all the thermodynamical quantities of interest. The temperature is defined as:

<math>\frac{1}{k T}\equiv\beta\equiv\frac{d\log\left[\Omega\left(E\right)\right]}{dE}\,</math>

See here for the justification for this definition. Suppose that the system has some external parameter, x, that can be changed. In general, the energy eigenstates of the system will depend on x. According to the Adiabatic theorem of quantum mechanics, in the limit of an infinitely slow change of the system's energy eigenstates, the system will stay in the same energy eigenstate and thus change its energy according to the change in energy of the energy eigenstate it is in.

The generalized force, X, corresponding to the external variable x is defined such that <math>X dx</math> is the work performed by the system if x is increased by an amount dx. E.g., if x is the volume, then X is the pressure. The generalized force for a system known to be in energy eigenstate <math>E_{r}</math> is given by:

- <math>X = -\frac{dE_{r}}{dx}</math>

Since the system can be in any energy eigenstate within an interval of <math>\delta E</math>, we define the generalized force for the system as the expectation value of the above expression:

- <math>X = -\left\langle\frac{dE_{r}}{dx}\right\rangle\,</math>

To evaluate the average, we partition the <math>\Omega\left(E\right)</math> energy eigenstates by counting how many of them have a value for <math>\frac{dE_{r}}{dx}</math> within a range between <math>Y</math> and <math>Y + \delta Y</math>. Calling this number <math>\Omega_{Y}\left(E\right)</math>, we have:

- <math>\Omega\left(E\right)=\sum_{Y}\Omega_{Y}\left(E\right)\,</math>

The average defining the generalized force can now be written:

- <math>X = -\frac{1}{\Omega\left(E\right)}\sum_{Y} Y\Omega_{Y}\left(E\right)\,</math>

We can relate this to the derivative of the entropy w.r.t. x at constant energy E as follows. Suppose we change x to x + dx. Then <math>\Omega\left(E\right)</math> will change because the energy eigenstates depend on x, causing energy eigenstates to move into or out of the range between <math>E</math> and <math>E+\delta E</math>. Let's focus again on the energy eigenstates for which <math>\frac{dE_{r}}{dx}</math> lies within the range between <math>Y</math> and <math>Y + \delta Y</math>. Since these energy eigenstates increase in energy by Y dx, all such energy eigenstates that are in the interval ranging from E - Y dx to E move from below E to above E. There are

- <math>N_{Y}\left(E\right)=\frac{\Omega_{Y}\left(E\right)}{\delta E} Y dx\,</math>

such energy eigenstates. If <math>Y dx\leq\delta E</math>, all these energy eigenstates will move into the range between <math>E</math> and <math>E+\delta E</math> and contribute to an increase in <math>\Omega</math>. The number of energy eigenstates that move from below <math>E+\delta E</math> to above <math>E+\delta E</math> is, of course, given by <math>N_{Y}\left(E+\delta E\right)</math>. The difference

- <math>N_{Y}\left(E\right) - N_{Y}\left(E+\delta E\right)\,</math>

is thus the net contribution to the increase in <math>\Omega</math>. Note that if Y dx is larger than <math>\delta E</math> there will be the energy eigenstates that move from below E to above <math>E+\delta E</math>. They are counted in both <math>N_{Y}\left(E\right)</math> and <math>N_{Y}\left(E+\delta E\right)</math>, therefore the above expression is also valid in that case.

Expressing the above expression as a derivative w.r.t. E and summing over Y yields the expression:

- <math>\left(\frac{\partial\Omega}{\partial x}\right)_{E} = -\sum_{Y}Y\left(\frac{\partial\Omega_{Y}}{\partial E}\right)_{x}= \left(\frac{\partial\left(\Omega X\right)}{\partial E}\right)_{x}\,</math>

The logarithmic derivative of <math>\Omega</math> w.r.t. x is thus given by:

- <math>\left(\frac{\partial\log\left(\Omega\right)}{\partial x}\right)_{E} = \beta X +\left(\frac{\partial X}{\partial E}\right)_{x}\,</math>

The first term is intensive, i.e. it does not scale with system size. In contrast, the last term scales as the inverse system size and will thus vanishes in the thermodynamic limit. We have thus found that:

- <math>\left(\frac{\partial S}{\partial x}\right)_{E} = \frac{X}{T}\,</math>

Combining this with

- <math>\left(\frac{\partial S}{\partial E}\right)_{x} = \frac{1}{T}\,</math>

Gives:

- <math>dS = \left(\frac{\partial S}{\partial E}\right)_{x}dE+\left(\frac{\partial S}{\partial x}\right)_{E}dx = \frac{dE}{T} + \frac{X}{T} dx\,</math>

which we can write as:

- <math>dE = T dS - X dx\,</math>