"compute spin" does not give the total magnetization

Dear LAMMPS users,

It is said in the manual that compute spin command calculates the total magnetization of the system, so I tried the script “in.spin.iron_dipole_pppm” from the examples subdirectory. It seems that this command does not evaluate the total magnetization, but the direction of something. The following is the output information from the log file.

 Time          v_magx         v_magy         v_magz       v_magnorm        v_tmag         v_emag    
   0             -1              0              0              1              5.6824563e-38 -383.9491     
   0.005         -1              3.6415984e-09 -1.9643831e-09  1              5.0559306e-10  0            
   0.01          -1              7.310821e-09  -3.9279138e-09  1              1.9879254e-09  0    

It can be observed that the norm of the total magnetization is always 1.

Best wishes,


This is a question for @julient

Hello everyone,

@akohlmey , thank you for forwarding the message.

It looks more like a round-off issue. Indeed, your y and z components of the magnetization are 10^-9 (so extremely small values), and the x component is still 1.

Try to turn on a Langevin thermostat (fix langevin/spin) connected to the spins with a rather high temperature. You should start to see more difference.

Hope this helps!

@julient, @akohlmey
Hello, thank you very much for your reply.

My question is that the magnitude of magnetic spin vector (in Bohr magneton’s unit) in this example is 2.2, there are totally 3456 atoms. And iron is ferromagnetic, thus the total magnetic is about 2.2x3456~7603.2. The total volume is 40700.5 A^3, so the total magnetization is about 7603.2/40700.5 ~ 0.18.

However, the value output by LAMMPS is always 1, the same is true for different temperatures. It does not give the correct value.

Best wishes,


Hello Wei,

Indeed, this is correct: we decided to output a normalized total magnetization vector. This is a rather common convention, which is usually giving a clear idea of the magnetic state of the system.
To access the actual magnetization of the system, you need to run the quick calculation you performed.

My apologies is it was not made clear enough in the documentation. I will try to improve it to avoid any confusion.

All the best,