polydisperse _spheres

polydisperse_spheres creates a 3 dimensional array of overlapping spheres. The size of the array is controlled by shape, and the porosity of the substance is input as the porosity vabribale the and size distribution of the spheres is input in dist and nbins. The minimum radius of the spheres is controlled by the r_min variable.

Import packages

[1]:
import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
import scipy

ps.visualization.set_mpl_style()
np.random.seed(10)

Create variables:

[2]:
shape = [300, 300, 300]
porosity = 0.5
dist = scipy.stats.norm(loc=20, scale=10)

#Default Values:
nbins = 5
r_min = 5

Apply generator function:

With different parameters

porosity

[3]:
x = ps.generators.polydisperse_spheres(shape, porosity, dist, nbins, r_min)
xx = ps.generators.polydisperse_spheres(shape, 0.25, dist, nbins, r_min)

graphx = ps.visualization.show_3D(x)
graphxx = ps.visualization.show_3D(xx)
fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].imshow(graphx)
ax[1].imshow(graphxx)
ax[0].axis(False)
ax[1].axis(False)
ax[0].set_title('porosity = 0.5')
ax[1].set_title('porosity = .25');
../../../_images/examples_generators_howtos_polydisperse_spheres_8_0.svg

dist

[4]:
d2 = scipy.stats.norm(loc=10, scale=15)
xx = ps.generators.polydisperse_spheres(shape, porosity, d2, nbins, r_min)

graphxx = ps.visualization.show_3D(xx)
fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].imshow(graphx)
ax[1].imshow(graphxx)
ax[0].axis(False)
ax[1].axis(False)
ax[0].set_title('dist = scipy.stats.norm(loc=20, scale=10)')
ax[1].set_title('dist = scipy.stats.norm(loc=10, scale=15)');
../../../_images/examples_generators_howtos_polydisperse_spheres_10_0.svg

nbins

[5]:
xx = ps.generators.polydisperse_spheres(shape, porosity, dist, 10, r_min)

graphxx = ps.visualization.show_3D(xx)
fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].imshow(graphx)
ax[1].imshow(graphxx)
ax[0].axis(False)
ax[1].axis(False)
ax[0].set_title('nbins = 5')
ax[1].set_title('nbins = 10');
../../../_images/examples_generators_howtos_polydisperse_spheres_12_0.svg

r_min

[ ]:
xx = ps.generators.polydisperse_spheres(shape, porosity, dist, nbins, 10)

graphxx = ps.visualization.show_3D(xx)
fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].imshow(graphx)
ax[1].imshow(graphxx)
ax[0].axis(False)
ax[1].axis(False)
ax[0].set_title('r_min = 5')
ax[1].set_title('r_min = 10');