# parity conservation for spin 1/2

+1 vote

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

//MPO
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!

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:
http://itensor.org/docs.cgi?page=classes/qn

commented by (260 points)

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 (49k 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:
QN({0,2})
or
QN({1,2})
The first number in each curly brace pair is the"value" and the second is the "modulus".

Pf quantum numbers are defined as
QN({0,-2})
or
QN({1,-2})

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 (49k 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.

Miles
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 (49k 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:
https://github.com/ITensor/website/blob/master/docs/book/itensor_basics.md

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:
https://github.com/ITensor/website/blob/master/docs/tutorials/fermions/main.md

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 -