def recast_to_supercell(z, z_min, z_max):
    """Gets the position of the particle at ``z`` within the simulation
    supercell with boundaries ``z_min`` y ``z_max``. If the particle is
    outside the supercell, it returns the position of its closest image.

    :param z:
    :param z_min:
    :param z_max:
    :return:
    """
    sc_size = (z_max - z_min)
    return z_min + (z - z_min) % sc_size