Variational calculation of Helmholtz free energies with applications to simple liquid metals and alloys