Fix atoms position while npt ensemble

Dear lammps users,

I’m trying to fix half of atoms position while npt ensemble

I have tried several ways. like,

fix 1 all npt temp 1200 4000 200 iso 0 0 1
fix 2 upper setforce 0 0 0
velocity upper set 0 0 0

///////////////////////////////////////////////

fix 1 lower npt temp 1200 4000 200 iso 0 0 1
fix 2 upper setforce 0 0 0
velocity upper set 0 0 0

////////////////////////////////////////////////

fix 1 all npt temp 1200 4000 200 iso 0 0 1
fix 2 upper freeze

atc(rigid, changing group…)

every command have problem like all atoms move or don’t move

I want to know what problem is.

Thanks a lot.

The problem is that using fix npt and thus changing the box size and having immobile atoms at the same time, is not a good idea. When adjusting the box dimensions you also rescale all atom positions with it by default. That avoids problems at the box boundaries, since otherwise there would either be an unphysical gap between periodic boundaries or immobile atoms may become located outside the box or atoms near the box boundaries - which would be displaced by the longest distance - can be moved on top of immobile atoms, but your immobile atoms are not really immobile. You can change the default behavior by changing the group to which the rescaling is applied via the “dilate” keyword, but you are replacing just one kind of problem with another one.