pbc_wrap_batched_and_get_lattice_shifts

torch_sim.transforms.pbc_wrap_batched_and_get_lattice_shifts(positions, cell, system_idx, pbc)[source]

Wrap Cartesian positions into the primary cell and return the applied shifts.

cell rows are lattice vectors (row-vector convention matching compute_cell_shifts and the batched neighbor-list APIs). Fractional coordinates use cell_col = cell[s].T so r = f @ cell[s] with f in [0, 1) on periodic axes. Atoms in non-periodic systems or systems with singular cells are left unchanged.

Returns (wrapped_positions, lattice_shifts) where lattice_shifts[i] is the integer vector floor(frac_i) on periodic axes (zero elsewhere). The neighbor-list code uses these to correct shifts_idx so they remain valid for the original (unwrapped) input positions.

Parameters:
Return type:

tuple[Tensor, Tensor]