# Replace siteIndex of MPO

+1 vote
reopened

Hi
I tried to use the wave function obtained form previous calculation as an initial wave function of dmrg calculation(I stored the wave function in the hard disk "./Wave/Psi", but the MPO is not stored), and I obtained MPO via AutoMPO by using the same rules as before. The id in site-indices of MPO is different form the ones of MPS read form disk, I met some problems in replacing the site-indices of MPO by the ones of MPS. The key code is as follow

auto psi = readFromFile<MPS>("./Wave/Psi");
auto newIndexSet = siteInds(psi);

vector<Index> indexMPO;
for (auto i : range1(length(H)))
{
auto siteIndexSet = siteInds(H, i);
indexMPO.push_back(siteIndexSet[1]);
}

auto oldIndexSet = IndexSet(indexMPO);

H.replaceSiteInds(oldIndexSet, newIndexSet);      // out arrow indices of MPO
H.replaceSiteInds(oldIndexSet.dag(), newIndexSet.dag()); // in arrow indices of MPO


But the code do not change the id in site-indices of MPO, could you give me some help?, thanks .

commented by (210 points)
I  achieved the same purpose by storing MPS and SiteSet simultaneously.  I read SiteSet  form disk at first when continue to optimize， and then initialize MPS and MPO by the SiteSet.
commented by (52.6k points)
Great! That is what I was going to recommend doing. Does this now solve your problem to write and read the site set also?

Thanks,
Miles
commented by (210 points)
Yes, this solved my problem.

Best regards
ZHOU Zongsheng
commented by (52.6k points)
Great- I will post below to mark the question as answered.