Nanomechanical magnetization reversal