cylindrical_plug#

This creates a cylinder which can be used to define the outer regions of a tomogram.

import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
import inspect
[17:46:00] ERROR    PARDISO solver not installed, run `pip install pypardiso`. Otherwise,          _workspace.py:56
                    simulations will be slow. Apple M chips not supported.                                         

The arguments and defaults for this function can be listed as follows:

inspect.signature(ps.generators.cylindrical_plug)
<Signature (shape, r=None, axis=2)>

shape#

This should be the same shape as the image which is being studied. Note that if the image does not have odd valued dimensions then the cylinder will not be centered.

im = ps.generators.blobs(shape=[15, 15, 15], porosity=0.6)
cyl = ps.generators.cylindrical_plug(shape=im.shape)

ax = plt.figure(figsize=[6, 6]).add_subplot(projection='3d')
ax.voxels(cyl, edgecolor='k', linewidth=.25);
../../../_images/4095acfa2a396b2f7610c1e1dad9a39f297f2ff4f5c67541dd83c84f6bb9465f.png

Or to generate a 2D disk

cyl = ps.generators.cylindrical_plug(shape=[21, 21])

plt.imshow(cyl, origin='lower', interpolation='none')
plt.axis(False);
../../../_images/39a086b0911b4010470c3b1b88ac6d519485622988038add04f3189b38248219.png

r#

The radius of the plug. By default it will fill the image, but it can be smaller or larger than the image too.

fig, ax = plt.subplots(1, 2, figsize=[12, 6])

r = 5
cyl = ps.generators.cylindrical_plug(shape=im.shape, r=r)

ax[0].imshow(cyl[..., 10], interpolation='none', origin='lower')
ax[0].axis(False)

r = 8
cyl = ps.generators.cylindrical_plug(shape=im.shape, r=r)

ax[1].imshow(cyl[..., 10], interpolation='none', origin='lower')
ax[1].axis(False);
../../../_images/8cc49e2aa906e77ce7fbd6fe6fcd71e4c06d474fde34b2aa7c7624a2e6f0ae6e.png

axis#

The orientation of the plug can be aligned with any axis:

fig, (ax1, ax2, ax3) = plt.subplots(ncols=3, subplot_kw={'projection': '3d'}, figsize=[15, 5])

cyl = ps.generators.cylindrical_plug(shape=im.shape, axis=0)
ax1.voxels(cyl, edgecolor='k', linewidth=.25)

cyl = ps.generators.cylindrical_plug(shape=im.shape, axis=1)
ax2.voxels(cyl, edgecolor='k', linewidth=.25)

cyl = ps.generators.cylindrical_plug(shape=im.shape, axis=2)
ax3.voxels(cyl, edgecolor='k', linewidth=.25);
../../../_images/67d3b8c0094434653da218c464df93748062d7047224d2c10526b126c0105e7f.png