Error in region_union

Hi,

I have come across an error in which there is a lack of interaction between particles and certain sets of regions joined by region_union. region_union checks if any sub-region lies within another to prevent double counting, e.g., of a force on a nearby atom. It does so using a >= sign meaning that multiple sub-regions can lie within each other simultaneously if the boundaries overlap exactly (cf. region_union.cpp lines 154 and 175 for the relevant comment and line of code, respectively).

The attached input file shows an example of this errant behavior. You will notice a conspicuous lack of potential energy despite the fact that the particle is very close to the region “blockade”. As a quick and dirty fix one can change the upper z-bound of block2 to either 1.001 or 0.999. The correct force is reported in this case. I’m not sure how best to rectify this error, though I believe the solution requires a boolean flag to ensure at least one of the sub-regions is counted. I also suspect a similar error might surface elsewhere like in region_intersect for example.

Thanks,

Bernard Beckerman
Graduate Student - Luijten Group
Materials Science and Engineering
Northwestern University

input.dat (678 Bytes)

I’m not clear this is bug vs doing something
the code cannot/should-not support.

First, using fix wall/region with union/intersect regions
is problematic. The fix wall/region doc page has a long

2nd NOTE about potential pitfalls.

Second, your example is defining a union region
with 2 identical blocks, which means your union
has parallel lines on top of each other. I think
that’s a bad idea for use with fix wall/region.

The logic in the code is trying to avoid the issues
at corner points where 2 sub-regions intersect, by ignoring

degenerate points common to multiple sub-regions.
But you made the entire edge(s) of your union region degenerate by putting
the lines on top of each other. I think that’s why

the particles don’t see it.

So I think the solution is to not use union regions
with anything more than point intersections between
the components and observe the other caveats in that
NOTE. (this additional issue should be documented).
That might require adjusting parameters of the

sub-regions by epsilon as you indicated.

Note that most uses of regions are simply to detect
if a particle is inside/outside a region. There is no
degeneracy issues there. It’s only the use
of union regions with fix wall/region that is tricky
b.c it needs distance to a region surface and the
surface normal, and that is a fundamentally hard

calculation for arbitrary unions/intersections.

Steve