import matplotlib.pyplot as plt
import numpy as np

import porespy as ps
ps.visualization.set_mpl_style()

shape#

The image can be 2D or 3D. The main purpose of this little function is to generate 2D images for visualization, but 3D may also be useful for other studies.

im1 = ps.generators.conical_capillary(shape=[25, 25], r=[5, 10])
im2 = ps.generators.conical_capillary(shape=[111, 151], r=[25, 50])

fig, ax = plt.subplots(1, 2, figsize=[8, 3])
ax[0].imshow(im1)
ax[0].axis(False)
ax[1].imshow(im2)
ax[1].axis(False);
../../../_images/5b4c58c7aa317e76533c83ef6cadbb8acfb6aa468d4a45592feb6efc5238b10a.png

The image can be 3D. Below is a rough visualization of the cone (i.e. inverted image):

im1 = ps.generators.conical_capillary(shape=[55, 55, 55], r=[15, 20])

fig, ax = plt.subplots(figsize=[4, 4])
ax.imshow(ps.visualization.show_3D(~im1), cmap=plt.cm.bone)
ax.axis(False);
../../../_images/b30f75db28b447babeef94f09b4703677f901cebd8e4cc4e6e7514800337af15.png

r#

This controls the radius of the left and right sides of the cone. If an int is provided then a straight tube is created. The left side can be bigger than the right as well.

im1 = ps.generators.conical_capillary(shape=[55, 55], r=[5, 20])
im2 = ps.generators.conical_capillary(shape=[55, 55], r=[20, 5])
im3 = ps.generators.conical_capillary(shape=[55, 55], r=18)

fig, ax = plt.subplots(1, 3, figsize=[12, 4])
ax[0].imshow(im1)
ax[0].axis(False)
ax[1].imshow(im2)
ax[1].axis(False)
ax[2].imshow(im3)
ax[2].axis(False);
../../../_images/bbec019458ac78f941f4b13f4214cb9eb199dd0d56ccdbe4d5def5d5250b4e21.png

axis#

The direction along which the cone should be oriented. The default is 0, meaning it is along the x-axis:

im1 = ps.generators.conical_capillary(shape=[55, 55], r=[5, 20], axis=0)
im2 = ps.generators.conical_capillary(shape=[55, 55], r=[20, 5], axis=1)

fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].imshow(im1)
ax[0].axis(False)
ax[1].imshow(im2)
ax[1].axis(False);
../../../_images/a33982debef46cc410a6e3b51fcb61119c3762aabfeb08a727feafccd6065380.png

Notes#

It is possible to join two images together to create a converging-diverging arrangement. Using numpy.concatenate works well as long as the orientation of the cones (i.e. axis) is the same as the axis along which the concatenation is applied:

im1 = ps.generators.conical_capillary(shape=[25, 25], r=[8, 5], axis=1)
im2 = ps.generators.conical_capillary(shape=[25, 25], r=[5, 12], axis=1)
im3 = np.concatenate((im1, im2), axis=1)

fig, ax = plt.subplots(1, figsize=[4, 4])
ax.imshow(im3)
ax.axis(False);
../../../_images/9f2b0550600cf63a9d986f9d8cefe1a44ab07abcdb997876f854209b2840a605.png

The same also works in 3D:

c1 = ps.generators.conical_capillary([61, 61, 31], r=[15, 5], axis=2)
c2 = ps.generators.conical_capillary([61, 61, 31], r=[5, 10], axis=2)
c = np.concatenate((c1, c2), axis=2)

fig, ax = plt.subplots(1, 2)
ax[0].imshow(ps.visualization.show_3D(c))
ax[1].imshow(ps.visualization.show_3D(~c));
../../../_images/e17e4923691d97d246226dd1fa2888af4ae41c71a7f2469bc90ef53e66a6e082.png