Using a modified Bak-Tang-Wiesenfeld model for sand piles, we simulate a Casimir-like effect in a granular pile with avalanches. Results obtained in the simulation are in good agreement with results previously acquired experimentally: two parallel walls are attracted to each other at small separation distances, with a force decreasing with increasing distance. In the simulation only, at medium distances a weak repulsion exists. Additionally, with the aim of avalanche prevention, the possibility of suppressing self-organized criticality with an array of walls placed on the slope of the pile is investigated, but the prevention effect is found to be negligible. © 2011 American Physical Society.