Introduction

Physical systems at equilibrium are studied in statistical mechanics through statistical ensembles. Each ensemble describes a system that exchanges certain physical quantities, typically extensive, with the surrounding. A terminology that is sometimes used in literature1 identifies statistical ensemble with the variables that are held fixed from each statistically conjugated couple \((\mu ,N)\), (PV), and \((\beta ,E)\), where \(\mu\) is the chemical potential and N is the number of particles, P is the pressure and V is the volume, \(\beta =\frac{1}{k_B T}\) is the inverse absolute temperature with \(k_B\) being the Boltzmann constant and E is the energy. Accordingly, the microcanonical ensemble describes an isolated system where none of the energy, volume and particles are exchanged, thus called NVE. A system in the canonical ensemble exchanges only energy with the surrounding, thus introducing \(\beta\) as a parameter of the ensemble which is called NVT. The grandcanonical ensemble allows to exchange also particles, with the new parameter \(\mu\), and is called \(\mu VT\). Finally, the isothermal-isobaric ensemble describes systems exchanging energy and volume with the surrounding, parametrised by \(\beta\) and P, and is called NPT. The NPT ensemble is used in Monte Carlo and molecular dynamics simulations1,2.

The above statistical ensembles are related to each other through Legendre transforms3,4,5; see also Ref.6 for a review on the general framework of Legendre transformations. Moreover, each ensemble is also derived from the maximisation of the Shannon entropy with constraints that fix the average of the fluctuating extensive quantities, following the Jaynes’ approach7,8. These two constructions are equivalent, resulting in the well-known Boltzmann weight of exponential form. This paper concerns the statistical ensemble, missing in the above picture, which represents a system exchanging energy, particles, and volume with the surrounding, and is parametrised by the intensive variables \(\beta\), \(\mu\), and P, therefore called \(\mu PT\) ensemble9,10,11. The \(\mu PT\) ensemble is derived using standard arguments either from the \(\mu VT\) ensemble through the Legendre transform with respect to the volume. or from the NPT ensemble through the Legendre transform with respect to the particle number, or again form the maximisation of the Shannon entropy with fixed average energy, particle number and volume.

The \(\mu PT\) ensemble is the extension of the \(\mu VT\) ensemble when the pressure instead of the volume is fixed, or the extension of the NPT ensemble when the chemical potential instead of the particle number is fixed. The latter conditions are met in several physical and chemical processes, e.g. naturally arise in systems confined within a porous and elastic membranes. Furthermore, the \(\mu PT\) ensemble has been studied in small systems12,13, like in nanothermodynamics14,15,16,17,18, or in systems with long-range interactions19,20,21. In these physical systems, the Gibbs-Duhem equation is not supposed to hold, and therefore the three intensive parameters \(\mu\), P, and T can be independent. In the following, I will investigate general properties of the \(\mu PT\) ensemble, and discuss ensemble equivalence in connection with non-analyticities and non-commutativity of Legendre transforms.

Results

General considerations

Following the Jaynes’ approach, the configuration probabilities of the \(\mu PT\) ensemble result from the constrained maximisation of the Shannon entropy:

$$\begin{aligned} \frac{\partial }{\partial p_j}\left( -\sum _{j}p_j\ln p_j-\lambda \left( \sum _jp_j-1\right) -\beta \langle H\rangle -\beta P\langle V\rangle +\mu \langle N\rangle \right) =0, \end{aligned}$$
(1)

where \(p_j\) is the probability of the j-th configuration with fixed energy, volume and particle number, H is the Hamiltonian, and \(\langle \cdot \rangle\) is the average with respect to the probability distribution \(\{p_j\}_j\). The configuration probabilities are

$$\begin{aligned} p_j=\frac{e^{-\beta (E_j+PV_j-\mu N_j)}}{Z_{\mu PT}}, \end{aligned}$$
(2)

with the \(\mu PT\) partition function

$$\begin{aligned} Z_{\mu PT}=\sum _{\begin{array}{c} j\in \text {configurations} \end{array}}e^{-\beta (E_j+PV_j-\mu N_j)}, \end{aligned}$$
(3)

where the sum runs over all configurations at different energy, particle numbers, and volume. According to the order in which the configurations are summed, the \(\mu PT\) partition function can be written either as the Legendre transform of the NPT ensemble, i.e.

$$\begin{aligned} Z_{\mu PT}=\sum _{N=N_1}^{N_2} e^{\beta \mu N}Z_{NPT}, \end{aligned}$$
(4)

or as the Legendre transform of the \(\mu VT\) ensemble, i.e.

$$\begin{aligned} Z_{\mu PT}=\int _{V_1}^{V_2}\frac{dV}{V_0}e^{-\beta PV}Z_{\mu VT}, \end{aligned}$$
(5)

where \(V_0\) is a constant with the dimension of a volume in order \(Z_{\mu PT}\) to be dimensionless, but does not affect physical quantities.

The logarithms of the partition function of statistical ensembles give thermodynamic potentials. These thermodynamic potentials, summarised in Table 1, are defined by means of thermal averages of extensive quantities, and can also be expressed as linear homogeneous functions of fixed extensive parameters using the Euler’s theorem5. In the \(\mu PT\) ensemble however, all possible Legendre transforms have been performed, such that thermal properties only depend on intensive parameters which gauge the extensive thermal averages. Without additional statistically conjugated couples, the intensive \(\mu PT\) thermodynamic potential is connected to finite-size effects9,11.

Table 1 Thermodynamic potentials.

Legendre transform of the \(\mu VT\) ensemble

The \(\mu VT\) partition function is

$$\begin{aligned} Z_{\mu VT}=e^{\beta P_c V}, \end{aligned}$$
(6)

where \(P_c\) is the pressure derived in the \(\mu VT\) ensemble. It is crucial to note that \(P_c\) depends only on the free parameters of the \(\mu VT\) ensemble, namely the chemical potential \(\mu\), the temperature T and the volume V, as all other physical quantities are functions of these parameters. Requiring that \(P_c\), \(\mu\), and T, are all intensive quantities, and that the \(\mu VT\) thermodynamic potential, i.e. \(-P_cV\), is extensive implies that \(P_c\) is a non-increasing function of V. In particular, the leading contribution to \(P_c\) for large volume does not depend on V.

The \(\mu PT\) partition function is thus

$$\begin{aligned} Z_{\mu PT}=\int _{V_1}^{V_2}\frac{dV}{V_0}e^{-\beta PV}Z_{\mu VT}=\frac{e^{\beta V_2(P_c-P)}-e^{\beta V_1(P_c-P)}}{\beta V_0(P_c-P)}, \end{aligned}$$
(7)

where the volume fluctuates in the interval \([V_1,V_2]\). The thermodynamic potential is

$$\begin{aligned} - \frac{1}{\beta }\ln Z_{{\mu PT}} & = - V_{2} (P_{c} - P) - \frac{1}{\beta }\ln \left( {1 - e^{{ - \beta (V_{2} - V_{1} )(P_{c} - P)}} } \right) + \frac{1}{\beta }\ln (\beta V_{0} (P_{c} - P)) \\ & = - V_{1} (P_{c} - P) - \frac{1}{\beta }\ln \left( {1 - e^{{\beta (V_{2} - V_{1} )(P_{c} - P)}} } \right) + \frac{1}{\beta }\ln (\beta V_{0} (P - P_{c} )), \end{aligned}$$
(8)

with the following asymptotic behaviours

$$- \frac{1}{\beta }\ln Z_{\mu PT} \, \xrightarrow [\beta (V_2-V_1)(P_c-P)\gg 1]{} \, -V_2(P_c-P)+\frac{1}{\beta }\ln (\beta V_0(P_c-P)) -\frac{1}{\beta } \, {\mathcal {O}}\left( e^{-\beta (V_2-V_1)(P_c-P)}\right) ,$$
(9)
$$- \frac{1}{\beta }\ln Z_{\mu PT} \, \xrightarrow [\beta (V_2-V_1)(P-P_c]{} \, V_1(P_c-P)+\frac{1}{\beta }\ln (\beta V_0(P_c-P))-\frac{1}{\beta } \, {\mathcal {O}}\left( e^{-\beta (V_2-V_1)(P-P_c)}\right) ,$$
(10)
$$- \frac{1}{\beta }\ln Z_{\mu PT} \, \xrightarrow [P\rightarrow P_c]{} \, -\frac{1}{\beta }\ln \frac{V_2-V_1}{V_0}.$$
(11)

Notice that \(P=P_c\) is a non-analytic point of the thermodynamic potential when \(V_2\rightarrow \infty\), which shall be characterised in the following.

Volume statistics

General features of the volume statistics are derived from pressure derivatives of (7). The average volume is

Figure 1
figure 1

Semi-log plot of the rescaled average volume \(\beta P_c\langle V\rangle\), the rescaled volume fluctuations \(\beta ^2 P_c^2\Delta ^2V\), and the rescaled density fluctuations \(\frac{\Delta ^2\rho }{P_c\partial ^2_\mu P_c}\) as a function of the rescaled pressure \(P/P_c\). The condition \(\beta P_c V_1=10\) has been set in the plot of \(\beta P_c\langle V\rangle\) and \(\frac{\Delta ^2\rho }{P_c\partial ^2_\mu P_c}\).

$$\begin{aligned} \langle V\rangle =-\frac{1}{\beta }\frac{\partial }{\partial P}\ln Z_{\mu PT}=\frac{1}{\beta (P-P_c)}+\frac{V_2-V_1 e^{-\beta (V_2-V_1)(P_c-P)}}{1-e^{-\beta (V_2-V_1)(P_c-P)}} \end{aligned}$$
(12)

with the following asymptotic behaviours

$$\begin{aligned} \langle V\rangle = {\left\{ \begin{array}{ll} \displaystyle V_2+\frac{1}{\beta (P-P_c)}+(V_2-V_1){\mathcal {O}}\left( e^{-\beta (V_2-V_1)(P_c-P)}\right) &{} \text {if } \beta (V_2-V_1)(P_c-P)\gg 1 \\ \displaystyle V_1+\frac{1}{\beta (P-P_c)}+(V_2-V_1){\mathcal {O}}\left( e^{-\beta (V_2-V_1)(P-P_c)}\right) &{} \text {if } \beta (V_2-V_1)(P-P_c)\gg 1 \\ \displaystyle \frac{V_2+V_1}{2}+(V_2-V_1){\mathcal {O}}\big (\beta (V_2-V_1)|P_c-P|\big ) &{} \text {if } \beta (V_2-V_1)|P_c-P|\ll 1 \end{array}\right. }. \end{aligned}$$
(13)

Therefore, the average volume has a discontinuity when \(V_2\rightarrow \infty\), as depicted in Fig. 1a.

The variance of the volume is proportional to the isothermal compressibility \(\kappa _T\):

$$\begin{aligned} \Delta ^2V=\frac{1}{\beta ^2}\frac{\partial ^2}{\partial P^2}\ln Z_{\mu PT}=-\frac{1}{\beta }\frac{\partial }{\partial P}\langle V\rangle =\frac{\kappa _T}{\beta }\langle V\rangle =\frac{1}{\beta ^2(P_c-P)^2}-\frac{(V_2-V_1)^2}{4\sinh ^2\left( \frac{\beta }{2}(V_2-V_1)(P_c-P)\right) }, \end{aligned}$$
(14)

plotted in Fig. 1b, whose asymptotic behaviours are

$$\begin{aligned} \Delta ^2V= {\left\{ \begin{array}{ll} \displaystyle \frac{1}{\beta ^2(P_c-P)^2}-(V_2-V_1)^2{\mathcal {O}}\left( e^{-\beta (V_2-V_1)|P_c-P|}\right) &{} \text {if } \beta (V_2-V_1)|P_c-P|\gg 1 \\ \displaystyle (V_2-V_1)^2\left( \frac{1}{12}+{\mathcal {O}}\big (\beta (V_2-V_1)|P_c-P|\big )^2\right) &{} \text {if } \beta (V_2-V_1)|P_c-P|\ll 1 \end{array}\right. }. \end{aligned}$$
(15)

Thus, the variance of the volume is superextensive around \(P=P_c\) and intensive away from \(P=P_c\), as shown in Fig. 1b.

Particle number statistics

The general relation between the average volume and the average particle number is straightforwardly derived:

$$\begin{aligned} \langle N\rangle =\frac{1}{\beta }\frac{\partial }{\partial \mu }\ln Z_{\mu PT}=\left( \frac{\partial }{\partial \mu }P_c\right) \langle V\rangle . \end{aligned}$$
(16)

Recalling the definition (6), the latter is the same equation as in the \(\mu VT\) ensemble with the volume, that is a fixed parameter in the grandcanonical ensemble, replaced by the average volume.

The general relation between the particle number and the volume fluctuations is

$$\begin{aligned} \Delta ^2 N=\frac{1}{\beta ^2}\frac{\partial ^2}{\partial \mu ^2}\ln Z_{\mu PT}=\left( \frac{\partial ^2}{\partial \mu ^2}P_c\right) \frac{\langle V\rangle }{\beta }+\frac{\langle N\rangle ^2}{\langle V\rangle ^2}\Delta ^2 V, \end{aligned}$$
(17)

where the first term in the right-hand-side equals the variance of the particle number in the \(\mu VT\) ensemble with the volume replaced by the average volume \(\langle V\rangle\).

Density statistics

Since both particle number and volume are fluctuating quantities, also the density \(\rho =N/V\) fluctuates. The average density is

$$\langle \rho \rangle = \frac{1}{{Z_{{\mu PT}} }}\int_{{V_{1} }}^{{V_{2} }} {\frac{{dV}}{{V_{0} }}} {\text{Tr}}\left( {\frac{N}{V}e^{{ - \beta (H + PV - \mu N)}} } \right) = \frac{1}{{\beta Z_{{\mu PT}} }}\frac{\partial }{{\partial \mu }}\int_{{V_{1} }}^{{V_{2} }} {\frac{{dV}}{{V_{0} V}}} {\text{Tr}}\left( {e^{{ - \beta (H + PV - \mu N)}} } \right) = \frac{\partial }{{\partial \mu }}P_{c} = \frac{{\langle N\rangle }}{{\langle V\rangle }}$$
(18)

and equals the density in the \(\mu VT\) ensemble. Equation (18) shows that there is no ambiguity to define the average density as the average of \(\frac{N}{V}\) or as the ratio of averages \(\frac{\langle N\rangle }{\langle V\rangle }\).

The variance of the density is

$$\begin{aligned} \Delta ^2\rho&=\langle \rho ^2\rangle -\langle \rho \rangle ^2 =\left( \frac{\partial ^2}{\partial \mu ^2}P_c\right) \left( P_c-P\right) \frac{\text {Ei}(\beta V_2(P_c-P))-\text {Ei}(\beta V_1(P_c-P))}{e^{\beta V_2(P_c-P)}-e^{\beta V_1(P_c-P)}} \nonumber \\&=\frac{\Delta ^2N-\langle \rho \rangle ^2\Delta ^2V}{\langle V\rangle }\beta \left( P_c-P\right) \frac{\text {Ei}(\beta V_2(P_c-P))-\text {Ei}(\beta V_1(P_c-P))}{e^{\beta V_2(P_c-P)}-e^{\beta V_1(P_c-P)}}, \end{aligned}$$
(19)

with \(\text {Ei}(x)=-\int _{-x}^\infty dt\frac{e^{-t}}{t}\) being the exponential integral22, and is sketched in Fig.  1c. The asymptotic limits of the density fluctuations are

$$\begin{aligned} \Delta ^2\rho \, \xrightarrow [\beta V_{1,2}|P_c-P|\ll 1]{} \, \frac{1}{\beta (V_2-V_1)}\left( \frac{\partial ^2}{\partial \mu ^2}P_c\right) \left( \ln \frac{V_2}{V_1}+{\mathcal {O}}\big (\beta V_{1,2}|P_c-P|\big )\right) , \end{aligned}$$
(20)

recalling the series23 \(\text {Ei}(x)=\gamma +\ln |x|+\sum _{k=1}^\infty \frac{x^k}{k\cdot k!}\) with \(\gamma\) the Euler–Mascheroni constant, while, using instead the asymptotic series24 \(\text {Ei}(x)=\frac{e^x}{x}\sum _{k=0}^{M-1}\frac{k!}{x^k}+{\mathcal {O}}\big (M!x^{-M}\big )\),

$$\begin{aligned}&\Delta ^2\rho \, \xrightarrow [\beta (V_2-V_1)(P_c-P)\gg 1]{} \, \frac{1}{\beta V_2}\left( \frac{\partial ^2}{\partial \mu ^2}P_c\right) \left( 1+{\mathcal {O}}\left( \frac{1}{\beta V_2(P_c-P)}\right) \right) , \end{aligned}$$
(21)
$$\begin{aligned}&\Delta ^2\rho \, \xrightarrow [\beta (V_2-V_1)(P-P_c)\gg 1]{} \, \frac{1}{\beta V_1}\left( \frac{\partial ^2}{\partial \mu ^2}P_c\right) \left( 1+{\mathcal {O}}\left( \frac{1}{\beta V_1(P_c-P)}\right) \right) . \end{aligned}$$
(22)

Therefore, the variance of the density \(\Delta ^2\rho ={\mathcal {O}}\big (1/\langle V\rangle \big )\), for \(\beta (V_2-V_1)|P_c-P|\gg 1\), satisfies the so-called shot-noise limit, i.e. scales as the inverse of the system size as in the central limit theorem. The variance \(\Delta ^2\rho\) for \(\beta V_{1,2}|P_c-P|\ll 1\) exhibits shot-noise limit with multiplicative logarithmic corrections.

Energy statistics

The average energy is

$$\begin{aligned} \langle H\rangle =-\frac{\partial }{\partial \beta }\ln Z_{\mu PT}-P\langle V\rangle +\mu \langle N\rangle =\left( \mu \frac{\partial }{\partial \mu }P_c-\beta \frac{\partial }{\partial \beta }P_c-P_c\right) \langle V\rangle , \end{aligned}$$
(23)

which again equals the expression of the \(\mu VT\) ensemble with the volume replaced by the average volume.

Heat capacities at constant volume and at constant pressure are related to derivatives of the mean energy, particle number, and volume:

$$\begin{aligned} C_V=&\left( \frac{dQ}{dT}\right) _{\langle V\rangle }=\left( \frac{d\langle H\rangle }{dT}-\mu \frac{d\langle N\rangle }{dT}\right) _{\langle V\rangle }=k_B\beta ^2\left( 2\,\frac{\partial }{\partial \beta }P_c+\beta \frac{\partial ^2}{\partial \beta ^2}P_c\right) \langle V\rangle , \end{aligned}$$
(24)
$$\begin{aligned} C_P=&\left( \frac{dQ}{dT}\right) _P=\left( \frac{d\langle H\rangle }{dT}+P\frac{d\langle V\rangle }{dT}-\mu \frac{d\langle N\rangle }{dT}\right) _P=C_V+k_B\beta ^2\left( P-P_c-\beta \frac{\partial P_c}{\partial \beta }\right) ^2\Delta ^2V. \end{aligned}$$
(25)

Legendre transform of the NPT ensemble

The NPT partition function is

$$\begin{aligned} Z_{NPT}=e^{-\beta \mu _c N}, \end{aligned}$$
(26)

where \(\mu _c\) is the chemical potential derived in the NPT ensemble. In analogy to the discussion after Eq. (6), note that \(\mu _c\) depends only on the free parameters of the NPT ensemble, namely the pressure P, the temperature T and the particle number N. Given that \(\mu _c\), P, and T, are intensive, and that the NPT thermodynamic potential, i.e. \(\mu _cN\), is extensive, \(\mu _c\) is a non-increasing function of N. In particular, the leading contribution to \(\mu _c\) for large volume does not depend on N.

The \(\mu PT\) partition function is

$$\begin{aligned} Z_{\mu PT}=\sum _{N=N_1}^{N_2}e^{\beta \mu N}Z_{NPT}=\frac{e^{\beta N_1(\mu -\mu _c)}-e^{\beta (N_2+1)(\mu -\mu _c)}}{1-e^{\beta (\mu -\mu _c)}}, \end{aligned}$$
(27)

where the number of particles fluctuates in the interval \([N_1,N_2]\). The thermodynamic potential is

$$\begin{aligned} - \frac{1}{\beta }\ln Z_{\mu PT} & =-(N_2+1)(\mu -\mu _c)-\frac{1}{\beta }\ln \left( 1-e^{-\beta (N_2-N_1+1)(\mu -\mu _c)}\right) +\frac{1}{\beta }\ln \left( e^{\beta (\mu -\mu _c)}-1\right) \\ & = -N_1(\mu -\mu _c)-\frac{1}{\beta }\ln \left( 1-e^{\beta (N_2-N_1+1)(\mu -\mu _c)}\right) +\frac{1}{\beta }\ln \left( 1-e^{\beta (\mu -\mu _c)}\right) , \end{aligned}$$
(28)

with the following asymptotic limit

$$\begin{aligned} - \frac{1}{\beta }\ln Z_{\mu PT} \, \xrightarrow [\beta (N_2-N_1+1)(\mu -\mu _c)\gg 1]{} & -(N_2+1)(\mu -\mu _c)+\frac{1}{\beta }\ln \left( e^{\beta (\mu -\mu _c)}-1\right) \\& +\frac{1}{\beta } \, {\mathcal {O}}\left( e^{-\beta (N_2-N_1+1)(\mu -\mu _c)}\right) , \end{aligned}$$
(29)
$$\begin{aligned} - \frac{1}{\beta }\ln Z_{\mu PT} \, \xrightarrow [\beta (N_2-N_1+1)(\mu _c-\mu )\gg 1]{} & -N_1(\mu -\mu _c) +\frac{1}{\beta }\ln \left( 1-e^{\beta (\mu -\mu _c)}\right) \\ & +\frac{1}{\beta } \, {\mathcal {O}}\left( e^{-\beta (N_2-N_1+1)(\mu _c-\mu )}\right) ,\end{aligned}$$
(30)
$$\ - \frac{1}{\beta }\ln Z_{\mu PT} \, \xrightarrow [\mu \rightarrow \mu _c]{} \, -\frac{1}{\beta }\ln (N_2-N_1+1).$$
(31)

Therefore, \(\mu =\mu _c\) is a non-analytic point of the thermodynamic potential when \(N_2\rightarrow \infty\).

Figure 2
figure 2

Semi-log plot of the average number of particles \(\langle N\rangle\) (setting \(N_1=10\)) and of the particle number fluctuations \(\Delta ^2N\) as a function of the rescaled chemical potential \(\beta (\mu -\mu _c)\).

Particle number statistics

General features of the particle number statistics are derived from derivatives of (27) with respect to the chemical potential. The average number of particles is

$$\begin{aligned} \langle N\rangle =\frac{1}{\beta }\frac{\partial }{\partial \mu }\ln Z_{\mu PT}=\frac{1}{e^{-\beta (\mu -\mu _c)}-1}+\frac{N_2+1-N_1 e^{-\beta (N_2-N_1+1)(\mu -\mu _c)}}{1-e^{-\beta (N_2-N_1+1)(\mu -\mu _c)}}, \end{aligned}$$
(32)

with the following asymptotic behaviours

$$\begin{aligned} \langle N\rangle = {\left\{ \begin{array}{ll} \displaystyle N_2+\frac{1}{1-e^{\beta (\mu -\mu _c)}}+(N_2-N_1+1){\mathcal {O}}\left( e^{-\beta (N_2-N_1)(\mu -\mu _c)}\right) &{} \text {if } \beta (N_2-N_1)(\mu -\mu _c)\gg 1 \\ \displaystyle N_1+\frac{1}{e^{\beta (\mu _c-\mu )}-1}+(N_2-N_1+1){\mathcal {O}}\left( e^{-\beta (N_2-N_1)(\mu _c-\mu )}\right) &{} \text {if } \beta (N_2-N_1)(\mu _c-\mu )\gg 1 \\ \displaystyle \frac{N_2+N_1}{2}+(N_2-N_1-2){\mathcal {O}}\big (\beta (N_2-N_1)|\mu -\mu _c|\big ) &{} \text {if } \beta (N_2-N_1)|\mu -\mu _c|\ll 1 \end{array}\right. }. \end{aligned}$$
(33)

As for the average volume, the number of particles has a discontinuity when \(N_2\rightarrow \infty\), as depicted in Fig. 2a.

The variance of the particle number is

$$\begin{aligned} \Delta ^2N=\frac{1}{\beta ^2}\frac{\partial ^2}{\partial \mu ^2}\ln Z_{\mu PT}=\frac{1}{\beta }\frac{\partial }{\partial \mu }\langle N\rangle =\frac{1}{4\sinh ^2\left( \frac{\beta }{2}(\mu -\mu _c)\right) }-\frac{(N_2-N_1+1)^2}{4\sinh ^2\left( \frac{\beta }{2}(N_2-N_1+1)(\mu -\mu _c)\right) }, \end{aligned}$$
(34)

plotted in Fig.  2b, whose asymptotic behaviours are

$$\begin{aligned} \Delta ^2N= {\left\{ \begin{array}{ll} \displaystyle \frac{1}{4\sinh ^2\left( \frac{\beta }{2}(\mu -\mu _c)\right) }-(N_2-N_1+1)^2{\mathcal {O}}\left( e^{-\beta (N_2-N_1)|\mu -\mu _c|}\right) &{} \text {if } \beta (N_2-N_1)|\mu -\mu _c|\gg 1 \\ \displaystyle (N_2-N_1)(N_2-N_1+2)\left( \frac{1}{12}+ {\mathcal {O}}\big (\beta (N_2-N_1)|\mu -\mu _c|\big )^2\right) &{} \text {if } \beta (N_2-N_1)|\mu -\mu _c|\ll 1 \end{array}\right. }. \end{aligned}$$
(35)

Thus, the variance of the particle number is superextensive around \(\mu =\mu _c\) and intensive away from \(\mu =\mu _c\), as shown in Fig. 2b.

Volume statistics

The general relation between the average particle number and the average volume is again straightforwardly derived:

$$\begin{aligned} \langle V\rangle =-\frac{1}{\beta }\frac{\partial }{\partial P}\ln Z_{\mu PT}=\left( \frac{\partial }{\partial P}\mu _c\right) \langle N\rangle . \end{aligned}$$
(36)

Recalling the definition (26), the latter is the same equation as in the NPT ensemble with the particle number, that is a fixed parameter in the isothermal-isobaric ensemble, replaced by the average particle number.

The general relation between the particle number and the volume fluctuations is

$$\begin{aligned} \Delta ^2 V=\frac{1}{\beta ^2}\frac{\partial ^2}{\partial P^2}\ln Z_{\mu PT}=-\frac{1}{\beta }\frac{\partial }{\partial P}\langle V\rangle =\frac{\kappa _T}{\beta }\langle V\rangle =-\left( \frac{\partial ^2}{\partial P^2}\mu _c\right) \frac{\langle N\rangle }{\beta }+\frac{\langle V\rangle ^2}{\langle N\rangle ^2}\Delta ^2 N, \end{aligned}$$
(37)

where the first term of Eq. (37) equals the variance of the volume in the NPT ensemble with the particle number replaced by the average particle number \(\langle N\rangle\).

Energy statistics

The average energy is

$$\begin{aligned} \langle H\rangle =-\frac{\partial }{\partial \beta }\ln Z_{\mu PT}-P\langle V\rangle +\mu \langle N\rangle =\left( \mu _c+\beta \frac{\partial }{\partial \beta }\,\mu _c-P\frac{\partial }{\partial P}\,\mu _c\right) \langle N\rangle , \end{aligned}$$
(38)

which again equals the expression of the NPT ensemble with the particle number replaced by the average particle number.

From the derivative of the averages of energy, volume and particle number, heat capacities at constant volume and at constant pressure are computed:

$$\begin{aligned} C_V&= \left( \frac{dQ}{dT}\right) _{\langle V\rangle }=\left( \frac{d\langle H\rangle }{dT}-\mu \frac{d\langle N\rangle }{dT}\right) _{\langle V\rangle } \nonumber \\&= k_B\beta ^2\left( \mu _c-\mu +\beta \frac{\partial \mu _c}{\partial \beta }\right) \frac{\partial ^2\mu _c}{\partial \beta \partial P}\left( \frac{\partial \mu _c}{\partial P}\right) ^{-1}\langle N\rangle -k_B\beta ^2\left( 2\,\frac{\partial \mu _c}{\partial \beta }+\beta \frac{\partial ^2\mu _c}{\partial \beta ^2}\right) \langle N\rangle , \end{aligned}$$
(39)
$$\begin{aligned} C_P&= \left( \frac{dQ}{dT}\right) _P=\left( \frac{d\langle H\rangle }{dT}+P\frac{d\langle V\rangle }{dT}-\mu \frac{d\langle N\rangle }{dT}\right) _P\nonumber \\&= -k_B\beta ^2\left( 2\,\frac{\partial \mu _c}{\partial \beta }+\beta \frac{\partial ^2\mu _c}{\partial \beta ^2}\right) \langle N\rangle +k_B\beta ^2\left( \mu _c-\mu +\beta \frac{\partial \mu _c}{\partial \beta }\right) ^2\Delta ^2N \nonumber \\&= C_V+k_B\beta ^2\left( \mu _c-\mu +\beta \frac{\partial \mu _c}{\partial \beta }\right) ^2\Delta ^2N -k_B\beta ^2\left( \mu _c-\mu +\beta \frac{\partial \mu _c}{\partial \beta }\right) \frac{\partial ^2\mu _c}{\partial \beta \partial P}\left( \frac{\partial \mu _c}{\partial P}\right) ^{-1}\langle N\rangle . \end{aligned}$$
(40)

Comparison with other ensembles

Some fundamental differences of the \(\mu PT\) ensemble with respect to other statistical ensembles stem from the fact that all possible Legendre transforms with respect to internal quantities have been computed. The \(\mu PT\) partition function thus depends only on intensive parameters unless other internal quantities \(\{X_l\}_l\), even though fixed, contribute to energy, particles, and volume exchanges.

One peculiarity of the \(\mu PT\) ensemble is that the above analysis of the volume statistics and of the particle number statistics is general, and does not rely upon the specific model. The reason for such generality is the dependence of the \(\mu VT\) thermodynamic potential and of the NPT thermodynamic potential on a single extensive parameter, i.e. V and N respectively. The same general behaviour does not hold for other statistical ensemble where the thermodynamic potential depends on more that one extensive quantity.

For instance, both the \(\mu VT\) ensemble and the NPT ensemble are derived from Legendre transforms of the NVT ensemble which, together with its thermodynamic potential \(F=-pV+\mu N\), depends on two extensive, fixed quantities, e.g. N and V. Thus, the intensive quantities P and \(\mu\) can depend on the ratio N/V, resulting in a non-linear dependence on N and yet an extensive Helmholtz free energy. An example is the ideal homogeneous classical gas in d dimensions, whose NVT partition function is5

$$\begin{aligned} Z_{NVT}=\frac{V^N}{N!\lambda _T^{dN}}, \end{aligned}$$
(41)

where \(\lambda _T=\sqrt{2\pi h^2\beta /m}\) is the thermal wavelength, and with the Helmholtz free energy

$$\begin{aligned} F=-\frac{\ln Z_{NVT}}{\beta }=-\frac{N}{\beta }\ln \frac{eV}{N\lambda _T^d}+{\mathcal {O}}(\ln N)=-PV+\mu N+{\mathcal {O}}(\ln N), \end{aligned}$$
(42)

where the Stirling’s approximation \(\ln N!=N\ln (N/e)+{\mathcal {O}}(\ln N)\) has been used. The pressure and the chemical potential are derivatives of the Helmholtz free energy:

$$\begin{aligned} P=-\frac{\partial F}{\partial V}=\frac{N}{\beta V}, \quad \mu =\frac{\partial F}{\partial N}=\frac{1}{\beta }\ln \frac{N\lambda _T^d}{V}. \end{aligned}$$
(43)

The possible non-linear dependence of the NVT thermodynamic parameter on N and on V, although F is extensive, results in model-dependent particle number statistics of the \(\mu VT\) ensemble and volume statistics of the NPT ensemble, after the respective Legendre transforms. This is not the case for volume statistics and particle number statistics in the \(\mu PT\) ensemble, because they are derived from Legendre transforms of the \(\mu VT\) ensemble and of the NPT ensemble respectively, which depend only on a single extensive, fixed parameter, namely V and N respectively. Thus, the \(\mu VT\) and the NPT thermodynamic potentials, in order to be extensive, can only have a linear dependence on V and N respectively. This implies simple and general volume and particle number statistics in the \(\mu PT\) ensemble.

Another difference between the \(\mu PT\) ensemble and others deals with the structure of Legendre transforms. When Legendre transforms are applied to derive statistical ensembles from others, e.g. NVT from NVE, \(\mu VT\) from NVT, or NPT from NVT, there are intensive quantities of the original ensemble that are not control parameters, but can be derived from derivatives of thermodynamic potentials (see the last column of Table 1, Eq. (43)). These intensive parameters depend on the control parameters that define the ensemble (as the ensemble names denote): among these control parameters there are also extensive quantities statistically conjugated to intensive parameters that are not control parameters. After a Legendre transform, an extensive, previously fixed, quantity becomes a stochastic variable and the dependence of its expectation value from the control parameters is the inverse function of its intensive statistically conjugated variable before the Legendre transform.

The aforementioned construction is not straightforward in the Legendre transform of the \(\mu VT\) ensemble with respect to the volume and in the Legendre transform of the NPT ensemble with respect to the particle number, both leading to the \(\mu PT\) ensemble. The reason is that pressure in the \(\mu VT\) ensemble and chemical potential in the NPT ensemble only depend on other intensive parameters and not on the volume or on the particle number respectively. This is the only way the thermodynamic potentials of the \(\mu VT\) and NPT ensembles, i.e. PV and \(-\mu N\) respectively, can be extensive. Nevertheless, the pressure and the chemical potential in the \(\mu PT\) ensemble are independent parameters. It is therefore natural to expect the emergence of a relation constraining the intensive parameters of the \(\mu PT\) ensemble from ensemble equivalence, as argued in “Discussion”.

Discussion

The following discussion summarizes general and model independent features of the \(\mu PT\) ensemble, based on derivations from the Legendre transform of the \(\mu VT\) ensemble with respect to the volume and from the Legendre transform of the NPT ensemble with respect to the particle number.

The average volume computed from the Legendre transform of the \(\mu VT\) ensemble (see Eq. (12), Fig. 1a) and the average number of particles computed from the Legendre transform of the NPT ensemble (see Eq. (32), Fig.  2a) resemble step functions. When \(V_2\) (\(N_2\)) diverges, the average volume (average number of particles) becomes discontinuous at the critical pressure \(P_c\) (critical chemical potential \(\mu _c\)), with a divergent plateau at small pressures \(P<P_c\) (large chemical potentials \(\mu >\mu _c\)). Such discontinuous behaviours resemble a first-order phase transition: e.g. the function \(\langle V\rangle (P)\), or its inverse \(P(\langle V\rangle )\), is qualitatively similar to the gas-liquid phase transition, and a similar behaviour for \(\langle N\rangle (\mu )\) and \(\mu (\langle N\rangle )\). The critical point is also characterised by variances of the volume and of the particle number diverging, respectively, as \((V_2-V_1)^2/12\) at \(P=P_c\) (see Eq. (15), Fig.  1b) and as \((N_2-N_1)^2/12\) at \(\mu =\mu _c\) (see Eq. (35) and Fig.  2b) for infinitely large \(V_2\) and \(N_2\), while they are intensive away from the critical values \(P=P_c\) and \(\mu =\mu _c\).

Fluctuations of the volume are related to fluctuations of the pressure, while fluctuations of the particle number are related to fluctuations of the chemical potential, through uncertainty relations that hold for statistically conjugated variables25,26,27,28. Even though pressure and chemical potential are fixed parameters, they can be seen as external fields subject to noise, e.g. experimental preparations or thermalisation processes affected by small imprecisions may lead to thermal states whose parameters have finite accuracy. Within estimation theory, the variance of pressure and chemical potential estimations, \(\delta ^2P\) and \(\delta ^2\mu\), are related to volume and particle number fluctuations by means of the Cramér–Rao bound29,30,31

$$\begin{aligned} \beta ^2\Delta ^2V\delta ^2P\geq \frac{1}{M}, \quad \beta ^2\Delta ^2N\delta ^2\mu \geq \frac{1}{M}, \end{aligned}$$
(44)

where M is the number of measurements. Similar relations can also be derived within the mathematical theory of Legendre transforms6. The Cramér–Rao bound is formulated using the Fisher information, which is a metric of states (or probability distributions) when they differ by an infinitesimally small parameter change. The Fisher information of the \(\mu PT\) ensemble equals \(\beta ^2\Delta ^2V\) when pressure is changed and \(\beta ^2\Delta ^2N\) when chemical potential is changed. Indeed, the estimation of intensive parameters of equilibrium ensembles are related to variances of statistically conjugated extensive variables: \(\beta ^2\Delta ^2X\delta ^2\xi \geq 1/M\), e.g. with \((\xi ,X)=(P,V)\) or \((\xi ,X)=(\mu ,N)\), and \(\Delta ^2H\delta ^2\beta \geq 1/M\). The connection between the Cramér–Rao bound, thermodynamic state geometry, and susceptibilities is discussed in Refs.32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54. For thermodynamic states away from critical points, variances of extensive variables X are extensive, implying fluctuations \(\Delta X/\langle X\rangle\) vanishing as the inverse of the square root of the system size; the same scaling, known as shot-noise limit in metrology, holds for the sensitivity \(\delta \xi\) of the intensive parameters \(\xi\).

Close to the critical pressure \(P=P_c\) and for large \(V_2\), the pressure is very close to the pressure in the \(\mu VT\) ensemble with a superextensive volume variance \(\Delta ^2V={\mathcal {O}}\big (\langle V\rangle ^2\big )\). This implies low, i.e. sub-shot-noise, uncertainty for the pressure, \(\delta P={\mathcal {O}}\big (1/\langle V\rangle \big )\). On the other hand, away from the critical pressure and for large \(V_2\), the variance of the volume is intensive, implying a large variance for the pressure \(\delta P={\mathcal {O}}(1)\), and sub-shot-noise scaling for the relative error of the volume \(\Delta V/\langle V\rangle ={\mathcal {O}}\big (1/\langle V\rangle \big )\). Moreover, when the domain of the volume integration is \([V_1,V_2]\rightarrow [0,\infty )\), the leftmost plateau in Fig.  1a goes to infinity, and the rightmost one assumes an intensive value. Therefore, the inverse function \(P\big (\langle V\rangle \big )\) is almost constant, i.e. equals \(P_c\) up to small deviations as discussed above, except for intensive average volume which is not very relevant for thermodynamic states. In this sense, the pressure in the \(\mu PT\) ensemble agrees with that in the \(\mu VT\) ensemble, namely \(P_c\) which is determined by \(\beta\), \(\mu\), and V.

A completely similar interpretation holds for the variance of the particle number and to that of the chemical potential. The chemical potential is very close to its value in the NPT ensemble with a superextensive particle number variance \(\Delta ^2N={\mathcal {O}}\big (\langle N\rangle ^2\big )\), close to the critical chemical potential \(\mu =\mu _c\) and for large \(N_2\). Therefore, the uncertainty for the chemical potential, \(\delta \mu ={\mathcal {O}}\big (1/\langle N\rangle \big )\), obeys sub-shot-noise scaling. On the other hand, the intensivity of the particle number variance, away from the critical chemical potential and for large \(N_2\), implies a large variance for the chemical potential, \(\delta \mu ={\mathcal {O}}(1)\), but sub-shot-noise limited relative error for the number of particles, \(\Delta N/\langle N\rangle ={\mathcal {O}}\big (1/\langle N\rangle \big )\). Furthermore, when the domain of the particle number summation is \([N_1,N_2]\rightarrow [0,\infty ]\), the rightmost plateau in Fig. 2a goes to infinity, and the leftmost one assumes an intensive value. Therefore, the inverse function \(\mu \big (\langle N\rangle \big )\) almost coincides with \(\mu _c\), with small deviations \(\delta \mu\), except for intensive average number of particles which is not very relevant for thermodynamic states. In this sense, the chemical potential in the \(\mu PT\) ensemble agrees with that in the NPT ensemble, namely \(\mu _c\) which is determined by \(\beta\), P, and V.

The thermodynamic equivalence between the \(\mu PT\) and the \(\mu VT\) ensembles require, in particular, that the two ensembles predict the same pressure, namely \(P=P_c\). Similarly, thermodynamic equivalence between the \(\mu PT\) and the NPT ensembles require \(\mu =\mu _c\). Relations \(P=P_c\) and \(\mu =\mu _c\) are manifestations of the Gibbs-Duhem equation. The need for relations among intensive quantities \(\beta\), \(\mu\) and P can be derived also from requiring equivalence of other thermal quantities when computed from the Legendre transform of the \(\mu VT\) and that of the NPT ensembles.

Consider the density

$$\begin{aligned} \frac{\langle N\rangle }{\langle V\rangle }\overset{\begin{array}{c} \text {from}\\ (16) \end{array}}{=}\frac{\partial P_c}{\partial \mu }\overset{\begin{array}{c} \text {from}\\ (36) \end{array}}{=}\left( \frac{\partial \mu _c}{\partial P}\right) ^{-1}. \end{aligned}$$
(45)

Since \(P_c\) is derived from the \(\mu VT\) ensemble, it depends only on \(\beta\) and \(\mu\) and not on P, and therefore the same holds for \(\frac{\partial P_C}{\partial \mu }\). Analogously, \(\mu\) and \(\frac{\partial \mu _c}{\partial P}\), being derived using the NPT ensemble, are functions of \(\beta\) and P but not of \(\mu\). In other words, the left-hand-side of the last equality in (45) is a function only of \(\beta\) and \(\mu\), while the right-hand-side is a function only of \(\beta\) and P. Thus, the only possibility to fulfil Eq. (45) for any value of intensive quantities is that \(\frac{\partial P_C}{\partial \mu }\) does not depend on \(\mu\) and that \(\frac{\partial \mu _c}{\partial P}\) does not depend on P. These conditions are so restrictive that are not met in several statistical models, like those studied below. It follows that intensive quantities \(\beta\), \(\mu\) and P cannot be completely independent, but are constrained by the relation (45).

Compare now fluctuations (14) and (17), derived from the Legendre transform of the \(\mu VT\) ensemble, with fluctuations (34) and (37), derived from the Legendre transform of the NPT ensemble. The fluctuation term \(\Delta ^2 V\) of the particle number variance (17) is superextensive close to the critical point \(P=P_c\) and intensive otherwise, whereas the contribution \(\langle V\rangle\) is extensive for \(P\leqslant P_c\). Therefore, the particle number variance (17), \(\Delta ^2 N\), is extensive for \(P\leqslant P_c\). This is in contradiction with the particle number variance (34), derived from the Legendre transform of the NPT ensemble, which is superextensive close to \(\mu =\mu _c\) and intensive otherwise.

Similarly, the term \(\Delta ^2 N\) of the volume variance (37) is intensive away from the critical point \(\mu =\mu _c\), whereas the contribution \(\langle N\rangle\) is extensive for \(\mu \geq \mu _c\). Therefore, the variance (37), \(\Delta ^2 V\), is extensive for \(\mu \geq \mu _c\). On the other hand, the volume variance (14), derived from the Legendre transform of the \(\mu VT\) ensemble, is superextensive close to \(P=P_c\) and intensive otherwise. In conclusion, fluctuations derived from the Legendre transform of the \(\mu VT\) ensemble agree with those derived from the Legendre transform of the NPT ensemble only if \(P=P_c\) and \(\mu =\mu _c\).

The reason for these apparent contradictions is that the Legendre transforms with respect to the volume and to the particle number, both needed to derive the \(\mu PT\) ensemble from the NVT ensemble, do not commute. Furthermore, the relations between thermodynamic potentials, \(-P_cV\) and \(\mu _cN\), with partition functions in Eqs. (6) and (26), respectively, are the leading orders for large system size3. Therefore, the order of the Legendre transforms could be dictated by the relative scaling between the volume range and the particle number range, which depends on the specific physical model or on experimental conditions. The ensemble equivalence can also be checked in specific models, as shall be discussed in the next Section.

Examples

Quantum ideal homogeneous gases

The above general results can be exemplified by specific models, e.g. the quantum ideal homogeneous gas in d dimensions. The Hamiltonian is \(H=\sum _{j=1}^N\frac{\mathbf{p}_j^2}{2m}\), with \(\mathbf{p}_j\) the momentum of the j-th particle. The pressure in the \(\mu VT\) ensemble is

$$\begin{aligned} P_c=\frac{\pm \text {Li}_{\frac{d}{2}+1}(\pm e^{\beta \mu })}{\beta \, \lambda _T^d}, \end{aligned}$$
(46)

where \(\lambda _T=\sqrt{2\pi h^2\beta /m}\) is the thermal wavelength, \(\text {Li}_s(\cdot )\) is the polylogarithm55 of order s, and the upper (lower) sign holds for Bosons (Fermions). Using this expression for \(P_c\) specifies thermal quantities of the \(\mu PT\) ensemble derived as the Legendre transform of the \(\mu VT\) ensemble (see “Legendre transform of the \(\mu VT\) ensemble ”). Recall that the derivative of the polylogarithm satisfies \(x\frac{\partial }{\partial x}\text {Li}_s(x)=\text {Li}_{s-1}(x)\).

Thermal averages and fluctuations

The relation between the average number of particles and the average volume is

$$\begin{aligned} \langle N\rangle =\pm \frac{\langle V\rangle }{\lambda _T^d}\text {Li}_{\frac{d}{2}}(\pm e^{\beta \mu }), \end{aligned}$$
(47)

which is, as the general case (16), the same equation as in the \(\mu VT\) ensemble with the fixed volume replaced by the average volume. In particular, Eq. (47) for the Bose gas implies that the critical temperature for the Bose–Einstein condensation in the \(\mu PT\) ensemble is the same as in the \(\mu VT\) one. In fact, the critical temperature is defined by the particle number reaching its upper bound in the continuum spectrum limit. Thus, when the actual particle number exceeds that bound, low-lying energy levels have macroscopic, and indeed singular in the continuum spectrum limit, occupations.

The average energy is

$$\begin{aligned} \langle H\rangle =\pm \frac{d\langle V\rangle }{2\beta \lambda _T^d}\text {Li}_{\frac{d}{2}+1}(\pm e^{\beta \mu })=\frac{d}{2}\,P_c\langle V\rangle . \end{aligned}$$
(48)

The relation between volume and particle number fluctuations is

$$\begin{aligned} \Delta ^2 N=\pm \frac{\langle V\rangle }{\lambda _T^d}\text {Li}_{\frac{d}{2}-1}(\pm e^{\beta \mu })+\frac{\langle N\rangle ^2}{\langle V\rangle ^2}\Delta ^2 V. \end{aligned}$$
(49)

Heat capacities

Heat capacities at constant volume and pressure are

$$\begin{aligned} C_V&= \left( \frac{d}{2}+1\right) k_B\beta \langle H\rangle -d\,k_B\beta \,\mu \,\langle N\rangle +k_B\,\beta ^2\mu ^2\left( \Delta ^2N-\frac{\langle N\rangle ^2}{\langle V\rangle ^2}\Delta ^2V\right) , \end{aligned}$$
(50)
$$\begin{aligned} C_P&= C_V+k_B\beta ^2\left( P+\frac{\langle H\rangle }{\langle V\rangle }-\mu \,\frac{\langle N\rangle }{\langle V\rangle }\right) ^2\Delta ^2V. \end{aligned}$$
(51)

Equations (50) and (51) are different from the standard textbook heat capacities where the particle number is fixed, because they also include contibutions due to fluctuations of particle number and volume.

When both volume and particle number are constant, \(\frac{\langle N\rangle }{\langle V\rangle }=\frac{\partial P_c}{\partial \mu }\) is constant as well, resulting in an implicit relation between \(\beta\) and \(\mu\). The heat capacity under these conditions is

$$\begin{aligned} C_{V,N}=\left( \frac{dQ}{dT}\right) _{\langle V\rangle ,\langle N\rangle }=-k_B\beta ^2\left( \frac{d\langle H\rangle }{d\beta }\right) _{\langle V\rangle ,\langle N\rangle }=\left( \frac{d}{2}+1\right) k_B\beta \langle H\rangle -\frac{d}{2}\,k_B\beta \langle N\rangle \,\frac{1}{z}\left( \frac{dz}{d\beta }\right) _{\langle V\rangle ,\langle N\rangle }, \end{aligned}$$
(52)

where \(z=e^{\beta \mu }\) is the fugacity. From the derivative of Eq. (47) with respect to \(\beta\), one obtains the derivative of the fugacity:

$$\begin{aligned} 0= & {} \left( \frac{d}{d\beta }\frac{\partial P_c}{\partial \mu }\right) _{\langle V\rangle ,\langle N\rangle }=-\frac{d}{2}\cdot \frac{\text {Li}_{\frac{d}{2}}(z)}{\beta \lambda _T^d} \pm \frac{\text {Li}_{\frac{d}{2}-1}(z)}{z\lambda _T^d}\cdot \left( \frac{dz}{d\beta }\right) _{\langle V\rangle ,\langle N\rangle } \nonumber \\= & {} -\frac{d}{2\beta }\cdot \frac{\langle N\rangle }{\langle V\rangle }+\left( \frac{\Delta ^2N}{\langle V\rangle }-\frac{\langle N\rangle ^2}{\langle V\rangle ^3}\Delta ^2V\right) \cdot \frac{1}{z}\left( \frac{dz}{d\beta }\right) _{\langle V\rangle ,\langle N\rangle }. \end{aligned}$$
(53)

Therefore, the heat capacity at constant volume and particle number is

$$\begin{aligned} C_{V,N}=\left( \frac{d}{2}+1\right) k_B\beta \langle H\rangle -k_B\,\frac{d^2}{4}\cdot \frac{\langle N\rangle ^2\langle V\rangle ^2}{\langle V\rangle ^2\Delta ^2N-\langle N\rangle ^2\Delta ^2V}. \end{aligned}$$
(54)

When pressure and particle number are both constant, the heat capacity is

$$\begin{aligned} C_{P,N}=&\left( \frac{dQ}{dT}\right) _{P,\langle N\rangle }=-k_B\beta ^2\left( \frac{d\langle H\rangle }{d\beta }\right) _{P,\langle N\rangle }-k_B\beta ^2P\left( \frac{d\langle V\rangle }{d\beta }\right) _{P,\langle N\rangle } \nonumber \\ =&\left( \frac{d}{2}+1\right) k_B\beta \langle H\rangle -\frac{d}{2}k_B\beta \langle N\rangle \cdot \frac{1}{z}\left( \frac{dz}{d\beta }\right) _{P,\langle N\rangle }-k_B\beta ^2\left( \frac{\langle H\rangle }{\langle V\rangle }+P\right) \left( \frac{d\langle V\rangle }{d\beta }\right) _{P,\langle N\rangle } \nonumber \\ =&-\frac{d}{2}k_B\beta ^2\left( \frac{dP_c}{d\beta }\right) _{P,\langle N\rangle }\langle V\rangle -k_B\beta ^2\left( \frac{d}{2}P_c+P\right) \left( \frac{d\langle V\rangle }{d\beta }\right) _{P,\langle N\rangle }. \end{aligned}$$
(55)

The derivative of the average volume is obtained from the following condition

$$\begin{aligned} 0&=\left( \frac{d\langle N\rangle }{d\beta }\right) _{P,\langle N\rangle }= \left( \frac{d}{d\beta }\frac{\partial P_c}{\partial \mu }\right) _{P,\langle N\rangle }\langle V\rangle +\frac{\partial P_c}{\partial \mu }\cdot \left( \frac{d\langle V\rangle }{d\beta }\right) _{P,\langle N\rangle } \nonumber \\&= -\frac{d}{2\beta }\langle N\rangle +\left( \Delta ^2N-\frac{\langle N\rangle ^2}{\langle V\rangle ^2}\Delta ^2V\right) \cdot \frac{1}{z}\left( \frac{dz}{d\beta }\right) _{P,\langle N\rangle }+\frac{\langle N\rangle }{\langle V\rangle }\cdot \left( \frac{d\langle V\rangle }{d\beta }\right) _{P,\langle N\rangle }, \end{aligned}$$
(56)

and the derivative of the fugacity follows from

$$\begin{aligned} \left( \frac{dP_c}{d\beta }\right) _{P,\langle N\rangle }=-\left( \frac{d}{2}+1\right) \frac{P_c}{\beta }+\frac{\langle N\rangle }{\langle V\rangle }\cdot \frac{1}{\beta z}\left( \frac{dz}{d\beta }\right) _{P,\langle N\rangle }. \end{aligned}$$
(57)

Using the above relations, we obtain

$$\begin{aligned} C_{P,N}=&-\frac{d}{2}k_B\beta \left( \beta \left( \frac{dP_c}{d\beta }\right) _{P,\langle N\rangle }+\frac{d}{2}P_c+P\right) \langle V\rangle \nonumber \\&+k_B\beta ^2\left( \frac{d}{2}P_c+P\right) \left( \beta \left( \frac{dP_c}{d\beta }\right) _{P,\langle N\rangle }+\left( \frac{d}{2}+1\right) P_c\right) \frac{\langle V\rangle ^2}{\langle N\rangle ^2}\left( \Delta ^2N-\frac{\langle N\rangle ^2}{\langle V\rangle ^2}\Delta ^2V\right) . \end{aligned}$$
(58)

Equation (58) is not an explicit formula, because the constrained derivative \(\left( \frac{dP_c}{d\beta }\right) _{P,\langle N\rangle }\) has to be determined yet but it vanishes when \(P=P_c\).

Classical ideal homogeneous gas

The Legendre transform of the \(\mu VT\) for the classical ideal homogeneous gas is the classical limit of the quantum homogeneous gas, namely the limit of small fugacity \(e^{\beta \mu }\ll 1\), which implies55 \(\text {Li}_s\big (\pm e^{\beta \mu }\big )\simeq \pm e^{\beta \mu }\). Therefore, thermal quantities computed in the previous section become

$$\begin{aligned} P_c&= \frac{e^{\beta \mu }}{\beta \lambda _T^d}, \end{aligned}$$
(59)
$$\begin{aligned} \langle N\rangle&= \frac{e^{\beta \mu }}{\lambda _T^d}\langle V\rangle , \end{aligned}$$
(60)
$$\begin{aligned} \langle H\rangle&= \frac{d}{2\beta }\langle N\rangle , \end{aligned}$$
(61)
$$\begin{aligned} \Delta ^2 N&= \langle N\rangle +\frac{\langle N\rangle ^2}{\langle V\rangle ^2}\Delta ^2 V, \end{aligned}$$
(62)
$$\begin{aligned} C_V&= k_B\left( \frac{d}{2}+\left( \frac{d}{2}-\beta \,\mu \right) ^2\right) \langle N\rangle , \end{aligned}$$
(63)
$$\begin{aligned} C_P&= C_V+k_B\beta ^2\left( P+\left( \frac{d}{2\beta }-\mu \right) \frac{e^{\beta \mu }}{\lambda _T^d}\right) ^2\Delta ^2V, \end{aligned}$$
(64)
$$\begin{aligned} C_{V,N}&= \frac{d}{2}k_B\langle N\rangle , \end{aligned}$$
(65)
$$\begin{aligned} C_{P,N}&= \frac{d}{2}k_B\left( 1-\frac{P}{P_c}\right) \langle N\rangle +\left( \frac{d}{2}+1+\frac{\beta }{P_c}\left( \frac{dP_c}{d\beta }\right) _{P,\langle N\rangle }\right) k_B\frac{P}{P_c}\langle N\rangle . \end{aligned}$$
(66)

Using the relation \(P=P_c\), which implies \(\left( \frac{dP_c}{d\beta }\right) _{P,\langle N\rangle }\rightarrow 0\), we derive the standard heat capacities of the classical ideal gas, i.e. \(C_{P,N}=C_{V,N}+k_B\langle N\rangle =\left( \frac{d}{2}+1\right) k_B\langle N\rangle\).

We now focus on the Legendre transform of the NPT ensemble for the classical ideal homogeneous gas. The NPT partition function is5

$$\begin{aligned} Z_{NPT}=\frac{e^{-\beta \mu _c N}}{V_0\beta P}, \end{aligned}$$
(67)

with

$$\begin{aligned} \mu _c=\frac{1}{\beta }\ln (\beta P\lambda _T^d), \end{aligned}$$
(68)

leading to the \(\mu PT\) partition function

$$\begin{aligned} Z_{\mu PT}=\sum _{N=N_1}^{N_2}e^{\beta \mu N}Z_{NPT}=\frac{e^{\beta N_1(\mu -\mu _c)}-e^{\beta (N_2+1)(\mu -\mu _c)}}{V_0\beta P(1-e^{\beta (\mu -\mu _c)})}. \end{aligned}$$
(69)

Note that the critical chemical potential \(\mu _c\) introduced in Eq. (67) is different from that in (26), but their difference is negligible, e.g., if \(N\gg 1\), so that \(Z_{NPT}=e^{-\beta \mu _c N-\ln (V_0\beta P)}\simeq e^{-\beta \mu _c N}\). In particular the two critical chemical potentials agree in the thermodynamic limit, but also for moderately large particle number, like \(N\sim 10^3\) as in small thermodynamical systems9,12,14. Consequently, also thermal quantities computed from the partition functions (69) and from (27), using the critical chemical potential (68), agree within negligible corrections.

Furthermore, the two equations \(P=P_c\) and \(\mu =\mu _c\) are equivalent. Therefore, as described in section “Discussion”, the variances of the volume and of the particle number are both superextensive, in agreement with the linear relations in Eqs. (49) and (62). The equivalence of the two critical conditions \(P=P_c\) and \(\mu =\mu _c\) agrees with our general arguments reported in Discussion, supporting that these conditions are necessary for the equivalence of the \(\mu PT\) ensemble with both the \(\mu VT\) and the NPT ones.

Thermal averages and fluctuations

Averages of particle number and of the volume are related by the following equation

$$\begin{aligned} \langle V\rangle =\frac{\langle N\rangle +1}{\beta P}=\frac{\lambda _T^d}{e^{\beta \mu _c}}\big (\langle N\rangle +1\big ). \end{aligned}$$
(70)

Equation (70) agrees with the prediction of the Legendre transform of the \(\mu VT\) ensemble, e.g. Eq. (60), in the thermodynamic limit only if \(\mu =\mu _c\).

The average energy is

$$\begin{aligned} \langle H\rangle =\frac{d}{2\beta }\langle N\rangle , \end{aligned}$$
(71)

which agrees with the formula derived from the Legendre transform of the \(\mu VT\) ensemble, i.e. Eq. (61).

The variances of the particle number and of the volume fulfil the following relation:

$$\begin{aligned} \Delta ^2V=\frac{\langle V\rangle ^2}{\big (\langle N\rangle +1\big )^2}\left( \Delta ^2N+\langle N\rangle +1\right) , \end{aligned}$$
(72)

which agrees with Eq. (62) for \(\langle N\rangle \gg 1\).

Heat capacities

Heat capacities at constant volume and pressure can be computed, respectively, from Eqs. (39) (40) using the critical chemical potential (68):

$$\begin{aligned} C_V=&k_B\,\beta \,\mu \,\langle N\rangle , \end{aligned}$$
(73)
$$\begin{aligned} C_P=&\left( \frac{d}{2}+1\right) k_B\langle N\rangle +\left( \frac{d}{2}+1-\beta \mu \right) ^2k_B\,\Delta ^2N. \end{aligned}$$
(74)

Heat capacities at constant particle number are easily computed:

$$\begin{aligned} C_{V,N}&= \left( \frac{dQ}{dT}\right) _{\langle V\rangle ,\langle N\rangle }=-k_B\beta ^2\left( \frac{d\langle H\rangle }{d\beta }\right) _{\langle V\rangle ,\langle N\rangle }=\frac{d}{2}k_B\langle N\rangle , \end{aligned}$$
(75)
$$\begin{aligned} C_{P,N}&= \left( \frac{dQ}{dT}\right) _{P,\langle N\rangle }=-k_B\beta ^2\left( \frac{d\langle H\rangle }{d\beta }+P\,\frac{d\langle V\rangle }{d\beta }\right) _{P,\langle N\rangle }=\left( \frac{d}{2}+1\right) k_B\langle N\rangle +k_B, \end{aligned}$$
(76)

which are the standard heat capacities for \(\langle N\rangle \gg 1\).

Mean-field Bose gas

This section is devoted to the Bose gas with mean-field interactions, namely with the interaction hamiltonian \(\lambda \frac{N}{2V}\). The partition function of the \(\mu VT\) ensemble was computed for a class of free Hamiltonians56. Consider here the free Hamiltonian of the ideal homogeneous gas in d dimensions for concreteness. The pressure derived in the \(\mu VT\) ensemble is

$$\begin{aligned} P_c^{(\lambda )}(\mu )=\frac{(\mu -\alpha )^2}{2\lambda }+P_c^{(0)}(\alpha ), \end{aligned}$$
(77)

where \(P_c^{(0)}(\alpha )\) is the critical pressure of the non-interacting gas in Eq. (46) with the upper sign and with \(\mu\) replaced by \(\alpha\), \(\alpha\) is zero is \(\mu \geq \lambda \rho _{\text {B}EC}\) and is the unique solution of \(\alpha +\lambda \partial _\alpha P_c^{(0)}(\beta ,\alpha )=\mu\) if \(\mu <\lambda \rho _{\text {B}EC}\), and \(\rho _{\text {B}EC}\) is the critical density of the Bose–Einstein condensation which coincides with that of the non-interacting gas. We shall focus on the regime \(\mu <\lambda \rho _{\text {B}EC}\), that is above the Bose-Einstein condensation temperature. Using the definition of \(\alpha\), the derivatives of the critical pressure (77) can be expressed as

$$\begin{aligned} \frac{\partial P_c^{(\lambda )}(\mu )}{\partial \beta }&=\frac{\alpha (\mu -\alpha )}{\lambda \beta }-\left( \frac{d}{2}+1\right) \frac{P_c^{(0)}(\alpha )}{\beta }, \end{aligned}$$
(78)
$$\begin{aligned} \frac{\partial P_c^{(\lambda )}(\mu )}{\partial \mu }&=\frac{\mu -\alpha }{\lambda }=\frac{\partial P_c^{(0)}(\alpha )}{\partial \alpha }=\frac{\text {Li}_{\frac{d}{2}}(e^{\beta \alpha })}{\lambda _T^d}, \end{aligned}$$
(79)
$$\begin{aligned} \frac{\partial P_c^{(\lambda )}(\mu )}{\partial \alpha }&=0. \end{aligned}$$
(80)

From the definition of \(\alpha\), its derivatives satisfy

$$\begin{aligned}&\frac{\partial \alpha }{\partial \beta } =-\lambda \frac{\partial ^2P_c^{(0)}(\alpha )}{\partial \beta \partial \alpha }=\frac{\lambda }{\lambda _T^d}\left( \frac{d}{2\beta }\text {Li}_{\frac{d}{2}}(e^{\beta \alpha })-\alpha \text {Li}_{\frac{d}{2}-1}(e^{\beta \alpha })\right) -\lambda \,\frac{\partial \alpha }{\partial \beta }\cdot \frac{\partial ^2P_c^{(0)}(\alpha )}{\partial \alpha ^2}, \end{aligned}$$
(81)
$$\begin{aligned}&\frac{\partial \alpha }{\partial \mu } =1-\lambda \,\frac{\partial ^2P_c^{(0)}(\alpha )}{\partial \mu \partial \alpha }=1-\lambda \,\frac{\partial \alpha }{\partial \mu }\cdot \frac{\partial ^2P_c^{(0)}(\alpha )}{\partial \alpha ^2}. \end{aligned}$$
(82)

Using the expression

$$\begin{aligned} \frac{\partial ^2P_c^{(0)}(\alpha )}{\partial \alpha ^2}=\frac{\beta }{\lambda _T^d}\,\text {Li}_{\frac{d}{2}-1}(e^{\beta \alpha }), \end{aligned}$$
(83)

one computes

$$\begin{aligned} \frac{\partial \alpha }{\partial \mu }&=\frac{\lambda _T^d}{\lambda _T^d+\lambda \beta \text {Li}_{\frac{d}{2}-1}(e^{\beta \alpha })}, \end{aligned}$$
(84)
$$\begin{aligned} \frac{\partial \alpha }{\partial \beta }&=\frac{\lambda }{2\beta }\cdot \frac{d\text {Li}_{\frac{d}{2}}(e^{\beta \alpha })-2\beta \alpha \text {Li}_{\frac{d}{2}-1}(e^{\beta \alpha })}{\lambda _T^d+\lambda \beta \text {Li}_{\frac{d}{2}-1}(e^{\beta \alpha })}. \end{aligned}$$
(85)

ddd Plugging these derivatives in the general formulas in section Results, we obtain the thermal quantities of the mean-field Bose gas.

Thermal averages and fluctuations

The average particle number and the average energy are, respectively,

$$\begin{aligned} \langle N\rangle&=\frac{\mu -\alpha }{\lambda }\langle V\rangle , \end{aligned}$$
(86)
$$\begin{aligned} \langle H\rangle&=\left( \frac{d}{2} \, P_c^{(0)}(\alpha )+\frac{\left( \mu -\alpha \right) ^2}{2\lambda }\right) \langle V\rangle =\left( P_c^{(\lambda )}(\mu )+\left( \frac{d}{2}-1\right) P_c^{(0)}(\alpha )\right) \langle V\rangle . \end{aligned}$$
(87)

The relation between the variance of the particle number and the variance of the volume is

$$\begin{aligned} \Delta ^2N=\left( 1-\frac{\partial \alpha }{\partial \mu }\right) \frac{\langle V\rangle }{\lambda \beta }+\left( \frac{\mu -\alpha }{\lambda }\right) ^2\Delta ^2V. \end{aligned}$$
(88)

Heat capacities

Heat capacities at constant volume and pressure are

$$\begin{aligned} C_V&= k_B\beta \langle V\rangle \left( \left( \frac{d}{2}+1\right) \frac{d}{2}P_c^{(0)}(\alpha )-\frac{d}{2}\cdot \frac{\alpha \,(\mu -\alpha )}{\lambda }-\left( \frac{\alpha }{\lambda }+\frac{d}{2}\cdot \frac{\mu -\alpha }{\lambda }\right) \beta \,\frac{\partial \alpha }{\partial \beta }\right) \end{aligned}$$
(89)
$$\begin{aligned} C_P&= C_V+k_B\beta ^2\left( P+\frac{\langle H\rangle }{\langle V\rangle }-\frac{\alpha \,(\mu -\alpha )}{\lambda }\right) ^2\Delta ^2V. \end{aligned}$$
(90)

When both volume and particle number are constant, the derivative of Eq. (86) reads, where \(t=e^{\beta \alpha }\),

$$\begin{aligned} 0= & {} \left( \frac{d}{d\beta }\frac{\langle N\rangle }{\langle V\rangle }\right) _{\langle V\rangle ,\langle N\rangle }=\left( \frac{d}{d\beta }\,\frac{\mu -\alpha }{\lambda }\right) _{\langle V\rangle ,\langle N\rangle }=\left( \frac{d}{d\beta }\,\frac{\partial P_c^{(0)}(\alpha )}{\partial \alpha }\right) _{\langle V\rangle ,\langle N\rangle }\nonumber \\= & {} \frac{\text {Li}_{\frac{d}{2}-1}(t)}{\lambda _T^dt}\cdot \left( \frac{dt}{d\beta }\right) _{\langle V\rangle ,\langle N\rangle } -\frac{d}{2}\cdot \frac{\text {Li}_{\frac{d}{2}}(t)}{\beta \lambda _T^d}. \end{aligned}$$
(91)

The second equality in (91) simplifies the heat capacity with both volume and particle number constant:

$$\begin{aligned} C_{V,N}=\left( \frac{dQ}{dT}\right) _{\langle V\rangle ,\langle N\rangle }=-k_B\beta ^2\left( \frac{d\langle H\rangle }{d\beta }\right) _{\langle V\rangle ,\langle N\rangle }=-k_B\beta ^2\langle V\rangle \frac{d}{2}\left( \frac{dP_c^{(0)}(\alpha )}{d\beta }\right) _{\langle V\rangle ,\langle N\rangle }. \end{aligned}$$
(92)

Using the following derivative

$$\begin{aligned} \frac{dP_c^{(0)}(\alpha )}{d\beta }=\frac{\text {Li}_{\frac{d}{2}-1}(t)}{\beta \lambda _T^d t}\cdot \frac{dt}{d\beta } -\left( \frac{d}{2}+1\right) \frac{P_c^{(0)}(\alpha )}{\beta }, \end{aligned}$$
(93)

and substituting \(\left( \frac{dt}{d\beta }\right) _{\langle V\rangle ,\langle N\rangle }\) from Eq. (91), one obtains the heat capacity

$$\begin{aligned} C_{V,N}=k_B\langle V\rangle \frac{d}{2}\left( \left( \frac{d}{2}+1\right) \beta P_c^{(0)}(\alpha ) -\frac{d}{2\lambda _T^d}\cdot \frac{\text {Li}^2_{\frac{d}{2}}(t)}{\text {Li}_{\frac{d}{2}-1}(t)} \right) . \end{aligned}$$
(94)

The heat capacity when pressure and particle number are both constant is

$$\begin{aligned} C_{P,N}=&\left( \frac{dQ}{dT}\right) _{P,\langle N\rangle }=-k_B\beta ^2\left( \frac{d\langle H\rangle }{d\beta }\right) _{P,\langle N\rangle }-k_B\beta ^2P\left( \frac{d\langle V\rangle }{d\beta }\right) _{P,\langle N\rangle } \nonumber \\ =&-k_B\beta ^2\langle V\rangle \left( \left( \frac{dP_c^{(\lambda )}(\mu )}{d\beta }\right) _{P,\langle N\rangle }+\left( \frac{d}{2}+1\right) \left( \frac{dP_c^{(0)}(\alpha )}{d\beta }\right) _{P,\langle N\rangle }+\left( \frac{\langle H\rangle }{\langle V\rangle }+P\right) \left( \frac{d\langle V\rangle }{d\beta }\right) _{P,\langle N\rangle } \right) . \end{aligned}$$
(95)

First, plug the derivative (93) into (95), then eliminate \(\left( \frac{d\langle V\rangle }{d\beta }\right) _{P,\langle N\rangle }\) from

$$\begin{aligned} 0=\left( \frac{d\langle N\rangle }{d\beta }\right) _{P,\langle N\rangle }=\frac{\text {Li}_{\frac{d}{2}}(t)}{\lambda _T^d}\left( \left( \frac{d\langle V\rangle }{d\beta }\right) _{P,\langle N\rangle }-\frac{d}{2\beta }\langle V\rangle \right) +\frac{\text {Li}_{\frac{d}{2}-1}(t)}{\lambda _T^d t}\cdot \left( \frac{dt}{d\beta }\right) _{P,\langle N\rangle }, \end{aligned}$$
(96)

and the derivative \(\frac{dt}{d\beta }\) from

$$\begin{aligned} \left( \frac{dP_c^{(\lambda )}(\mu )}{d\beta }\right) _{P,\langle N\rangle }&=\frac{\lambda }{2}\left( \frac{d}{d\beta }\left( \frac{\partial P_c^{(0)}(\alpha )}{\partial \alpha }\right) ^2\right) _{P,\langle N\rangle }+\left( \frac{dP_c^{(0)}(\alpha )}{d\beta }\right) _{P,\langle N\rangle } \nonumber \\&= \left( \frac{dt}{d\beta }\right) _{P,\langle N\rangle }\frac{\text {Li}_{\frac{d}{2}}(t)}{t\lambda _T^d}\left( \frac{1}{\beta }+\frac{\lambda \text {Li}_{\frac{d}{2}-1}(t)}{\lambda _T^d}\right) -\left( \frac{d}{2}+1\right) \frac{P_c^{(0)}(\alpha )}{\beta }-\frac{d\lambda }{2\beta }\left( \frac{\text {Li}_{\frac{d}{2}}(t)}{\lambda _T^d}\right) ^2. \end{aligned}$$
(97)

Finally, the heat capacity at constant pressure and particle number is

$$\begin{aligned} C_{P,N}=&-k_B\beta \langle V\rangle \left( \beta \left( \frac{dP_c^{(\lambda )}(\mu )}{d\beta }\right) _{P,\langle N\rangle }\frac{\frac{d}{2}\lambda _T^d+\lambda \beta \text {Li}_{\frac{d}{2}-1}(t)}{\lambda _T^d+\lambda \beta \text {Li}_{\frac{d}{2}-1}(t)}+\frac{d}{2}\left( \frac{\langle H\rangle }{\langle V\rangle }+P\right) \frac{\lambda _T^d+2\lambda \beta \text {Li}_{\frac{d}{2}-1}(t)}{\lambda _T^d+\lambda \beta \text {Li}_{\frac{d}{2}-1}(t)}\right. \nonumber \\&+\left( \frac{\langle H\rangle }{\langle V\rangle }+P\right) \left( \beta \left( \frac{dP_c^{(\lambda )}(\mu )}{d\beta }\right) _{P,\langle N\rangle }+\left( \frac{d}{2}+1\right) P_c^{(\lambda )}(\mu )\right) \left( \frac{\lambda _T^d}{\text {Li}_{\frac{d}{2}}(t)}\right) ^2\frac{\text {Li}_{\frac{d}{2}-1}(t)}{\lambda _T^d+\lambda \beta \text {Li}_{\frac{d}{2}-1}(t)} \nonumber \\&\left. -\left( \frac{d^2}{4}-1\right) P_c^{(\lambda )}(\mu )\frac{\lambda \beta \text {Li}_{\frac{d}{2}-1}(t)}{\lambda _T^d+\lambda \beta \text {Li}_{\frac{d}{2}-1}(t)}+\frac{d}{2}\left( \frac{d}{2}-1\right) \left( \frac{\lambda _T^d}{\lambda \text {Li}_{\frac{d}{2}}(t)}\right) ^2\frac{\lambda \lambda _T^d}{\lambda _T^d+\lambda \beta \text {Li}_{\frac{d}{2}-1}(t)}\right) . \end{aligned}$$
(98)

All the expressions for the mean field Bose gas recover those for the ideal homogeneous gas, when \(\lambda \rightarrow 0\), recalling that \(\alpha \rightarrow \mu\) and \(t\rightarrow z\) in this limit.

Conclusions

In conclusion, the \(\mu PT\) statistical ensemble, analysed here, describes equilibrium systems which exchange energy, particles, and volume with the surrounding. This ensemble finds applications in the thermodynamics of small systems, like nanothermodynamics, systems with long-range interactions, and systems confined within porous and elastic membranes. The statistics of the volume and of the particle number do not depend on the specific model, i.e. on the Hamiltonian, as a consequence of the Legendre transforms performed on all the extensive quantities. Another peculiarity of the \(\mu PT\) ensemble is that values of pressure and chemical potential agree with \(\mu VT\) and NPT ensembles only around non-analytic points \(P=P_c\) and \(\mu =\mu _c\) at which, however, fluctuations of volume and particle number are superextensive. The constraint on intensive parameters, in agreement with the thermodynamical Gibbs-Duhem equation, also emerges from the requirement that the order of the Legendre transforms with respect to the volume and to the particle number do not alter thermodynamic relations in the \(\mu PT\) ensemble. Therefore, the breakdown of the Gibbs-Duhem equation is related to the non-commutativity of Legendre transforms for large system size. The order of the Legendre transforms could be indicated by the specific model or by experimental conditions. Quantum and classical ideal gases, and a quantum mean-field Bose gas exemplify the general features of the \(\mu PT\) ensemble. In particular, ensemble properties of the classical ideal gas can be derived both from the Legendre transform of the \(\mu VT\) ensemble and from the Legendre transform of the NPT ensemble. Therefore, this model shows a specific instance of the non-commutativity of the Legendre transforms and of the need of the self-consistency conditions \(P=P_c\) and \(\mu =\mu _c\), described in full generality in section “Discussion”.