Avoid the molecule going out of the box when pbc=xy

GROMACS version:2022.1
GROMACS modification: No
Dear all,

when I am modeling a polymer in water system, there are always several water molecules running out from the top of my box in z direction.
Could you please give some ideas of how to avoid the running out of water molecules?

My mdp setting related to pbc=xy is below:
pbc = xy ; Periodic Boundary Conditions in all 3 dimensions
nwall = 2
wall-atomtype = opls_135 opls_135 ;carbon atoms
wall-type = 9-3
wall-r-linpot = 3
wall-density = 150 150
ewald-geometry = 3dc ; Only Ewald sum compatible with slab geometry, requires box_height >= slab_height * 3
wall-ewald-zfac = 3 ; Extra empty space for slab geometry calculation (reducing coulomb interaction)

By the way, from the gromacs manual, nwall = 2 means there are two walls (one at z=0 and the other at z=z-box), but I am a bit confused about the value of z here, where the second wall exactly be? Is it at the top of the box? (eg. when the box in z direaction the length is 5nm, then the second wall is at z=5?)

Thanks advance for your help!

You have a wall-r-linpot setting of 3 nm. This makes the wall attractive. This value should be smaller than the sigma of the LJ potentials involved.

Thanks Hess! I will give it a try :)