Dear Lammps users,
I am interested in making molecular simulations with an external magnetic field.I want to simulate the effect of an applied magnetic field on the size of water molecule clusters, and the number of hydrogen bonds, but I’m not quite sure how to add an external magnetic field.Can a teacher help me?
Probably not, you are not the first one to ask for the possibility to apply magnetic field in LAMMPS, see Axel’s answer here: [lammps-users] Magnetic Field
Applying a magnetic field to a system simulated by LAMMPS is not a topic suitable for a beginner.
A magnetic field causes forces due to the velocity of charged atoms and not their position (like an electric field). That conflicts with the velocity-Verlet integration algorithm, that assumes that forces are dependent on position only.
This is also a problem with DPD models, but people have developed specialized integrator fixes to minimize the impact of that inconsistency. Nothing equivalent exists yet for magnetic fields. The work-in-progress implementation mentioned in the post linked to by @simongravelle is available in the lammps-plugins repository, but it is lacking documentation and has significant restrictions on how it can be used.
Hi Mr. akohlmey, thank you very much for your answer. But I read in some papers that someone used velocity-Verlet algorithm to apply Lorentz force on charged particles and control the magnetic field strength by changing the time step. I don’t know if this method is feasible.For example, both papers mention the vv algorithm"Implementation of magnetic field force in molecular dynamics algorithm: NAMD source code version 2.12" and " Magnetic molecular dynamics simulations with Velocity Verlet algorithm"
Hi Mr. simongravelle, thank you very much for your reply. I read Axel’s reply and did not find a way to add a magnetic field, I saw some papers written about simulating an applied magnetic field by introducing the Lorentz force under the action of a magnetic field, I wonder if this method is feasible and can simulate the effect of a magnetic field on water molecules
NAMD is a different code than LAMMPS: https://www.ks.uiuc.edu/Research/namd/ Probably you should use it instead.
As I already wrote, a partial implementation is available as an undocumented, external LAMMPS plugin. I also wrote that an updated fix for time integration for use with DPD style models exists.
To make this all work for LAMMPS and correctly test, use, and document this is far beyond the capabilities of a LAMMPS beginner and requires you to find a collaborator that is knowledgeable in C++ programming with LAMMPS, has sufficient experience to understand and apply the knowledge presented in the articles you are referring to and then is willing to do the implementation in LAMMPS. The LAMMPS developers would be happy to include such a change in the distribution.
However, the existence of such articles and references to custom integrator schemes, does not automatically mean that this can be realized in LAMMPS. You cannot use what is not there.
As I already mentioned, this is a rather advanced subject that requires knowledge of statistical mechanics and physics that you apparently do not (yet) posses. So pursuing this further on your own is a bad idea.