+2 votes
asked by (170 points)


I want to consider a mixture of 2 bosonic type of sites (with different local dimensions, for example one site with hard core bosons and one site with soft core bosons with a certain cutoff) and perform a swap operation on the 2 sites. I am asking in the context of performing Trotter time evolution with swap gates and I would have to swap the soft core site through a hard core chain.

Can the Swap Gate implemented in 'bondgate.h' be used in this situation with non identical sites with different local dimensions? And can this still be used with IQTensors, if, for example, I want to conserve the total number of hard-core bosons?

Thank you very much!

1 Answer

0 votes
answered by (70.1k points)

Hi Catalin,
The short answer to your question is "no, the swap gate implemented in bondgate.h cannot be used to swap two sites of different dimension". But the longer answer is that it would be hard to make it work within the current design. This is because it uses a SiteSet object that is predicated on the assumption that the sites always have the same dimension throughout the algorithm. One could imagine a design that lifts this restriction perhaps (e.g. swapping the site definitions within the SiteSet itself when a swap gate) but I think that would be much too complicated.

So I think a better way for you to go is to write a special-case function to use in your code. You can use the code in itensor/mps/bondgate.h (the function "makeSwapGate") as a template to start from. Once you generalize the code, you can check that the swap gate returned by your function has the correct matrix elements / tensor components by using "PrintData" to print it out along with all its non-zero components.

Please write back with a comment below if you need help making this function.

Best regards,

commented by (440 points)
Hi Miles,

I am also interested in performing swaps where the sites are of different dimensions.
I was wondering what is this "better way" that you had in mind in the answer above.
The solution I came up with is the following: to swap two sites next to each other, we first contract their tensors, then reshape and SVD the matrix such that the physical indices are swapped. But this is not really a gate, but rather and operation on the MPS itself.
Is there another/better way?

commented by (70.1k points)
Hi, so the better way I was thinking of above was more of a comment on how to organize your code. But the way to define a swap gate, even for two different sites, is always the same: you define a tensor and set certain elements equal to 1.0 such that the action of the tensor on your two sites results in the states being swapped afterward. Diagrammatically this looks like two identity tensors "braided" with each other.

However, I have another suggestion for you which I learned from my summer intern, Yiqing Zhang. She had the nice idea of using the fact that the ITensor SVD lets you put which indices go to the "left" and the "right" when implicitly reshaping a tensor as a matrix. So say you have two MPS tensors with site indices s1 and s2. So you have two neighboring tensors with indices like A(l1,s1,l2) and A(l2,s2,l3). Now multiply these together to get the "bond tensor" B(l1,s1,s2,l3). Now SVD this B tensor back apart, grouping l1 and s2 together to go onto "U" and s1 and l3 to go onto V. So like B(l1,s2,s2,l3) = U(l1,s2,a) S(a,a') V(a',s1,l3). Now re-form the MPS as [U] [SV]. The result is that s1 and s2 have been swapped and you skip the overhead of having to make and apply a gate - you can just go straight to the SVD step which has to be done anyway!

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.