new_wignerseitz_cell Subroutine

public subroutine new_wignerseitz_cell(self, mol, error)

Construct a Wigner-Seitz cell for a molecular structure

Arguments

Type IntentOptional Attributes Name
type(wignerseitz_cell), intent(out) :: self

Wigner-Seitz cell instance

type(structure_type), intent(in) :: mol

Molecular structure data

type(error_type), intent(out), allocatable :: error

Error handling


Source Code

subroutine new_wignerseitz_cell(self, mol, error)

   !> Wigner-Seitz cell instance
   type(wignerseitz_cell), intent(out) :: self

   !> Molecular structure data
   type(structure_type), intent(in) :: mol

   !> Error handling
   type(error_type), allocatable, intent(out) :: error

   integer :: iat, jat, nimg, empty(0)
   real(wp) :: vec(3), min_r2
   real(wp), allocatable :: trans(:, :)

   call get_wignerseitz_translations(mol, trans, error)
   if (allocated(error)) return

   ! Count the images of every pair first, such that the image indices are
   ! only stored up to the largest number of images found
   allocate(self%nimg(mol%nat, mol%nat))
   !$omp parallel do default(none) schedule(runtime) collapse(2) &
   !$omp& shared(mol, trans, self) private(iat, jat, vec, nimg, empty, min_r2)
   do iat = 1, mol%nat
      do jat = 1, mol%nat
         vec(:) = mol%xyz(:, iat) - mol%xyz(:, jat)
         call find_wsc_pairs(trans, vec, nimg, empty, min_r2)
         self%nimg(jat, iat) = nimg
      end do
   end do

   if (mol%nat > 0) self%nimg_max = maxval(self%nimg)

   allocate(self%tridx(self%nimg_max, mol%nat, mol%nat), source=0)
   !$omp parallel do default(none) schedule(runtime) collapse(2) &
   !$omp& shared(mol, trans, self) private(iat, jat, vec, nimg, min_r2)
   do iat = 1, mol%nat
      do jat = 1, mol%nat
         vec(:) = mol%xyz(:, iat) - mol%xyz(:, jat)
         call find_wsc_pairs(trans, vec, nimg, self%tridx(:, jat, iat), min_r2)
      end do
   end do

   call move_alloc(trans, self%trans)

end subroutine new_wignerseitz_cell