# Classical and Quantum Gases on a Semiregular Mesh
## Appendix A Calculation of Specific Heats  
In this Appendix, we derive the statistical-mechanical formulae for the specific heats in Equation (3).  
Working in the grand-canonical ensemble, the partition function (a sum over microstates) reads  
\[\Xi=\sum_{\sigma}e^{\beta\mu N_{\sigma}}e^{-\beta E_{\sigma}}\, \tag{11}\]  
with \(T\), \(V\), and \(\mu\) as control parameters (\(V\) is the system volume). The grand potential \(\Omega\), that is the thermodynamic potential in the \(T\), \(V\), \(\mu\) representation, is given by \(\Omega=-k_{\text{B}}T\ln\Xi\). The constant-\(\mu\) specific heat is  
\[C_{\mu}=\frac{T}{N}\frac{\partial S}{\partial T}\bigg{|}_{V,\mu}=-\frac{T}{N} \frac{\partial^{2}\Omega}{\partial T^{2}}\bigg{|}_{V,\mu}\, \tag{12}\]  
where the number of particles \(N\) is  
\[N=-\left.\frac{\partial\Omega}{\partial\mu}\right|_{T,V}=\left.\frac{\partial \ln\Xi}{\partial\beta\mu}\right|_{\beta,V}=\frac{\sum_{\sigma}N_{\sigma}e^{ \beta\mu N_{\sigma}}e^{-\beta E_{\sigma}}}{\sum_{\sigma}e^{\beta\mu N_{\sigma }}e^{-\beta E_{\sigma}}}\equiv\left\langle N\right\rangle. \tag{13}\]  
From  
\[\frac{\partial}{\partial T}=-k_{\text{B}}\beta^{2}\frac{\partial}{\partial \beta} \tag{14}\]  
it soon follows that  
\[C_{\mu}=\frac{1}{\left\langle N\right\rangle}k_{\text{B}}\beta^{2}\left.\frac {\partial^{2}\ln\Xi}{\partial\beta^{2}}\right|_{V,\mu}. \tag{15}\]  
Upon inserting Equation (11) into (15) we eventually obtain:  
\[\frac{C_{\mu}}{k_{\text{B}}} = \frac{\beta^{2}}{\left\langle N\right\rangle}\left(\left((E- \left\langle E\right\rangle)^{2}\right)-2\mu(\left\langle EN\right\rangle- \left\langle E\right\rangle\left\langle N\right\rangle)+\mu^{2}\langle(N- \left\langle N\right\rangle)^{2}\rangle\right) \tag{16}\] \[\equiv \frac{\beta^{2}}{\left\langle N\right\rangle}\left(\left\langle \delta E^{2}\right\rangle-2\mu\langle\delta E\delta N\rangle+\mu^{2}\langle \delta N^{2}\rangle\right).\]  
The averages in (16) can be computed in a grand-canonical MC simulation.  
Next, we focus on a different specific heat, calculated by keeping \(N\) (and \(V\)) fixed:  
\[C_{N}=\frac{T}{N}\frac{\partial S}{\partial T}\bigg{|}_{V,N}\,. \tag{120}\]  
To enforce \(N=\text{const.}\), the chemical potential must be in a suitable relation with \(T\) and \(V\):  
\[N(T,V,\mu)=\text{const.}\implies\mu=\mu(T,V)\,. \tag{121}\]  
Hence  
\[\frac{\partial\mu}{\partial T}\bigg{|}_{V}=-\frac{\left(\frac{\partial N}{ \partial T}\right)_{V,\mu}}{\left(\frac{\partial N}{\partial\mu}\right)_{T,V}} \tag{122}\]  
and  
\[\frac{\partial S}{\partial T}\bigg{|}_{V,N}=\left.\frac{\partial}{\partial T }S(T,V,\mu(T,V))\right|_{V}=\left.\frac{\partial S}{\partial T}\right|_{V,\mu }+\left.\frac{\partial S}{\partial\mu}\right|_{T,V}\frac{\partial\mu}{\partial T }\bigg{|}_{V}\,. \tag{123}\]  
In turn, the \(\mu\) derivative of \(S\) is given by a Maxwell relation:  
\[\left.\frac{\partial S}{\partial\mu}\right|_{T,V}=\left.\frac{\partial N}{ \partial T}\right|_{V,\mu}=-\left.\frac{\partial N}{\partial\mu}\right|_{T,V }\frac{\partial\mu}{\partial T}\bigg{|}_{V}\,. \tag{124}\]  
Putting Equations (120)-(124) together, we end up with:  
\[C_{N}=C_{\mu}-\frac{T}{\left\langle N\right\rangle}\frac{\left(\frac{\partial N }{\partial T}\right)^{2}_{V,\mu}}{\left(\frac{\partial N}{\partial\mu}\right) _{T,V}}\,. \tag{125}\]  
Now, using (121) we obtain:  
\[\left(\frac{\partial N}{\partial\mu}\right)_{T,V}=\beta\langle\delta N^{2}\rangle \tag{126}\]  
and  
\[\left(\frac{\partial N}{\partial T}\right)_{V,\mu}=k_{\text{B}}\beta^{2}\Big{(} \langle\delta E\delta N\rangle-\mu\langle\delta N^{2}\rangle\Big{)}\,. \tag{127}\]  
Finally, substituting Equations (122), (126), and (127) into (125), we arrive at  
\[\frac{C_{N}}{k_{\text{B}}}=\frac{\beta^{2}}{\left\langle N\right\rangle}\! \left(\langle\delta E^{2}\rangle-\frac{\langle\delta E\delta N\rangle^{2}}{ \langle\delta N^{2}\rangle}\right). \tag{128}\]