Application of the Metropolis–Hastings algorithm in 2D and 3D nano-materials with magnetic properties.