cylindrical_pillars_array#

Generates an array of cylindrical pillars with a specified pillar size distribution.

import matplotlib.pyplot as plt
import porespy as ps
import numpy as np
from porespy.visualization import set_mpl_style
set_mpl_style()
[17:45:42] ERROR    PARDISO solver not installed, run `pip install pypardiso`. Otherwise,          _workspace.py:56
                    simulations will be slow. Apple M chips not supported.                                         

spacing#

Controls the spacing between the pore centers.

fig, ax = plt.subplots(1, 2, figsize=(10, 5))
np.random.seed(0)
im1 = ps.generators.cylindrical_pillars_array(
    shape=[401, 601], spacing=30)
im2 = ps.generators.cylindrical_pillars_array(
    shape=[401, 601], spacing=60)

ax[0].imshow(im1, origin='lower', interpolation='none')
ax[0].set_title('Spacing=30')
ax[1].imshow(im2, origin='lower', interpolation='none')
ax[1].set_title('Spacing=60');
../../../_images/21e33f127a4fdae96ae97f7c167eda489b92c98395f59b3f2debf9daf955428a.png

lattice#

The type of lattice to use, options are 'simple' and 'triangular'

fig, ax = plt.subplots(1, 2, figsize=(10, 5))
np.random.seed(0)
im1 = ps.generators.cylindrical_pillars_array(
    shape=[401, 601],
    spacing=70,
    lattice='simple',
)
im2 = ps.generators.cylindrical_pillars_array(
    shape=[401, 601],
    spacing=70,
    lattice='triangular',
)

ax[0].imshow(im1, origin='lower', interpolation='none')
ax[0].set_title('Simple Cubic Lattice')
ax[1].imshow(im2, origin='lower', interpolation='none')
ax[1].set_title('Triangular Lattice');
../../../_images/e9254493d84db2cf1451722281ecf0afc63653c1eeb4c01cd8ef0509cdd0212e.png

truncate#

If True it returns the array within an image of the specified size (i.e. it truncates the full pattern). If False it returns an image that is larger than the requested shape but contains a whole number of unit cells.

fig, ax = plt.subplots(1, 2, figsize=(10, 5))
np.random.seed(0)
im1 = ps.generators.cylindrical_pillars_array(
    shape=[401, 601],
    spacing=70,
    lattice='simple',
    truncate=True,
)
im2 = ps.generators.cylindrical_pillars_array(
    shape=[401, 601],
    spacing=70,
    lattice='simple',
    truncate=False,
)

ax[0].imshow(im1, origin='lower', interpolation='none')
ax[0].set_title('Truncated to Shape')
ax[1].imshow(im2, origin='lower', interpolation='none')
ax[1].set_title('Expanded to whole number of unit cells');
../../../_images/6ee9ff33f8c9811646d53e96fcc057af94f2107b09cf9635f6bb9b1d833f1215.png

dist and dist_kwargs#

Allows for full control over the distribution of the opening size between pillars. The default is a uniform distribution with sizes ranging from 5 to 15, but any distribution from scipy.stats can be used:

fig, ax = plt.subplots(1, 2, figsize=(10, 5))
np.random.seed(0)
im1 = ps.generators.cylindrical_pillars_array(
    shape=[401, 601],
    dist='uniform',
    dist_kwargs=dict(loc=10, scale=10),
)
im2 = ps.generators.cylindrical_pillars_array(
    shape=[401, 601],
    dist='norm',
    dist_kwargs=dict(loc=10, scale=4),
)

ax[0].imshow(im1, origin='lower', interpolation='none')
ax[0].set_title('Narrow Uniform Distribution')
ax[1].imshow(im2, origin='lower', interpolation='none')
ax[1].set_title('Normal Distribution');
../../../_images/9be57769809ad3114c0086f348b2fdfb2ecf3f63fa809d511b5a4dd0c67b8af6.png

seed#

Initializes the random number generator at a specified state so that identical realizations can be obtained if desired:

fig, ax = plt.subplots(1, 2, figsize=(10, 5))
np.random.seed(0)
im1 = ps.generators.cylindrical_pillars_array(
    shape=[401, 601],
    seed=0,
)
im2 = ps.generators.cylindrical_pillars_array(
    shape=[401, 601],
    seed=0,
)

ax[0].imshow(im1, origin='lower', interpolation='none')
ax[1].imshow(im2, origin='lower', interpolation='none');
../../../_images/89a36ca443c52632aaa7c97471d35a5bb50ab2ba4b5ab98e1d98bfa342acd766.png