+1 vote
asked by (760 points)

Is it possible to define an MPS with different quantum number on difference sites? For example if I want the particle numbers in every 2 sites conserved. I know that one way to do it is to define dummy quantum numbers by giving only the value zero, but this will make each tensor having many quantum numbers, most are dummy except one. Is there a better way to do it?

2 Answers

+1 vote
answered by (14.1k points)

At least in the Julia version it is pretty simple:

using ITensors

N = 10

space_odd = [QN("Podd", 0, 2) => 1, QN("Podd", 1, 2) => 1]
space_even = [QN("Peven", 0, 2) => 1, QN("Peven", 1, 2) => 1]
index_space(n) = isodd(n) ? space_odd : space_even
s = [Index(index_space(n), "Qubit,n=$n") for n in 1:N]

# Alternatively using siteinds
#s_odd = siteinds("Qubit", N÷2; conserve_parity=true, qnname_parity="Podd")
#s_even = siteinds("Qubit", N÷2; conserve_parity=true, qnname_parity="Peven")
#s = collect(Iterators.flatten(zip(s_odd, s_even)))

state_odd = [isodd(n) ? 1 : 2 for n in 1:N÷2]
state_even = [isodd(n) ? 1 : 2 for n in 1:N÷2]
psi0 = productMPS(s, collect(Iterators.flatten(zip(state_odd, state_even))))

function random_gate(s, i, j)
  return randomITensor(dag(s[i]), dag(s[j]), s[i]', s[j]')

rg = [random_gate(s, i, j) for i in 1:N, j in 1:N]
g1 = [rg[n, n+1] for n in 1:N-1]
g = copy(g1)
nlayers = 8
for _ in 1:nlayers
  append!(g, g1)
psi = apply(g, psi0)

I showed the custom one first to show you that you can really generalize the QNs however you want to, the siteinds version is basically doing the same thing internally but with some hardcoded options for the QNs.

+1 vote
answered by (70.1k points)

Hi Chia Min,
Not sure if this exactly gets to your question, but have you seen this example of mixing two different site types in ITensor?

In version 3 of ITensor, the quantum numbers on different sites no longer have to be the same at all. For example, if one of the sites has a quantum number "N" and the other one "Sz", then it's fine if the one with "N" does not define the quantum number "Sz" on that site. When the QNs get added together later on inside the library, it figures out for you that if "Sz" is missing, just to treat it as zero.

Hope that helps or please comment below if you still have a question about this capability -


commented by (760 points)
Thanks Miles. I think this is exactly what I was looking for. Fantastic.
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.