Wrap Cartesian coordinates into the central cell along the periodic directions, the components perpendicular to the periodic subspace are kept.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(inout) | :: | xyz(:,:) |
Cartesian atomic coordinates, updated in place |
||
| real(kind=wp), | intent(in) | :: | lattice(:,:) |
Lattice vectors |
||
| logical, | intent(in) | :: | periodic(:) |
Periodic dimensions |
pure subroutine wrap_to_central_cell(xyz, lattice, periodic) !> Cartesian atomic coordinates, updated in place real(wp), intent(inout) :: xyz(:, :) !> Lattice vectors real(wp), intent(in) :: lattice(:, :) !> Periodic dimensions logical, intent(in) :: periodic(:) integer :: iat real(wp) :: lat(3, 3), ginv(3, 3), frac(3) type(error_type), allocatable :: error if (.not. any(periodic)) return ! A cell without volume in the periodic subspace cannot be wrapped into call get_inverse_metric(periodic, lattice, lat, ginv, error) if (allocated(error)) return do iat = 1, size(xyz, 2) frac(:) = matmul(ginv, matmul(transpose(lat), xyz(:, iat))) xyz(:, iat) = xyz(:, iat) + matmul(lat, shift_back_abc(frac) - frac) end do end subroutine wrap_to_central_cell