The correct boundary condition is to use Neumann boundary conditions along the direction where the gate is defined.
However, Neumann boundary conditions are more difficult to converge, thus, a good strategy is to converge with Dirichlet boundary conditions and then use the converged state to start up the Neumann boundary condition calculation.