Chapter-2---Thermodynamics-and-statistical-_2023_Understanding-Molecular-Sim
Chapter-2---Thermodynamics-and-statistical-_2023_Understanding-Molecular-Sim
1 Simulations can also be used to test theoretical predictions, but such predictions also tend to
focus on reproducible properties, even though they may not always correspond to experimentally
accessible quantities.
either as a refresher, or as an incentive to learn more about the subject from the
many excellent textbooks.
In what follows, we present a brief overview of classical thermodynamics
and a quick (and slightly dirty) derivation of the basic expressions of statistical
mechanics. The aim of these derivations is only to show that there is nothing
mysterious about concepts such as phase space, temperature, entropy, and many
of the other statistical mechanical objects that will appear time and again in the
remainder of this book.
If you are familiar with thermodynamics, you may wish to skip the next
section. But remember the quote attributed to Sommerfeld:
“Thermodynamics is a funny subject. The first time you go through it, you don’t
understand it at all. The second time you go through it, you think you understand
it, except for one or two points. The third time you go through it, you know you
don’t understand it, but by that time you are so used to the subject, it doesn’t bother
you anymore.”
sustain a spontaneous heat flow in the “wrong” direction (e.g., if heat can flow
spontaneously from system A to system B, and from system B to system C,
then heat cannot flow spontaneously from C to A). How do we get from such
a seemingly trivial statement to something as abstract as entropy? This is most
easily achieved by introducing the concept of a reversible heat engine, i.e., an
engine that is completely free of internal dissipative energy losses.
A reversible engine is, as the word suggests, an engine that can be operated
in reverse. During one cycle (a sequence of steps that is completed when the
engine is returned to its original state) this engine takes in an amount of heat q1
from a hot reservoir, converts part of it into work w, and delivers a remaining
amount of heat q2 to a cold reservoir. The reverse process is that, by performing
an amount of work w, we can take an amount of heat q2 from the cold reservoir
and deliver an amount of heat q1 to the hot reservoir. Reversible engines are an
idealization because in any real engine, there will be additional frictional losses.
However, the ideal reversible engine can be approximated arbitrarily closely by
a real engine if, at every stage, the real engine is sufficiently close to equilibrium.
As the engine is returned to its original state at the end of one cycle, its internal
energy E has not changed. Hence, the First Law tells us that
E = q1 − (w + q2 ) = 0, (2.1.2)
or
q1 = w + q2 . (2.1.3)
Now consider the “efficiency”, η, of the engine η ≡ w/q1 —i.e., the amount
of work delivered per amount of heat taken in. At first, one might think that
η depends on the precise design of our reversible engine. However, this is not
true. η is the same for all reversible engines operating between the same two
reservoirs. To demonstrate this, we show that if different engines could have
different values for η then we would contradict the Second Law in its form
“heat can never spontaneously flow from a cold to a hot reservoir”. Suppose,
therefore, that we have another reversible engine that takes in an amount of heat
q1 from the hot reservoir, delivers the same amount of work w, and then delivers
an amount of heat q2 to the cold reservoir. Let us denote the efficiency of this
engine by η . Now, we use the work generated by the engine with the highest
efficiency (say η) to drive the second engine in reverse. The amount of heat
delivered to the hot reservoir by the second engine is
where we have used w = q1 η. As, by assumption, η < η it follows that q1 >
q1 . Hence there would be a net heat flow from the cold reservoir into the hot
reservoir. But this contradicts the Second Law of thermodynamics. Therefore
we must conclude that the efficiency of all reversible heat engines operating
between the same reservoirs is identical. The efficiency only depends on the
14 PART | I Basics
f (t2 )
R(t2 , t1 ) = , (2.1.6)
f (t1 )
where f (t) is an, as yet unknown function of our measured temperature. What
we do now is to introduce an “absolute” or thermodynamic temperature T given
by
T ≡ f (t). (2.1.7)
Then, it immediately follows that
q2 T2
= R(t2 , t1 ) = . (2.1.8)
q1 T1
Note that the thermodynamic temperature could just as well have been de-
fined as c × f (t). In practice, c has been fixed such that, around room temper-
ature, 1 degree in the absolute (Kelvin) scale is equal to 1 degree Celsius. But
that choice is, of course, purely historical and —as it will turn out later— a bit
unfortunate.
Why do we need all this? We need it to introduce entropy, the most mys-
terious of all thermodynamic quantities. To do so, note that Eq. (2.1.8) can be
written as
q1 q2
= , (2.1.9)
T1 T2
where q1 is the heat that flows in reversibly at the high temperature T1 , and q2
is the heat that flows out reversibly at the low temperature T2 . We see there-
fore that, during a complete cycle, the difference between q1 /T1 and q2 /T2 is
zero. Recall that, at the end of a cycle, the internal energy of the system has not
changed. Now Eq. (2.1.9) tells us that there is also another quantity, denoted by
S, which is unchanged when we restore the system to its original state. Follow-
ing Clausius, we use the name “entropy” for S.
In Thermodynamics, quantities such as S that are unchanged if we return a
system to its original state, are called state functions. We do not know what S is,
Thermodynamics and statistical mechanics Chapter | 2 15
but we do know how to compute its change. In the above example, the change in
S was given by S = (q1 /T1 ) − (q2 /T2 ) = 0. In general, the change in entropy
of a system due to the reversible addition of an infinitesimal amount of heat
δqrev from a reservoir at temperature T is
δqrev
dS = . (2.1.10)
T
We also note that S is extensive. That means that the total entropy of two
non-interacting systems, is equal to the sum of the entropies of the individual
systems. Consider a system with a fixed number of particles2 N and a fixed vol-
ume V . If we transfer an infinitesimal amount of heat δq to this system, then the
change in the internal energy of the system, dE is equal to δq. Hence,
∂S 1
= . (2.1.11)
∂E V ,N T
The most famous, though not the most intuitively obvious, statement of the Sec-
ond Law of Thermodynamics is that A spontaneous change in a closed system,
i.e., a system that exchanges neither energy nor particles with its environment,
can never lead to a decrease of the entropy. Hence, in equilibrium, the entropy of
a closed system is at a maximum. The argument behind this sweeping statement
is simple: consider a system with energy E, volume V and number of particles
N that is in equilibrium. We denote the entropy of this system by S0 (E, V , N ).
In equilibrium, all spontaneous changes that can happen, have happened. Now
suppose that we want to change something in this system —for instance, we
increase the density in one half of the system and decrease it in the other half.
As the system was in equilibrium, this change does not occur spontaneously.
Hence, in order to realize this change, we must perform a certain amount of
work, w (for instance, by placing a piston in the system and moving it). We
assume that this work is performed reversibly in such a way that E, the total
energy of the system, stays constant (and also V and N ). The First Law tells us
that we can only keep E constant if, while doing the work, we allow an amount
of heat q, to flow out of the system, such that q = w. Eq. (2.1.10) tells us that
when an amount of heat q flows reversibly out of the system, the entropy S of
the system must decrease. Let us denote the entropy of this constrained state by
S1 (E, V , N ) < S0 (E, V , N ). Having completed the change in the system, we
insulate the system thermally from the rest of the world, and we remove the
constraint that kept the system in its special state (taking the example of the
piston: we make an opening in the piston). Now the system goes back spon-
taneously (and irreversibly) to equilibrium. However, no work is done, and no
2 Thermodynamics does not assume anything about atoms or molecules. In thermodynamics, we
would specify the total mass (a macroscopic quantity) of a given species in the system, rather than
the number of particles. But when we talk about Statistical Mechanics or simulation techniques, we
will always specify the amount of matter in a system by the number of molecules. By doing the
same while discussing thermodynamics, we can keep the same notation throughout.
16 PART | I Basics
heat is transferred. Hence the final energy E is equal to the original energy (and
V and N are also constant). This means that the system is now back in its orig-
inal equilibrium state and its entropy is once more equal to S0 (E, V , N ). The
entropy change during this spontaneous change is equal to S = S0 − S1 . But,
as S1 < S0 , it follows that S > 0. As this argument is quite general, we have
indeed shown that any spontaneous change in a closed system leads to an in-
crease in the entropy. Hence, in equilibrium, the entropy of a closed system is at
a maximum.
We can now combine the First Law and the Second Law to arrive at an
expression for the energy change of a thermodynamic system. We consider an
infinitesimal reversible change in the system due to heat transfer and work. The
First Law states:
dE = q + w.
For a reversible change, we can write q = T dS. In the case of w, there are many
ways in which work can be performed on a system, e.g., compression, electrical
polarization, magnetic polarization, elastic deformation, etc. Here we will focus
on one such form of work, namely work due to a volume change against an
external pressure P . In that case, the work performed on the system during an
infinitesimal volume change dV is w = −P dV , and the First Law can be written
as
dE = T dS − P dV .
However, there is another, important way in which we can change the energy
of a system, namely by transferring matter into or out of the system. For conve-
nience, we consider a system containing only one species. As before, the number
of molecules of this species is denoted by N . As we (reversibly) change the num-
ber of molecules in the system at constant V and S, the energy of the system
changes: dE = μdN . This expression defines the constant of proportionality, μ,
the “chemical potential”
∂E
μ≡ . (2.1.12)
∂N S,V
We note that, for consistency with the rest of the book, we have defined the
chemical potential in terms of the number of molecules. In classical thermody-
namics, the chemical potential is defined as
∂E
μ thermo
≡ , (2.1.13)
∂n S,V
where n denotes the number of moles. The relation between the thermodynamic
μthermo and the molecular μ is simple:
μthermo = NA μ,
Thermodynamics and statistical mechanics Chapter | 2 17
E = T S − P V + μN . (2.1.16)
Enthalpy
For instance, if we use S, P , and N as the independent variables we can carry
out a so-called Legendre transform, which allows us to replace the energy with
a new state function that is a function of S, P , and N . This function is called the
Enthalpy (H ), defined as H ≡ E + P V . Clearly
dH = dE + dP V = T dS − P dV + μdN + P dV + V dP = T dS + V dP + μdN,
(2.1.18)
showing that the independent variables controlling the enthalpy are S, P , and N .
FIGURE 2.1 An isolated system consisting of two boxes 1 and 2 that each have a fixed volume, the
two subsystems can exchange heat but the subsystem 2 is much larger than system 1 and therefore
acts as a heat bath.
Grand Potential
Finally, we can introduce the Grand Potential, , which is ≡ F − μN , satis-
fying
However, for homogeneous systems, we rarely use the symbol for the Grand
Potential, because, if the pressure of a system is well-defined, F − μN = −P V ,
we can replace by −P V .3
3 The pressure is not a convenient variable for describing the state of confined or porous systems.
For such systems, it is best to use ≡ F − μN .
20 PART | I Basics
must have
Stot = S1 + S2 ≥ 0. (2.1.22)
As the heat bath (subsystem 2) is much larger than subsystem 1, its tem-
perature T will not change when a small amount of energy is exchanged with
subsystem 1. Using dS = δqrev /T (Eq. (2.1.10)), we can then write:
E2
S2 = . (2.1.23)
T
As the total energy is conserved, (i.e., E2 = −E1 ), we can then write:
1
S1 + S2 = (T S1 − E1 ) ≥ 0. (2.1.24)
T
This equation expresses the condition for equilibrium in terms of the properties
of subsystem 1. The only effect of the heat bath is that it imposes the temperature
T . Note that the quantity that is varied in Eq. (2.1.24) is nothing else than the
Helmholtz free energy (see Eq. (2.1.19))
F1 (N, V , T ) ≡ E1 − T S1 .
Then the Second Law, in the form given by Eq. (2.1.24), implies that, for a
system in contact with a heat bath,
1
− F1 ≥ 0. (2.1.25)
T
In other words: when an N-particle system in a volume V is in contact with a
heat bath at a (positive) temperature T , then a spontaneous change can never
increase its Helmholtz free energy:
dF ≤ 0. (2.1.26)
Similarly, we can define two systems that can not only exchange of energy,
but also change their volumes in such a way that the total volume remains con-
stant (see Fig. 2.2). As before, the combined system is isolated and its total
volume is fixed. Then we can again apply the Second Law of thermodynam-
ics to the combined system. As system 2 is again assumed to be much larger
than system 1, its temperature and pressure do not change when the energy and
volume of system 1 change. The entropy change of system 2 is therefore given
by
E2 P V2
S2 = + . (2.1.27)
T T
As the total energy is conserved (E2 = −E1 ) and the total volume remains
constant (V2 = −V1 ), we can write for the total entropy change:
1
S1 + S2 = (T S1 − E1 − P V1 ) ≥ 0, (2.1.28)
T
Thermodynamics and statistical mechanics Chapter | 2 21
FIGURE 2.2 An isolated system consisting of two boxes 1 and 2 that can exchange heat and
change their volume in such a way that the total volume and energy remains constant. System 2 is
much larger compared to system 1 so it can act as a heat bath that exerts a constant pressure on
system 1.
or (dG)/T ≤ 0, where dG is the variation in the Gibbs free energy (Eq. (2.1.20)).
In this equation, we have again expressed the inequality in terms of the proper-
ties of system 1 only. A spontaneous change in a system at constant temperature
and pressure can never increase its Gibbs free energy.
E1 μN1
Stot = S1 + S2 = S1 − + ≥0 (2.1.29)
T T
or
(T S1 − E1 + μN1 )
Stot = ≥ 0, (2.1.30)
T
or, using Eq. (2.1.21), ≤ 0. Hence, at constant T , V , and μ, is at a mini-
mum in equilibrium.
22 PART | I Basics
We have now obtained the conditions for equilibrium for some of the condi-
tions of the greatest practical importance, namely:
dF = dE − dT S.
1 P μ
dS = dE + dV − dN
T T T
dF = −SdT − P dV + μdN
dG = −SdT + V dP + μdN
d = −SdT − P dV − N dμ . (2.1.32)
If we combine Eq. (2.1.33) with the expression for dS, Eq. (2.1.32), we obtain
1 1
=
T1 T2
P1 P2
=
T1 T2
μ1 μ2
= . (2.1.34)
T1 T2
The first condition implies thermal equilibrium between the two systems, i.e.,
T1 = T2 ≡ T . Then the second condition simply implies P1 = P2 , and the third
is μ1 = μ2 .4 Eq. (2.1.34) is the starting point for all free-energy-based calcula-
tions to locate the point where two systems (two phases) are in equilibrium (see
Chapter 8).
4 For a multicomponent mixture, the chemical potential μα of each component α in the mixture
must be equal in the two subsystems: μα1 = μα2 .
24 PART | I Basics
where xi is the partial derivative of the quantity X with respect to Ni , the number
of particles of species i, at constant P , T , and Nj :
∂X
xi ≡ .
∂Ni P ,T ,{Nj }
T si − P vi − ei μi 1 ∂G
= =− =− .
T T T ∂Ni P ,T ,{Nj }
many ways in which we can distribute the total energy over the two subsystems
such that E1 + E2 = E. For a given choice of E1 , the total number of degenerate
states of the system is 1 (E1 ) × 2 (E2 ). Note that the total number of states is
the product of the number of states in the individual systems. In what follows,
it is convenient to have a measure of the degeneracy of the subsystems that is
additive. A logical choice is to take the (natural) logarithm of the degeneracy.
Hence:
ln (E1 , E − E1 ) = ln 1 (E1 ) + ln 2 (E − E1 ). (2.2.1)
We assume that subsystems 1 and 2 can exchange energy. What is the most
likely distribution of the energy? We know that every energy state of the total
system is equally likely. But the number of eigenstates corresponding to a given
distribution of the energy over the subsystems depends very strongly on the
value of E1 . We wish to know the most likely value of E1 , that is, the one that
maximizes ln (E1 , E − E1 ). The condition for this maximum is that
∂ ln (E1 , E − E1 )
=0 (2.2.2)
∂E1 N,V ,E
Clearly, if initially, we put all energy in system 1 (say), there will be energy
transfer from system 1 to system 2 until Eq. (2.2.3) is satisfied. From that mo-
ment on, no net energy flows from one subsystem to the other, and we say
that the two subsystems are in (thermal) equilibrium. When this equilibrium
is reached, ln of the total system is at a maximum. This suggests that ln is
somehow related to the thermodynamic entropy S of the system. As we have
seen in the previous section, the Second Law of thermodynamics states that the
entropy of a system N, V , and E is at its maximum when the system has reached
thermal equilibrium.
To establish the relation between ln and the entropy we could simply start
by assuming that the entropy is equal to ln and then check whether predictions
based on this assumption agree with experiment. If we do so, we find that the
answer is “not quite”: for (unfortunate) historical reasons (entropy already had
Thermodynamics and statistical mechanics Chapter | 2 27
units before statistical mechanics had been created), entropy is not simply equal
to ln ; rather we have
where kB is Boltzmann’s constant, which in S.I. units has the value 1.380649
10−23 J/K. With this identification, we see that our assumption that all degen-
erate eigenstates of a quantum system are equally likely immediately implies
that, in thermal equilibrium, the entropy of a composite system is at a maxi-
mum. It would be a bit premature to refer to this statement as the Second Law
of thermodynamics, as we have not yet demonstrated that the present definition
of entropy is, indeed, equivalent to the thermodynamic definition. We simply
take an advance on this result.
The next thing to note is that thermal equilibrium between subsystems 1 and
2 implies that β1 = β2 . In everyday life, we have another way to express the
same thing: we say that two bodies brought into thermal contact are in equilib-
rium if their temperatures are the same. This suggests that β must be related to
the absolute temperature. The thermodynamic definition of temperature is given
by Eq. (2.1.11), or
∂S
1/T = . (2.2.7)
∂E V ,N
If we use the same definition here, we find that
β = 1/(kB T ). (2.2.8)
2 (E − Ei )
Pi = . (2.2.9)
j 2 (E − Ej )
∂ ln 2 (E)
ln 2 (E − Ei ) = ln 2 (E) − Ei + O(1/E), (2.2.10)
∂E
28 PART | I Basics
If we insert this result in Eq. (2.2.9), and take the limit E → ∞, we get
exp(−Ei /kB T )
Pi = . (2.2.12)
j exp(−Ej /kB T )
where i|A|i denotes the expectation value of the operator A in quantum state
i. This equation suggests how we should go about computing thermal averages:
first we solve the Schrödinger equation for the (many-body) system of inter-
est, and next we compute the expectation value of the operator A for all those
quantum states that have a non-negligible statistical weight. Unfortunately, this
approach is doomed for all but the simplest systems. First of all, we cannot
hope to solve the Schrödinger equation for an arbitrary many-body system. And
second, even if we could, the number of quantum states that contribute to the
25
average in Eq. (2.2.15) would be so huge (O(1010 )) that a numerical evalua-
tion of all expectation values would be inconceivable. Fortunately, Eq. (2.2.15)
can be simplified to a more workable expression in the classical limit. To this
end, we first rewrite Eq. (2.2.15) in a form that is independent of the specific
basis set. We note that exp(−Ei /kB T ) = i| exp(−H/kB T )|i, where H is the
Hamiltonian of the system. Using this relation, we can write
i| exp(−H/kB T )A|i
A = i
j j | exp(−H/kB T )|j
Tr exp(−H/kB T )A
= , (2.2.16)
Tr exp(−H/kB T )
where Tr denotes the trace of the operator. As the value of the trace of an op-
erator does not depend on the choice of the basis set, we can compute thermal
averages using any basis set we like. Preferably, we use simple basis sets, such as
the set of eigenfunctions of the position or the momentum operator. Next, we use
the fact that the Hamiltonian H is the sum of a kinetic part K and a potential part
U. The kinetic energy operator is a quadratic function of the momenta of all par-
ticles. As a consequence, momentum eigenstates are also eigenfunctions of the
kinetic energy operator. Similarly, the potential energy operator is a function of
the particle coordinates. Matrix elements of U, therefore, are most conveniently
computed in a basis set of position eigenfunctions. However, H = K + U itself is
not diagonal in either basis set nor is exp[−β(K + U)]. However, if we could re-
place exp(−βH) by exp(−βK) exp(−βU), then we could simplify Eq. (2.2.16)
considerably. In general, we cannot make this replacement because
where [K, U] is the commutator of the kinetic and potential energy operators:
O([K, U]) stands for all terms containing commutators and higher-order com-
mutators of K and U. It is easy to verify that the commutator [K, U] is of order
( ≡ h/(2π), where h is Planck’s constant). Hence, in the limit → 0, we may
ignore the terms of order O([K, U]). In that case, we can write
If we use the notation |r for eigenvectors of the position operator and |k for
eigenvectors of the momentum operator, we can express Eq. (2.2.17) as
Tr exp(−βH) = r|e−β U |r r|k k|e−β K |k k|r. (2.2.18)
r,k
N
k| exp(−βK)|k = exp −β pi2 /(2mi ) ,
i=1
where d is the dimensionality of the system and the last line defines the classical
partition function. The factor 1/N ! corrects for the fact that any permutation of
indistinguishable particles corresponds to the same macroscopic state.5
Similarly, we can derive the classical limit for Tr exp(−βH)A, and finally,
we can write the classical expression for the thermal average of the observable
A as
2 N N N
dpN drN exp −β i pi /(2mi ) + U r A p ,r
A = . (2.2.20)
dpN drN exp −β j pj /(2mj ) + U r
2 N
Eqs. (2.2.19) and (2.2.20) constitute the starting points for a wide range of simu-
lations of classical many-body systems. Eqs. (2.2.19) and (2.2.20) are expressed
in terms of high-dimensional integrals over the dN momenta and dN coordi-
nates of all N particles, where d denotes the dimensionality of the system. The
2dN-dimensional space spanned by all momenta and coordinates is called phase
space.
2.3 Ensembles
In statistical mechanics as in thermodynamics, the state of the system is deter-
mined by a number of control parameters, some of them extensive (e.g., N , the
number of particles), some of them intensive (e.g., the pressure P or the tem-
perature T ). For historical reasons we denote the collection of all realizations
of a system, which are compatible with a set of control parameters by the name
“ensemble”. There are different ensembles for different sets of control parame-
ters. The historical names of these ensembles (“micro-canonical,” “canonical,”
“grand-canonical,” etc.) are not particularly illuminating. Below, we will list
these names when we describe the most frequently used ensembles. However,
in what follows, we will often denote ensembles by the control variables that
are kept constant, e.g., the “constant-N V E ensemble” or the “constant-μV T
ensemble”. In the following sections, we assume for convenience that the sys-
tem consists of particles with no internal degrees of freedom (i.e., no rotations,
vibrations, or electronic excitations). That assumption simplifies the notation,
but for molecular systems, we will of course have to take internal degrees of
freedom into account.
energy:
N
p2i
H= + U rN , (2.3.1)
2m
i=1
in which we have assumed that the potential energy does not depend on the
momenta p. The classical partition function in the micro-canonical ensemble is
the phase-space integral over a hyper-surface where the value of the Hamiltonian
is equal to the imposed value of the energy E.
The constraint that the system has to be on the hyper-surface H pN , rN =
E can be imposed via a δ-function, and hence for a three-dimensional system
(d = 3):
1
E,V ,N ≡ 3N dpN drN δ H pN , rN − E . (2.3.2)
h N!
1
QN,V ,T ≡ dpN drN exp −βH pN , rN . (2.3.3)
h3N N !
As the potential energy does not depend on the momenta of the system, the
integration over the momenta can be done analytically7
N 3N
p2i p2 2πm 3N/2
dp exp −β
N
= dp exp −β = .
2m 2m β
i=1
(2.3.4)
If we define the thermal Broglie wavelength as
h2
= , (2.3.5)
2πmkB T
1 1
Q (N, V , T ) = 3N N !
drN exp −βU rN ≡ 3N N !
Z (N, V , T ) ,
(2.3.6)
7 For molecular systems, in particular for systems of flexible molecules where bond lengths are
fixed by holonomic constraints (see section 14.1), the integration over momenta may result in a
Jacobian that depends on the coordinates of the nuclei in the molecule.
Thermodynamics and statistical mechanics Chapter | 2 33
Unlike the integral over momenta, the configurational integral can almost never
be computed analytically. The canonical partition function Q (N, V , T ) is re-
lated to the Helmholtz free energy, F , through
βF = − ln Q (N, V , T ) . (2.3.8)
1
A = drN A rN exp −βU rN . (2.3.9)
Z (N, V , T )
E − E1 P (V − V1 )
= ln (E, V , N2 ) + + + ··· ,
kB T kB T
(2.3.12)
where we have used Eq. (2.1.15), which relates the derivative of the entropy
with respect to energy and volume to 1/T and P /T , respectively. We can then
write the probability to find system 1 with an energy E1 and volume V1 as:
(E − E1 , V − V1 , N2 )
P (E1 , V1 , N1 ) =
j dV E − Ej , V − V , N2
E1 P V1
∝ exp − − . (2.3.13)
kB T kB T
Taking the classical limit, we obtain an expression for the N , P , T -partition
function, Q ≡ Q (N, P , T ), which is an integral over particle coordinates and
over the volume V :
βP
Q (N, P , T ) ≡ 3N dV exp (−βP V ) drN exp −βU rN ,
N!
(2.3.14)
where the factor βP has been included to make Q (N, P , T ) dimensionless.
From Eq. (2.3.14) we obtain the probability to find our system in a particular
configuration rN and volume V :
N rN ∝ exp −βP V − βU rN . (2.3.15)
FIGURE 2.3 An isolated system consisting of two boxes 1 and 2 that can exchange heat and
exchange particles in such a way that the total energy and number of particles remain constant.
System 2 is much larger compared to system 1, so it can act as a heat bath and buffer on system 1.
where we have used Eq. (2.1.15) to relate the derivative of the entropy with
respect to the number of particles to the chemical potential. It then follows that
the probability to find system 1 with an energy E1 and number of particles N1
is:
(E − E1 , V2 , N − N1 )
P (E − E1 , V2 , N − N1 ) = N
j M=0 E − Ej , V2 , N − M
E1 μN1
∝ exp − + . (2.3.18)
kB T kB T
The classical partition function now involves a summation of over all particles
in system 1. As the reservoir is much larger than system 1, we can replace the
upper limit of this summation by ∞:
36 PART | I Basics
∞
exp (βμN)
(μ, V , T ) ≡ 3N N !
drN exp −βU rN
N =0
∞
= exp (βμN) e−βF (N,V ,T ) , (2.3.19)
N =0
From Eqs. (2.3.19) and (2.3.8) it follows, using the maximum term method, that
− kB T ln = F − Nμ = , (2.3.21)
where is the grand potential defined in section 2.1.2. For homogeneous sys-
tems, we can replace by −P V .
2.4 Ergodicity
Thus far, we have discussed the average behavior of many-body systems in a
purely static sense: we introduced only the assumption that every quantum state
of a many-body system with energy E is equally likely to be occupied. Such
an average over all possible quantum states of a system is called an ensemble
average. However, this is not how we usually think about the average behavior
of a system. In most experiments, we perform a series of measurements during
a certain time interval and then determine the average of these measurements.
In fact, the idea behind Molecular Dynamics simulations is precisely that we
can study the average behavior of a many-particle system simply by comput-
ing the natural time evolution of that system numerically and then average the
quantity of interest over a sufficiently long time. To take a specific example, let
us consider a fluid consisting of atoms. Suppose that we wish to compute the
average density of the fluid at a distance r from a given atom i, ρi (r). Clearly,
the instantaneous density depends on the coordinates rj of all particles j in
the system. As time progresses, the atomic coordinates will change (according
to Newton’s equations of motion), and hence the density around atom i will
change. Provided that we have specified the initial coordinates and momenta of
all atoms (rN (0), pN (0)), we know, at least in principle, the time evolution of
ρi (r; rN (0), pN (0), t).
In a standard Molecular Dynamics simulation, we measure the time-
averaged density ρi (r) of a system of N atoms, in a volume V , at a constant
total energy E:
1 t
ρi (r) = lim dt ρi (r; t ). (2.4.1)
t→∞ t 0
Thermodynamics and statistical mechanics Chapter | 2 37
Note that, in writing down this equation, we have implicitly assumed that, for
t sufficiently long, the time average does not depend on the initial conditions.
This is, in fact, a subtle assumption that is not true in general (see e.g., [53]).
However, we shall disregard subtleties and simply assume that, once we have
specified N , V , and E, time averages do not depend on the initial coordinates
and momenta. If that is so, then we would not change our result for ρi (r) if we
average over many different initial conditions; that is, we consider the hypothet-
ical situation where we run a large number of Molecular Dynamics simulations
at the same values for N , V , and E, but with different initial coordinates and
momenta,
1 t N
lim dt ρi r; r (0), pN (0), t
t→∞ t 0
initial conditions
ρi (r) = . (2.4.2)
number of initial conditions
We now consider the limiting case where we average over all initial conditions
compatible with the imposed values of N , V , and E. In that case, we can replace
the sum over initial conditions with an integral:
f rN (0), pN (0) N
N N N
initial conditions E dr dp f r (0), p (0)
→ , (2.4.3)
number of initial conditions (N, V , E)
Note that the second line in Eq. (2.4.3) is nothing else than the micro-canonical
(constant-N V E) average of f . In what follows, we denote an ensemble average
by · · · to distinguish it from a time average, denoted by a bar. If we switch the
order of the time averaging and the averaging over initial conditions, we find
1 t
ρi (r) = lim dt ρi r; rN (0), pN (0), t . (2.4.4)
t→∞ t 0 NV E
However, the ensemble average in this equation does not depend on the time
t . This is so because there is a one-to-one correspondence between the ini-
tial phase-space coordinates of a system and those that specify the state of
the system at a later time t (see e.g., [53,54]). Hence, averaging over all ini-
tial phase-space coordinates is equivalent to averaging over the time-evolved
phase-space coordinates. For this reason, we can leave out the time averaging in
Eq. (2.4.4), and we find
ρi (r) = ρi (r)N V E . (2.4.5)
This equation states that, if we wish to compute the average of a function of the
coordinates and momenta of a many-particle system, we can either compute that
quantity by time averaging (the “MD” approach) or by ensemble averaging (the
38 PART | I Basics
“MC” approach). It should be stressed that the preceding paragraphs are meant
only to make Eq. (2.4.5) plausible, not as a proof. In fact, that would have been
quite impossible because Eq. (2.4.5) is not true in general. However, in what
follows, we shall simply assume that the “ergodic hypothesis”, as Eq. (2.4.5) is
usually referred to, applies to the systems that we study in computer simulations.
The reader should be aware that there are many examples of systems that are not
ergodic in practice, such as glasses and metastable phases, or even in principle,
such as nearly harmonic solids.
Taking again the example of the electric polarization, we can compute the
change in dipole moment of a system due to an applied field Ex :
∂Mx
Mx = Ex = βEx Mx2 − Mx 2 . (2.5.4)
∂Ex Ex =0
= N (μix )2
N μ2
= ,
3
and hence,
Mx μ2 ρ
Px ≡ = Ex . (2.5.5)
V 3kB T
Of course, this example is special because it can be evaluated exactly. But, in
general, we can compute the expression (2.5.3) for the susceptibility, only nu-
merically. It should also be noted that, actually, the computation of the dielectric
susceptibility is quite a bit more subtle than suggested in the preceding exam-
ple. The subtleties are discussed in the book by Allen and Tildesley [21] and the
contribution of McDonald in [44]).
where A(t) is the value of A at time t if the system started at point in phase
space and then evolved according to the natural time evolution of the unper-
turbed system. For convenience, we have assumed that the average of A in the
unperturbed system vanishes. In the limit λ → 0, we can write
d exp[−βH0 ]BA(t)
A(t) = βλ
d exp[−βH0 ]
= βλ B(0)A(t) . (2.5.8)
1 t0
B(0)A(t) ≡ lim dτ A rN (τ ), pN (τ ) B rN (t + τ ), pN (t + τ ) ,
t0 →∞ t0 0
(2.5.9)
where {rN (x), pN (x)} denotes the phase-space coordinates at time x. Note that
the time evolution of {rN (x), pN (x)} is determined by the unperturbed Hamil-
tonian H0 .
To give a specific example, consider a gas of dipolar molecules again in
the presence of a weak electric field Ex . The perturbation is equal to −Ex Mx .
At time t = 0, we switch off the electric field. When the field was still on, the
system had a net dipole moment. When the field is switched off, this dipole
moment decays:
Mx (t) = Ex β Mx (0)Mx (t) . (2.5.10)
In words, the decay of the macroscopic dipole moment of the system is de-
termined by the dipole autocorrelation function, which describes the decay of
spontaneous fluctuations of the dipole moment in equilibrium. This relation be-
tween the decay of the response to an external perturbation and the decay of
fluctuations in equilibrium is an example of Onsager’s regression hypothesis.
42 PART | I Basics
To linear order in f (t), the most general form of the response of a mechanical
property A to this perturbation is
∞
A(t) = dt χAB (t, t )f (t ), (2.5.12)
−∞
where χAB , the “after-effect function”, describes the linear response. We know
several things about the response of the system that allow us to simplify
Eq. (2.5.12). First of all, the response must be causal; that is, there can be no
response before the perturbation is applied. As a consequence,
Once we know χ, we can compute the linear response of the system to an arbi-
trary time-dependent perturbing field f (t). To find an expression for χAB , let us
consider the situation described in Eq. (2.5.8), namely, an external perturbation
that has a constant value λ until t = 0 and 0 from then on. From Eq. (2.5.14), it
follows that the response to such a perturbation is
0
A(t) = λ dt χAB (t − t )
−∞
∞
=λ dτ χAB (τ ). (2.5.15)
t
If we compare this expression with the result of Eq. (2.5.8), we see immediately
that
∞
λ dτ χAB (τ ) = βλ B(0)A(t) (2.5.16)
t
Thermodynamics and statistical mechanics Chapter | 2 43
or
−β B(0)Ȧ(t) for t >0
χAB (t) = (2.5.17)
0 for t ≤ 0.
H = H0 − Fx x. (2.5.18)
In the last line of Eq. (2.5.20), we used the stationarity property of time-
correlation functions:
d
A(t)B(t + t ) = 0. (2.5.21)
dt
Carrying out the differentiation, we find that
Ȧ(t)B(t + t ) = − A(t)Ḃ(t + t ) . (2.5.22)
Power spectra
Time-correlation functions are often computed (and also measured in spectro-
scopic experiments), by Fourier transforming from the frequency domain using
the Wiener-Khinchin (WK) theorem (see e.g., [53]).
To derive the WK theorem, we first define the Fourier transform of the ob-
servable of interest over time interval T
T
â(ω) ≡ dt A(t)eiωt . (2.5.24)
0
Note that we define the Fourier transform over a finite time interval {0 − T},
because the simulation has a finite length. We now define GA (ω), the power
spectrum of A, as
1
GA (ω) ≡ lim |â(ω)|2 (2.5.25)
T→∞ 2πT
1 T T
= lim dt dt A(t)A(t ) eiωt e−iωt
T→∞ 2πT 0 0
1 T T−t
= lim dt dt − t A(0)A(t − t ) eiω(t−t ) ,
T→∞ 2πT 0 −t
where we have used the fact that an equilibrium time correlation function only
depends on the time difference t − t . When T is much longer than the time
it takes the correlation function to decay, we can now write (in the limit that
T → ∞):
1 ∞
GA (ω) = dτ A(0)A(τ ) eiωτ , (2.5.26)
2π −∞
− ln [Q (N, V , T )]
F= ,
β
one can derive all thermodynamic properties. Show this by deriving equations
for U , p, and S.
Question 3 (Ideal gas (Part 1)). The canonical partition function of an ideal
gas consisting of monoatomic particles is equal to
1 VN
Q (N, V , T ) = d exp [−βH ] = ,
h3N N ! λ3N N !
√
in which λ = h/ 2πm/β and d = dq1 · · · dqN dp1 · · · dpN .
Derive expressions for the following thermodynamic properties:
• F (N, V , T ) (hint: ln (N !) ≈ N ln (N ) − N )
• p (N, V , T ) (which leads to the ideal gas law)
• μ (N, V , T ) (which leads to μ = μ0 + RT ln ρ)
• U (N, V , T ) and S (N, V , T )
• Cv (heat capacity at constant volume)
• Cp (heat capacity at constant pressure)
46 PART | I Basics
Question 4 (Van der Waals equation of state). The van der Waals equation of
state describes the behavior of non-ideal gasses.
RT a
P= − 2,
v−b v
where R is the gas constant. Show that the constants a and b can be related to
the critical point:
27 R 2 Tc2
a=
64 Pc
1 RTc
b= .
8 Pc
In this book, we will use the Lennard-Jones fluid very often. The critical point
of the Lennard Jones fluid is Tc = 1.32, ρc = 0.32 (molecules per unit volume),
and Pc = 0.131 [63]. These constants are expressed in reduced units (see sec-
tion 3.3.2.5).
Plot the equation of state (pressure as a function of the molar volume for
T = 2.00 and T = 1.00.
Question 5 (Fugacity). In most Chemical Engineering textbooks, the chemical
potential is replaced by the fugacity, f .
f
βμ − βμ0 = ln ,
f0
dE = q + w ,
10 Note that for an ideal gas, P = ρk T . We can therefore also write = f/(ρ k T ). In the rest
B id B
of the book, we use this relation to define the fugacity through = f /ρid . Note that f = f/kB T .
In what follows, we drop the prime.
Thermodynamics and statistical mechanics Chapter | 2 47
where q and w denote the (infinitesimal) energy changes of the system due to
heat flow and work, respectively. In the case of reversible changes, we can use
the First and Second Laws together, to express how the different state functions
(E, S, F , G, · · · ) change in a reversible transformation. The best-known expres-
sion is
dE = T dS − P dV + μdN ,
or, in terms of the Helmholtz free energy F :
This expression for dF applies to the case where the reversible work is due to
a change of the volume against an external pressure P . However, we can also
consider other forms of work, for instance, due to changing the polarization of
a system at a constant applied electric field, or to changing the surface area A
at constant surface tension γ . Here, we consider the latter case:
dF = −SdT + γ dA − P dV + μdN.
1. We will assume that both V and A are linear in N . Making use of the fact
that the free energy of a system is extensive, show that
F = μN − P V + γ A
(∂Fs /∂A)N,V ,T = γ ?
N
U =− H si − J si sj ,
i=1 i>j
where J is called the coupling constant (J > 0) and si = ±1. The second sum-
mation is a summation over all pairs (d × N for a periodic system, d is the
dimensionality of the system). This system is called the Ising model.
48 PART | I Basics
1. Show that for positive J , and H = 0, the lowest energy of the Ising model is
equal to
U0 = −dN J .
2. Show that the free energy per spin of a 1d Ising model with zero field is equal
to
F (β, N) ln (2 cosh (βJ ))
=−
N β
when N → ∞. The function cosh (x) is defined as
exp [−x] + exp [x]
cosh (x) = . (2.6.1)
2
3. Derive equations for the energy and heat capacity of this system.
Question 8 (The photon gas). An electromagnetic field in thermal equilibrium
can be described as a photon gas. From the quantum theory of the electromag-
netic field, it is found that the total energy of the system (U ) can be written as
the sum of photon energies:
N
N
U= nj ω j = n j j
j =1 j =1
Hint: you will have to use the following identity for | x |< 1:
i=∞
1
xi = . (2.6.3)
1−x
i=0
Question 9 (Ideal gas (Part 2)). An ideal gas is placed in a constant gravita-
tional field. The potential energy of N gas molecules at height z is Mgz, where
M = mN is the total mass of N molecules, and g the gravitational acceleration.
The temperature in the system is uniform, and the system is infinitely large. We
assume that the system is locally in equilibrium, so we are allowed to use a local
partition function.
1. Show that the grand-canonical partition function of a system in volume V at
height z is equal to
∞
exp [βμN]
Q (μ, V , T , z) = d exp [−β (H0 + Mgz)] (2.6.6)
h3N N !
N =0
(Hint: you will need the formula for the chemical potential of an ideal gas.)
Exercise 1 (Distribution of particles). Consider an ideal gas of N particles in a
volume V at constant energy E. Let us divide the volume into p identical compart-
ments. Every compartment contains ni molecules such that
i=p
N= ni . (2.6.8)
i=1
N!
P (n1 ) = . (2.6.9)
(N/2 − n1 )!(N/2 + n1 )!2N
Compare your numerical results with the analytical expression for different val-
ues of N . Show that this distribution is a Gaussian for small n1 /N . Hint: For
50 PART | I Basics
2I
q= (2.6.11)
β 2
for different temperatures. Note that the energy levels of a linear rotor are
2
U = J (J + 1) (2.6.12)
2I
with J = 0, 1, 2, · · · , ∞. The degeneracy of level J equals 2J + 1.
2. Compare your numerical result for the root mean-squared displacement with
the theoretical prediction (the computed function P (n, N ). What is the diffu-
sivity of this system?
3. Modify the program in such a way that the probability to jump in the forward
direction equals 0.8. What happens?
D ≈ D0 (1 − θ) .
Why is this equation reasonable at low densities? Why does it break down at
higher densities?
3. Modify the program in such a way that the probability of jumping in one direc-
tion is larger than the probability of jumping in the other direction. Explain the
results.
4. Modify the program in such a way that periodic boundary conditions are used in
one direction and reflecting boundary conditions in the other. What happens?