# Convergence issue in TDVP

**URL:** <https://itensor.discourse.group/t/convergence-issue-in-tdvp/1398>\
**Category:** ITensor C++ Questions\
**Tags:** cpp\
**Created:** [January 8, 2024, 4:23pm UTC](https://itensor.discourse.group/t/convergence-issue-in-tdvp/1398 "2024-01-08T16:23:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![debamalya](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/debamalya/32/328_2.png) [@debamalya](https://itensor.discourse.group/u/debamalya)\
**Post date:** [January 8, 2024, 4:23pm UTC](https://itensor.discourse.group/t/convergence-issue-in-tdvp/1398/1 "2024-01-08T16:23:13Z")

</div>

Hi, I am trying to calculate the spectral function. There are several methods for that, like the correction vector method, and another is to find the Greens function in time space and then do the FFT of its imaginary part. I have not found any built-in method in the ITensor library to implement the correction vector method, and I have chosen the second one to do calculations in time space. I have coded that in the following way.

> vector GreensFunction(const ITensor SR, const int siteR, const ITensor SL, const int siteL, const MPO H, const MPS psi, const double en0, const int nsw, const double dt)  
> {  
> vector GREEN;  
> auto psi0 = psi;  
> auto psi1 = SingleSiteOp(SR, psi0, siteR);
> 
> ```
> auto sweeps = Sweeps(20);
> sweeps.maxdim() = 10, 20, 30, 40, 50, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 330, 360, 400;
> sweeps.cutoff() = 1E-8;
> sweeps.niter() = 10;
> 
> for (int n = 1; n <= nsw; ++n)
> {
> if (n < 3)
> {
> // Global subspace expansion
> vector<Real> epsilonK = {1E-8, 1E-8};
> addBasis(psi1, H, epsilonK, {"Cutoff", 1E-8, "Method", "DensityMatrix", "KrylovOrd", 3, "DoNormalize", true, "Quiet", true});
> }
> 
> // TDVP sweep
> tdvp(psi1, H, -dt * Cplx_i, sweeps, {"Truncate", true, "DoNormalize", true, "Quiet", true, "NumCenter", 1, "ErrGoal", 1E-8});
> auto psi2 = SingleSiteOp(SL, psi1, siteL);
> auto Greens = exp(1_i * en0) * innerC(psi, psi2);
> GREEN.push_back(Greens);
> }
> return GREEN;
> 
> ```
> 
> }

The `sweep` and `maxdim` parameters are the same as I used to find the ground state. But the problem is `warning: applyExp not converged in 10 steps`, in TDVP. This problem does not go away if I increase `niter`. Instead, if I decrease `nsw` to 10 and `dt` to 0.1, i.e. total time is 1, the problem goes away. But I need a larger time like the total time as `80` instede of `1`. How to handle this warning.

It would be helpful if you could comment on the vector correction method in ITensor as well.
