# Two-componente Bose-Hubbard (each species conserving number)

**URL:** <https://itensor.discourse.group/t/two-componente-bose-hubbard-each-species-conserving-number/1074>\
**Category:** ITensor Julia Questions\
**Created:** [August 2, 2023, 1:52pm UTC](https://itensor.discourse.group/t/two-componente-bose-hubbard-each-species-conserving-number/1074 "2023-08-02T13:52:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElevenBadger](https://avatars.discourse-cdn.com/v4/letter/e/6bbea6/32.png) [@ElevenBadger](https://itensor.discourse.group/u/ElevenBadger)\
**Post date:** [August 2, 2023, 1:52pm UTC](https://itensor.discourse.group/t/two-componente-bose-hubbard-each-species-conserving-number/1074/1 "2023-08-02T13:52:43Z")

</div>

Hi! Probably a very basic issue, but I haven’t been able to solve a (balanced) two-component Bose-Hubbard model:

\hat{H}=-t\sum\_{\sigma=A,B}\sum\_i\left(\hat{a}^\dag\_{\sigma,i}\hat{a}\_{\sigma,i+1}+h.c.\right)+\frac{U}{2}\sum\_{\sigma=A,B}\sum\_i \hat{n}\_{\sigma,i}\left(\hat{n}\_{\sigma,i}-1\right)+U\_{AB}\sum\_i \hat{n}\_{A,i}\hat{n}\_{B,i}

with soft-core bosons and a fixed (and say equal) number of bosons of each species N=N\_A=N\_B (total N\_A+N\_B conserved number of particles has been asked before).

For a lattice with M=5 sites and N=M particles of each species, my current code is

```julia
using ITensors

let
  M = 5
  U = 1.0
  UAB = 0.0
  t = 1.0

  sites = [isodd(n) ? siteind("Boson", n; dim=M+1, conserve_qns=true, qnname_number="Number_odd") : siteind("Boson", n; dim=M+1, conserve_qns=true, qnname_number="Number_even") for n in 1:2*M]

  os = OpSum()

  for i in 1:M
    # Interaction AA
    os += - 0.5*U, "N", 2*i-1
    os += 0.5*U, "N", 2*i-1, "N", 2*i-1
    # Interaction BB
    os += - 0.5*U, "N", 2*i
    os += 0.5*U, "N", 2*i, "N", 2*i
    # Interaction AB
    os += UAB, "N", 2*i-1, "N", 2*i
    if i<M
      # Tunneling A
      os += -t, "A", 2*i-1, "Adag", 2*(i+1)-1
      os += -t, "Adag", 2*i-1, "A", 2*(i+1)-1
      # Tunneling B
      os += -t, "A", 2*i, "Adag", 2*(i+1)
      os += -t, "Adag", 2*i, "A", 2*(i+1)
    end
  end

  H = MPO(os, sites)

  states = ["1" for j in 1:2*M]

  psi0 = randomMPS(sites,states)

  nsweeps = 5
  maxdim = [10,20,100,100,200]
  cutoff = [1E-10]

  energy, psi = dmrg(H,psi0; nsweeps, maxdim, cutoff)

  println(energy)

  return

end

```

I have set U\_{AB}=0 to check that I recover two uncoupled one-component Bose-Hubbards. However, I simply get vanishing energy (zero error, one bond, etc) in each sweep. Not sure what I am doing wrong. I guess the problem is with the tunneling or with the sites?

Thanks!

---

<div class="post-metadata">

**Author:** ![ryanlevy](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/ryanlevy/32/150_2.png) [@ryanlevy](https://itensor.discourse.group/u/ryanlevy)\
**Post date:** [August 2, 2023, 2:19pm UTC](https://itensor.discourse.group/t/two-componente-bose-hubbard-each-species-conserving-number/1074/2 "2023-08-02T14:19:06Z")

</div>

Without looking at your code, I will add that if you include a noise in your sweeps you’ll get non-zero energy. My guess is that your initial state isn’t good?

---

<div class="post-metadata">

**Author:** ![ElevenBadger](https://avatars.discourse-cdn.com/v4/letter/e/6bbea6/32.png) [@ElevenBadger](https://itensor.discourse.group/u/ElevenBadger)\
**Post date:** [August 2, 2023, 2:27pm UTC](https://itensor.discourse.group/t/two-componente-bose-hubbard-each-species-conserving-number/1074/3 "2023-08-02T14:27:18Z")

</div>

Yep! That (the lack of noise) was the issue 🙃. Thanks!

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [August 2, 2023, 3:11pm UTC](https://itensor.discourse.group/t/two-componente-bose-hubbard-each-species-conserving-number/1074/4 "2023-08-02T15:11:37Z")

</div>

Take a look at the DMRG FAQs for useful information on running DMRG: [DMRG FAQs · ITensors.jl](https://docs.juliahub.com/ITensors/P3pqL/0.2.9/faq/DMRG.html)

---

<div class="post-metadata">

**Author:** ![lorenzocarfora2000](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/lorenzocarfora2000/32/471_2.png) [@lorenzocarfora2000](https://itensor.discourse.group/u/lorenzocarfora2000)\
**Post date:** [May 9, 2024, 4:24pm UTC](https://itensor.discourse.group/t/two-componente-bose-hubbard-each-species-conserving-number/1074/5 "2024-05-09T16:24:10Z")

</div>

I understand that you are doubling the number of sites so that one Half is for the A bosons and the other is for the B bosons. Is there a way to “combine” the sites of the A and B bosons, so that the number of sites would be M again? and if so, is it possible to have operators that only act on the “Number\_even” or “Number\_odd” population?
