pbc_wrap_general

torch_sim.transforms.pbc_wrap_general(positions, lattice_vectors)[source]
Apply periodic boundary conditions using lattice

vector transformation method.

This implementation follows the general matrix-based approach for periodic boundary conditions in arbitrary triclinic cells: 1. Transform positions to fractional coordinates using B = A^(-1) 2. Wrap fractional coordinates to [0,1) using f - floor(f) 3. Transform back to real space using A

Parameters:
  • positions (Tensor) – Tensor of shape (…, d) containing particle positions in real space.

  • lattice_vectors (Tensor) – Tensor of shape (d, d) containing lattice vectors as columns (A matrix in the equations).

Returns:

Tensor of wrapped positions in real space with

same shape as input positions.

Return type:

Tensor