Log the velocity of all atoms that leave the simulation box

Setup: I have a material in a simulation box with periodic x and y boundaries, frozen atoms along the lower z face and several Angstroms of free space above between the z directed material surface and the top of the simulation box.

Experiment: I impact this material with an atom inserted into the free space above the surface having a large, surface directed, velocity.

Goal: I want to record the velocity of all atoms that subsequently leave the simulation box though the top z face.

Current solution: I do this at present by regularly dumping all atoms in the free space region above the surface. I then parse these dump files and record the velocity of all atoms that are far from the surface and have a positive vz, assuming that these will shortly exit the simulation box.

Problem with this solution: There are a number of issues with this solution, but the most significant is that it requires me to dump sufficiently often so that no particle can transit the volume before being dumped. This results in a large amount of unneeded data being written to disk which then needs to be post processed.

Question: I simply want to log the velocity of all atoms that escapes the simulation box. Is there a way to do this in lammps?

Here’s what I would try:

  1. Define a “steps-to-escape” variable:

variable step_escape atom (zhi-z)/(vz*dt)

This is negative for atoms moving downwards and, for atoms moving upwards, calculates the number of steps within which they would reach zhi, the top boundary of the box.

  1. Set up a dump custom every N timesteps outputting your desired information (just vz in your case? But you could add more output fields).
  2. Use dump_modify ... thresh v_step_escape > 0 thresh v_step_escape < ${SOME_X} on the previous dump custom so it only dumps atoms which are within some X steps of escaping.

To be completely rigorous you can just set both N and X to 1. You may also use some N < X to dump regularly and capture how particles’ velocities change “on the way out” – for example, if N = 5 and X = 10, then every 5 steps you will dump all particles within 10 steps of escaping (so you should catch each particle twice on the way out).

Please note I have not personally done this before – and even if I had, you need to verify for yourself that this combination of commands will have the desired correct output.

Here are some thoughts on this:

  • You don’t really want to look at atoms that have left the box, since their information is no longer available.
  • LAMMPS does not accurately process dropping atoms from the box. The “lost atom” check and the removal of atoms from the simulation only happens during reneighboring and for performance reasons, that is not done on every step.
  • Thus you would rather have a region where you monitor atoms that is still inside and where you define a specific coordinate determining the threshold.
  • That region would have to be large enough for the maximum expected exit velocity, so that atoms are within that region for at least 2 timesteps
  • You would need to write a custom fix that tracks the atom IDs of atoms within that region and thus can determine when an atom has crossed the threshold
  • At that point you can reconstruct the exact time when the atom has crossed the threshold and from that also the exact velocity at that point (both by reversing the velocity verlet timestepping for a partial step).
  • Since atoms can move between subdomains, this would require to collect the information of potentially leaving atoms globally in every timestep, but would allow you to only output the data when the event happens.

Hi @srtee . Thanks for the reply. Unfortunately the velocity of the particles emitted from the surface have a wide distribution and so there is no suitable value for vz in your suggested approach. This is why I currently just dump suitably often that I capture a snap of atoms leaving for all v.

@akohlmey This is very helpful information, thank you.

I don’t care about the time when, or location where, the atoms cross the boundary, just their velocity. I don’t expect their velocity to change outside of the box so the velocity at the point when the particles are discarded is still of value to me. But I understand from your post why lammps has no facility to record this data.

I will look into writing a custom fix.

Note vz is not a user-inputted value. Used inside an atom-style variable, it takes on the value of the z-velocity at that timestep, for that atom.

I hope you can see how that would work to give you something like what you want (up to some uncertainty in exact timestep).

@srtee Oh, apologies, then that is very interesting. I’ll give it a try! Thanks.