lattice_spheres

Generates a cubic packing of spheres in a specified lattice arrangement.

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 = [100, 100, 100]
radius = 10

#Default Values:
offset = 0
lattice = "sc"

Apply generator function:

With different parameters

radius

[3]:
x = ps.generators.lattice_spheres(shape=shape,
                                  r=radius,
                                  offset=offset,
                                  lattice=lattice)
xx = ps.generators.lattice_spheres(shape=shape,
                                   r=15,
                                   offset=offset,
                                   lattice=lattice)

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

offset

[4]:
xx = ps.generators.lattice_spheres(shape=shape,
                                   r=radius,
                                   offset=5,
                                   lattice=lattice)

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('offset = 0')
ax[1].set_title('offset = 5');
../../../_images/examples_generators_howtos_lattice_spheres_10_0.svg

lattice

lattice options are sc, fcc, and bcc

[5]:
xx = ps.generators.lattice_spheres(shape=shape,
                                   r=radius,
                                   offset=offset,
                                   lattice="fcc")

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('lattice = sc')
ax[1].set_title('lattice = fcc');
../../../_images/examples_generators_howtos_lattice_spheres_12_0.svg