Source code for py_core.Fx_avg_tilde

r"""Observable functionals with the change of variable that cancels the ghost mode.

The change of variable is :math:`x = \tilde{x} + \frac{1}{24}(dt^2\Delta^{(2)} +
dt^2\omega^2)\tilde{x}`; the MCMC samples :math:`\tilde{x}`, and these classes
transform to :math:`x` before evaluating the propagator correlators.
"""
from .Fx_avg import *

xi = 1.0 / 24.0


[docs] def D(x): r"""Discrete second difference with PBC: :math:`D(x)_i = x_{i+1} + x_{i-1} - 2x_i = dt^2\Delta^{(2)}x_i`. Parameters ---------- x : ndarray Matrix of paths, shape (N_c, N-1), with periodic boundary conditions. Returns ------- ndarray Matrix of finite differences :math:`dt^2 \Delta^{(2)}` with PBC, same shape as `x`. """ return np.roll(x, -1, axis=1) + np.roll(x, +1, axis=1) - 2 * x
[docs] class xx_tilde: r"""Propagator correlator :math:`\langle x(t_2)x(t_1)\rangle` evaluated after the ghost-removing change of variable :math:`x = \tilde{x} + \frac{1}{24}(dt^2\Delta^{(2)} + dt^2\omega^2)\tilde{x}`. Parameters ---------- dt : float Lattice spacing. omega : float, optional Angular frequency, by default 1.0. """
[docs] def __init__(self, dt, omega=1.0): self.__dt = dt self.__omega = omega
def __call__(self, x, **kwargs): """Apply the change of variable to the sampled paths and return the per-path correlator. Parameters ---------- x : ndarray Matrix of sampled paths :math:`\tilde{x}`, shape (N_c, N-1). **kwargs Forwarded to :func:`py_core.Fx_avg.xx` (e.g. ``i`` for the time separation). Returns ------- ndarray Per-path correlator values, shape (N_c,). """ x = x + xi * (D(x) + ((self.__dt * self.__omega) ** 2) * x) return xx(x, **kwargs)
[docs] class xx2_tilde: r"""Squared propagator correlator after the ghost-removing change of variable. Parameters ---------- dt : float Lattice spacing. omega : float, optional Angular frequency, by default 1.0. """
[docs] def __init__(self, dt, omega=1.0): self.xx_tilde = xx_tilde(dt, omega)
def __call__(self, x, **kwargs): """Return the square of the per-path correlator after the change of variable. Parameters ---------- x : ndarray Matrix of sampled paths :math:`\tilde{x}`, shape (N_c, N-1). **kwargs Forwarded to :math:`xx_tilde.__call__`. Returns ------- ndarray Per-path squared correlator, shape (N_c,). Used for variance estimates. """ return self.xx_tilde(x, **kwargs) ** 2