# TDVP for a long-range hamiltonian to compute thermal state

**URL:** <https://itensor.discourse.group/t/tdvp-for-a-long-range-hamiltonian-to-compute-thermal-state/1603>\
**Category:** DMRG and Numerical Methods\
**Created:** [April 2, 2024, 12:05am UTC](https://itensor.discourse.group/t/tdvp-for-a-long-range-hamiltonian-to-compute-thermal-state/1603 "2024-04-02T00:05:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![quics-silver](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@quics-silver](https://itensor.discourse.group/u/quics-silver)\
**Post date:** [April 2, 2024, 12:05am UTC](https://itensor.discourse.group/t/tdvp-for-a-long-range-hamiltonian-to-compute-thermal-state/1603/1 "2024-04-02T00:05:26Z")

</div>

I would like to use the TDVP function under iTensorTDVP to evaluate a thermal state under a long-range Hamiltonian. My fermionic Hamiltonian is the following form, and I use `opsum()` method to create it:

H = \sum\_j c^{\dagger}\_j c\_{j+1} + hc + \sum\_j \sum\_{k\>j} exp(-|j-k|/\xi) n\_j n\_k 

I first create a system+bath MPS where alternating sites belong to the system and bath, respectively, and then create a bell pair between adjacent system and bath sites to create an infinite temperature state. Then I use tdvp to perform imaginary time evolution. (Following the purification procedure in [1901.05824](https://arxiv.org/pdf/1901.05824.pdf) sec2.7)

```julia
ttotal = 0.6
tau = 0.02;

ϕ = tdvp(H, -im*ttotal, ψ0;
    time_step= -im*tau, #nsweeps=5,
    reverse_step=false,
    normalize=true, maxdim=250,cutoff=1e-10,outputlevel=3);

```

I measure the final energy using `E_f = inner(ϕ',H,ϕ)`  
As the size of the simulation (ttotal) increases, the bond dimension increases and maxes out. However, I am not able to get the ground state energy for very long imaginary time evolution to match with DMRG results i.e by using :

```julia
e2, ϕ2 = ITensors.dmrg(H, ψ0; nsweeps=25, maxdim=250, cutoff=1e-10)

```

Am I missing something in the `tdvp()` function? How do I verify that `tdvp()` is doing what I want it to do? Like make sure that it gives the ground state for very long imaginary time evolution? Should I change the timestep “tau” ? Any suggestions would be very helpful!

Also, how do I check if this TDVP algorithm is 1-site or 2-site ? Can this be altered just be altering the argument `nsite=1/2` in the `tdvp()` function ?

Thanks!

---

<div class="post-metadata">

**Author:** ![quics-silver](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@quics-silver](https://itensor.discourse.group/u/quics-silver)\
**Post date:** [April 17, 2024, 11:16pm UTC](https://itensor.discourse.group/t/tdvp-for-a-long-range-hamiltonian-to-compute-thermal-state/1603/2 "2024-04-17T23:16:09Z")

</div>

I solved the problem.

The mistake was with the convention for time I was using. The package considers U=exp(-Ht), and for imaginary time evolution, you only need to provide “t” as say -5 or something. I assumed U = exp(-iHt) and used t = -5im. ending up doing forward-time evolution.

Guess that solves the problem.

---

<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:** [April 18, 2024, 12:51am UTC](https://itensor.discourse.group/t/tdvp-for-a-long-range-hamiltonian-to-compute-thermal-state/1603/3 "2024-04-18T00:51:46Z")

</div>

Glad you found the issue – thanks for letting us know.

Even with the correct code, it can be challenging to push the purification method all the way to the ground state. But you can get close if you use a large enough bond dimension or work on smaller sizes (or for systems without an excessive amount of entanglement). So I’m glad it worked in your case.

Yes, the way to switch between one and two site TDVP is to pass the `nsite` keyword option. The default is `nsite=2` which can be more reliable in general. We should add that to the docstring but are in the process of moving some of the code so will do that when that process is settled. For now, you can take a [look at the tests at this link](https://github.com/ITensor/ITensorTDVP.jl/blob/main/test/test_tdvp.jl) where you can see the `nsite` keyword being used in many cases.

---

<div class="post-metadata">

**Author:** ![quics-silver](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@quics-silver](https://itensor.discourse.group/u/quics-silver)\
**Post date:** [May 26, 2024, 6:57pm UTC](https://itensor.discourse.group/t/tdvp-for-a-long-range-hamiltonian-to-compute-thermal-state/1603/4 "2024-05-26T18:57:44Z")

</div>

Thank you for the reply @miles! This was helpful.  
I am trying to understand how to choose the right timestep because, currently, different timesteps (with the same total time) give me different results and trajectories (expectation of energy with time). Is there some literature or maybe a best-practices heuristic on choosing the right timesteps?

Thanks!

---

<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:** [May 26, 2024, 8:19pm UTC](https://itensor.discourse.group/t/tdvp-for-a-long-range-hamiltonian-to-compute-thermal-state/1603/5 "2024-05-26T20:19:28Z")

</div>

I’m not sure of the best reference, but this one:  
[https://journals.aps.org/prx/abstract/10.1103/PhysRevX.11.031007](https://journals.aps.org/prx/abstract/10.1103/PhysRevX.11.031007)  
does a detailed analysis in the case of imaginary time evolution (to implement the METTS algorithm). See the discussion around Fig. 10.

I notice you mention the energy changing in time. For the one-site TDVP algorithm that basically should not happen, so I wonder if you are mostly using two-site? That is ok, but maybe if you switch to one-site TDVP for part of your evolution, once your bond dimension has grown to close to its maximum value, if you might get more consistent results. That strategy is also used in the above paper, although there one is converging toward the ground state so the setting is a bit different.
