First-principles study of the ferroelastic phase transition in CaCl 2