Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Intro to Statistical Ensembles

Microcanonical Ensemble (NVE)

  • A collection of all possible microscopic arrangements consistent with an equilibrium thermodynamic state is called statistical ensemble.

  • Ensemble defines sample space over microstates over which we define micro and macro-state probabilities

  • Consider an isolated fluid system with N=constN=const, V=constV=const and E=constE=const. This is called a microcanonical ensemble

  • In the absence of any physical constraints, no micro state is more probable than any other. This is known as “principle of equal a priory probability”.

<Figure size 1200x400 with 1 Axes>
  • We can use postulate of equal microstate probabilities and plug into probabilisti expression of entropy to obtain a simple relationship between number of microstates and entropy:

S=kBipilogpi=kBΩ1Ωlog1ΩS = -k_B \sum_i p_i log p_i = -k_B \Omega \cdot \frac{1}{\Omega} log \frac{1}{\Omega}

Simple example of NVE ensemble

  • Consider a system of three non-interacting spins, each of which can point either up (\uparrow) or down (\downarrow), and both orientations carry the same energy ϵ\epsilon. The total energy is therefore always E=Nϵ=3ϵE = N\epsilon = 3\epsilon, and the microcanonical ensemble is defined by N=3N=3, VV, and E=3ϵE=3\epsilon.

  • Because every spin state costs the same energy, all 23=82^3 = 8 configurations are microstates of this ensemble:

,,,,,,,\boxed{ \uparrow \uparrow \uparrow, \quad \uparrow \uparrow \downarrow, \quad \uparrow \downarrow \uparrow, \quad \downarrow \uparrow \uparrow, \quad \uparrow \downarrow \downarrow, \quad \downarrow \uparrow \downarrow, \quad \downarrow \downarrow \uparrow, \quad \downarrow \downarrow \downarrow}
  • There are Ω=23=8\Omega = 2^3 = 8 microstates, and the Boltzmann entropy is:

S=kBlog23=3kBlog2S = k_B \log 2^3 = 3k_B \log 2
  • For NN spins with equal energies, Ω=2N\Omega=2^N and entropy scales linearly (extensively) with system size NN:

S=NkBlog2S = Nk_B \log 2

Microcanonical partition function grows exponentially with system size

<Figure size 400x400 with 1 Axes>
  • To estimate how the number of microstates behave as a function of system size consider N N particles in a volume V V , and particle density ρ=NV\rho = \frac{N}{V}

  • Dividing the system into M=V/v M = V/v statistically independent subregions (each of volume vv) containing Ωsub \Omega_{\text{sub}} microstates each, we get:

Ω(E)=(Ωsub)M=(Ωsub1/ρv)N\Omega(E) = \left( \Omega_{\text{sub}} \right)^M = \left( \Omega^{1/\rho v}_{\text{sub}} \right)^N
  • We find that number of microstates grows exponentially with system size NN. This implies a large deviation property: entropy scales extensively and grows monotonically with energy.

Applications of NVE

Particles in a box

  • For a single quantum particle in a cubical box of side L L , the allowed energy levels are:

Enx,ny,nz(nx2+ny2+nz2)E_{n_x, n_y, n_z} \sim (n_x^2 + n_y^2 + n_z^2)
  • Where nx,ny,nz n_x, n_y, n_z are positive integers (quantum numbers).

  • To determine the number of microstates with total energy at most E E , we count the number of allowed quantum states (nx,ny,nz) (n_x, n_y, n_z) satisfying:

nx2+ny2+nz2En_x^2 + n_y^2 + n_z^2 \leq E
  • For large E E , this corresponds to counting integer lattice points inside a sphere of radius:

R=ER = \sqrt{E}
  • Since the number of points inside a sphere scales approximately as the volume of the sphere, we get:

Ω(E)43πR3E3/2\Omega(E) \approx \frac{4}{3} \pi R^3 \propto E^{3/2}
  • Thus, for a single particle, the number of accessible microstates grows as:

Ω(E)E3/2\Omega(E) \sim E^{3/2}
  • For N N independent particles, each particle contributes an independent set of quantum numbers, meaning we now count lattice points in a 3N 3N -dimensional hypersphere.

Ω(E)E3N/2\Omega(E) \sim E^{3N/2}
Source
# Create a combined figure
fig = plt.figure(figsize=(14, 6))

# ---------------- Plot 1: Scaling of Microstates ----------------
ax1 = fig.add_subplot(131)
E = np.linspace(1, 10, 200)

N=10

Omega = E**(1.5 * N)
ax1.plot(E, Omega, label=f"N = {N}", color='black', lw=3.5)

ax1.set_xlabel("Energy E")
ax1.set_ylabel(r"$\Omega(E) \sim E^{\frac{3N}{2}}$")
ax1.set_title("Scaling of $\Omega(E)$")
ax1.set_yscale('log')  # Logarithmic scale to better display the exponential growth
ax1.grid(True, linestyle='--', alpha=0.7)
ax1.legend()

# ---------------- Plot 2: Growth of Quantum States in 2D ----------------
ax2 = fig.add_subplot(132)
n_max = 15  # Reduce max quantum number for clarity
R_values = [5, 10, 15]
n_x_values = np.arange(1, n_max + 1)
n_y_values = np.arange(1, n_max + 1)

for n_x in n_x_values:
    for n_y in n_y_values:
        energy = n_x**2 + n_y**2
        if energy <= max(R_values)**2:
            ax2.scatter(n_x, n_y, color='black', s=10)

theta = np.linspace(0, 2 * np.pi, 300)
for R in R_values:
    ax2.plot(R * np.cos(theta), R * np.sin(theta), label=f'R = {R}', linewidth=1.5)

ax2.set_xlabel(r'$n_x$')
ax2.set_ylabel(r'$n_y$')
ax2.set_title('Quantum States Growth (2D)')
ax2.legend()
ax2.set_xlim(0, n_max)
ax2.set_ylim(0, n_max)
ax2.grid(True, linestyle='--', alpha=0.5)
ax2.set_aspect('equal')

# ---------------- Plot 3: 3D Representation of Quantum States ----------------
ax3 = fig.add_subplot(133, projection='3d')
n_max_3d = 10  # Reduce quantum number range for clarity

# Generate 3D quantum states
n_z_values = np.arange(1, n_max_3d + 1)
for n_x in np.arange(1, n_max_3d + 1):
    for n_y in np.arange(1, n_max_3d + 1):
        for n_z in np.arange(1, n_max_3d + 1):
            energy = n_x**2 + n_y**2 + n_z**2
            if energy <= max(R_values)**2:
                ax3.scatter(n_x, n_y, n_z, color='black', s=5)

ax3.set_xlabel(r'$n_x$')
ax3.set_ylabel(r'$n_y$')
ax3.set_zlabel(r'$n_z$')
ax3.set_title('Quantum States Growth (3D)')
ax3.view_init(elev=20, azim=45)

# Show the combined figure
plt.tight_layout()
plt.show()
<>:15: SyntaxWarning: invalid escape sequence '\O'
<>:15: SyntaxWarning: invalid escape sequence '\O'
/tmp/ipykernel_2926/3458926410.py:15: SyntaxWarning: invalid escape sequence '\O'
  ax1.set_title("Scaling of $\Omega(E)$")
<Figure size 1400x600 with 3 Axes>

Two state system

  • Given NN non-interacting spins where each spin can be up (\uparrow) with energy ϵ \epsilon or down (\downarrow) with energy 0 0 . The total energy is:

    E=nϵE = n\epsilon
  • Determine fraction of excited states f=nN=ENϵf=\frac{n}{N} = \frac{E}{N\epsilon} where nn is number of up spins. Show how this fraction changes with temperature

logΩ(E,N)=logN!n!(Nn)!=N!(E/ϵ)!(NE/ϵ)!log\Omega(E, N) = log \frac{N!}{n! (N-n)!} = \frac{N!}{(E/\epsilon)! (N-E/\epsilon)!}
  • Using Striling’s approximation logN!=NlogNNlogN!=NlogN-N we get:

logΩ(E,N)NlogNEϵlogEϵ(NEϵ)log(NEϵ)log\Omega(E, N) \approx N \log N - \frac{E}{\epsilon} \log \frac{E}{\epsilon} - \bigg(N - \frac{E}{\epsilon}\bigg) \log \bigg(N - \frac{E}{\epsilon}\bigg)
  • We connect number of excited states to equilibrium temperature via thermodynamics

1T=dSdE=kBdlogΩdE\frac{1}{T} = \frac{dS}{dE} = k_B \frac{d log\Omega}{dE}
1kBT=1ϵlogEϵ+1ϵlog(NEϵ)\frac{1}{k_BT} = - \frac{1}{\epsilon} \log \frac{E}{\epsilon} + \frac{1}{\epsilon} \log \bigg(N - \frac{E}{\epsilon}\bigg)
Eϵ=(NEϵ)eϵkBT\frac{E}{\epsilon} = \bigg(N - \frac{E}{\epsilon}\bigg) e^{-\frac{\epsilon}{k_B T} }
f=ENϵ=11+eϵkBTf = \frac{E}{N\epsilon} = \frac{1}{1 + e^{\frac{\epsilon}{k_B T} }}
  • This is the well-known Boltzmann factor result for a two-level system in thermal equilibrium. At high temperatures (kBTϵk_B T \gg \epsilon), approximately half the spins are excited (f1/2f \to 1/2). At low temperatures (kBTϵk_B T \ll \epsilon), the excited fraction vanishes exponentially: feϵ/kBT0f \approx e^{-\epsilon / k_B T} \to 0.

Source
import numpy as np
import scipy.special as sp
import matplotlib.pyplot as plt

# Create a figure with two subplots
fig, axes = plt.subplots(1, 2, figsize=(14, 6))

# Subplot 1: Growth of Ω(E) with Energy for Different Spin System Sizes
N_values = [10, 20, 50]  # Different spin system sizes

for N in N_values:
    energies = np.arange(0, N+1, 1)  # Possible energy levels
    multiplicities = sp.binom(N, energies)  # Compute binomial coefficient
    axes[0].plot(energies, multiplicities, label=f'N = {N}', linestyle='-', marker='o')

# Plot settings for first subplot
axes[0].set_yscale('log')  # Use logarithmic scale to highlight exponential growth
axes[0].set_xlabel(r'Total Energy $E$')
axes[0].set_ylabel(r'$\Omega(E)$ (Number of Microstates)')
axes[0].set_title(r'Growth of $\Omega(E)$ with Energy')
axes[0].legend()
axes[0].grid(True, which='both', linestyle='--')

# Subplot 2: Fraction of Particles in the Excited State vs. Temperature
epsilon = 1.0  # Set energy scale to 1 for simplicity
k_B = 1.0  # Boltzmann constant set to 1 for simplicity
T_values = [0.5, 1.0, 2.0, 5.0]  # Different temperature values

# Define function for fraction of excited particles
def fraction_excited(beta_epsilon):
    return 1 / (1 + np.exp(beta_epsilon))

# Generate beta_epsilon values
beta_epsilon_values = np.linspace(0, 5, 100)

# Plot f for different temperatures
for T in T_values:
    beta_epsilon = epsilon / (k_B * T) * beta_epsilon_values
    f_values = fraction_excited(beta_epsilon)
    axes[1].plot(beta_epsilon_values, f_values, label=f"T = {T}")

# Plot settings for second subplot
axes[1].set_xlabel(r"$\beta \epsilon$")
axes[1].set_ylabel(r"Fraction of Excited Particles $f$")
axes[1].set_title("Fraction of Particles in the Excited State")
axes[1].legend()
axes[1].grid(True, linestyle='--')

# Adjust layout
plt.tight_layout()
plt.show()
<Figure size 1400x600 with 2 Axes>

Energy partitioning in an isolated system

<Figure size 700x600 with 1 Axes>
  • ΩT(Et) \Omega_T(E_t) is the total number of microstates of the whole isoluate box divided into:

    • Ω(E) \Omega(E) number of microstates available to the system of interest

    • ΩR(ETE) \Omega_R(E_T - E) number of microstates available to the Reservoir

  • Since reservoir and system can be considered statistically independent, the probability of finding the system in a macrostate with energy EE is:

    p(E)=Ω(E)ΩR(EtE)ΩT(ET)p(E) = \frac{\Omega(E) \Omega_R(E_t - E)}{\Omega_T(E_T)}
  • This is a ratio of all microstate where system gets EE and reservoir EtEE_t-E energies divided by total number of microstates. The latter given as sum of all possible partitionings of energy

    Ωt(Et)=EΩ(E)ΩR(ETE)\Omega_t(E_t) = \sum_E \Omega(E) \Omega_R(E_T - E)
  • We can see that probability of macrostates is normalized EP(E)=1\sum_E P(E)=1. The system is more likely to be in a macrostate E E if there are more microstates that reaalize this partitioning.

<Figure size 1200x400 with 6 Axes>
Source
# Re-import necessary libraries since execution state was reset
import numpy as np
import matplotlib.pyplot as plt

# Define different system sizes
system_sizes = [(5, 10), (10, 20), (20, 40)]

# Define total energy
E_total = 5

# Create figure
plt.figure(figsize=(7, 6))

# Loop over different system sizes and plot
for N1, N2 in system_sizes:
    # Define energy range for system 1 (from 0 to E_total)
    E1_values = np.linspace(0.01, E_total, 50)  # Avoid E=0 to prevent singularities
    E2_values = E_total - E1_values  # Energy remaining for system 2

    # Compute microstates using Omega(E) ~ E^(3N/2)
    Omega1 = E1_values**(3 * N1 / 2)
    Omega2 = E2_values**(3 * N2 / 2)

    # Compute total number of microstates (product of subsystems)
    Omega_total = Omega1 * Omega2 / np.sum(Omega1 * Omega2)  # Normalize to get probability

    # Plot results
    plt.plot(E1_values, Omega_total, label=rf'$N_1={N1}, N_2={N2}$')

    # Draw vertical line at the peak (mean energy E = U)
    E_peak = E1_values[np.argmax(Omega_total)]
    plt.axvline(E_peak, color='black', linestyle=':', linewidth=2)

# Plot settings
plt.xlabel(r"Energy given to System: $E_1$")
plt.ylabel(r"$P(E_1)$")
plt.title("Probability Distribution of Energy Partitioning")
plt.legend()
plt.grid(True)

# Show plot
plt.show()
<Figure size 700x600 with 1 Axes>

Temperature is the driver of energy partitioning

  • Which partitioning is most likely? For two systems exchanging energy we can write down probability of macrostate and find its maxima with respect to EE

ddElogP(E)=ddE[logΩ(E)Ω2(ETE)]=0\frac{d }{dE}logP(E) = \frac{d }{dE} \bigg[ log\Omega(E)\Omega_2(E_{T}-E) \bigg]= 0
ddElogP(E)=[ddElogΩ1ddElogΩ2]=0\frac{d}{dE}logP(E) = \bigg[ \frac{d }{dE} log\Omega_1 - \frac{d}{dE}log\Omega_2 \bigg]= 0
  • Since logP(E)S(E)+SR(ETE)logP(E)\sim S(E)+S_R(E_T-E) we note that Maximizing probability of a macrostate is the same as maximizing entropy of macrostate!

  • We also come to appreciate that inverse temperature β=1kBT\beta=\frac{1}{k_BT}, quantifies rate of growth of microstates.

  • At lower temperatures β\beta is larger indicating faster growth of microstates. At higher temperatures β\beta is smaller indicating slower groth of microstates with addition of energy.

Thermal Equilibrium in Ideal Gases

  • For a system of non-interacting particles in a box, the number of microstates follows ΩE32N\Omega \sim E^{\frac{3}{2}N}. The entropy is defined as:

    StotalkBlogΩ1(E1)Ω2(EtotE1)=32NkBlogE1+32NkBlog(EE1)S_{\text{total}} \sim k_B \log \Omega_1(E_1)\Omega_2(E_{tot}-E_1) = \frac{3}{2} Nk_BlogE_1 + \frac{3}{2} Nk_Blog(E-E_1)
  • Maximizing entropy with respect to energy exchange between two subsystems E1E_1 gives use the equilibrium value U1U_1 that system gets.

    StotalE1E1=U1=32kBN1U132kBN2EU1=0.\frac{\partial S_{\text{total}}}{\partial E_1}\bigg|_{E_1=U_1} = \frac{3}{2} k_B \frac{N_1}{U_1} - \frac{3}{2} k_B \frac{N_2}{E-U_1} = 0.
  • Plugging the definition of temperature on left hand side which in equilibrium we see is equal for two systems exchangeing energy:

    1kBT=32N1U1=32N2U2.\frac{1}{k_B T} = \frac{3}{2} \frac{N_1}{U_1} = \frac{3}{2} \frac{N_2}{U_2}.
  • This leads to the well-known result that each degree of freedom receives 12kBT\frac{1}{2} k_B T of thermal energy:

    U=32NkBT.U = \frac{3}{2} N k_B T.
  • Solving for U1U_1 we also see that each system gets energy proportionate to its size

    U1=N1N1+N2EtotU_1 = \frac{N_1}{N_1 + N_2} E_{tot}

Constant temperature ensemble (NVT)

<Figure size 1200x400 with 1 Axes>
  • We start by considering an isolated box (NVENVE ensemble) inside which there is a system of interest which is exchanging energy with much larger reservoir or heat bath.

  • Using the fact that reservoir is much larger than the system EEt E \ll E_t we can taylor expand log of microstates (entropy) around EtE_t

p(E)=Ω(E)Ωr(EtE)Ωt(Et)p(E) = \frac{\Omega(E) \Omega_r(E_t - E)}{\Omega_t(E_t)}
logΩr(EtE)logΩr(Et)(logΩrE)E=constβElog\Omega_r(E_t-E) \approx log\Omega_r(E_t) - \bigg(\frac{\partial log \Omega_r}{\partial E} \bigg) E = const - \beta E
  • The first factor is a constant independent of energy the second factor in front of energy is recognize as inverse temperature β=dlogΩdE=1kBT\beta = \frac{dlog\Omega}{dE}=\frac{1}{k_BT}

  • We have now have an ensemble of microstates of systems specified by NVTNVT variables and and reservoir influence enters through temperature!

  • Ensemble of NVTNVT microstates has different energies that are exponentially distributed (price for borrowing energy from the bath).

Ωr(EtE)eβE\Omega_r(E_t - E) \sim e^{- \beta E}

Partition Functions and Thermodynamic limit

Z=EΩ(E)eβEcontinuum limitΩ(E)eβEdEZ = \sum_E \Omega(E)\, e^{-\beta E} \xrightarrow{\text{continuum limit}} \int \Omega(E)\, e^{-\beta E}\, dE
  • We find that microcanonical and canonical ensebles are linked via Laplace transform. Recall that EE and free energy FF via Legendre transform

  • This shows that when going from NVENVE to NVTNVT ensemble we are adopting a conveneint variable β\beta by replacing EE.

  • The number of states grows exponentially with system size N N , Ω(E)=eSkBeN \Omega(E) = e^{\frac{S}{k_B}} \sim e^{N} while the Boltzmann factor decays exponentially with energy eβEeNe^{-\beta E} \sim e^{-N}

  • The dominant contribution to the partition function comes from narrow region around ensemble average or equilibrium value of energy U=EU=\langle E\rangle. Deviations from average are xponentially negligble!

Source
import numpy as np
import matplotlib.pyplot as plt

# Define energy range
E = np.linspace(0, 10, 100)

# Define parameters
beta = 1.0  # Inverse temperature (1/kT)

# Compute the Boltzmann factor
Boltzmann_factor = np.exp(-beta * E)

# Increase the entropy prefactor to shift the peak to the right
S_prefactor_new = 2.5  # Larger prefactor makes entropy increase faster

# Recalculate entropy and probability density
S_new = S_prefactor_new * np.log(1 + E)
Probability_density_new = np.exp(S_new) * Boltzmann_factor

# Create the updated plot
plt.figure(figsize=(8, 6))

# Plot entropy (scaled for visualization)
plt.plot(E, S_new / max(S_new), label=r"Entropy $S(E)$ (scaled)", color="blue", linestyle="--")

# Plot Boltzmann factor (scaled for visualization)
plt.plot(E, Boltzmann_factor / max(Boltzmann_factor), label=r"Boltzmann Factor $e^{-\beta E}$ (scaled)", color="red", linestyle="--")

# Plot updated probability density (product of both)
plt.plot(E, Probability_density_new / max(Probability_density_new), label=r"Probability Density $\Omega(E) e^{-\beta E}$", color="black")

# Highlight new peak region
E_peak_new = E[np.argmax(Probability_density_new)]
plt.axvline(E_peak_new, color="green", linestyle=":", label="New Peak Region")

# Labels and title
plt.xlabel("Energy $E$")
plt.ylabel("Scaled Functions")
plt.title("Shifted Peak: Entropy Growth, Boltzmann Factor Decay, and Probability Density")
plt.legend()
plt.grid(True, linestyle="--", alpha=0.6)

# Show plot
plt.show()
<Figure size 800x600 with 1 Axes>

Examples of using NVT

non-interacting spins

  • Consider an ensemble of three non-interacting spins under constant temperature. The up spin has ϵ\epsilon and down spin 0 energy.

MicrostateConfigurationTotal Energy EEDegeneracy Ω(E)\Omega(E)
1\downarrow \downarrow \downarrow01
2\downarrow \downarrow \uparrowϵ\epsilon3
3\downarrow \uparrow \downarrowϵ\epsilon3
4\uparrow \downarrow \downarrowϵ\epsilon3
5\downarrow \uparrow \uparrow2ϵ2\epsilon3
6\uparrow \downarrow \uparrow2ϵ2\epsilon3
7\uparrow \uparrow \downarrow2ϵ2\epsilon3
8\uparrow \uparrow \uparrow3ϵ3\epsilon1
  • The partition function would be sum over all 23=82^3=8 microstaes.

Z=1+3eβϵ+3e2βϵ+e3βϵZ = 1+3e^{-\beta \epsilon}+ 3e^{-2\beta \epsilon}+e^{-3\beta \epsilon}
  • Probability of a microstate \downarrow \downarrow \uparrow is:

p2=eβϵZp_2 = \frac{e^{-\beta \epsilon}}{Z}
  • Probability of a macrostate E=ϵE=\epsilon is

P(E=ϵ)=3eβϵZP(E=\epsilon) = \frac{3e^{-\beta \epsilon}}{Z}

Two-state particles (NVT)

  • Consider a simple two-level system where lower level has energy 0 and upper level ϵ\epsilon. Determine how the fraction of excited states f=nNf=\frac{n}{N} changes with temperature.

  • Solving a two-state particle system in an NVT ensemble is much easier because the partition function decouples into single particle contributions.

Z=n=0n=NeβEn=(1+eβϵ)NZ = \sum^{n=N}_{n=0} e^{-\beta E_n} = (1+e^{-\beta \epsilon})^N
F=kBTlogZ=kBTNlog(1+eβϵ)F= -k_B T log Z = -k_BT N log(1+e^{-\beta \epsilon})
E=logZ(β)=Nϵ1+eβϵ\langle E \rangle = \frac{\partial log Z}{\partial (-\beta)} = \frac{N\epsilon}{1+e^{\beta \epsilon}}
f=ENϵ=11+eβϵf = \frac{E}{N\epsilon} = \frac{1}{1+e^{\beta \epsilon}}
  • We obtained same expression we got when using NVE but it tooks us less number of steps!

Free energy and macrostate probabilities

  1. Microstates: The relative population of microstates is dictated by the ratio of Boltzmann weights which depends on energy difference ΔE\Delta E

p1=eβE1Z=eβE1eβFp_1 = \frac{e^{-\beta E_1}}{Z} = \frac{e^{-\beta E_1}}{e^{-\beta F}}
p2p1=eβ(E2E1){\frac{p_2}{p_1} = e^{-\beta (E_2-E_1)}}
  1. Macrostates: Probability of macrostates with energy EAE_A is obtained by summing over all microstates with energy E_A or simply by multiplying by ΩA\Omega_A. The latter is related to entropy, which ends up turning the numerator into the free energy of a macrostate AA: FA=EATSAF_A = E_A-TS_A

pA=Ω(EA)eβEAZA=eβFAeβFp_A =\frac{\Omega (E_A) e^{-\beta E_A}}{Z_A} = \frac{e^{-\beta F_A}}{e^{-\beta F}}
  • The relative population of macrostates is dictated by the ratio of entropic term times Boltzmann weights which depends on free energy difference ΔF\Delta F

pBpA=eβ(FBFA){\frac{p_B}{p_A} = e^{-\beta (F_B-F_A)}}
Source
# Define reaction coordinate
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-2, 2, 400)

# Define a tilted asymmetric double-well free energy profile
F_x = 3 * (x**4 - 1.2*x**2) + 2 + 0.5*x  # Added tilt to shift one minimum

# Identify macrostates A and B based on regions left and right of the transition state (x=0)
x_A_region = x[x < 0]  # Left basin (macrostate A)
x_B_region = x[x > 0]  # Right basin (macrostate B)
F_A = np.min(F_x[x < 0])  # Free energy of macrostate A (left well minimum)
F_B = np.min(F_x[x > 0])  # Free energy of macrostate B (right well minimum)
ΔF = F_B - F_A  # Free energy difference

# Compute probability distribution P(X) from free energy F(X)
P_x = np.exp(-F_x)  # Exponential of negative free energy
P_x /= np.trapezoid(P_x, x)  # Normalize probability

# Create figure with side-by-side subplots: Free Energy and Probability Distribution
fig, axes = plt.subplots(1, 2, figsize=(12, 5), sharex=True)

# --- Free Energy Profile ---
axes[0].plot(x, F_x, label=r'Free Energy $F(X)$', color='b', linewidth=2)
axes[0].fill_between(x_A_region, F_x[x < 0], max(F_x), color='red', alpha=0.3, label="Macrostate A")
axes[0].fill_between(x_B_region, F_x[x > 0], max(F_x), color='green', alpha=0.3, label="Macrostate B")
axes[0].axhline(F_A, color='red', linestyle='--', label=r'$F_A$')
axes[0].axhline(F_B, color='green', linestyle='--', label=r'$F_B$')

# Indicate ΔF with an arrow
axes[0].annotate("", xy=(1.1, F_B), xytext=(1.1, F_A),
                 arrowprops=dict(arrowstyle="<->", color='black', linewidth=1.5))
axes[0].text(1.15, (F_A + F_B) / 2, r'$\Delta F$', va='center', fontsize=12, color='black')

axes[0].set_xlabel("Reaction Coordinate X")
axes[0].set_ylabel("Free Energy $F(X)$")
axes[0].set_title("Free Energy Profile of Macrostates A and B")
axes[0].legend()
axes[0].grid(True, linestyle="--", alpha=0.5)
axes[0].set_xlim([-1.5, 1.5])
axes[0].set_ylim([0, 5])

# --- Probability Distribution ---
axes[1].plot(x, P_x, label=r'Probability $P(X) \propto e^{-F(X)}$', color='black', linewidth=2)
axes[1].fill_between(x_A_region, P_x[x < 0], 0, color='red', alpha=0.3, label="Macrostate A")
axes[1].fill_between(x_B_region, P_x[x > 0], 0, color='green', alpha=0.3, label="Macrostate B")

axes[1].set_xlabel("Reaction Coordinate X")
axes[1].set_ylabel("Probability $P(X)$")
axes[1].set_title("Probability Distribution of Macrostates A and B")
axes[1].legend()
axes[1].grid(True, linestyle="--", alpha=0.5)

# Adjust layout and show the plots
plt.tight_layout()
plt.show()
<Figure size 1200x500 with 2 Axes>

Energy Fluctuations

  • Log of canonical partition function logZlogZ has some interesting mathematical properties.

  • We are going to show that first and second dderivatives yield average and fluctuations of energy.

Pi=eβEiZ,Z=ieβEiP_i = \frac{e^{-\beta E_i}}{Z}, \quad Z = \sum_i e^{-\beta E_i}
  • The ensemble average energy can be related to the dderivative of log of partition function:

E=iPiEi=1ZiEieβEi=1ZZβ=lnZβ\langle E \rangle = \sum_i P_i E_i = \frac{1}{Z} \sum_i E_i e^{-\beta E_i} = -\frac{1}{Z} \frac{\partial Z}{\partial \beta} = -\frac{\partial \ln Z}{\partial \beta}
  • To quantify fluctuations, we define the variance of energy and proceed to show that this is equal to second derivative of logZ

(ΔE)2=E2E2\langle (\Delta E)^2 \rangle = \langle E^2 \rangle - \langle E \rangle^2
  • Taking first dderivative:

lnZβ=1ZiEieβEi=E\frac{\partial \ln Z}{\partial \beta} = -\frac{1}{Z} \sum_i E_i e^{-\beta E_i} = -\langle E \rangle
  • Taking the second dderivative:

2lnZβ2=1ZiEi2eβEi(1ZiEieβEi)2\frac{\partial^2 \ln Z}{\partial \beta^2} = \frac{1}{Z} \sum_i E_i^2 e^{-\beta E_i} - \left(\frac{1}{Z} \sum_i E_i e^{-\beta E_i} \right)^2
2lnZβ2=E2E2=(ΔE)2\frac{\partial^2 \ln Z}{\partial \beta^2} = \langle E^2 \rangle - \langle E \rangle^2 = \langle (\Delta E)^2 \rangle
  • Since β=1kBT \beta = \frac{1}{k_B T} , we can use chain rule and express this in terms of temperature:

(ΔE)2=kBT2ET=kBT2Cv\langle (\Delta E)^2 \rangle = k_B T^2 \frac{\partial \langle E \rangle}{\partial T} = k_B T^2C_v
  • Where in the last line we used definition of heat capacity CV=dEdTC_V = \frac{d\langle E\rangle}{dT}

  • The probability distribution of energy, P(E)P(E), follows a Gaussian distribution in equilibrium:

    P(E)exp((EE)22kBT2CV)P(E) \propto \exp\left(-\frac{(E - \langle E \rangle)^2}{2 k_B T^2 C_V} \right)
  • Relative energy fluctuations decrease with NN. In the thermodynamic limit NN\rightarrow \infty , fluctuations become negligible, justifying ensemble equivalence.

    σEECV1/2EO(N1/2)\frac{\sigma_E}{\langle E \rangle} \sim \frac{C_V^{1/2}}{\langle E \rangle} \sim O(N^{-1/2})

Statistical nature of irreversibility

  • From the perspective of the NVE ensemble, we can state that if the number of accessible microstates increases upon the removal of a constraint, then reinstating the constraint will not spontaneously reduce it. This reflects the fundamental irreversibility of spontaneous processes in an isolated system:

ΔS=logΩBΩA0.\Delta S = \log \frac{\Omega_{B}}{\Omega_{A}} \geq 0.
  • A similar conclusion holds in the NVT ensemble: Under constant temperature, the number of microstates, represented by the partition function ZZ, increases during a spontaneous process when a system is in contact with a heat bath.

    βΔF=logZBZA0.-\beta \Delta F = \log \frac{Z_{B}}{Z_{A}} \geq 0.
  • This formulation underscores the irreversibility of thermodynamic processes and highlights the natural tendency of a system to evolve towards configurations with higher entropy (in the microcanonical ensemble) or lower free energy (in the canonical ensemble).

Problems

Problem 1 Shottky defects

Schotky defects are vacancies in a lattice of atoms. Creating a single vacancy costs an energy ϵ\epsilon. Consider a lattice with NN atoms and nn vacacnies. In this model the total energy is solely a function of defects: E=nϵE=n\epsilon

  • Write down number of states and compute the entropy via Boltzmann formula. Plot number of states as a function of energy. You can use log of number of states for plotting.

  • Compute how the temperature would affect the fraction of vacancies on the lattice. Plot fraction of vacancies as a function of temperature.

  • How would the total energy depend on temperature TT. Derive expression for the high temperature limit (ϵkbT1\frac{\epsilon}{k_b T} \gg 1).

  • Plot total energy as a function of temperature E(T)

Problem 2 Lattice gas

Consider NN particles distributed among VV cells (with NVN\ll V). This is a lattice model of a dilute gas. Suppose that each cell may be either empty or occupied by a single particle. The number of microscopic states of this syste will be given by:

Ω(N,V)=V!N!(VN)!\Omega (N, V) = \frac{V!}{N! (V-N)!}
  • Obtain an expression for the entropy per particle s(v)=1NS(N,V)s(v)=\frac{1}{N} \cdot S(N,V) where v=VNv=\frac{V}{N}.

  • From this simple fundamental equation, obtain an expression of equation of state p/Tp/T.

    • Write an expansion of p/Tp/T in terms of density 1/v1/v. Show that the first term gives Boyle law of ideal gases.

  • Sketch a graph of μ/T\mu/T, where μ(ρ)\mu(\rho) is a chemical potential as a function of density. Comment on ρ0\rho\rightarrow 0 and ρ1\rho\rightarrow 1 limits.

Problem 3 Polymer Elasticity

Solve the problem 2.7 from the book.

Problem 4

Consider a system of N classical and non-interacting particles in contact with a thermal reservoir at a temperature TT. Each particle can have be in three states with energy 0, ϵ\epsilon or 3ϵ3\epsilon where ϵ>0\epsilon>0.

  • Obtain an expression for ZZ then compute the average and fluctuation of energy.

  • Plot the heat capacity as a function of temperature Cv(T)C_v(T)

  • Plot the average enegy as a function of temperature U(T)U(T)

  • Plot the entropy as a function of temperature S(T)S(T).

Problem 5

Consider NN lattice sites which have quantum spins s=1s=1 (not to be confused with entropy) with a mangnetic moment μ\mu. Spins are subject to a uniform magnetic field in z direction B=BzB=B_z making the energy of each spin μBm-\mu B m where mm is the magnetic quantum number thattakes on three possible values m=0,±1m=0, \pm 1.

  • Compute the entropy SS and the magnetization of the system MM

  • Plot entropy as a function of temperatures and study the limit of low temperatures S(T0)S(T\rightarrow 0)