0 votes
asked by (960 points)

I am using an observer function to print data at each sweep to a datafile, and I'd like to compute measurements of the truncation error using the observer function.

First, can the observer function access both the pre- and post-truncation eigenvalues? I suppose this is related to whether the spectrum object has both of these stored?

Second, when does the observer function access the spectrum during a DMRG sweep?


1 Answer

0 votes
answered by (70.1k points)

Hi Jon,
So looking at the current ITensor code, the Spectrum object only contains the post-truncation density matrix eigenvalues. This could be modified if you really need them. Probably an easier way to go about this, though (if cost isn't a huge issue), would be to do the SVD twice inside of DMRG: once without any truncation, then a second time with truncation.

To do the SVD step twice, just repeat line 404 of this file:

but the first time, write the line like this:

auto spec_full = psi.svdBond(b,phi,(ha==1?Fromleft:Fromright),PH,{args,"Truncate=",false});

The "spec_full" Spectrum object should have the full spectrum contained inside.

As you can see from line 423 of dmrg.h, the Observer is given the truncation error though its args. Take a look at this file:
to see how DMRGObserver grabs this truncation error, and takes a max over it over each sweep, only reporting the max. You could modify DMRGObserver or make your own observer which does a different thing with the truncation error information.

Due to limitations of C++, the observer doesn't have access to the spectrum. You'll have to modify the code in dmrg.h directly to save / print / otherwise access the spectrum during DMRG.

Finally, definitely consider also how meaningful the spectrum of eigenvalues is during DMRG versus that of the MPS after DMRG. As you know, these eigenvalues during DMRG will change depending on many possible, reasonable choices of the sweep parameters. So they might not be precisely physically meaningful, and rather reflect how the optimization was done. But of course toward the later sweeps, they should become close to those of the fully optimized MPS.


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.