translate_pretty

torch_sim.transforms.translate_pretty(fractional, pbc)[source]

ASE pretty translation in pytorch.

Translates atoms such that fractional positions are minimized.

Parameters:
  • fractional (Tensor) – Tensor of shape (n_atoms, 3) containing fractional coordinates.

  • pbc (Union[Tensor, list[bool]]) – Boolean tensor or list of shape (3,) indicating periodic boundary conditions.

Returns:

Translated fractional coordinates of shape (n_atoms, 3).

Return type:

Tensor

Example

>>> coords = torch.tensor([[0.1, 1.2, -0.3], [0.7, 0.8, 0.9]])
>>> pbc = [True, True, True]
>>> translate_pretty(coords, pbc)
tensor([[0.1000, 0.2000, 0.7000],
        [0.7000, 0.8000, 0.9000]])