Added periodicity in heisenberg_hamiltonian_subsp and added function to get number of spins from psi.