Restrarin a group of atoms inside a fixed volume

Dear all,

I have a metal slab surrounded by fluids. At lower temperature, the fluids is always moving around the slab and slab is in the middle of the simulation box. However, At higher temperature, after about 150ps, the slab starts to have a z-direction velocity and move upside and down.
I dont know why it happened. I am trying to fix the metal slab in a fictitious box but to allow it move ‘freely’ inside that fictitious box. After looking up the manual, I found three possible solutions. Fix rigid, spring, wall. Which one is a better option here?
Is there any suggestions?
Thank you.

What you describe is what should be happening.

Of all the options you mentioned only fix spring is suitable if you want to keep doing research. The others would turn your simulation into a computer animation.

I understand your point sir. That’s why I want to compare the original simulation and restrained simulation so that I can find out what happened here for z-direction velocity.
Thank you!

I want to understand your simulation a little more clearly. Do you mean:

  • The metal slab is periodic in the x and y directions, with both surfaces in the z direction
  • There is fluid at each surface, flowing in the transverse directions (x? y? How do you make the fluid flow?)
  • You want the slab to not move in the z direction

If that’s the case, you could try fix recenter with the shift keyword.

fix recenter is a bad choice as it does not change the simulation dynamics, but only retranslates the positions. This makes them unusable for any kind of dynamics analysis unless you only what to look at motions relative to the centered object.

Thank you for attention.

Yes, it is periodic in all x,y,z directions.
I don’t make fluid flow. I just set the temperature and it will move around the metal slab.
That’s what I want to try here so that I can find out why after some time the metal slab has a z-direction velocity and it won’t stop moving.

Yes, I think we should avoid any change on the dynamics itself because it is what I want to investigate.

The following commands are my test to use fix spring. I try to get the center of mass for group 1 in the beginning.

compute         1 1 com
variable        x equal c_1[1]
variable        y equal c_1[2]
variable        z equal c_1[3]
run             0
variable        com_x equal ${x}
variable        com_y equal ${y}
variable        com_z equal ${z}
fix             1 1 spring tether 50 ${com_x} ${com_y} ${com_z} 0

I followed the variable command mannual but I still got the error message, Compute used in variable between runs is not current.
How to solve it? I am a little confused here.
Thank you.

Please try this more compact approach where the center of mass is computed via the xcm() variable function instead of a compute.

fix             1 1 spring tether 50 $(xcm(1,x)) $(xcm(1,y)) $(xcm(1,z)) 0

For most compute styles cannot “consume” them (i.e. trigger the computation) in between run commands. For some you can use them if they are “consumed” on the same timestep during a run before, but you are not doing that. That is a principal property of computes and there are technical reasons for that.

Thank you sir!

Understood.

Could also try fix momentum to occasionally zero out the total momentum of the box (say every 1000 timesteps), along with fix recenter. That is what I use to pin density profiles of liquid-vapor simulations for fix ave/chunk, seems to work well.