Adjusted code for open boundary conditions and added in diamagnetism measurement