function d = distancePBC(r1,r2)

global L


dist = r2 - r1;


for i = 1:3
    if dist(i) > 1500
        dist(i) =  -3000 + dist(i);
    end
    if dist(i) < -1500
        dist(i) = 3000 + dist(i);
    end
end

d = dist;
