Theoretical study of the formation, evolution, and breaking of gold nanowires