Spin-phonon Hamiltonians for 4fn ions in cubic sites