simulations
simulations
Functions
| Name | Description |
|---|---|
| bond_percolation | Assigns cluster numbers to sites and bonds acccording to a bond |
| ispercolating | Determines if a percolating cluster exists in the network spanning |
| remove_isolated_clusters | Finds cluster labels not attached to the inlets, and sets them to |
| site_percolation | Assigns cluster numbers to sites and bonds acccording to a site |
| trim_disconnected_clusters | Computes actual node and edge occupancy based on connectivity to the given |
bond_percolation
simulations.bond_percolation(conns, occupied_bonds)Assigns cluster numbers to sites and bonds acccording to a bond percolation process, given a list of occupied bonds.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| conns | array_like | An N x 2 array connections. Any sites connected to an occupied bond will also be considered occupied and given the same cluster number as the bond. | required |
| occupied_bonds | ndarray | A boolean array with one element for each bond, with True values indicating that a bond is occupied |
required |
Returns
| Name | Type | Description |
|---|---|---|
| A tuple containing a list of site and bond labels, indicating which | ||
| cluster each belongs to. A value of -1 indicates uninvaded. |
Notes
The connected_components function of scipy.sparse.csgraph will give a cluster number to ALL bonds whether they are occupied or not, so this function essentially adjusts the cluster numbers to represent a percolation process.
ispercolating
simulations.ispercolating(conns, occupied, inlets, outlets)Determines if a percolating cluster exists in the network spanning the given inlet and outlet nodes
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| conns | array_like | An N x 2 array connections. If two connected sites are both occupied they are part of the same cluster, as is the bond connecting them. | required |
| occupied | array_like | A boolean array with True values indicating if a bond or site is occupied. If the length of this array is equal to the number of bonds (i.e. conns.shape[0]) then bond percolation is assumed, otherwise site percolation is assumed. |
required |
| inlets | array_like | An array of indices indicating which nodes are part of the inlets | required |
| outlets | array_like | An array of indices indicating which nodes are part of the outlets | required |
remove_isolated_clusters
simulations.remove_isolated_clusters(labels, inlets)Finds cluster labels not attached to the inlets, and sets them to unoccupied (-1)
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| labels | tuple of node and edge labels | This information is provided by the site_percolation or bond_percolation functions |
required |
| inlets | array_like | A list of which nodes are inlets. Can be a boolean mask or an array of indices. | required |
Returns
| Name | Type | Description |
|---|---|---|
| A tuple containing a list of node and edge labels, with all clusters | ||
| not connected to the inlets set to not occupied (-1). |
site_percolation
simulations.site_percolation(conns, occupied_sites)Assigns cluster numbers to sites and bonds acccording to a site percolation process, given a list of occupied sites.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| conns | array_like | An N x 2 array connections. If two connected sites are both occupied they are part of the same cluster, as is the bond connecting them. | required |
| occupied_sites | ndarray | A boolean array with one element for each site, with True values indicating that a site is occupied |
required |
Returns
| Name | Type | Description |
|---|---|---|
| A tuple containing a list of site and bond labels, indicating which | ||
| cluster each belongs to. A value of -1 indicates unoccupied. |
Notes
The connected_components function of scipy.sparse.csgraph will give ALL sites a cluster number whether they are occupied or not, so this function essentially adjusts the cluster numbers to represent a percolation process.
trim_disconnected_clusters
simulations.trim_disconnected_clusters(b_labels, s_labels, inlets)Computes actual node and edge occupancy based on connectivity to the given inlets
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| b_labels | ndarray | An array of cluster labels assigned to each bond. -1 indicates unoccupied | required |
| s_labels | ndarray | An array of cluster labels assigned to each site. -1 indicates unoccupied. Site cluster numbers must correspond to the bond clusters, such that if bond j has a cluster number N, then both sites on each end of j are also labeled N. | required |
| inlets | ndarray | An array containing node indices that are to be treated as inlets. Any clusters labels not found in these nodes will be considered disconnected and set to -1. | required |
Returns
| Name | Type | Description |
|---|---|---|
| occupancy | tuple of ndarrays | The returned tuple containing arrays of cluster numbers of occupied_sites and occupied_bonds, after accounting for connection to the inlets. |
Notes
The b_labels and s_labels arrays are returned from the bond_percolation or site_percolation function.