The easiest way to make a simulation tileable is to simply copy each "particle" beyond each border.
So when a particle leaves your tileable grid at the top it also comes back in at the bottom (and vice versa), same for left and right.
But if you like to share some more details about your algorithm, there might be more appropriate solutions...