Saving atom configuration when crossing a periodic boundary

I would like to calculate the flux of a heterogeneous material.
This requires knowing how many atoms cross a boundary as well as where the atom crossed.
I know that I can retrieve the image flags to determine the number of crossings, but I would also like to know the atom’s position when the image flag changes.

Is there a way to save an atom’s position upon crossing a periodic boundary?

Thanks,
Ernesto

The only way to do this efficiently would be to write your own compute. See, for example, how plane-crossing events are detected in fix_wall_reflect.cpp. Instead of changing the atom position and velocity, the corresponding compute could update a set of counters associated with the wall.

Aidan

Is there a way to save an atom’s position upon crossing a periodic boundary?

I can’t think of a simple way to do this within LAMMPS. If you

have dump files which track the image flag changes at a sufficiently

small time resolution (e.g. might be different for solids vs liquids),

then the dump coords in the other 2 dims at the time the image

flags change, will be the info you want.

You can also make a small dump file with only atoms near a periodic

boundary (both sides), by using the dump_modify region option

to limit dumped atoms. A union region could be a thin slice on]

either side of the boundary.

Steve

hmm... if i put together what aidan and steve suggest, then i would
look at fix store/state and have it keep a copy of xu,yu,zu and iz at
regular intervals,
and then determine boundary crossing by checking the image counter
variable and approximating the location of the crossing through linear
interpolation. you can define an atom-style variable that compares iz
from fix store/state with the current iz and thus can provide a
variable to be used with the "thresh" option of the dump command. then
you can define a dump that will output both, the current and previous
coordinates and do the rest in post-processing. this would avoid
having to program anything inside of LAMMPS and output only
"interesting" data.

axel.

yes, I like that idea of Axel’s - it could be used

a lot more generally than crossing boundaries.

It should probably be a new dump_modify option

instead of “thresh attribute op value”, like “change attribute op”,

and the dump would internally store the last value

of the attribute for each atom.

Then

change ix != would dump atoms which crossed the boundary

change v_inregion != would dump atoms which entered/exited

a region, using a per-atom variable

change v_velthresh != would dump atoms whose velocity (or

any other attribute) went above of below

a) crossed a box boundary: ix != ix_old

b) entered/exited a region: v_inregion

or atoms that entered/exited a region or crossed

an internal plane. Or atoms whose velocity or energy

went above or below some threshhold. Etc.

Steve

sorry, sent it prematurely, completed below …

Steve

yes, I like that idea of Axel’s - it could be used

a lot more generally than crossing boundaries.

It should probably be a new dump_modify option

instead of “thresh attribute op value”, like “change attribute op”,

and the dump would internally store the last value

of the attribute for each atom.

Then

change ix != would dump atoms which crossed the boundary

change ix == would dump atoms which did not cross the boundary

change v_inregion != would dump atoms which entered/exited

a region, using a per-atom variable

which is 1/0 for atoms in/out of the region

change v_velthresh != would dump atoms whose velocity (or

any other attribute) went above or below

a threshold, where

variable velthresh atom vx > 5.0 for example

Implemented this idea as a LAST option with

the dump_modify thresh command. It can do

at least some of what you are asking …

See the 11Oct patch

Steve