0 votes
asked by (120 points)

Is it possible to obtain this value? I am running DMRG sweep by sweep until I obtain a desired energy convergence. I would also like to adjust maxm sweep by sweep so that its value is sufficiently large enough throughout my calculation.

I realize this is printed out using the "Quiet" option, however, I wonder if there is an easy way to save the value without e.g. parsing the print output.

commented by (37k points)
Hi, so would computing the maximum bond dimension of the MPS returned after the DMRG code finishes serve your purpose? Usually the bond dimension only goes up during DMRG, so the maximum bond dim. after DMRG is done should be the same as the maximum bond dim. in the last sweep. If so, I will post an answer suggesting a convenient way to obtain this maximum dimension of an MPS.

commented by (120 points)
Thank you for your reply Miles. Yes, that should work.

My problem stems from the fact that sometimes I do not know beforehand a sufficient maxm for a calculation, so I would like to systematically increase the maxm until the max. bond dimension is less than maxm. I apologize for my naivety here, but to me, this seemed like the most straightforward solution.
commented by (37k points)
Hi, so now I'm afraid I don't understand your question. If you set a small cutoff and then raise the maxdim (maxm in v2), then the bond dimension will generally always grow until it reaches the maxdim you set, for a large enough system. So is your question that you are planning to set a moderate (not very small) cutoff, and hope to reach a regime where the bond dimension falls below the maxdim because the cutoff starts to be the dominating effect?

commented by (120 points)
I think I understand that the bond dimension will generally grow until it reaches the maxdim. However, in cases where I have clearly set the maxdim too low, it seems the bond dimension very quickly reaches maxdim and even after many sweeps the final energy is still quite off from expected. Instead, if the bond dimension quickly reaches maxdim, I would like to increase maxm in my future iterations. The goal here is to avoid knowing an appropriate maxm beforehand and to maximize efficiency: I would rather not use a large maxm if it is not needed.

If I could know the maximum bond dimension after the DMRG code finishes that would be great, since I could get a sense of whether maxm needs to be increased in my next run.
commented by (37k points)
So the I think the answer to your first question is that you need to set the cutoff parameter (truncation error cutoff) to be larger. If you set the cutoff (at least in your later sweeps) to be, say, 1E-8, then at some point once the maxdim is large enough it will stop growing, because an accuracy of 1E-8 has been reached. For 1d systems this happens usually when the dimension reaches a few hundred. For 2d systems it depends quite a lot on the Ny system size.

But if you set the cutoff very small, say 1E-12, then basically the bond dimension will always saturate the maxdim that you set, no matter how large (essentially).

But I still don't understand your problem totally. If the problem is that you are finding your last maxdim isn't high enough, can you not just set DMRG to do many sweeps (say 20 or 30 sweeps) and then set your maxdim to keep increasing, say exponentially quickly, while keeping a reasonable cutoff (I'd suggest 1E-8 unless you want very high accuracy). Then eventually you should get an accurate energy because you are allowing the bond dimension to grow to very large values in the end.

Then if your DMRG calculation is still running but has already converged, you can always tell it to exit early using this technique: http://itensor.org/docs.cgi?vers=cppv3&page=formulas/stopping_dmrg

I would recommend starting with smaller system sizes to do short-time studies of what bond dimensions are needed to reach good accuracy. Then you don't have to do as many calculations on large systems which can take a lot of time.

Finally, the answer to your question about obtaining the max bond dimension of an MPS after DMRG is finished is that you can use the maxM function. So just like:
auto max_m = maxM(psi);
for some MPS psi.

Best regards,
commented by (120 points)
I think this answers my question. Yes, I was using a small cutoff of 1E-12 with 1D systems. I noticed that in most cases the energy would converge to my desired criteria before saturating the maxdim. In other cases, however, the maxdim would saturate before the energy converged. I was specifically trying to address these cases. I will take your suggestion of using 1E-8 as the cutoff and increasing the maxdim if it is being saturated before convergence. The maxM(psi) works well for my purposes here.

commented by (37k points)
Glad to hear that the answer above was helpful!

1 Answer

0 votes
answered by (880 points)

You can gradually increase maxm, e.g. 50, 100, 150..., and set very big nsweeps, like 5000. Don't worry the bond dimension will go to very high because the truncation error will control it. Then you can add an arg in DMRGObserver.h, like "EnergyErrgoal" which is the difference between last two sweeps. Let dmrg stop if this quantity meet your convergence criteria, e.g. 1e-12.

commented by (880 points)
By the way, Miles, could you add a "EntropyErrgoal" to DMRGObserver.h? Because I found the energy converges faster than entropy. Sometimes I need accurate entropy. I had to add it very time I downloaded a new version.
commented by (37k points)
Hi, thanks for the question. However for questions like these it's better to email me or post as a new question, because I might not have seen this (since it's a comment to an answer to a different question).

So I think instead of adding this every time to your code, a better solution would be to make your own custom observer type and give that to DMRG as an argument. That is, there is a version of the DMRG function which can accept a custom observer object.

Best regards,
commented by (37k points)
If you do want this to be a builtin feature, it could be nice since we already have a calculation of entropy happening. Could you submit a pull request making this change to us?
commented ago by (880 points)
Hi Miles, I have pulled a request. Thanks.
commented ago by (37k points)
Much appreciated! Thanks
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.