<jupyter_start><jupyter_text>`sierpinski_foam`The sierpinski gasket is a classic example of a fractal image with self-similar properties across all length scales.  It has also been extensively analyzed so these properties are well know.  The ``sierpinski_foam`` is a 3D version of the gasket.<jupyter_code>import porespy as ps
import matplotlib.pyplot as plt
import numpy as np
import inspect
inspect.signature(ps.generators.sierpinski_foam)<jupyter_output><empty_output><jupyter_text>`dmin` and `n`This generator does not accept size.  Instead you specify the smallest hole to add with ``dmin`` and the number of scales to create with ``n``:<jupyter_code>fig, ax = plt.subplots(1, 2, figsize=[12, 6])

dmin = 5
n = 3
im = ps.generators.sierpinski_foam(dmin=dmin, n=n)
ax[0].imshow(im, interpolation='none')
ax[0].axis(False)

dmin = 3
n = 5
im = ps.generators.sierpinski_foam(dmin=dmin, n=n)
ax[1].imshow(im, interpolation='none')
ax[1].axis(False);<jupyter_output><empty_output><jupyter_text>``ndim`` The dimensionality of the image, either 2 or 3.  A value of 2 (as above) technically makes a gasket while 3 makes a foam:<jupyter_code>ndim = 3
dmin = 5
n = 3
im = ps.generators.sierpinski_foam(dmin=dmin, n=n, ndim=3)

ax = plt.figure().add_subplot(projection='3d')
ax.voxels(1-im[30:60, 30:60, 30:60]);<jupyter_output><empty_output><jupyter_text>`max_size`This puts a cap on the maximum number of voxel in the generated image so that it doesn't get too large.  The function will stop iterating if the image size exceeds this value.<jupyter_code>fig, ax = plt.subplots(1, 2, figsize=[12, 6])

max_size=1e4
im = ps.generators.sierpinski_foam(dmin=dmin, n=100, max_size=max_size)
ax[0].imshow(im, interpolation='none')
ax[0].axis(False)
ax[0].set_title(f'actual size = {im.size}')

max_size=1e6
im = ps.generators.sierpinski_foam(dmin=dmin, n=100, max_size=max_size)
ax[1].imshow(im, interpolation='none')
ax[1].axis(False)
ax[1].set_title(f'actual size = {im.size}');<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12856428214107055, 'fraction_numerical': 0.028514257128564282, 'mean_word_length': 6.462686567164179, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '378409', 'license': 'MIT', 'n_tokens_mistral': 806, 'n_tokens_neox': 763, 'n_words': 201, 'path': 'examples/generators/reference/sierpinski_foam.ipynb', 'repo_name': 'xu-kai-xu/porespy', 'size': '1999'}