polydisperse_spheres#

Overlapping spheres with a distribution of sizes

import inspect

import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as spst

import porespy as ps

np.random.seed(10)
inspect.signature(ps.generators.polydisperse_spheres)
<Signature (shape: List, porosity: float, dist, nbins: int = 5, r_min: int = 5, seed=None)>

shape#

Images can be 2D or 3D.

shape = [150, 150]
porosity = 0.5
dist = spst.norm(loc=10, scale=5)
im = ps.generators.polydisperse_spheres(shape=shape, porosity=porosity, dist=dist)

fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.imshow(im, interpolation='none', origin='lower')
ax.axis(False);
../../../_images/bc32f6cf807b48be8370a7ad68f7008fb1fba9eea7a2884053090198d81ae246.png

porosity#

Porosity controls how many spheres are added. The algorithms for determining the number of spheres to add is not very sophisticated, so the actual porosity is not perfect.

fig, ax = plt.subplots(1, 2, figsize=[12, 6])

porosity = 0.75
im1 = ps.generators.polydisperse_spheres(shape=shape, porosity=porosity, dist=dist)
ax[0].imshow(im1, interpolation='none', origin='lower')
ax[0].set_title(f'porosity = {im1.sum()/im1.size}')
ax[0].axis(False)

porosity = 0.5
im2 = ps.generators.polydisperse_spheres(shape=shape, porosity=porosity, dist=dist)
ax[1].imshow(im2, interpolation='none', origin='lower')
ax[1].set_title(f'porosity = {im2.sum()/im2.size}')
ax[1].axis(False);
../../../_images/609501d7e5d40b36bc42a53a23b79b7168f8f5615e89b201641a905651f61118.png

dist#

The statistical distribution from which sphere diameter should be drawn. This should be a handle to an initialized scipy.stats object:

fig, ax = plt.subplots(1, 2, figsize=[12, 6])

dist = spst.norm(loc=10, scale=5)
im1 = ps.generators.polydisperse_spheres(shape=shape, porosity=porosity, dist=dist)
ax[0].imshow(im1, interpolation='none', origin='lower')
ax[0].set_title(f'distribution = {dist.kwds}')
ax[0].axis(False)

dist = spst.norm(loc=5, scale=2)
im2 = ps.generators.polydisperse_spheres(shape=shape, porosity=porosity, dist=dist)
ax[1].imshow(im2, interpolation='none', origin='lower')
ax[1].set_title(f'distribution = {dist.kwds}')
ax[1].axis(False);
../../../_images/1ed684076abf14854b686e3812f19aabaa41ee322a277ccc3af51f7c4ecc09bf.png

nbins#

Spheres must be generated with discrete sizes, so this controls how many unique sizes are used. The default is 5.

fig, ax = plt.subplots(1, 2, figsize=[12, 6])

dist = spst.norm(loc=10, scale=5)
nbins = 3
im1 = ps.generators.polydisperse_spheres(shape=shape, porosity=porosity, dist=dist, nbins=nbins)
ax[0].imshow(im1, interpolation='none', origin='lower')
ax[0].set_title(f'nbins = {nbins}')
ax[0].axis(False)

nbins = 10
im2 = ps.generators.polydisperse_spheres(shape=shape, porosity=porosity, dist=dist, nbins=nbins)
ax[1].imshow(im2, interpolation='none', origin='lower')
ax[1].set_title(f'nbins = {nbins}')
ax[1].axis(False);
../../../_images/c7bcedf76191d05bd34af7029f8f8f2929b4823a3cf3951faed4658f72a71fb7.png

r_min#

The smallest sphere to generate, essentially limiting the size of the smallest bin. The default is 5.

fig, ax = plt.subplots(1, 2, figsize=[12, 6])

dist = spst.norm(loc=10, scale=5)
r_min = 5
im1 = ps.generators.polydisperse_spheres(shape=shape, porosity=porosity, dist=dist, r_min=r_min)
ax[0].imshow(im1, interpolation='none', origin='lower')
ax[0].set_title(f'r_min = {r_min}')
ax[0].axis(False)

r_min = 2
im2 = ps.generators.polydisperse_spheres(shape=shape, porosity=porosity, dist=dist, r_min=r_min)
ax[1].imshow(im2, interpolation='none', origin='lower')
ax[1].set_title(f'r_min = {r_min}')
ax[1].axis(False);
../../../_images/8d89122aa3d5b4a75efa0e05333be15a33ea78d89d5ebf798eb823b5cd16093e.png