cylindrical_pillars_mesh#

Generates an array of cylindrical pillars by putting a cylinder at each vertext in a triangular mesh of the domain, so has some randomness while still being quite uniform.

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:55] ERROR    PARDISO solver not installed, run `pip install pypardiso`. Otherwise,          _workspace.py:56
                    simulations will be slow. Apple M chips not supported.                                         

a#

Controls the number of pillars to add. This number tells the mesher the area of each triangle, so a smaller value of a results in more pillars.

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

ax[0].imshow(im1, origin='lower', interpolation='none')
ax[0].set_title('a=500')
ax[1].imshow(im2, origin='lower', interpolation='none')
ax[1].set_title('a=5000');
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File ~/work/porespy/porespy/src/porespy/generators/_micromodels.py:289, in cylindrical_pillars_mesh(shape, f, a, n, truncate)
    288 try:
--> 289     from nanomesh import Mesher2D
    290 except ModuleNotFoundError:

ModuleNotFoundError: No module named 'nanomesh'

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 3
      1 fig, ax = plt.subplots(1, 2, figsize=(10, 5))
      2 np.random.seed(0)
----> 3 im1 = ps.generators.cylindrical_pillars_mesh(
      4     shape=[401, 601],
      5     a=500,
      6 )
      7 im2 = ps.generators.cylindrical_pillars_mesh(
      8     shape=[401, 601], 
      9     a=5000,
     10 )
     12 ax[0].imshow(im1, origin='lower', interpolation='none')

File ~/work/porespy/porespy/src/porespy/generators/_micromodels.py:292, in cylindrical_pillars_mesh(shape, f, a, n, truncate)
    290 except ModuleNotFoundError:
    291     msg = "The nanomesh package can be installed with `pip install nanomesh`"
--> 292     raise ModuleNotFoundError(msg)
    294 if len(shape) != 2:
    295     raise Exception('shape must be 2D for this function')

ModuleNotFoundError: The nanomesh package can be installed with `pip install nanomesh`
../../../_images/8970f04acca0df74369b57411953e8e1a074505d0822a1288953b7dcecf47c20.png

f#

A scale factor to control how large the pillars are relative their maximal size (i.e. overlapping neighboring pillars)

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

ax[0].imshow(im1, origin='lower', interpolation='none')
ax[0].set_title('f=0.5')
ax[1].imshow(im2, origin='lower', interpolation='none')
ax[1].set_title('f=0.95');
../../../_images/8505a3c4351ed91a5600e24978cfdfd6d9e15907df160557549c318da6f22305.png

n#

Controls the density of pillars along the edges. The default is \(\sqrt{a}/f\), which does a decent job a keeping the edge pillars the same size as the internal ones, but this can be overwritten if needed:

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

ax[0].imshow(im1, origin='lower', interpolation='none')
ax[0].set_title('n=20')
ax[1].imshow(im2, origin='lower', interpolation='none')
ax[1].set_title('n=40');
../../../_images/4aa6c3cf9f401833da5aafc1ef3fe9afa9d34664c3b323624c7e146effe620be.png

truncate#

If True it returns an image of the specified size by truncated the pillars on the edge of the image. If False it returns an image that is larger than the requested shape but contains the edge pillars in their entirety.

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

ax[0].imshow(im1, origin='lower', interpolation='none')
ax[0].set_title('truncate=False')
ax[1].imshow(im2, origin='lower', interpolation='none')
ax[1].set_title('truncate=True');
../../../_images/b905660ba7632c7a75b079f34b587ede5613a2da82b0f3784da9d2abb7c1199f.png