class Cubic(*args, **kwargs)[source]


Simple cubic lattice with connectivity from 6 to 26

Though simple, the Cubic network offers many advantages such as easy visualization and accurate determination of domain area and length in transport calculations.

  • shape (array_like) – The [Nx, Ny, Nz] size of the network in terms of the number of pores in each direction

  • spacing (array_like, optional) – The spacing between pore centers in each direction. If not given, then [1, 1, 1] is assumed.

  • connectivity (int, optional) –

    The number of connections to neighboring pores. Connections are made symmetrically to any combination of face, edge, or corners neighbors. The default is 6 to create a simple cubic structure, but options are:

    • 6: Faces only

    • 14: Faces and Corners

    • 18: Faces and Edges

    • 20: Edges and Corners

    • 26: Faces, Edges and Corners

    For a more random distribution of connectivity, use a high connectivity (i.e. 26) and then delete a fraction of the throats using openpnm.topotools.reduce_coordination.

  • name (string) – An optional name for the object to help identify it. If not given, one will be generated.

  • project (OpenPNM Project object, optional) – Each OpenPNM object must be part of a Project. If none is supplied then one will be created and this Network will be automatically assigned to it. To create a Project use openpnm.Project().


The distance between pore centers. This value becomes meaningless if the topology is manipulated at all (i.e. by adding boundary pores) since there is not unique or consistent value. In such cases an exception is thrown.


int or array


The shape of the network. Like spacing this values is meaningless if the topology is manipulated, so an Exception is thrown.




>>> import openpnm as op
>>> import matplotlib.pyplot as plt
>>> pn =[5, 5, 5], spacing=[1, 1, 1])
>>> pn.Np

And it can be plotted for quick visualization using:

>>> fig, ax = plt.subplots()
>>> _ = op.topotools.plot_connections(network=pn, ax=ax)
>>> _ = op.topotools.plot_coordinates(network=pn, c='r', s=75, ax=ax)

For larger networks and more control over presentation use Paraview.

add_boundary_pores(labels=['top', 'bottom', 'front', 'back', 'left', 'right'], spacing=None)[source]

Add pores to the faces of the network for use as boundary pores.

Pores are offset from the faces by 1/2 a lattice spacing such that they lie directly on the boundaries.

  • labels (string or list of strings) – The labels indicating the pores defining each face where boundary pores are to be added (e.g. ‘left’ or [‘left’, ‘right’])

  • spacing (scalar or array_like) – The spacing of the network (e.g. [1, 1, 1]). This should be given since it can be quite difficult to infer from the network, for instance if boundary pores have already added to other faces.