Theory and simulation of dynamics in heterogeneous environments