I am simulating water molecules and have a question about the periodic
boundary. Under this boundary condition, the atoms are possible to go out
from one side of the boundary and enter at the other side.
that is not quite correct. what happens is that if one atom leaves the
principal cell, a *periodic copy* of it enters. in many MD codes this
achieved by only storing one instance of each atom and then figured
out what is the distance to the closest periodic image when computing
the distance between those two atoms, i.e. the periodic copies are
implicit (often referred to as "minimum image conventions"). this is
the reason why in such codes the non-bonded cutoff is restricted to
half the shortest box diameter. in LAMMPS the periodic copies are
explicit (as ghost atoms) and thus LAMMPS supports using larger
But when it comes
to molecule, when one H of the water molecule flow out the boundary, and
others do not (one H and one O), the bond OH will run through the whole
simulation box until all the water molecule atoms have flow out the
no, it doesn't. what you see is entirely a visualization issue. in
both scenarios i've outlined above, the x,y,z coordinates written to a
trajectory file are those of the copy that is currently inside the
principal unit cell (technically, that is not 100% true in LAMMPS, for
performance reasons it is only enforced on timesteps, where the
neighbor lists are updated). these are also often referred to as
"wrapped coordinates". in addition, LAMMPS keeps track of when atoms
pass through PBC and get replaced by their periodic images in the
"image flags". applying those in combination with the box vectors to
wrapped coordinates will produce "unwrapped coordinates". in this case
an atom/molecule in the visualization will continue their path.
I will like to know will this OH bond which run through the whole
box will effect the simulation?
it doesn't. if it would, you would notice.
I will also like to know if there is any
command that can make the whole molecule flow out instead of one atom, I
try to find but do not see any.
as steve already mentioned, what you are asking for is a visualization
problem (in combination with an incomplete understanding of PBC). if
you write out your trajectory in unwrapped coordinates (or as wrapped
coordinates plus image flags), you can postprocess your trajectory to
wrap back molecules based on a reference atom and only wrap entire
groups. if you are visualizing (or post-processing) your trajectory
with VMD, this can be done with the pbctools plugin, e.g. via: pbc
wrap -compound fragment -all
i suggest you think about this some and then improve your
understanding of PBC by revisiting your MD textbook(s).