connect_pores

openpnm.topotools.connect_pores(network, pores1, pores2, labels=[], add_conns=True)[source]

Returns the possible connections between two groups of pores, and optionally makes the connections.

See Notes for advanced usage.

Parameters
  • network (GenericNetwork) –

  • pores1 (array_like) – The first group of pores on the network

  • pores2 (array_like) – The second group of pores on the network

  • labels (list of strings) – The labels to apply to the new throats. This argument is only needed if add_conns is True.

  • add_conns (bool) – Indicates whether the connections should be added to the supplied network (default is True). Otherwise, the connections are returned as an Nt x 2 array that can be passed directly to extend.

Notes

(1) The method also works if pores1 and pores2 are list of lists, in which case it consecutively connects corresponding members of the two lists in a 1-to-1 fashion. Example: pores1 = [[0, 1], [2, 3]] and pores2 = [[5], [7, 9]] leads to creation of the following connections:

0 --> 5     2 --> 7     3 --> 7
1 --> 5     2 --> 9     3 --> 9

(2) If you want to use the batch functionality, make sure that each element within pores1 and pores2 are of type list or ndarray.

(3) It creates the connections in a format which is acceptable by the default OpenPNM connections (‘throat.conns’) and either adds them to the network or returns them.

Examples

>>> import openpnm as op
>>> pn = op.network.Cubic(shape=[5, 5, 5])
>>> pn.Nt
300
>>> op.topotools.connect_pores(network=pn, pores1=[22, 32],
...                            pores2=[16, 80, 68])
>>> pn.Nt
306
>>> pn['throat.conns'][300:306]
array([[16, 22],
       [22, 80],
       [22, 68],
       [16, 32],
       [32, 80],
       [32, 68]])