Skip to content

Commit b08075b

Browse files
committed
fix: do not self interact
1 parent b7d3072 commit b08075b

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/neighbours.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ end
429429
These neighbours are all particles within a distance `rcut` + `dr`
430430
"""
431431
function build_neighbour_list!(system::Particles, neighbour_list::VerletList)
432-
# Populate cell list
432+
# Populate cell list
433433
for (i, position_i) in enumerate(system)
434434
c = get_cell_index(position_i, neighbour_list)
435435
neighbour_list.cs[i] = c
@@ -446,7 +446,7 @@ function build_neighbour_list!(system::Particles, neighbour_list::VerletList)
446446
for c2 in neighbour_cells
447447
@inbounds for j in neighbour_list.cells[c2]
448448
# Don't double count
449-
if j < i
449+
if j <= i
450450
continue
451451
end
452452
position_j = get_position(system, j)
@@ -505,9 +505,8 @@ function update_neighbour_list!(system::Particles, i::Int, neighbour_list::Verle
505505
# Alternatively, we could redo everything and reset all positions, unclear which one is the fastest
506506

507507
# First, remove i for all other lists
508-
for j in neighbour_list.neighbours[i]
509-
# no idea what the fastest way to do this is
510-
# TODO: benchmark against filter from update_cell_list
508+
@inbounds for j in neighbour_list.neighbours[i]
509+
# TODO: benchmark against filter
511510
deleteat!(neighbour_list.neighbours[j], neighbour_list.neighbours[j] .== i)
512511
end
513512
neighbour_list.neighbours[i] = Int[]

0 commit comments

Comments
 (0)