+1 vote
asked by (310 points)

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)

1 Answer

+2 votes
answered by (1.1k points)

According to this page in the ITensor documentation (https://itensor.org/docs.cgi?vers=cppv3&page=upgrade2to3), physics-specific site sets (e.g. SpinHalf) carry QNs by default. You can see this point in the "Recommended, Optional Changes" section.

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});.

As a side remark, I am only truly familiar with the Julia version of the ITensor code, and there they still have QNs as false by default, even for physics-specific site sets. I actually don't know whether this change will eventually be made in the Julia version of the code too.

commented by (310 points)
This solves the problem! Wonderful. Thank you very much!
commented by (70.1k points)
Thanks for a great answer Sujay. Yes we changed the default in Julia; sorry if that’s confusing to C++ users such as yourself, NianGao. If in doubt, always provide the conserve_qns (Julia) or ConserveQNs (C++) keyword argument with the value you want.

Miles
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...