Direct calculation of interaction energies with configuration-interaction wavefunctions