wall/reflect in a periodic system

Dear LAMMPS users,

Are there any pitfalls with using f-x wall/reflect in a periodic system (by commenting corresponding check)? In fix wall/reflect there is constrain that the system must not be periodic in the wall direction. Although it might have sense in terms of encouraging user to use lammps in a more efficient way (saving space by not using image and pbc and related transformations), I don’t see why it is a must. I tried to run in a toy simulation wall/reflect with commented check on periodicity, it seems it works correctly.

What physical reason would there be for using both? Perhaps I am naive, but I can’t think of occasion where you would need a “hard” wall and interactions with periodic images(usually intended to mimic and infinite system).

Dear LAMMPS users,

Are there any pitfalls with using f-x wall/reflect in a periodic system (by
commenting corresponding check)? In fix wall/reflect there is constrain that

the question is: on which side of a wall would a particle be under PBC?

it is effectively on both sides. thus reflecting walls under PBC only
make sense when they come in pairs, so that you can define an "inside"
and "outside" again. the need for this is extremely rare, but most
other naiive uses of a reflecting wall under PBC are problematic,
hence the check and the error termination.

the system must not be periodic in the wall direction. Although it might
have sense in terms of encouraging user to use lammps in a more efficient
way (saving space by not using image and pbc and related transformations), I
don't see why it is a must. I tried to run in a toy simulation wall/reflect
with commented check on periodicity, it seems it works correctly.

it is difficult to discuss this without also knowing the justification
for wanting to use reflecting walls under PBC. any valid uses that i
can personally imagine are extremely limited. for most other cases,
there are better alternatives, or they are plain wrong.

axel.

This is an interesting question. What Axel says is all correct, but I
will say it slightly differently.

The reason for the non-periodic restriction is that the LAMMPS
reflective walls operate on particle coordinates asymmetrically, as if
the wall were an impenetrable half-space. Particles are only
reflected out of the wall if they lie inside the wall. For walls
specified by xlo, ylo, or zlo, inside means to the left of the wall
position. For walls specified by xhi, yhi, or zhi, inside means to
the right of the wall position. Any particle that starts out inside
the wall is reflected to the outside during the first timestep.* For
most applications this is the desired behavior and it is also the most
straightforward to implement and document, but it is inconsistent with
PBCs, where every particle would be simultaneously outside and inside
every wall.

Applying the minimum image convention in a simple manner does not
help. For a pair of walls at the left and right periodic boundaries,
a particle would always be inside one of them. Not good!

To work with PBCs in a sensible manner, the wall would need to operate
symmetrically and *dynamically*, so that particles crossing from the
left would be reflected to the left, while particles crossing from the
right would be reflected to the right. A rare example of where this
would be useful is equilibrating a planar interface between two
fluids. It is desired that the fluid particles interact fully with
each other, without actually mixing. A periodic cell with a pair of
symmetric reflective walls would achieve the desired goal. There would
still be a pressure difference between the two subvolumes that would
have to be eliminated by adjusting the wall positions manually. In
any case, implementing the fix dynamically would be considerably more
complicated than the existing fix, and the benefit is negligible.

Now that I think about it, the above application could be enabled if
wall/reflect allowed PBCs. It requires that the fix itself not be
periodic. This is a somewhat dubious thing, since the action of the
fix will not be invariant under periodic translation. However, the
other wall fixes already allow this as an option. The difference here
is that any malfunction will not directly generate an error, just an
unphysical reflection of the particle. It would then be possible to
build a periodic cell with two slabs of fluid A and B. For each of
the corresponding groups, a fix wall/reflect could define a pair
impenetrable half-spaces. The half-spaces for both groups would
terminate at the same positions, but be oriented in opposite
directions. This would achieve the desired planar interfaces between
the two slabs of fluid.

Aidan

*Note that this behavior is different from other wall fixes in LAMMPS,
which give a LAMMPS error if a particle ever goes inside the wall.

1 Like

if you put a single reflective wall, within PBC, you’d be getting effectively a reflecting pair of walls, right? I mean, it would be “non-periodic” in that direction. The one reason I can think of doing this is if you have more than one wall per cell (or, walls that are apart from each other at a distance larger than 2*r_cutoff)

pablo