jaxrens.sampling.moves.galilean

Galilean Monte Carlo (GMC) move with elastic reflection.

A persistent-direction move that follows a straight-line trajectory, reflecting off the energy constraint surface when violated. Much more efficient than random walk for exploring constrained regions.

Algorithm per NS step (Baldock semantics — mirrors jaxnest_dev/src/jaxnest/mcmc.py::create_GMC_atom_walk):

  1. Initialize or perturb the velocity direction.

  2. For each of n_reflect iterations:

    1. Step: new_pos = pos + step_size * direction. Position always advances — even into the violated region.

    2. Evaluate energy at new_pos. NaN energies are coerced to +inf so they always trigger reflection (matches legacy mcmc.py:788-792).

    3. If new_energy >= Emax: reflect direction off the constraint surface using forces: direction -= 2 * (F_hat . direction) * F_hat.

  3. Accept iff the trajectory’s final energy is below Emax — i.e. the walker has exited the violated region by the last step. Reject reverts to the initial position and flips the direction.

The non-obvious bit: position drifts through violated regions inside the scan; the final-state gate is what enforces in-region acceptance. This is the standard Baldock construction. An earlier variant of this kernel reverted pos/energy on every violation, which made the final accept-gate trivially True (carry always held the last good state) and silently NaN-corrupted under NaN-producing backends.

Species scoping

Passing species=(code, ...) restricts the move to the atoms of those type codes and holds every other atom fixed — a GMC trajectory confined to one element’s sublattice. This is what makes independent step sizes per sublattice possible: register one scoped kernel per element and the MWG per-move step-size array (plus the per-move bisection in adaptation/manager.py) tunes each one on its own acceptance rate. Useful when one sublattice melts well before the other, where a single joint move is throttled by whichever sublattice is stiffer.

The move stays a valid NS kernel: confining it to a linear subspace is just GMC with the frozen coordinates as fixed parameters. Reflection off the projected gradient is still volume-preserving, the flip-on-reject still gives reversibility, and the Emax gate is still on the total energy. Ergodicity comes from composing the per-species moves, exactly as it does for single_atom.

Single-walker function, designed for shard_map(vmap(vmap(…))) wrapping.

Functions

build_kernel

Build a Galilean Monte Carlo move kernel.