calculate hamiltonian