# How to create a random state with definite fermion parity?

I wish to perform fermion parity conserving DMRG in Julia. In order to do this, I need to create an initial state psi0 with a definite fermion parity. I tried doing this by specifying input states with a definite number of fermonic sites being occupied. However, such input states are turning out to be too "regular" and lead to the DMRG getting stuck in a local minimum. How can I create random enough definite fermion parity states? Thank you!

+1 vote

I realized that the randomMPS function:

 randomMPS(sites::Vector{<:Index}, state; linkdims=1)


allows me to add a state with the appropriate quantum number as an argument, and outputs a random state with the same quantum number.

commented by (70.1k points)
Hi Navya,
Glad you found that. Yes it's the function I was going to suggest you try. Please let us know if it doesn't work as you expect but it could definitely help with the case you described above.

Best,
Miles
commented by (400 points)
Hi Miles,
Thank you! I tried doing this but ran into the error "No block found with QN equal to QN("Nf",-2,-1)". What does this mean?
Best,
Navya
commented by (70.1k points)
Hi Navya,
It could be a bug, or an issue with an invalid or unsatisfiable input to the function. Is it coming from the randomMPS function itself? What is the state that you passed to it? What QNs are you conserving?

Thanks,
Miles
commented by (400 points)
Hi Miles,
The randomMPS function is working. I am trying to conserve fermion parity. I have passed states with all sites occupied, all sites empty or alternating sites occupied to randomMPS. The error pops up when I convert the Hamiltonian OpSum() to an MPO. The Hamiltonian is the p-wave superconductor Hamiltonian. I am defining the sites as "s = siteinds("Fermion",N;conserve_qns=true)".
Thanks,
Navya
commented by (70.1k points)
Ah ok thanks for explaining. I see what is happening then. Turning on conserve_qns=true turns on both fermion parity and total fermion number for the "Fermion" site type.

To only conserve fermion parity and not total particle number only use the option conserve_nfparity=true, so like siteinds("Fermion",N;conserve_nfparity=true). Please print out a few of the site indices to check that only QNs like QN("NfParity",0,-2) appear and not ones with the name "Nf" appear. Then that will mean only parity is going to be conserved (the thing which makes the QN be a parity one is actually the -2 at the end, and not the name which is just a convention and can actually be changed to any name you like such as "Par" or "NfP").
commented by (400 points)
edited by
Hi Miles,

Thank you for your help! I am now able to perform fermion parity conserving DMRG for the p-wave Hamiltonian. Now I am trying to do the same thing with a more complicated system which involves alternating spin-half and fermion sites. The only quantum number that I would like to conserve is fermion parity. Thus, I am able to define the appropriate site type as sites  = [isodd(n) ? Index([QN()=>2];tags="S=1/2,Site,n=$n") : siteind("Fermion",n,conserve_qns=true) for n in 1:2N] (following the discussion here: https://www.itensor.org/support/3162/julia-two-types-sites-with-conserve_qns-true-only-for-one-them?show=3162#q3162). Now I would like to create a random MPS psi0 which has a definite fermion parity. I am doing this using the code psi0 = randomMPS(sites, states, bondim), where states is some assignment of Sz and fermion occupation values for each site. The resulting MPS is indeed random at the "S=1/2" sites (as diagnosed by the random values of Sz at each site). However, the fermionic wavefunction is not randomized at all and I just get the same values of fermion occupation as specified in the object states which is an input to the randomMPS function. So how should I construct a random MPS satisfying these properties? Thanks and regards, Navya commented by (400 points) One thing that comes to my mind is creating a random state for the spin half and fermionic sites separately and then taking their tensor product. However, I am not sure how to implement this. Moreover, I think that a product state between the two types of sites may not be a good initial state for DMRG... +1 vote answered by (610 points) Hi Navya, This is not an answer to your question. Just provide some information. In my case, when using the following site type sites = [ if mod(n,3) == 2 Index([QN()=>2]; tags="S=1/2, Site, n=$n")
else
siteind("Fermion", n;conserve_qns=true)
end
for n = 1:3*ns
]


and randomMPS(sites,state,10), I obtain the following warning:

Warning: MPS center bond dimension is less than requested (you requested 10, but in practice it is 1. This is likely due to technicalities of truncating quantum number sectors.

And I find the fermion number distribution is the same as given, i.e., there is no randomness in the fermion sector. However, the spin sector is indeed random.

Instead, if I use the following site type

sites = [
if mod(n,3) == 2
Index([QN()=>2]; tags="S=1/2, Site, n=$n") else siteind("Fermion", n;conserve_nfparity=true) end for n = 1:3*ns ]  The good news is that now the fermion sector also becomes random (by checking the fermion number distribution), however, it seems that the fermion parity is not conserved! In fact the total number of fermion is found to be a non-integer. Note, in my own project, the first site type and an essentially non-random (in the fermion sector) state randomMPS(sites,state) are used, and it is so far so good :) Best, Junsen commented by (400 points) Hi Junsen, Thank you so much for the information! :) I just realized that I made a mistake in my previous comment. I meant to say that I am using the site type sites = [isodd(n) ? Index([QN()=>2];tags="S=1/2,Site,n=$n") : siteind("Fermion",n,conserve_nfparity=true) for n in 1:2N] and not  sites  = [isodd(n) ? Index([QN()=>2];tags="S=1/2,Site,n=\$n") : siteind("Fermion",n,conserve_qns=true) for n in 1:2N]. Here, I am noticing that even when only nfparity is conserved the fermion number distribution is not randomized. This seems to be unlike your observation...so I am not sure what is going on.

For now it seems that a non random fermion sector state works for me. But I am going to work with a more complicated system soon (for which I do not have theoretical results to compare against), and thus I am quite interested in understanding how the state could be randomized over the fermonic sector as well.

Thanks,
Navya