For a phase space distribution given by $e^{-\beta H(x,p)}$ (Gibbs distribution), the partition function $Z$ is

$$ Z = \frac{1}{h}\iint e^{-\beta H(x,p)} \mathrm{d}x\,\mathrm{d}p $$

The observable $\left<A(x,p)\right>$ for a function $A(x,p)$ is

$$ \left<A(x,p)\right> = \frac{1}{Z}\frac{1}{h}\iint A(x,p)\,e^{-\beta H(x,p)} \,\mathrm{d}x\,\mathrm{d}p $$

For classic crystals, $Z = (\beta\hbar\omega)^{-1} = k_BT / \hbar\omega$

Other thermodynamic functions

$$ E = -\frac{\partial \ln Z}{\partial \beta} $$

$$ F = -k_\text{B}T\ln Z $$

$$ P = -\frac{\partial F}{\partial V} = k_\text{B}T \frac{\partial \ln Z}{\partial V} $$

Lattice entropy can be derived from $S = \partial F / \partial T$ or $S = \frac{1}{T} (E - F)$, which gives for harmonic crystals $S = k_B[1 + \ln (k_BT / \hbar\omega)]$.

The diamond vs. graphite example

The carbon phase diagram (via Chris lecture notes)

The carbon phase diagram (via Chris lecture notes)

For the diamond vs. graphite example, clearly $\gamma_\text{d} > \gamma_\text{g}$, thus we have $\omega_\text{d} > \omega_\text{g}$, and $S_\text{d} < S_\text{g}$.

For $\ce{graphite -> diamond}$ transition, $\Delta S < 0$, thus according to $\Delta G = \Delta H - T\Delta S$, high temperature is good for graphite. The slope is given by Clausius–Clapeyron relation $\mathrm{d}P / \mathrm{d}T = \Delta S / \Delta V = \Delta H / T\Delta V > 0$, thus $V_\text{d} < V_\text{g}$ (diamond has higher density than graphite).