def _apply_percolation(self, inv_val):
        r"""
        Determine which pores and throats are invaded at a given applied
        capillary pressure.  This method is called by ``run``.
        """
        # Generate a list containing boolean values for throat state
        Tinvaded = self['throat.entry_pressure'] <= inv_val
        # Add residual throats, if any, to list of invaded throats
        Tinvaded = Tinvaded + self['throat.residual']
        # Find all pores that can be invaded at specified pressure
        [pclusters, tclusters] = self._net.find_clusters2(mask=Tinvaded,
                                                          t_labels=True)

        # Identify clusters connected to inlet sites
        inv_clusters = sp.unique(pclusters[self['pore.inlets']])
        inv_clusters = inv_clusters[inv_clusters >= 0]

        # Find pores on the invading clusters
        pmask = np.in1d(pclusters, inv_clusters)
        # Store current applied pressure in newly invaded pores
        pinds = (self['pore.inv_Pc'] == sp.inf) * (pmask)
        self['pore.inv_Pc'][pinds] = inv_val

        # Find throats on the invading clusters
        tmask = np.in1d(tclusters, inv_clusters)
        # Store current applied pressure in newly invaded throats
        tinds = (self['throat.inv_Pc'] == sp.inf) * (tmask)
        self['throat.inv_Pc'][tinds] = inv_val

        # Set residual pores and throats, if any, to invaded
        if sp.any(self['pore.residual']):
            self['pore.inv_Pc'][self['pore.residual']] = 0
        if sp.any(self['throat.residual']):
            self['throat.inv_Pc'][self['throat.residual']] = 0
dataset/ETHPy150Open PMEAL/OpenPNM/OpenPNM/Algorithms/__Drainage__.py/Drainage._apply_percolation/original