Skip to content

Commit

Permalink
reordered folding and shifting coordinates. fixes #65
Browse files Browse the repository at this point in the history
  • Loading branch information
Kay-Robert Dormann committed Oct 18, 2024
1 parent 24740b8 commit 1336a73
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions amep/pbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,20 +635,19 @@ def kdtree(
# get center of the simulation box
center = np.mean(box_boundary, axis=1)

# fold coords back into box (to avoid errors)
coords = fold(coords, box_boundary)

# shift all coordinates to be within [0,L_i), i=x,y,z
# (this is required by the KDTree algorithm)
coords = coords + box/2. - center

# fold coords back into box (to avoid errors)
coords = fold(coords, box_boundary)

# shift particles at the right border to the left border
# to avoid errors occuring if a particle is placed at L_i
coords[coords[:,0]==box[0],0]=0
coords[coords[:,1]==box[1],1]=0
coords[coords[:,2]==box[2],2]=0
# print(box_boundary, box)
# print(np.max(coords, axis=0))

return KDTree(coords, boxsize=box)

# =============================================================================
Expand Down

0 comments on commit 1336a73

Please sign in to comment.