A novel technique for nanomagnetism