added magnetization calculation