adding external field Magnetic field

Hi Lammps users,

I have recently tried to simulate magnetized plasma (electron - ion point particles in a 3-D box) using 14-Sep 2016 Lammps version.

I used addforce command to add q[v x B] force in x,y,z directions. Though the particles look gyrating; the system gets heated up immediately after we removed the thermostat. (Without magnetic field, equilibration and evolution all goes well)

After looking at literature, seems that the velocity-verlet is not suitable integrator to model magnetic fields. Here is one reference:

I am still trying to understand best way to include magnetic filed effects. Meanwhile, suggestions about making it possible wth present Lammps capabilities or other comments are welcome.


Have a look at the weak-field limit of the Spreiter and Walter integrator. It can fit into the LAMMPS VV timesteping


There is an intrinsic accuracy issue with velocity Verlet (as implemented in LAMMPS)

for any interactions where the force depends on velocity. E.g. for

the pair granular and pair dpd pair styles. Which is that the point

at which forces are applied is in the middle of the timestep where

velocitices are on the half step. Your fix addforce version of adding

the magnetic forces is also on the half step, so I’m guessing the

issue is similar. For those pair styles it is not an issue

for small timesteps, or DPD thermostatting (for example) takes

care of it

Can you not take care of it with a simple thermostat?

Failing that, you could write your own integration fix, like

a fix bfield, that applied the B-field whenever you wished,

e.g. at the start or end of the timestep when velocities are

on the full timestep.


Along the lines of Steve’s comment, I have a fix bfield if you’d like to have it. Its an integrator for the lorentz force (qv x B) that’s mostly taken from the Spreiter and Walter paper. It avoids the 1/2 step issue by analytical integrating the lorentz force. The B-field contribution to x and v are known on a particular timestep, so the fix simply adds these deltas in the appropriate parts of the step. The exact solution was heavy on trig functions and I ended up using a Taylor expansion instead of the full expression. It seems to work fine for small timesteps like would be in an LJ-system. This fix bfield also adds a torque on magnetic point dipoles. So you’d either have to remove that part of the code or (even better!) add a couple other updates to have full-blown lorentz + magnetic dipoles

Thanks Timothy and Steve for your ideas and comments.

Timothy, Yes, I will appreciate if I can get your version of Bfield fix. Then I can evolve further as the simulation results need.


This might be a ‘general interest’ type of feature for magnetic materials, plasmas, etc.
I’ve added it as a pull request on the LAMMPS github


Thanks Tim.
I will explore it and let you all know the outcome for plasma systems.