Add `expect_and_forces` method to variational states
Created by: femtobit
Gradients of observables are estimated in VMC via the covariance F_j = \mathrm{cov}(O_j, E_\mathrm{loc})
where O_j = \partial\ln\psi(s)/\partial\theta_j
is the derivative of the log-probability. This is called the force vector here.
For real parameters, the observable gradient is then \partial\langle \hat O\rangle / \partial\theta_j = 2\mathrm{Re}[F_j]
. For a complex holomorphic parametrization \partial\langle \hat O\rangle / \partial\theta_j^* = F_j.
Note that F
is generally complex even for real-parameter models. Since expect_and_grad
returns the gradient and thus only the real part of F
, information is lost in this step, which is needed in particular in time evolution (where the RHS of the equation of motion given by McLachlan's variational principle involves \mathrm{Im}[F_j]
).
expect_and_forces
adds a way to get the original forces for use in TDVP
. I've added some tests and docs, the specific implementation in this PR has been written by @PhilipVinc.