# Isothermal–isobaric ensemble

The isothermal–isobaric ensemble (constant temperature and constant pressure ensemble) is a statistical mechanical ensemble that maintains constant temperature $T\,$ and constant pressure $P\,$ applied. It is also called the $NpT$-ensemble, where the number of particles $N\,$ is also kept as a constant. This ensemble plays an important role in chemistry as chemical reactions are usually carried out under constant pressure condition. The NPT ensemble is also useful for measuring the equation of state of model systems whose virial expansion for pressure cannot be evaluated, or systems near first-order phase transitions.
In the ensemble, the probability of a microstate $i$ is $Z^{-1}e^{-\beta (E(i)+pV(i))}$, where $Z$ is the partition function, $E(i)$ is the internal energy of the system in microstate $i$, and $V(i)$ is the volume of the system in microstate $i$.
The probability of a macrostate is $Z^{-1}e^{-\beta (E+pV-TS)}=Z^{-1}e^{-\beta G}$, where $G$ is the Gibbs free energy.

## Derivation of key properties

The partition function for the $NpT$-ensemble can be derived from statistical mechanics by beginning with a system of $N$ identical atoms described by a Hamiltonian of the form $\mathbf {p} ^{2}/2m+U(\mathbf {r} ^{n})$ and contained within a box of volume $V=L^{3}$. This system is described by the partition function of the canonical ensemble in 3 dimensions:
    $Z^{sys}(N,V,T)={\frac {1}{\Lambda ^{3N}N!}}\int _{0}^{L}...\int _{0}^{L}d\mathbf {r} ^{N}\exp(-\beta U(\mathbf {r} ^{N}))$,
where $\Lambda ={\sqrt {h^{2}\beta /(2\pi m)}}$, the thermal de Broglie wavelength ($\beta =1/k_{B}T\,$ and $k_{B}\,$ is the Boltzmann constant), and the factor $1/N!$ (which accounts for indistinguishability of particles) both ensure normalization of entropy in the quasi-classical limit. It is convenient to adopt a new set of coordinates defined by $L\mathbf {s} _{i}=\mathbf {r} _{i}$ such that the partition function becomes
    $Z^{sys}(N,V,T)={\frac {V^{N}}{\Lambda ^{3N}N!}}\int _{0}^{1}...\int _{0}^{1}d\mathbf {s} ^{N}\exp(-\beta U(\mathbf {s} ^{N}))$.
If this system is then brought into contact with a bath of volume $V_{0}$ at constant temperature and pressure containing an ideal gas with total particle number $M$ such that $M-N\gg N$, the partition function of the whole system is simply the product of the partition functions of the subsystems:
    $Z^{sys+bath}(N,V,T)={\frac {V^{N}(V_{0}-V)^{M-N}}{\Lambda ^{3M}N!(M-N)!}}\int d\mathbf {s} ^{M-N}\int d\mathbf {s} ^{N}\exp(-\beta U(\mathbf {s} ^{N}))$.
The integral over the $\mathbf {s} ^{M-N}$ coordinates is simply $1$. In the limit that $V_{0}\rightarrow \infty$, $M\rightarrow \infty$ while $(M-N)/V_{0}=\rho$ stays constant, a change in volume of the system under study will not change the pressure $p$ of the whole system. Taking $V/V_{0}\rightarrow 0$ allows for the approximation $(V_{0}-V)^{M-N}=V_{0}^{M-N}(1-V/V_{0})^{M-N}\approx V_{0}^{M-N}\exp(-(M-N)V/V_{0})$. For an ideal gas, $(M-N)/V_{0}=\rho =\beta P$ gives a relationship between density and pressure. Substituting this into the above expression for the partition function, multiplying by a factor $\beta P$ (see below for justification for this step), and integrating over the volume V then gives
    $\Delta ^{sys+bath}(N,P,T)={\frac {\beta PV_{0}^{M-N}}{\Lambda ^{3M}N!(M-N)!}}\int dVV^{N}\exp({-\beta PV})\int d\mathbf {s} ^{N}\exp(-\beta U(\mathbf {s} ))$.
The partition function for the bath is simply $\Delta ^{bath}=V_{0}^{M-N}/[(M-N)!\Lambda ^{3(M-N)}$. Separating this term out of the overall expression gives the partition function for the $NpT$-ensemble:
    $\Delta ^{sys}(N,P,T)={\frac {\beta P}{\Lambda ^{3N}N!}}\int dVV^{N}\exp(-\beta PV)\int d\mathbf {s} ^{N}\exp(-\beta U(\mathbf {s} ))$.
Using the above definition of $Z^{sys}(N,V,T)$, the partition function can be rewritten as
    $\Delta ^{sys}(N,P,T)=\beta P\int dV\exp(-\beta PV)Z^{sys}(N,V,T)$,
which can be written more generally as a weighted sum over the partition function for the canonical ensemble
    $\Delta (N,P,T)=\int Z(N,V,T)\exp(-\beta PV)CdV.\,\;$
The quantity $C$ is simply some constant with units of inverse volume, which is necessary to make the integral dimensionless. In this case, $C=\beta P$, but in general it can take on multiple values. The ambiguity in its choice stems from the fact that volume is not a quantity that can be counted (unlike e.g. the number of particles), and so there is no “natural metric” for the final volume integration performed in the above derivation. This problem has been addressed in multiple ways by various authors, leading to values for C with the same units of inverse volume. The differences vanish (i.e. the choice of $C$ becomes arbitrary) in the thermodynamic limit, where the number of particles goes to infinity.
The $NpT$-ensemble can also be viewed as a special case of the Gibbs canonical ensemble, in which the macrostates of the system are defined according to external temperature $T$ and external forces acting on the system $\mathbf {J}$. Consider such a system containing $N$ particles. The Hamiltonian of the system is then given by ${\mathcal {H}}-\mathbf {J} \cdot \mathbf {x}$ where ${\mathcal {H}}$ is the system's Hamiltonian in the absence of external forces and $\mathbf {x}$ are the conjugate variables of $\mathbf {J}$. The microstates $\mu$ of the system then occur with probability defined by
    $p(\mu ,\mathbf {x} )=\exp[-\beta {\mathcal {H}}(\mu )+\beta \mathbf {J} \cdot \mathbf {x} ]/{\mathcal {Z}}$
where the normalization factor ${\mathcal {Z}}$ is defined by
    ${\mathcal {Z}}(N,\mathbf {J} ,T)=\sum _{\mu ,\mathbf {x} }\exp[\beta \mathbf {J} \cdot \mathbf {x} -\beta {\mathcal {H}}(\mu )]$.
This distribution is called generalized Boltzmann distribution by some authors.
The $NpT$-ensemble can be found by taking $\mathbf {J} =-P$ and $\mathbf {x} =V$. Then the normalization factor becomes
    ${\mathcal {Z}}(N,\mathbf {J} ,T)=\sum _{\mu ,\{\mathbf {r} _{i}\}\in V}\exp[-\beta PV-\beta (\mathbf {p} ^{2}/2m+U(\mathbf {r} ^{N}))]$,
where the Hamiltonian has been written in terms of the particle momenta $\mathbf {p} _{i}$ and positions $\mathbf {r} _{i}$. This sum can be taken to an integral over both $V$ and the microstates $\mu$. The measure for the latter integral is the standard measure of phase space for identical particles: ${\textrm {d}}\Gamma _{N}={\frac {1}{h^{3}N!}}\prod _{i=1}^{N}d^{3}\mathbf {p} _{i}d^{3}\mathbf {r} _{i}$. The integral over $\exp(-\beta \mathbf {p} ^{2}/2m)$ term is a Gaussian integral, and can be evaluated explicitly as
    $\int \prod _{i=1}^{N}{\frac {d^{3}\mathbf {p} _{i}}{h^{3}}}\exp {\bigg-\beta \sum _{i=1}^{N}{\frac {p_{i}^{2}}{2m}}{\bigg ]}={\frac {1}{\Lambda ^{3N}}}$ .
Inserting this result into ${\mathcal {Z}}(N,P,T)$ gives a familiar expression:
    ${\mathcal {Z}}(N,P,T)={\frac {1}{\Lambda ^{3N}N!}}\int dV\exp(-\beta PV)\int d\mathbf {r} ^{N}\exp(-\beta U(\mathbf {r} ))=\int dV\exp(-\beta PV)Z(N,V,T)$.
This is almost the partition function for the $NpT$-ensemble, but it has units of volume, an unavoidable consequence of taking the above sum over volumes into an integral. Restoring the constant $C$ yields the proper result for $\Delta (N,P,T)$.
From the preceding analysis it is clear that the characteristic state function of this ensemble is the Gibbs free energy,
    $G(N,P,T)=-k_{B}T\ln \Delta (N,P,T)\;\,$
This thermodynamic potential is related to the Helmholtz free energy (logarithm of the canonical partition function), $F\,$, in the following way:
    $G=F+PV.\;\,$

## Applications

* Constant-pressure simulations are useful for determining the equation of state of a pure system. Monte Carlo simulations using the $NpT$-ensemble are particularly useful for determining the equation of state of fluids at pressures of around 1 atm, where they can achieve accurate results with much less computational time than other ensembles.
* Zero-pressure $NpT$-ensemble simulations provide a quick way of estimating vapor-liquid coexistence curves in mixed-phase systems.
* $NpT$-ensemble Monte Carlo simulations have been applied to study the excess properties and equations of state of various models of fluid mixtures.
* The $NpT$-ensemble is also useful in molecular dynamics simulations, e.g. to model the behavior of water at ambient conditions.