  The quasiharmonic approximation (QHA) is the simplest nontrivial
approximation for interacting phonons under constant pressure, bringing the
effects of anharmonicity into temperature dependent observables. Nonetheless,
the QHA is often implemented with additional approximations due to the
complexity of computing phonons under arbitrary strains, and the generalized
QHA, which employs constant stress boundary conditions, has not been completely
developed. Here we formulate the generalized QHA, providing a practical
algorithm for computing the strain state and other observables as a function of
temperature and true stress. We circumvent the complexity of computing phonons
under arbitrary strains by employing irreducible second order displacement
derivatives of the Born-Oppenheimer potential and their strain dependence,
which are efficiently and precisely computed using the lone irreducible
derivative approach. We formulate two complementary strain parametrizations: a
discretized strain grid interpolation and a Taylor series expansion in
symmetrized strain. We illustrate our approach by evaluating the temperature
and pressure dependence of the elastic constant tensor and the thermal
expansion in thoria (ThO$_2$) using density functional theory with three
exchange-correlation functionals. The QHA results are compared to our
measurements of the elastic constant tensor using time domain Brillouin
scattering and inelastic neutron scattering. Our irreducible derivative
approach simplifies the implementation of the generalized QHA, which will
facilitate reproducible, data driven applications.
