overlapping_spheres

overlapping_spheres generates overlapping spheres within a space. The size of the space and the radius of the spheres are determined in the function input. The porosity is also an input to the function, and iter_max and tol are used to determines how many iterations can occur and how much the result can vary from the input value for porosity.

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 = [250, 250, 250]
radius = 15
porosity = 0.5

#Default Values:
iter_max = 10
tol = 0.01

Apply generator function:

With different parameters

radius

[3]:
x = ps.generators.overlapping_spheres(shape, radius, porosity, iter_max, tol)
xx = ps.generators.overlapping_spheres(shape, 20, porosity, iter_max, tol)

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('radius = 15')
ax[1].set_title('radius = 20');
../../../_images/examples_generators_howtos_overlapping_spheres_8_0.svg

porosity

[4]:
xx = ps.generators.overlapping_spheres(shape, radius, 0.25, iter_max, tol)

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_overlapping_spheres_10_0.svg

iter_max

maximum iterations to match porosity to input value

[5]:
xx = ps.generators.overlapping_spheres(shape, radius, porosity, 2, tol)

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('iter_max = 10')
ax[1].set_title('iter_max = 2');
../../../_images/examples_generators_howtos_overlapping_spheres_12_0.svg

tol

tolerance for porosity relative to input value

[6]:
xx = ps.generators.overlapping_spheres(shape, radius, porosity, iter_max, 0.25)

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('tol = 0.01')
ax[1].set_title('tol = .25');
../../../_images/examples_generators_howtos_overlapping_spheres_14_0.svg