Problems with setforce

Hi all,

I am going to simulate methane flow within the kaolinite nanoslit. I fixed the bottom layer of kaolinite while applying force on the top layer to create a 10 MPa pore pressure. But I found only hydrogen atoms in the top layer move down during the simulation. Following is the command I used to fix the boundary, can anyone tell me how to make the top layer move as a whole. The version I used is LAMMPS (29 Sep 2021)


fix sfbot botwall setforce 0.0 0.0 0.0


fix sftop topwall setforce 0.0 0.0 0.0
fix aftop topwall aveforce 0.0 0.0 v_Ftop
velocity ch4 create 313 84512 rot yes dist gaussian
fix eq1 topwall nve
fix eq2 ch4 rigid/nvt molecule temp 313 313 100


Hi all,

I found that if I use “fix rigid/nve” instead of “fix nve” to make top layer rigid, it can move as a whole, anyone has other methods for this?


There is not enough information here for any specific advice. Most likely there are some issues with other parts if the input, probably with the group definitions.

Your combination of applying fix setforce 0 0 0 followed by fix aveforce on the same group of atoms doesn’t make much sense.

Hi Alex,

I have attached my input file, and the data file is shared through google drive (kao - Google Drive).

Another question is how can we calculate the gas pressure between the kaolinite layers. I am trying to use “compute stress/atom” to calculate the pressure of the methane group and then divide its volume. But when I change the force on the top layer, the pressure value obtained through the above method does not change. Would you please also tell me if there is a solution for this?


in.kaoch4 (2.5 KB)

I’ve looked at your input and a few things can be changed:

  • fix sfbot botwall setforce 0.0 0.0 0.0 is not needed
  • fix sftop topwall setforce 0.0 0.0 NULL is not needed
  • fix aftop topwall aveforce 0.0 0.0 v_Ftop
    should be fix aftop topwall addforce 0.0 0.0 v_Ftop
  • fix box all recenter NULL NULL INIT is not needed
  • fix eq1 topwall rigid/nve group 1 topwall
    should be fix eq1 topwall rigid single or fix eq1 topwall rigid/nve single
  • fix eq2 ch4 rigid/nvt molecule temp ${temp} ${temp} $(100*dt)
    should be fix eq2 ch4 rigid/nvt/small molecule temp ${temp} ${temp} $(100*dt)

I do see a difference, but it will not show immediately. Adding a force is not like adding a displacement. A larger force means a larger acceleration, but when you start from an object at rest, there is no motion initially and thus it will take a while until the acceleration will have an impact at all and the impact from the difference in added force will take even longer, depending on how large the difference it. Using a 10x larger force has an impact on the pressure after 100 steps, for example. Please also note that this added force is on top of the force the wall experiences from the methane molecules, so the magnitude of the effect of changing the added force also depends on the relative magnitudes of those two contributions to the force on the wall.