# How to restart iDMRG using the state "psi" from previous run?

Hi Miles,

It is considerate of you to add a template in idmrg.h for "restarting idmrg calculations from a previous run". But I still cannot use it. Let me show you my code:

in my own idmrg.cc I wrote:

auto res = idmrg(psi, H, sweeps, { Args }); auto res2 = idmrg(psi, H, res, sweeps,{ Args});

The first idmrg runs well, but the second one cannot work—— it stops after printing sweeps and a line:

Sweep=1, HS=1, Bond=(1,2)

which comes from the first step of dmrg in this iDMRG, the exit without error messages.
Could you spot any error here?

Thank you in advance.

Zhiyu

commented Mar 14 by (280 points)
The version I am using is V2.0.11

+1 vote
answered Mar 20 by (280 points)
selected Mar 22 by Zhiyu

I have solved that.
I think the key point is to add a step to contract "D" from the first idmrg with the initial psi.A(1) in the second idmrg. So I added "D" into the return value of idmrg. Sometimes I want to run another app to measure or continue idmrg starting from a psi stored in the disk. So I also added some codes to write the "res" in idmrg.h into disk.
Besides, I am actually doing adiabatic evolution of a state. So in every idmrg, I have to vary my H by a little, which requires me to reconstruct H every time. This also caused some inconvenience because the indices of the Link on H.A(1) towards HL are random though H's are constructed from the same site. My solution is to identify the indices with an identity matrix.
I am not sure whether it is the best way to tackle the problem, but anyway it works.
Thank you!

Zhiyu

commented Mar 22 by (19,400 points)
Hi Zhiyu,
Glad that you figured out how to get it working properly. I put that template in once a while ago but haven't used it in a while. It was for some research I was doing so I may have not finished preparing and documenting it for general use. But I am glad you have found it useful.

About the MPO having different virtual/link indices every time, one idea is that you could modify the code that makes the MPO to take a vector of indices that you make once at the beginning (similar to how the code probably makes a vector called "links"; you could move this code outside and run it just once). Then you would pass the same set of link indices to the code every time so it would always use these and keep them the same.

Best,
Miles
commented Mar 22 by (280 points)
Hi Miles,
This method is much better. Many thanks!

Zhiyu