Skip to content

Commit

Permalink
Test supplied neighbour list data in debug
Browse files Browse the repository at this point in the history
Note, testers for this API setter don't pass these tests.
  • Loading branch information
bhourahine committed Sep 30, 2023
1 parent 7bfd505 commit 26a5e98
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/dftbp/dftbplus/mainapi.F90
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ end subroutine setGeometry
subroutine setNeighbourList(env, main, nNeighbour, iNeighbour, neighDist, cutOff,&
& coordNeighbours, neighbour2CentCell)

!> Instance
!> Instance of computational environment
type(TEnvironment), intent(inout) :: env

!> Instance
!> Instance of DFTB+ calculator
type(TDftbPlusMain), target, intent(inout) :: main

!> number of neighbours of an atom in the central cell
Expand All @@ -124,8 +124,31 @@ subroutine setNeighbourList(env, main, nNeighbour, iNeighbour, neighDist, cutOff
!> mapping between neighbour reference and atom index in the central cell
integer, intent(in) :: neighbour2CentCell(:)

#:block DEBUG_CODE

logical, allocatable :: centralAtoms(:)
integer :: iAt, jAt, iNeigh

@:ASSERT(size(nNeighbour) == main%nAtom)
@:ASSERT(size(neighbour2CentCell) == size(coordNeighbours, dim=2))
@:ASSERT(all(nNeighbour >= 0))
! cycle over neighbours, looking for array boundary fails, but also lack of any atoms in the
! central cell in the mapping
allocate(centralAtoms(main%nAtom), source=.false.)
do iAt = 1, main%nAtom
@:ASSERT(iNeighbour(1, iAt) == iAt)
do iNeigh = 1, nNeighbour(iAt)
jAt = iNeighbour(iNeigh, iAt)
@:ASSERT(jAt <= size(coordNeighbours, dim=2))
jAt = neighbour2CentCell(jAt)
centralAtoms(jAt) = .true.
end do
end do
@:ASSERT(all(centralAtoms))
@:ASSERT(cutOff > 0.0_dp)
@:ASSERT(all(neighDist > 0.0_dp))

#:endblock DEBUG_CODE

if (allocated(main%electronDynamics)) then
call error("Not implemented: Cannot set the neighbour list when time propagation is enabled")
Expand Down

0 comments on commit 26a5e98

Please sign in to comment.