Create Bilayer Topology with Stitch

OpenPNM includes numerous tools for manipulating and altering the topology. Most of these are found in the topotools submodule. This example will illustrate who to join or 'stitch' two distinct networks, even if they have different lattice spacing. In this example we'll create a coarse and a fine network then stitch them together to make a network with two distinct layers.

Start by creating a network with a large lattice spacing:


In [7]:
import scipy as sp
import matplotlib.pyplot as plt
%matplotlib inline
# Import OpenPNM and the topotools submodule and initialize the workspace manager
import openpnm as op
from openpnm import topotools as tt
wrk = op.Workspace()
wrk.clear()  # Clear the existing workspace (mostly for testing purposes)
wrk.loglevel=50
coarse_net = op.network.Cubic(shape=[10, 10, 10], spacing=5e-1)

The coarse_net network has 1000 pores in a cubic lattice with a spacing of 50 um for a total size of 500 um per size. Next, we'll make another network with smaller spacing between pores, but with the same total size.


In [8]:
fine_net = op.network.Cubic(shape=[25, 25, 5], spacing=2e-1)

These two networks are totally independent of each other, and actually both spatially overlap each other since the network generator places the pores at the [0, 0, 0] origin. Combining these networks into a single network is possible using the stitch function, but first we must make some adjustments. For starters, let's shift the fine_net along the z-axis so it is beside the coarse_net to give the layered effect:


In [9]:
fine_net['pore.coords'] += sp.array([0, 0, 5])

Before proceeding, let's quickly check that the two networks are indeed spatially separated now:


In [10]:
fig = tt.plot_connections(coarse_net)
fig = tt.plot_connections(fine_net, fig=fig)


As can be seen below, fine_net (orange) has been repositioned above the coarse_net (blue).

Now it's time stitch the networks together by adding throats between the pores on the top of the coarse network and those on the bottom of the fine network. The stitch function uses Euclidean distance to determine which pore is each face is nearest each other, and connects them.


In [11]:
tt.stitch(network=fine_net, donor=coarse_net,
          P_network=fine_net.pores('bottom'),
          P_donor=coarse_net.pores('top'),
          len_max=4e-1)

And we can quickly visualize the result using OpenPNM's plotting tools:


In [12]:
fig = tt.plot_connections(fine_net)


The diagonal throats between the two networks have been added by the stitch process. The next step would be to assign different geometry objects to each network, with different pore sizes and such.