  Selected configuration interaction (SCI) methods, when complemented with a
second-order perturbative correction, provide near full configuration
interaction (FCI) quality energies with only a small fraction of the Slater
determinants of the FCI space. However, a selection criterion based on
determinants alone does not ensure a spin-pure wave function. In other words,
such SCI wave functions are not eigenfunctions of the $S^2$ operator. In many
situations (bond breaking, magnetic system, excited state, etc), having a
spin-adapted wave function is essential for a quantitatively correct
description of the system. Here, we propose an efficient algorithm which, given
an arbitrary determinant space, generates all the missing Slater determinants
allowing one to obtain spin-adapted wave functions while avoiding manipulations
involving configuration state functions. For example, generating all the
possible determinants with 6 spin-up and 6 spin-down electrons in 12 open
shells takes 21 CPU cycles per generated Slater determinant. The selection is
still done with individual determinants, and one can take advantage of the
basis of configuration state functions in the diagonalization of the
Hamiltonian to reduce significantly the memory footprint.
