Learning Modular Simulations for Homogeneous Systems