How to reverse some atom's velocity every time step

Hi all Lammps users,

I want to set up a virtual membrane. An atom can pass through it from left to right, but can not pass from right to left. If an atom reach the membrane from right, it’s velocity vx should be reversed.
So, if I locate the the virtual membrane at x=0, then if I found an atom “x<0 and vx<0”, then I think this atom passed through the membrane and it’s vx should become -vx. How can I realize it in Lammps?

I think I can find these atoms using following command,

variable atomout atom “(x < 0) && (vx < 0)”
group group_atomout variable atomout

and reserve the velocity using

variable minusvx atom -vx
velocity group_atomout set v_minusvx NULL NULL

But now there is several questions,

  1. I should apply this before periodic boundary works. When does the periodic boundary works? every time step?

  2. I have to apply this boundary every time step. How can I do this? I don’t think “run every” is a good idea.

Does this idea works?

Thank you very much.

Regards,

Fubing

Sounds like this can be done using fix
wall/reflect:http://lammps.sandia.gov/doc/fix_wall_reflect.html

Ray

Sounds like this can be done using fix
wall/reflect:http://lammps.sandia.gov/doc/fix_wall_reflect.html

not quite:

Restrictions:

Any dimension (xyz) that has a reflecting wall must be non-periodic.

the problem is than in all generality, you cannot know with PBC
whether a particle is on the left or on the right side of a reflecting
wall, since it is essentially on both. so theoretically, the check for
this could be disabled and it might work.

a cleaner and more general approach would be to set up a "one-way
zone", i.e. define a fix that operates on a group and a region and if
an atom is inside both, its velocity would be forced to be positive or
negative in either x, y, or z direction. by defining a region, the
ambiguity of what is left or right is removed.

axel.

Good point/suggestion. Thanks, Axel.

And sure if fix wall/reflect is used, the direction parallel to the
wall normal has to be non-periodic.

Ray

Thank you, Axel and Ray,

Sounds like a good idea to set up “one-way zone”. I look out the manual and but find no appropriate fix to operate on a group and a region. I find in mailing list that there are some topics about controlling temperature on a region using “compute temp/region” command, but is not suitable here.

I can define a group based on a region and then reverse the velocity as I want use “fix move” command. But the group member is fixed and will not change with time.
I want to reverse the velocity “vx” when an atom enter a specific region with “vx<0”. So have you got any suggestions about this ?

Thanks.

Fubing

Thank you, Axel and Ray,
     Sounds like a good idea to set up "one-way zone". I look out the manual
and but find no appropriate fix to operate on a group and a region. I find
in mailing list that there are some topics about controlling temperature on
a region using "compute temp/region" command, but is not suitable here.
     I can define a group based on a region and then reverse the velocity as
I want use "fix move" command. But the group member is fixed and will not
change with time.
     I want to reverse the velocity "vx" when an atom enter a specific
region with "vx<0". So have you got any suggestions about this ?

i didn't say that such a command exists but am suggesting to implement
such a feature as a fix. if a feature does not exist, it needs to be
programmed and LAMMPS makes it extremely easy to add a new code.
http://lammps.sandia.gov/doc/Section_modify.html

axel.

Thank you, Axel and Ray,
     Sounds like a good idea to set up "one-way zone". I look out the manual
and but find no appropriate fix to operate on a group and a region. I find
in mailing list that there are some topics about controlling temperature on
a region using "compute temp/region" command, but is not suitable here.
     I can define a group based on a region and then reverse the velocity as
I want use "fix move" command. But the group member is fixed and will not
change with time.
     I want to reverse the velocity "vx" when an atom enter a specific
region with "vx<0". So have you got any suggestions about this ?

i didn't say that such a command exists but am suggesting to implement
such a feature as a fix. if a feature does not exist, it needs to be
programmed and LAMMPS makes it extremely easy to add a new code.
http://lammps.sandia.gov/doc/Section_modify.html

well, and *now* this command *does* exist. please see the sources and
associated doc file in the attachment.
extract and add them to your lammps sources and compile again. i'm
also adding this to LAMMPS-ICMS and will submit this to be included
into the regular LAMMPS distribution after some more testing and
feedback.

axel.

lammps-fix_oneway.tar.gz (2.39 KB)

Hi Axel,

Thank you very much.

Regards.

Fubing