pseudo_gravity_packing#

This is a form of random sequential addition (rsa) that mimics gravity by always putting the next sphere at the lowest possible location.

import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
import inspect
inspect.signature(ps.generators.pseudo_gravity_packing)
<Signature (im, r, clearance=0, axis=0, maxiter=1000, edges='contained')>

im#

The image into which the spheres should be inserted. Spheres will be inserted into the True locations, as if these indicate void space.

im = ps.generators.cylindrical_plug(shape=[151, 101, 101], axis=0)
packing = ps.generators.pseudo_gravity_packing(im=im, r=8, maxiter=100)

fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].imshow(ps.visualization.sem(~packing), interpolation='none', origin='lower')
ax[0].axis(False)
ax[1].imshow(ps.visualization.sem(~packing, axis=2).T, interpolation='none', origin='lower')
ax[1].axis(False);
../../../_images/3532fa385e18742a092d579d4801ef384758243823c2fdf965454cbb6fe6d350.png

r#

The radius of the spheres to add:

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

r = 5
im = ps.generators.cylindrical_plug(shape=[151, 101, 101], axis=0)
packing = ps.generators.pseudo_gravity_packing(im=im, r=r, maxiter=500)
ax[0].imshow(ps.visualization.sem(~packing, axis=2).T, interpolation='none', origin='lower')
ax[0].axis(False)

r = 10
im = ps.generators.cylindrical_plug(shape=[151, 101, 101], axis=0)
packing = ps.generators.pseudo_gravity_packing(im=im, r=r, maxiter=100)
ax[1].imshow(ps.visualization.sem(~packing, axis=2).T, interpolation='none', origin='lower')
ax[1].axis(False);
../../../_images/61b6727603b5bcb52c5c9df47cbc01d7833114891e68e6ffc2f29b3b99f2c5e7.png

clearance#

The spheres can be forced to have some spacing between them by setting clearance > 0, or they can overlap if clearance < 0:

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

im = ps.generators.cylindrical_plug(shape=[151, 101, 101], axis=0)
packing = ps.generators.pseudo_gravity_packing(im=im, r=r, clearance=3, maxiter=500)
ax[0].imshow(ps.visualization.sem(~packing, axis=2).T, interpolation='none', origin='lower')
ax[0].axis(False)

im = ps.generators.cylindrical_plug(shape=[151, 101, 101], axis=0)
packing = ps.generators.pseudo_gravity_packing(im=im, r=r, clearance=-1, maxiter=100)
ax[1].imshow(ps.visualization.sem(~packing, axis=2).T, interpolation='none', origin='lower')
ax[1].axis(False);
../../../_images/9c8ced53cd8005f049ab87be997ff16f28e3ef728bc0e7c4245fc3a02496c4c2.png

axis#

Controls the direction of gravity. The default is 0, which means the spheres fall towards the x=0 axis.

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

im = ps.generators.cylindrical_plug(shape=[151, 101, 101], axis=0)
packing = ps.generators.pseudo_gravity_packing(im=im, r=r, axis=0, maxiter=500)
ax[0].imshow(ps.visualization.sem(~packing, axis=2).T, interpolation='none', origin='lower')
ax[0].axis(False)

im = ps.generators.cylindrical_plug(shape=[151, 101, 101], axis=0)
packing = ps.generators.pseudo_gravity_packing(im=im, r=r, axis=2, maxiter=100)
ax[1].imshow(ps.visualization.sem(~packing, axis=0).T, interpolation='none', origin='lower')
ax[1].axis(False);
../../../_images/e298639e7ff654b1b1dde8fc706f840bbf287020ca840e71422919dae96d54cb.png

maxiter#

The maximum number of spheres to add. Limiting this number can ensure the process does not take too long if the image is large, as well allow for partial filling of the image.

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

im = ps.generators.cylindrical_plug(shape=[151, 101, 101], axis=0)
packing = ps.generators.pseudo_gravity_packing(im=im, r=r, maxiter=50)
ax[0].imshow(ps.visualization.sem(~packing, axis=2).T, interpolation='none', origin='lower')
ax[0].axis(False)

im = ps.generators.cylindrical_plug(shape=[151, 101, 101], axis=0)
packing = ps.generators.pseudo_gravity_packing(im=im, r=r, maxiter=100)
ax[1].imshow(ps.visualization.sem(~packing, axis=2).T, interpolation='none', origin='lower')
ax[1].axis(False);
../../../_images/55db8a8411654555796670601bc77fbc1c415c7776064368029fdb313b11f661.png