# TEBD for electrons with hopping and onsite energy

**URL:** <https://itensor.discourse.group/t/tebd-for-electrons-with-hopping-and-onsite-energy/987>\
**Category:** ITensor Julia Questions\
**Tags:** julia, mps, fermions\
**Created:** [June 28, 2023, 3:24pm UTC](https://itensor.discourse.group/t/tebd-for-electrons-with-hopping-and-onsite-energy/987 "2023-06-28T15:24:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZhenZhao](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/zhenzhao/32/563_2.png) [@ZhenZhao](https://itensor.discourse.group/u/ZhenZhao)\
**Post date:** [June 28, 2023, 3:24pm UTC](https://itensor.discourse.group/t/tebd-for-electrons-with-hopping-and-onsite-energy/987/1 "2023-06-28T15:24:30Z")

</div>

Hi there!

I am trying to apply TEBD to electronic systems. I start with a two-site system

H=-t\sum\_\sigma(c\_{1\sigma}^\dagger c\_{2\sigma}+c\_{2\sigma}^\dagger c\_{1\sigma})+\epsilon (n\_{1\uparrow}+n\_{1\downarrow})

I use dmrg to get the ground state, then evolve it with gates created by

```auto
function genGate(tau,sites,N,ene,t)
    gates = ITensor[]
    for i in 1:(N-1)
      s1 = sites[i]
      s2 = sites[i+1]
      hj =
        -t * op("Cdagup", s1) * op("Cup", s2) +
        -t * op("Cdagup", s2) * op("Cup", s1) +
        -t * op("Cdagdn", s1) * op("Cdn", s2) +
        -t * op("Cdagdn", s2) * op("Cdn", s1)
      if i == 1
        hj += ene * op("Ntot", s1) * op("I", s2)
      end
      Gj = exp(-im * tau / 2 * hj )
      push!(gates, Gj)
    end
    return gates
  end

```

The ground state is obtained with t=1,\epsilon=0.6. For time evolution, I use \tau=0.01.

1. If the gates are created with t=2,\epsilon=0, \langle n\_{1\uparrow}(t)\rangle from TEBD matches with my ED benchmark.
2. If the gates are created with t=0,\epsilon=1.2, \langle n\_{1\uparrow}(t)\rangle also matches.
3. If the gates are created with t=1,\epsilon=1.2, the results don’t match. I would expect \langle n\_{1\uparrow}(t)\rangle decreases in time since the onsite energy is higher, but the TEBD result of it increases with time.

Following the discussion in the forum [https://itensor.discourse.group/t/proper-way-to-construct-fermion-gates/172](https://itensor.discourse.group/t/proper-way-to-construct-fermion-gates/172), I think since I use `OpSum()` and `apply` methods, the Jordan-Wigner string issue should be handled automatically. Or should I do it by hand since I mixed fermionic operator c with bosonic operator n in the gates?

Again, many thanks for developing and maintaining such good package!  
Best,  
Zhen

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [July 31, 2023, 1:45pm UTC](https://itensor.discourse.group/t/tebd-for-electrons-with-hopping-and-onsite-energy/987/2 "2023-07-31T13:45:55Z")

</div>

Hi Zhen,  
Glad you are enjoying using ITensor!

Yes, if you use `apply` and `OpSum`, the Jordan-Wigner string should be handled for you. The only exception is if you measure operators like c^\dagger in a “manual” way i.e. by contracting tensors then you have to use the string, but functions like `correlation_matrix` also put in the string for you.

If you are getting correct results for cases 1 and 2 above, then I think the problem is unlikely to be about the J-W string. Perhaps the problem is an accuracy/convergence sort of issue? How well did the DMRG part of the calculation work? What if you run DMRG for more sweeps? Also please try adjusting the `cutoff` you use in both DMRG and TEBD to be smaller to see if that may give different results.

---

<div class="post-metadata">

**Author:** ![ZhenZhao](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/zhenzhao/32/563_2.png) [@ZhenZhao](https://itensor.discourse.group/u/ZhenZhao)\
**Post date:** [August 23, 2023, 9:40am UTC](https://itensor.discourse.group/t/tebd-for-electrons-with-hopping-and-onsite-energy/987/3 "2023-08-23T09:40:14Z")

</div>

Hi Miles,

Thanks for the reply. The DMRG part worked very well. The ground state energy and expectation values from DMRG are almost the same as those from ED. I used `cutoff = 1e-8` originally and I tried to use `cutoff = 1e-12`, which gave the same result. I will also use TDVP for the same system and see what will happen.

Best,  
Zhen

---

<div class="post-metadata">

**Author:** ![wangfh5](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/wangfh5/32/619_2.png) [@wangfh5](https://itensor.discourse.group/u/wangfh5)\
**Post date:** [September 15, 2024, 3:45pm UTC](https://itensor.discourse.group/t/tebd-for-electrons-with-hopping-and-onsite-energy/987/4 "2024-09-15T15:45:30Z")

</div>

Hi Zhen,

Thanks for your post. I’d like to ask if you figure out the right way to do TEBD in this example?

Best,  
Fo-Hong

---

<div class="post-metadata">

**Author:** ![ZhenZhao](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/zhenzhao/32/563_2.png) [@ZhenZhao](https://itensor.discourse.group/u/ZhenZhao)\
**Post date:** [September 24, 2024, 1:54pm UTC](https://itensor.discourse.group/t/tebd-for-electrons-with-hopping-and-onsite-energy/987/5 "2024-09-24T13:54:15Z")

</div>

Hi Fo-Hong,

Sorry for the late reply. I used TDVP instead to time-evolve fermionic systems, which works well.  
For the J-W string, I think [this page](https://itensor.org/docs.cgi?page=tutorials/fermions) is quite helpful. Also, since my original post was almost one year ago, I should have taken Miles’ reply as the solution. My apologies.

Best,  
Zhen

---

<div class="post-metadata">

**Author:** ![wangfh5](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/wangfh5/32/619_2.png) [@wangfh5](https://itensor.discourse.group/u/wangfh5)\
**Post date:** [September 24, 2024, 2:20pm UTC](https://itensor.discourse.group/t/tebd-for-electrons-with-hopping-and-onsite-energy/987/6 "2024-09-24T14:20:10Z")

</div>

Hi Zhen,

Thank you for your reply. Although I have met problem in using TEBD for fermionic systems (as discussed in [https://itensor.discourse.group/t/question-on-tebd-for-fermionic-systems/1991](https://itensor.discourse.group/t/question-on-tebd-for-fermionic-systems/1991)), I did find that TDVP works perfectly for me as well.

Best,  
Fo-Hong

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/itensor/original/1X/d3072b13e047cd06df7f3981547c0917d940dfa4.png) [@system](https://itensor.discourse.group/u/system)\
**Post date:** [October 4, 2024, 2:20pm UTC](https://itensor.discourse.group/t/tebd-for-electrons-with-hopping-and-onsite-energy/987/7 "2024-10-04T14:20:47Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
