# Ensuring Eigenstate Accuracy in DMRG: Can I moniter energy variance in 'checkdone!'?

**URL:** <https://itensor.discourse.group/t/ensuring-eigenstate-accuracy-in-dmrg-can-i-moniter-energy-variance-in-checkdone/1367>\
**Category:** DMRG and Numerical Methods\
**Tags:** julia, dmrg\
**Created:** [December 18, 2023, 2:23am UTC](https://itensor.discourse.group/t/ensuring-eigenstate-accuracy-in-dmrg-can-i-moniter-energy-variance-in-checkdone/1367 "2023-12-18T02:23:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![swanchristmas](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/swanchristmas/32/395_2.png) [@swanchristmas](https://itensor.discourse.group/u/swanchristmas)\
**Post date:** [December 18, 2023, 2:23am UTC](https://itensor.discourse.group/t/ensuring-eigenstate-accuracy-in-dmrg-can-i-moniter-energy-variance-in-checkdone/1367/1 "2023-12-18T02:23:11Z")

</div>

I’m interested in leveraging the ‘checkdone!’ function during sweeps to not only secure a low ground state energy but also ensure accurate eigenstate determination. Specifically, I’m considering tracking the convergence of energy variance as an indicator.

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [December 18, 2023, 5:18pm UTC](https://itensor.discourse.group/t/ensuring-eigenstate-accuracy-in-dmrg-can-i-moniter-energy-variance-in-checkdone/1367/2 "2023-12-18T17:18:23Z")

</div>

Monitoring variance in checkdone would be rather difficult, and not really the right “level” at which to do it, if you wanted to do it in the most efficient way possible. I could see two options for you:

1. [Overloading the `measure!` method](https://itensor.github.io/ITensors.jl/dev/Observer.html) to compute the variance of the entire state, but only on certain steps to keep the costs lower. Here you would overload `measure!` as outlined in the documentation on the Observer system and check whether you are, say, at the end of a sweep and on the first bond. Then you could run code that would compute the variance of the entire MPS. This might not be as efficient as possible since each variance calculation would itself cost something like an extra sweep of DMRG. But it could be practical if it’s fast enough in practice for what you need.

2. Altering the DMRG code itself. Inside ITensor’s DMRG code, we use an object called `ProjMPO` to store the projection of the Hamiltonian MPO into the current MPS basis. Hypothetically this could be expanded or altered to also store the projection of H^2 into the MPS basis, to allow computing the variance at each step of DMRG. However, it’s not totally clear this would be cheaper than the option 1 above if you only needed the variance in between each sweep.

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [December 18, 2023, 5:53pm UTC](https://itensor.discourse.group/t/ensuring-eigenstate-accuracy-in-dmrg-can-i-moniter-energy-variance-in-checkdone/1367/3 "2023-12-18T17:53:56Z")

</div>

You can also look into [[1711.01104] Error estimates for extrapolations with matrix-product states](https://arxiv.org/abs/1711.01104) as a cheaper way of approximating the energy variance.
