how to construct two component bose hubbard model in Julia Itensor?

Hello everyone,
I went through the answers to code 2 component bose Hubbard model in the Itensor C++ version however I was not able to code in the Julia version. Could you please let me know the way to code the following hamiltonian?

Starting with the C++ code here I came up with this:

using ITensors
function two_component_BH(N::Int64;U=1.0,U12=-0.5,t1=0.5,t2=0.25,kwargs...)
    sites = siteinds("Boson",N;conserve_qns=true,conserve_number=false)
    op = OpSum()
    for i in 1:2:N-3
        op += -U/2, "N", i
        op += U/2, "N", i,"N",i
        op += -t1, "a", i, "a†", i + 2
        op += -t1, "a†", i, "a", i + 2
    end
    op += -U/2, "N", N-1
    op += U/2, "N", N-1,"N",N-1

    for i in 2:2:N-2
        op += -U/2, "N", i
        op += U/2, "N", i,"N",i
        op += -t2, "a", i, "a†", i + 2
        op += -t2, "a†", i, "a", i + 2
    end
    op += -U/2, "N", N
    op += U/2, "N", N,"N",N

    for i in 1:2:N-1
        op +=U12, "N", i,"N",i+1
    end
    MPO(op,sites;kwargs...)
end

two_component_BH(6)

Hopefully you can adjust this to meet your needs. ITensors uses “a” and “a†” for bosons, and “c” and “c†” for fermions. There details are here.

Let us know how you make out.
Kind Regards
Jan

Hi, I’m working on a similar system and came across your answer. Does your method mean you are treating a_{j,\up} as a_{2k} and a_{j,\down} as a_{2k+1}? Does this work with situations that involve spin filpping? Thanks!

Hi Victor,
Yes my method means I am treating a_{j,\up} as a_{2k} and a_{j,\down} as a_{2k+1}. I am not sure about the spin flipping case, could you elaborate, or mention the hamiltonian you are talking about?

Thanks your the reply. In my model, a spin flip would look like a^{\dagger}_{j\uparrow}a_{i\downarrow}. Would that simply be a^{\dagger}_{2j}a_{2i+1}?

yes, sorry for the late reply.