# Addition of a chemical potential term to 2D Hubbard Hamiltonians

**URL:** <https://itensor.discourse.group/t/addition-of-a-chemical-potential-term-to-2d-hubbard-hamiltonians/1740>\
**Category:** DMRG and Numerical Methods\
**Tags:** julia, dmrg\
**Created:** [May 21, 2024, 4:12am UTC](https://itensor.discourse.group/t/addition-of-a-chemical-potential-term-to-2d-hubbard-hamiltonians/1740 "2024-05-21T04:12:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [May 21, 2024, 11:03am UTC](https://itensor.discourse.group/t/addition-of-a-chemical-potential-term-to-2d-hubbard-hamiltonians/1740/2 "2024-05-21T11:03:53Z")

</div>

Particle conserving Hamiltonians dont need this term - just specify the sector you want by the initial state as you said. If they, for example, only conserve parity due to a pinning term (like equation 17 in your arxiv link), then you’ll need that term to control filling.

Regardless, with `OpSum` that term is easy to add, e.g. a 1d Hubbard model

```julia
os = OpSum()
for b in 1:(N - 1)
  os += -t, "Cdagup", b, "Cup", b + 1
  os += -t, "Cdagup", b + 1, "Cup", b
  os += -t, "Cdagdn", b, "Cdn", b + 1
  os += -t, "Cdagdn", b + 1, "Cdn", b
end
for i in 1:N
  os += U, "Nupdn", i
  os += -mu, "Ntot", i # The term you're asking about
end
H = MPO(os, sites)

```

---

_[View the full topic](https://itensor.discourse.group/t/addition-of-a-chemical-potential-term-to-2d-hubbard-hamiltonians/1740)._
