FaceCenteredCubic.num_neighbors(pores, mode='or', flatten=False)#

Returns the number of neigbhoring pores for each given input pore

  • pores (array_like) – Pores whose neighbors are to be counted

  • flatten (bool, optional) – If False (default) the number of pores neighboring each input pore as an array the same length as pores. If True the sum total number of is counted.

  • mode (str) –

    The logic to apply to the returned count of pores:




    (default) All neighbors of the input pores. Also accepts ‘any’ and ‘union’.


    Only neighbors of one and only one input pore. This is useful for counting the pores that are not shared by any of the input pores. Also accepts ‘exclusive_or’.


    Neighbors that are shared by two or more input pores. This is equivalent to counting all neighbors with ‘or’, minus those found with ‘xor’, and is useful for finding neighbors that the inputs have in common.


    Only neighbors shared by all input pores. Also accepts ‘intersection’ and ‘all’


  • If flatten is False, a 1D array with number of neighbors in each

  • element, otherwise a scalar value of the number of neighbors.


This method literally just counts the number of elements in the array returned by find_neighbor_pores using the same logic. Explore those methods if uncertain about the meaning of the mode argument here.


>>> import openpnm as op
>>> pn =[5, 5, 5])
>>> Np = pn.num_neighbors(pores=[0, 1], flatten=False)
>>> print(Np)
[3 4]
>>> Np = pn.num_neighbors(pores=[0, 2], flatten=True)
>>> print(Np)
>>> Np = pn.num_neighbors(pores=[0, 2], mode='and', flatten=True)
>>> print(Np)