" ""Computes distances between all particles and places the result in a matrix such that the ij th matrix entry corresponds to the distance between particle i and j"" "
"""Computes distances between all particles and places the result
in a matrix such that the ij th matrix entry corresponds to the
distance between particle i and j"""
N=len(x)
xtemp=np.tile(x,(N,1))
xtemp=np.tile(x,(N,1))
dx=xtemp-xtemp.T
ytemp=np.tile(y,(N,1))
ytemp=np.tile(y,(N,1))
dy=ytemp-ytemp.T
ztemp=np.tile(z,(N,1))
ztemp=np.tile(z,(N,1))
dz=ztemp-ztemp.T
# Particles 'feel' each other across the periodic boundaries
ifperiodicX:
dx[dx>L/2]=dx[dx>L/2]-L
dx[dx<-L/2]=dx[dx<-L/2]+L
dx[dx>L/2]=dx[dx>L/2]-L
dx[dx<-L/2]=dx[dx<-L/2]+L
ifperiodicY:
dy[dy>L/2]=dy[dy>L/2]-L
dy[dy<-L/2]=dy[dy<-L/2]+L
dy[dy>L/2]=dy[dy>L/2]-L
dy[dy<-L/2]=dy[dy<-L/2]+L
ifperiodicZ:
dz[dz>L/2]=dz[dz>L/2]-L
dz[dz<-L/2]=dz[dz<-L/2]+L
dz[dz>L/2]=dz[dz>L/2]-L
dz[dz<-L/2]=dz[dz<-L/2]+L
# Total Distances
d=np.sqrt(dx**2+dy**2+dz**2)
d=np.sqrt(dx**2+dy**2+dz**2)
# Mark zero entries with negative 1 to avoid divergences