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¶

:
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:¶

:
shape = [250, 250, 250]
porosity = 0.5

#Default Values:
iter_max = 10
tol = 0.01

Apply generator function:¶

With different parameters

:
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.imshow(graphx)
ax.imshow(graphxx)
ax.axis(False)
ax.axis(False) porosity¶

:
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.imshow(graphx)
ax.imshow(graphxx)
ax.axis(False)
ax.axis(False)
ax.set_title('porosity = 0.5')
ax.set_title('porosity = .25'); iter_max¶

maximum iterations to match porosity to input value

:
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.imshow(graphx)
ax.imshow(graphxx)
ax.axis(False)
ax.axis(False)
ax.set_title('iter_max = 10')
ax.set_title('iter_max = 2'); tol¶

tolerance for porosity relative to input value

:
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.imshow(graphx)
ax.imshow(graphxx)
ax.axis(False)
ax.axis(False)
ax.set_title('tol = 0.01')
ax.set_title('tol = .25'); 