[lammps-users] Trouble with fix wall/region

Hi all,
I’m getting an odd error with fix wall/region: I’m getting an Error: Particle on or inside fix wall/region surface when starting a simulation even though there aren’t any atoms remotely close to the region. I thought I’d use some region functions to try to understand the mistake I’d made by checking which atoms were being counted as inside my region, but count(all,myregionID) turns up 0 atoms (also, count for the same region with side out gives the correct total number of atoms, so there aren’t any atoms on the surface of the region). I’m using a small cylindrical region in a large void where I’ve removed all the atoms. Has anybody encountered any trouble like this before? Or, does anybody have ideas for how I might go about troubleshooting this? Thanks,
Tyler Harvey

I would put some print statements in the region
command that generates the error and see what
particle it is and what its coords are.


Hey Steve,
I think this might be a bug. It looks, as far as I can tell, like fix wall/region is erroneously finding atoms in a region where there aren’t any.

Now, I don’t know c++, so I could be way off here, but I know this is a relatively new fix, and I’m a little concerned by a line in FixWallRegion::post_force where it looks like this error’s being called, in fix_wall_region.cpp:

// region->match() insures particle is in region or on surface, else error
// if returned contact dist r = 0, is on surface, also an error
// in COLLOID case, r <= shape radius is an error

for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
if (!region->match(x[i][0],x[i][
1],x[i][2])) {
onflag = 1;


if (onflag) error->one(“Particle on or inside fix wall/region surface”);

Shouldn’t onflag go to 1 here if region->match() is true? Shouldn’t the call to region->match() insure that the particle is not in region or on surface, else error? I.e., shouldn’t the if statement be
if (region->match(x[i][0],x[i][1],x[i][2])) {
onflag = 1;
without a NOT?

The reason I’m worried about a bug here is because I’ve tried identifying the bad atoms as you suggested. The trouble is that count() finds no atoms in the region, so I can’t go about locating which particles are causing the error–they seem to be nonexistent. I.e., for this input:

The logic in the match() and if statement is correct. Possibly what
is confusing you is how this command is intended to be used.
The surface of the region is supposed to provide a boundary that
will contain particles which are "in" the region. So if you use
a sphere as the region in fix wall/region, then you should put
all your particles inside the sphere, and they will "bounce" off
the inner surface and stay inside. If you start with any particles
outside the sphere or exactly on the surface, then you will
get an error, which is what the logic below is checking for.

Note that if you define the region with the "side out" option,
then all of this is reversed, since what is now considered
"in" the region is the volume outside the sphere. Hence in
a simulation with all particles starting outside the sphere,
they will bounce off the outer surface and not go inside.

So are you using the command in this manner? If so,
and you still getting an error? If so, please post a simple
example input file. I am seeing no problems running
it with my test input script.


Hey Steve,
Okay, that makes perfect sense now–exactly the behavior that I was seeing, but I’d assumed the exact opposite, so it made no sense to me at the time. Maybe this is just me, but the error message “Particle on or inside fix wall/region surface” definitely confused me–as I read it, it reinforced my wrong assumption that all particles were supposed to be outside the defined region. If I’m understanding the command correctly now, perhaps something like “Particle outside or on surface of region used in fix wall/region” would be clearer, if wordier?

changed the message to:
error->one("Particle on or inside surface of region "
       "used in fix wall/region");