Generate lattice points from repeatitions
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | lat(:,:) |
Lattice vectors |
||
integer, | intent(in) | :: | rep(:) |
Repeatitions of lattice points to generate |
||
logical, | intent(in) | :: | origin |
Include the origin in the generated lattice points |
||
real(kind=wp), | intent(out), | allocatable | :: | trans(:,:) |
Generated lattice points |
subroutine get_lattice_points_rep_3d(lat, rep, origin, trans) !> Lattice vectors real(wp), intent(in) :: lat(:, :) !> Repeatitions of lattice points to generate integer, intent(in) :: rep(:) !> Include the origin in the generated lattice points logical, intent(in) :: origin !> Generated lattice points real(wp), allocatable, intent(out) :: trans(:, :) integer :: itr, ix, iy, iz, jx, jy, jz itr = 0 if (origin) then allocate(trans(3, product(2*rep+1))) do ix = 0, rep(1) do iy = 0, rep(2) do iz = 0, rep(3) do jx = 1, merge(-1, 1, ix > 0), -2 do jy = 1, merge(-1, 1, iy > 0), -2 do jz = 1, merge(-1, 1, iz > 0), -2 itr = itr + 1 trans(:, itr) = lat(:, 1)*ix*jx & & + lat(:, 2)*iy*jy + lat(:, 3)*iz*jz end do end do end do end do end do end do else allocate(trans(3, product(2*rep+1)-1)) do ix = 0, rep(1) do iy = 0, rep(2) do iz = 0, rep(3) if (ix == 0 .and. iy == 0 .and. iz == 0) cycle do jx = 1, merge(-1, 1, ix > 0), -2 do jy = 1, merge(-1, 1, iy > 0), -2 do jz = 1, merge(-1, 1, iz > 0), -2 itr = itr + 1 trans(:, itr) = lat(:, 1)*ix*jx & & + lat(:, 2)*iy*jy + lat(:, 3)*iz*jz end do end do end do end do end do end do end if end subroutine get_lattice_points_rep_3d