Simulations of the heterogeneity of environments by finite element methods