def back_map(ppos, box):
    """Map particles which are outside of the box back into the box,
    using periodic boundary conditions.

    Arguments:
        ppos        (ndarray):      A two-dimensional array with shape (n,d) (Positions of all particles)   
        box         (ndarray):      A one dimensional numpy-array with d elements (size of preriodic box)

    Returns:
        ppos        (ndarray):      A two-dimensional array with shape (n,d) (Positions of all particles, which are all inside the box) 
    """

    for i, length in enumerate(box):
        while any(ppos[:, i] >= length):
            ppos.T[i][ppos[:, i] >= length] -= length
        while any(ppos[:, i] < 0):
            ppos.T[i][ppos[:, i] < 0] += length
    return ppos