Physics, Science, Programming, Deep Dives, Thoughts And Theory.
self.wall_collisions+=1 #Check whether collision in x or y direction _coll_ind=np.argwhere(_x_new<0) #For component(s) to be reflected for c in _coll_ind: #Reflect velocity _v[c]=-_v[c] #Increment wall momentum self.wall_momentum+=2*_m*np.abs(_v[c]) #Update velocity m.set_velocity(_v) #Update