code: def set_residual(self, pores=[], overwrite=False):
          r
          Ps = self._parse_indices(pores)
          if overwrite:
              self['pore.residual'] = False
          self['pore.residual'][Ps] = True
          residual = self['pore.residual']
          net = self.project.network
          conns = net['throat.conns']
          rclusters = site_percolation(conns, residual).sites
          rcluster_ids = np.unique(rclusters[rclusters > -1])
          initial_num = len(self.queue)-1
          for rcluster_id in rcluster_ids:
              rPs = rclusters == rcluster_id
              existing = np.unique(self['pore.cluster'][rPs])
              existing = existing[existing > -1]
              if len(existing) > 0:
                  cluster_num = existing[0]
              else:
                  cluster_num = len(self.queue)
                  self.queue.append([])
              queue = self.queue[cluster_num]
              self['pore.cluster'][rPs] = cluster_num
              Ts = net.find_neighbor_throats(pores=rPs,
                                             flatten=True,
                                             mode='xnor')
              self['throat.cluster'][Ts] = cluster_num
              self['pore.invasion_sequence'][rPs] = 0
              self['throat.invasion_sequence'][Ts] = 0
              self['pore.invasion_pressure'][rPs] = -np.inf
              self['throat.invasion_pressure'][Ts] = -np.inf
              Ts = net.find_neighbor_throats(pores=rPs,
                                             flatten=True,
                                             mode='exclusive_or')
              for T in Ts:
                  data = []
                  data.append(self['throat.entry_pressure'][T])
                  data.append(T)
                  data.append('throat')
                  hq.heappush(queue, data)
          self.invasion_running = [True]*len(self.queue)
          for c_num in range(len(self.queue)):
              if c_num > initial_num:
                  self.invasion_running[c_num] = False