Exact solutions for post-buckling deformations of nanorods