Function Repository Resource:

# PeriodicBoxDisplacement

Get the shortest displacement between two points in a box with periodic boundary conditions

Contributed by: Matt Kafker
 ResourceFunction["PeriodicBoxDisplacement"][u,v,L] gives the shortest displacement between vectors u and v in a cubic box of side length L centered on the origin with periodic boundary conditions.

## Details

ResourceFunction["PeriodicBoxDisplacement"] works for boxes in any spatial dimension.

## Examples

### Basic Examples (3)

Compute a 1D periodic box displacement in the "box" represented by the interval [-1,1]:

 In[1]:=
 Out[1]=

PeriodicBoxDisplacement reverts to Euclidean displacement when points are close by within the box:

 In[2]:=
 Out[2]=

Parallel points on the boundaries of the box are mapped to the same point:

 In[3]:=
 Out[3]=

### Scope (1)

PeriodicBoxDisplacement also works in higher dimensions:

 In[4]:=
 Out[4]=

### Neat Examples (2)

Visualize the displacement vector between two points in different boxes (dashed boxes are "copies" of the main box due to periodic boundary conditions):

 In[5]:=
 Out[5]=

In three dimensions:

 In[6]:=
 Out[6]=

## Publisher

Wolfram Summer School

## Version History

• 1.0.0 – 05 August 2021