Restart DMRG with stored MPS

Dear professors,

Recently, I use Julia Itensor to calculate the two-dimensional Hubbard model.

I define my sites and MPO.

sites = siteinds("Electron", N ; conserve_qns=true, conserve_sz=false);

H = MPO(os, sites);

psi_init = random_mps(sites, state);

energy1, psi1 = dmrg(H, psi_init; nsweeps, maxdim, cutoff, noise, observer = obs, outputlevel = 1);

For the convenience of increasing maxdim in subsequent calculations, I have stored psi1.

f = h5open("FE_$indexx _state_1.h5","w");
write(f,"psi1",psi1);
close(f);

Now I intend to restart the program and increase the maxdim

sites = siteinds("Electron", N ; conserve_qns=true, conserve_sz=false);

H = MPO(os, sites);

f = h5open("FE_12 _state_1.h5","r")
psi_init = read(f,"psi1",MPS)
close(f);

energy1, psi1 = dmrg(H, psi_init; nsweeps, maxdim, cutoff, noise, observer = obs, outputlevel = 1);

An error occurs, MPO A and MPS B must share site indices.

I realize that my stored MPS has different site indexs and link indexs from the current MPO. Is there any good way to solve this problem?

Regards,
YD Shen.

Hello professors, I think I have solved this problem.

f = h5open("FE_12 _state_1.h5","r")
psi_shen = read(f,"psi1",MPS)
close(f);
psi_init = replace_siteinds(psi_shen, sites);

Thank you very much for your efforts!!

Two quick comments:
I would recommend the do syntax for opening the h5 object:

psi_shen = h5open("FE_12 _state_1.h5","r") do f
    read(f,"psi1",MPS)
end

And while your solution definitely works, may I recommend instead using the sites from the read in MPS:

sites = siteinds(psi_shen)

and pass this to the MPO etc to keep consistent site indices throughout all your calculations

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