0
$\begingroup$

I am currently trying to adapt a code working well with Qutip to Quspin to optimize it.
I managed to create what I believe are the same systems with both libraries, but I don't get the same eigenstates.
I suspect it is just written differently, or maybe Quspin doesn't understand the Hamiltonian the same way (it might have to do with the "dims"), but still I don't get it. In the following output, I print $H$ and then the associated ground state with each library: Qutip vs Quspin for the "same" Hamiltonian

Here is my code:

import qutip as qt
import quspin

N = 3
wx = 1

## Qutip
print("Qutip:\n")

# x Pauli matrix for the particle k
def SX(N,k):
    L=[qt.qeye(2)]*N
    L[k]=qt.sigmax()
    return qt.tensor(L)

# initialization of Hi
Hi=qt.Qobj(np.zeros((2**N,2**N)))
Hi.dims=[[2]*N,[2]*N]

for k1 in range(N):
    Hi=Hi+wx*SX(N,k1)

STi=Hi.eigenstates()[1][0] # recover the ground state vector

print(Hi) # visualize H
print(STi) # visualize the ground state

## Quspin
print("\n\nQuspin:\n")

# basis for H
basis=quspin.basis.spin_basis_1d(N)
print(basis)

# preparing H
x_field=[[wx,i] for i in range(N)]

static = [["x",x_field]]
dynamic = []

H=hamiltonian(static,dynamic,dtype=np.float64,basis=basis)

STi2=H.eigh()[1][0]

print(H.todense()) # visualize sparse matrix H
print(STi2) # visualize the ground state

Thank you

$\endgroup$

1 Answer 1

1
$\begingroup$

It turns out Quspin throws the eigenstates a different way than Qutip does.

  • Qutip shows each eigenstate such as Hi.eigenstates()[1][0] is the ground, Hi.eigenstates()[1][1] is the first excited state, etc....
  • Quspin shows them such as H.eigh()[1][0] are the values the first element of the basis takes for the different states, still with increasing energy, H.eigh()[1][1] is for the second element of the basis, etc...

in order to make it work like Qutip, just do H.eigh()[1].transpose()[0] !

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.