Code is attached. It can be used as:
fix ID group_ID dipole Nsteps Filename
It will generate a file with the name ‘Filename’ giving Dipole moment (x,y,z and Total) in Debye units every Nsteps. The style_user.h needs to be modified in order to incorporate this into your LAMMPS version. There are certain unnecessary variables for debugging purposes which i have not removed. Let me know if you have any questions/suggestions/find any problem with the code. I have used/tested it for group ‘all’ and my system is neutral. Hope this helps.
fix_dipole.h (1.34 KB)
fix_dipole.cpp (9.76 KB)