Entropy function in heterogeneous and anisotropic nonlinear ferroelastic crystals