[lammps-users] changing the per atom charge for all molecules in my system

Dear all,
I’ve seen that Lammps gives the possibility to set the charge property for existing atoms while the simulation is running. Now, I’m restarting a simulation on a system is composed of 40 molecules plus a substrate. Only, I want to change the charges I have set for the system molecules.
Is there a way to tell lammps
“here is the list of charges for the atoms in one molecule mol_id. Set the charges for the atom each molecule with id mol_id to that list of charge”.
Or I can only give Lammps a list of all the charges in the system by copying and pasting the list of charges?
Mattia Siviero

The most straightforward way to do this would be to create a file with the charges for all atoms (e.g. by extracting and post-processing a custom dump file or a data file)
and then read those back via an atomfile variable and then use the set command to set all charges to the values stored in that variable.

LAMMPS has no concept of “molecules” the way you do. the molecule ID is just a number associated with atoms that has no specific function except in a few specialized cases where it labels atoms to belong to one group (which may be different from a molecule).


If you must update the charges during the simulation, ‘fix bond/react’ can allow you to do that as you described.