Generate a bunch of MPS's in the computational basis that have a certain filling number

I am currently thinking of generating a bunch of MPS’s in the computational basis that have half fillings. Let me give an example here:

Say N=10, spin-1/2 systems, no number conservation. I want to quickly generate \begin{pmatrix}10 \\ 5\end{pmatrix}=252 states in the computational basis which are half-filling’s, i.e. 5 spin-up’s and 5 spin-down’s. What I currently thought of (and already done) is that I generated a total of 252 combinations of half of the list of numbers between 1 and 1024, and manually constructed the total 252 MPS’s needed. But I am just simply wondering if that is the only way one could do in ITensors.jl? And yes, I am trying to compute the inverse participation ratio (IPR).

Hi talentkeychen, If you are using Julia I can suggest the Combinatorics package.

collect(combinations(1:10,5))
252-element Vector{Vector{Int64}}:
 [1, 2, 3, 4, 5]
 [1, 2, 3, 4, 6]
 [1, 2, 3, 4, 7]
 [1, 2, 3, 4, 8]
 [1, 2, 3, 4, 9]
 [1, 2, 3, 4, 10]
 ⋮
 [5, 6, 7, 8, 10]
 [5, 6, 7, 9, 10]
 [5, 6, 8, 9, 10]
 [5, 7, 8, 9, 10]
 [6, 7, 8, 9, 10]

Kind regards
Jan

2 Likes

Another option is multiset_permutations from Combinatorics.jl:

julia> collect(multiset_permutations([0, 0, 0, 0, 0, 1, 1, 1, 1, 1], 10))
252-element Vector{Vector{Int64}}:
 [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
 [0, 0, 0, 0, 1, 0, 1, 1, 1, 1]
 [0, 0, 0, 0, 1, 1, 0, 1, 1, 1]
 [0, 0, 0, 0, 1, 1, 1, 0, 1, 1]
 [0, 0, 0, 0, 1, 1, 1, 1, 0, 1]
 [0, 0, 0, 0, 1, 1, 1, 1, 1, 0]
 [0, 0, 0, 1, 0, 0, 1, 1, 1, 1]
 [0, 0, 0, 1, 0, 1, 0, 1, 1, 1]
 [0, 0, 0, 1, 0, 1, 1, 0, 1, 1]
 ⋮
 [1, 1, 1, 0, 1, 0, 1, 0, 0, 0]
 [1, 1, 1, 0, 1, 1, 0, 0, 0, 0]
 [1, 1, 1, 1, 0, 0, 0, 0, 0, 1]
 [1, 1, 1, 1, 0, 0, 0, 0, 1, 0]
 [1, 1, 1, 1, 0, 0, 0, 1, 0, 0]
 [1, 1, 1, 1, 0, 0, 1, 0, 0, 0]
 [1, 1, 1, 1, 0, 1, 0, 0, 0, 0]
 [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]

Here’s a complete code to make the MPS product states:

julia> using ITensors

julia> n = 10;

julia> s = siteinds("S=1/2", n);

julia> using Combinatorics

julia> product_states = multiset_permutations([fill(0, n ÷ 2); fill(1, n ÷ 2)], n);

julia> psi = [MPS(s, string.(state)) for state in product_states];
1 Like

Thanks so much Jan!

Thanks Matt!