+1 vote
asked by (260 points)

Hi all,

Maybe I missed the point in the documentation, but I could not manage to enforce parity conservation in the dmrg search of the ground state/first excited states of this model

        auto sites = SpinHalf(N);

    auto ampo = AutoMPO(sites);
    for(int j = 1; j <= N; ++j)
            ampo += 2.*Delta,"Sz",j;
            for(int k = 1; k <= ncut; ++k)
                    if (j+k<=N){
                            ampo += 4.*J*std::pow(k,-alpha),"Sx",j,"Sx",j+k;
    auto H = MPO(ampo);

Is there an option to do that when I load the site set SpinHalf ? Thanks a lot!

1 Answer

0 votes
answered by (70.1k points)

Hi, so first of all to conserve a quantum number of any type, you have to use the IQMPO class as the type of your Hamiltonian:

auto H = IQMPO(ampo);

Also you have to initialize the wavefunction as an IQMPS and use the InitState feature to set the initial state to a particular product state. After that, calling the DMRG method is guaranteed to keep the total quantum number fixe (see sample/iqdmrg.cc for a good example of this all together).

SpinHalf doesn't provide the option to conserve a type of parity quantum number. It only lets you conserve the total Sz. But the quantum number system in ITensor is very flexible and can handle pretty exotic types of quantum numbers. To conserve parity you'll need to define your own SiteSet, which is now pretty easy to do. Check out the provided site sets defined in the itensor/mps/sites/ folder for many examples and let me know if you have questions about it.

There is an in-depth discussion of the quantum number system here:

commented by (260 points)
Thanks Miles for your reply

I defined my own site set spinhalfparity.h with QN indices defined as
           Index(nameint("Up ",j),1,Site),QN("Pf=",1),
           Index(nameint("Dn ",j),1,Site),QN("Pf=",0));

( I borrowed the parity type for the fermion case, I hope it is no problem ?)

and it seems to work! Thanks!
commented by (70.1k points)
Hi, good to hear this is working for you. Using "Pf" ought to work fine here, so you can go ahead.

To give a more techical answer (and this is described somewhat on the QN documentation page) "Pf" quantum numbers have a mod-2 addition rule which I think is what you wanted. But they also carry a flag that marks them as fermionic. Right now, this fermionic flag doesn't do anything. But I put it in as a "future proof" design for a future version of ITensor where I want to allow certain IQIndex sectors (certain QNs) to anticommute so we can support fermions more automatically without Jordan-Wigner string hassles.

So the really correct way to make a "bosonic" Z2 parity quantum number without any fermionic flag is to write:
The first number in each curly brace pair is the"value" and the second is the "modulus".

Pf quantum numbers are defined as

If that's confusing, don't worry about it. Doing what you did should be fine. Also, it may even be that the parity QN's you are defining are technically associated with fermions since they involve spin 1/2, but I'd have to think about it more to be sure.
commented by (260 points)
ok I understand. I just implemented  the bosonic version. thanks again.
commented by (70.1k points)
Great. By the way, it would be nice to have some "case studies" on the ITensor website. You could write a short article about what problem you were trying to solve and how you used ITensor to tackle it. It doesn't even have to be about published research: you could just describe the Hamiltonian you want to study and explain this site set customization. Your name would appear at the top and I would write a news post announcing it.

Just an idea if you are interested. No problem if you don't have the time.

commented by (260 points)
Why not ? Let me first finish the project then I try to write something.
commented by (260 points)
Hi Miles, I can write the case study. That would be a pleasure actually.  Where can I find the template ? or I send you directly the short article  as a small latex document ? Just tell me.
Best Benoit
commented by (70.1k points)
Hi Benoit,
Good to hear. Our documentation system uses Markdown text files as input, and they get automatically converted to html on the fly as our website loads.

Here is a (randomly chosen) link to one of the source files for our website:

If you look at the raw (text) version of that file (not processed by Github's Markdown engine I mean) you can use it as a template for how to notate sections (prepend with ##) and code blocks (indent four spaces). Our site engine futhermore supports Latex. For an example of a file that uses this feature extensively, see:

You can either send me your Markdown text file or fork our website repo and submit the file as a pull request. Either way is fine. Thanks -
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.