Constantly Fill Simulation Domain with Molecules

Dear Dr. Steve Plimpton and LAMMPS Users,

Hello Dr. Steve Plimpton. Thank you so much for your advice.

I was curious if LAMMPS could possibly insert molecules in a dynamical simulation box such that the box is always filled with molecules at any instant in time.

Although I was able to insert specific number of molecules in a dynamic simulation domain using the fix deposit command, I was curious if there is any way for a dynamic simulation box to be constantly filled with molecules since the fix deposit command can, at most, insert a single molecule at every timestep. Thank you so much for your time.


Masato Koizumi

You don’t say why you expect there to continually be
empty space to insert atoms or molecules. But assuming
there is within some geometric region (see region command),
you could do something like this with the run every command.

region insert block …
run 10000 every 100 1 command1 command2
command1 = create_atoms 1 region insert
command2 = delete_atoms overlap 2.0 all all

Create_atoms will add new atoms. Delete_atoms
will delete overlaps within a cutoff distance of 2.0
in case there were other atoms in the insert region.
Note that the delete_atoms command will delete
such overlaps over the entire simulation domain
so you need to make sure you choose 2.0 small
enough to avoid deleting atoms/molecules you
want to keep.

Both commands can also work with molecules.
See their doc pages.


Dear Dr. Steve Plimpton and LAMMPS Users,

Hello Dr. Plimpton, and, once again, I would like to deeply thank you for your continuous advice. I apologize for being unclear on my explanation.

I am trying to simulate an inflating simulation box that contains polymer chains. The dilation of the simulation domain is triggered by dimers continuously being inserted into the simulation box much like air is entering the balloon and the volume of the balloon inflates.

To simulate this inflation due to dimers entering the domain, I adhered to your advice by using the create_atoms and the run every command which will instantaneously fill the inflating box with dimers.

However, the I received an error that states “Cannot create atoms with undefined lattice.” I understand that I need to use the lattice command prior to using the create_atoms command but since the create_atoms command is specified in the run every command loop, I was curious if there is a way to solve this error by also defining lattice command in the run every command. I am trying to equate the simulation box defined by read_data command to the lattice command, but I was curious if there is a way to connect these two.

Also, I have named the inserted dimers as “addatoms” since I would like to have these inserted dimers be subjected to nve ensemble and langevin thermostat. However, since the create_atoms command does not provide the argument for specifying the names of atoms that will be created, how will the created molecules be identified as addatoms?

Thank you so much for your time and help.


Masato Koizumi

P.S. I have displayed a portion of my input script:

pair_style lj/cut 2.5
bond_style fene

special_bonds lj 0.0 1.0 1.0

read_data extra/atom/types 1000 extra/bond/types 1000

mass * 1.0

pair_coeff * * 1.0 1.0 2.5
bond_coeff * 30.0 1.5 1.0 1.0

pair_modify shift yes

timestep 0.0010

reset_timestep 0

fix 1 all langevin 1.0 1.0 2.0 542305

fix 3 all nve

fix 4 all deform 1 x erate 0.001 y erate 0.001 z erate 0.001 remap v

group addatoms type 2
region mobile block EDGE EDGE EDGE EDGE EDGE EDGE side in
group mobile region mobile

molecule dimer molecule.dimer

fix 8 addatoms nve
fix 9 addatoms langevin 1.0 1.0 2.0 587283

run 100000 every 1 “create_atoms 0 region mobile mol dimer 12345” “delete_atoms overlap 2.0 addatoms all”

Do you really want to create your molecules on a lattice? From your description maybe random locations (within some region) would be better, in which case you do not have to define a lattice.

If you do want a lattice, you can simply add that in the “every” part of the run command before the “create_atoms” command.

Do you really want to create your molecules on a lattice? From your
description maybe random locations (within some region) would be better, in
which case you do not have to define a lattice.

​random placement doesn't help much unless you use fix gcmc to do it. what
steve was suggesting, would only work, if there was an actual empty region
created, but that would effectively mean, to rip the system apart, fill the
void, and then continue. however, the quoted input just scales the entire
system, which is more physically meaningful, but won't result in a suitable
region to insert (but the whole system). doing insertions on fixed lattice
positions is flat out crazy under those conditions, as it will cause
trouble with the second and all following insertions, even if the first was
successful. also, i don't quite get the point of why the system is forcibly
expanded. that is the reversal of the description below, where insertion
expands the system. overall, this looks like a completely bogus model
combined with bad explanations and incomplete information. this whole
project looks like it needs the help of a competent supervisor/tutor as it
shows a worrisome disregard for physics and modeling concepts. ​this is
*far* beyond what help can be provided over e-mail.