Obtaining a Heisenberg Hamiltonian from the Hubbard model