Magnetoelastic interaction in rare earth systems