# How to create the MPO of the transverse-field Ising model Hamiltonian with AutoMPO?

+1 vote

Dear Itensor,

I'm trying to create the MPO of the transverse-field Ising model Hamiltonian with AutoMPO. The piece of the code that Itensor reports an error is

int N = 8;
auto sites = SpinHalf(N);
auto ampo = AutoMPO(sites);
for(int j = 1; j <=N; ++j)
{ ampo += 2, "Sx", j;}
auto H = toMPO(ampo);

The error message is
"Trying to set element:
Index: (dim=2|id=13|"n=1,Site,S=1/2")
1: 1 QN({"Sz",1})
2: 1 QN({"Sz",-1}), Val: 2
Index: (dim=2|id=13|"n=1,Site,S=1/2")'
1: 1 QN({"Sz",1})
2: 1 QN({"Sz",-1}), Val: 1
Element flux is: QN({"Sz",2})
ITensor flux is: QN({"Sz",-2})
From line 327, file ~/itensor3/itensor/itensor_impl.h
In .set, cannot set element with flux different from ITensor flux"

It seems that ITensor is complaining that the Hamiltonian Sx is not block-spare with respect to the Sz basis. Is there any way to circumvent this difficulty?

More generally, it seems that indices with quantum numbers are automatically used in the Site classes. Is there anyway to tell ITensor that these quantum numbers are not important?

Thanks very much,
Yantao

commented by (310 points)
P.S., I'm using ITensor3. (I worked with ITensor2 before, and there didn't seem to be a problem like this)

So all you need to do is put {"ConserveQNs=",false} when creating the sites object. In your case, you can do auto sites = SpinHalf(N, {"ConserveQNs=",false});.