Setting charges to atoms in the lammps data file

Hello all,

I am trying to assign charges to different atom types in the lammps data file instead of setting it in the input script. I need this for system charge neutralization.

I am unable to find the syntax for setting charges in the data file itself, and I am unable to find it online. Could someone please share the syntax?

In LAMMPS charges are not stored per atom type, but per atom. Thus charges are entered together with the atom type and positions in the Atoms section of the data file. The exact number and meaning of the fields depend on the chosen atom style.
The details of the format are explained (in great detail) in read_data command — LAMMPS documentation

1 Like

Thanks for your help!

While we’re on this subject, I’d greatly appreciate it if you could answer two more of my questions:
a)how does one access a certain atom index within a group, for instance I have a polymer and I want to set a parameter or a force to the 26th particle only
b)does lammps offers support for logical flow of statements(for loops, if conditions etc) which could be involved in dynamically setting up parameters for atoms on the go based on recorded actions or performing other actions? Such as for instance:

Modelling a polymer system with crowders involving charges, with the polymer possessing charge qp and crowders charge qs. I intend on making the system charge neutral by doing as follows:
-assign charge qp to polymer type consisting of N beads:
-assign charge -qs to qp*N/qs crowders
-assign +qs to 50% of the remaining crowders and -qs to the remaining 50% of crowders(assuming the remaining crowders are exactly divisible by two)

It would be really great if it were possible the above charge assignment in the lammps input script

The set command has multiple options to select atoms, including atom ID.

Yes and no. There is the option to do loops (it seems you need to spend some more time reading the manual), but in general the script language has only minimal options. For more sophisticated setups and processing of input geometries, you either need to use a more sophisticated tool (the homepage lists several) or you need to do your own programming in python using the LAMMPS python module
(or some other interfaced script language via the library interface).

I personally prefer programming such tasks in VMD, but that is mostly because I have been using it for a very long time and I know VMD and its Tcl script programming very well (good enough to have contributed a few plugins and C++ code to VMD).

Thank you for your suggestions!