Most convenient way to add atoms to a system (by C/C++ API)

Dear LAMMPS users,

I'm not sure how to add atoms with mass and charge
to a MD system by the C/C++ API the best way.

Should I write/extend the configuration file by
the atoms I need and then re-read the configuration
file with C/C++ API?

Or: Should I create atoms with the create_atom
command which I can execute with LAMMPS API by
lampps->one("create_atom ...") string?

Thanks in advance.

Best,
Stephan

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Dear LAMMPS users,

I'm not sure how to add atoms with mass and charge
to a MD system by the C/C++ API the best way.

this ​depends ​a bit on whether those atoms need to have
bond/angle/dihedral/improper interactions or not.
also, would those new atoms have to have atom/bond/angle/dihedral/improper
types not yet present.
it also depends, how much you care about efficiency.

Should I write/extend the configuration file by

the atoms I need and then re-read the configuration
file with C/C++ API?

if you have code ​that can do this easily, it is most certainly the
cleanest way, but this would require to use the clear command or delete and
recreate the LAMMPS object and then re-initialize from scratch. if you need
to add molecules, this is pretty much the only viable option at the moment.

Or: Should I create atoms with the create_atom
command which I can execute with LAMMPS API by
lampps->one("create_atom ...") string?

​that is one option. another would be to use read_data with the ​add option
(this is a rather new feature). please note that if you need to add new
types, you need to reserve space for them when the simulation cell is
created. after that, certain system specific properties are locked in.

also read_dump can add atoms, or fix deposit.

axel.