Principles of Nanomagnetism