quantax.optimizer.EnergyGrad#

class quantax.optimizer.EnergyGrad#

Energy gradient source defining \(\bar \epsilon\) from the local energies of a Hamiltonian, used for ground-state search and time evolution.

__init__(hamiltonian: Operator, clip: float | None = 5.0)#
Parameters:
  • hamiltonian – The Hamiltonian for the evolution.

  • clip –

    Clipping the local energies to \(\bar E \pm c \sigma\) to avoid divergence, default to 5.0. Clipping is disabled if set to None.

    The clipping only enters \(\bar\epsilon\) (the gradient); the reported energy and VarE remain the unclipped, unbiased estimators. For complex local energies, the real and imaginary parts are clipped independently with the shared scale \(\sigma = \sqrt{\mathrm{VarE}}\), as they enter the stacked SR equations as two equivalent real samples.

    Clipping is a biased operation, recommended for ground-state search but not for real-time evolution, where the bias is a systematic error in the dynamics instead of a stabilizer. TimeEvol disables it; pass clip=None when using SR with imag_time=False directly.

property hamiltonian: Operator#

The Hamiltonian for the evolution.

property energy: Array | ndarray | bool | number | bool | int | float | complex | None#

Energy of the current step.

property VarE: Array | ndarray | bool | number | bool | int | float | complex | None#

Energy variance \(\left< (H - E)^2 \right>\) of the current step.

ebar(state: Variational, samples: Samples | Array) → Array#

Compute \(\bar \epsilon\) for given samples. The local energy is \(E_{loc, s} = \sum_{s'} \frac{\psi_{s'}}{\psi_s} \left< s|H|s' \right>\), and \(\bar \epsilon\) is defined as \(\bar \epsilon = \frac{1}{\sqrt{N_s}} (E_{loc, s} - \left<E_{loc, s}\right>)\).

Samples with non-finite local energy (e.g. from an overflowed or NaN wave function) are excluded from all estimators and contribute zero to \(\bar \epsilon\), so a single corrupted sample can’t poison the mean energy or the clipping threshold. A warning is emitted when such samples are detected.

ebar_dense(psi: Array, symm: Symmetry, Ns: int) → Array#

Compute \(\bar \epsilon = (H - E) \psi\) for the normalized wave function psi given in the full Hilbert space of symm, whose first Ns entries are the physical amplitudes.