I'm now using rtag to rearrange forces, but I still can't get the right result.
It means that forces were still applied to false particles.
class CustomActiveForce_2D(hoomd.md.force.Custom):
def __init__(self):
super().__init__(aniso=True)
self.ori_forces = np.array([[1,0,0],[-1,0,0],[0,1,0]])
def re_Arrange_force(self):
with sim.state.cpu_local_snapshot as data:
ori_tag = data.particles.rtag[:].copy()
self.rearrange_forces = self.ori_forces[ori_tag]
def set_forces(self,timestep):
self.re_Arrange_force()
with self.cpu_local_force_arrays as arrays:
arrays.force[:] = 0
arrays.force[:] = self.rearrange_forces