← Microstructure notebook · Topology and connectivity tutorial

A playground of connected patterns

Can one point reach the entire red region? And the blue region? Flood each phase from one seed and watch the connected cluster fill. These three movable sections come from the original 256 × 256 × 256 saved microstructure. The simulation does not evolve here.

Loading the full-resolution connectivity volume…

—
Reached voxels / phase voxels
One seed, six face-sharing neighbors, periodic boundaries.

Reached redReached blueAdvancing frontPale selected phase: not reached yetOther phase

Why demonstrate this in 3D? To demonstrate two interpenetrating phase networks throughout a three-dimensional material, we must inspect the 3D field and measure connectivity in both phases. A labyrinthine 2D image alone is insufficient. In 2D, both phases can span as non-crossing bands, including curved or wavy bands: exact parallelism is not required. During coarsening, pinching off or reconnecting a band can break one phase’s spanning connection. In 3D, paths can pass around one another, allowing much richer interpenetrating networks. Even then, bicontinuity must be checked rather than assumed.

Rotate the 3D spinodal isosurface

The original c = 0.5 isosurface is retained and shown here automatically. Drag to rotate; scroll or pinch to zoom. Switch red/blue above to inspect the selected side of the shared interface. Reveal the three sections to see the flood inside the volume, then press Flood from one seed. Move the section sliders below to explore deeper layers. Click a section in the Plotly view to move the three sections through that location.

Loading the rotatable 3D isosurface…

The gold marker follows the flood on exact full-volume reach curves. The Plotly 3D sections sample every fourth voxel for responsive graphics; the canvas sections below show every voxel. Plotly joins samples visually, so use the full-resolution analysis for connectivity conclusions. Camera rotation and zoom are interactive.

x section
y section
z section

What to notice: the flood travels through the selected phase in the whole 3D volume. It can leave a section and return elsewhere, so islands in one section can fill without touching in that picture. A ring marks the seed where it lies in the displayed plane. Opposite box faces are identified; crossing one continues at the corresponding location on the other.

At 100%: every voxel of the selected phase is reachable from that one seed. Repeat for the other phase. This demonstrates complete phase connectivity. Periodic percolation is an additional measurement: each phase also contains three independent wrapping loops.

See the shared interface in 3D

Open a lit, opaque c = 0.5 isosurface to inspect the morphology. The phase color identifies the selected side of the interface; both phases share this same surface. For a focused percolation view, reveal one verified wrapping loop. The surface becomes transparent and paired gold dots mark its boundary crossing.

VPython / GlowScript graphics; full-resolution isosurface simplified to 60,000 triangles for display only. No artificial box-face caps. The flood and cluster calculations use every original voxel. The selected loop is a witness, not a longest path or an exhaustive tour.

Make a pattern. Watch labels merge.

This separate, editable 24 × 24 toy pattern shows how Hoshen–Kopelman style scanning works. A gold box visits cells from left to right. Occupied cells get labels; touching labels merge and change to a common color. The final step optionally joins periodic edges.


Click cells to draw bridges or cut channels, then replay. Try making a connection across opposite edges. Colors identify components, not composition or curvature. This four-neighbor toy labels clusters; periodic winding rank is measured separately in the full 3D analysis above.

Measure what the demonstration shows

Hoshen–Kopelman style label-and-merge scanning assigns connected-component labels, merges periodic seam neighbors and tracks unwrapped displacements. A nonzero displacement on closing a loop gives its winding vector. Three independent vectors give winding rank three. These results agree with the independent flood-fill calculation.

Measure the interface’s topology and geometry

Loading full-resolution morphology measurements…

Euler characteristic is calculated separately for the phase solid and the interface surface. The surface has χ = V − E + F after periodic seam identification; for S closed orientable components, χ = 2S − 2Σg. Area and curvature are measured before display simplification. Closure and orientation must pass before genus is reported.

These complementary measures follow the ideas studied by Fiałkowski, Aksimentiev and Hołyst. The analysis is a new implementation; it does not claim to be their historical C program. Euler characteristic combines topological counts and does not alone prove percolation. Digital 6- and 26-neighbor Euler results are both saved so corner-contact sensitivity is visible.

Reproduce the measurements without evolving the simulation

Download the saved composition field and analysis source to one folder, then run:

python -m pip install numpy scipy numba scikit-image
python connectivity_morphology.py composition.npy connectivity-output

This writes analysis.json and phase-flood.bin.gz. The latter stores one little-endian unsigned 16-bit word per original voxel: the high bit indicates red and the remaining bits give the shortest-path distance from that phase’s seed. It is lossless for the selected phase definition and distances. Both seeds reach their entire phase.

Root labels are identifiers, not geometric locations. The JSON records the actual flood seeds, cluster sizes, winding vectors, threshold checks, volume, digital Euler values and periodic interface geometry. Integrated mean curvature uses H = (k₁+k₂)/2, with the normal pointing out of the high-c phase; a convex high-c ball gives positive integrated H. Gaussian curvature is integrated through Gauss–Bonnet on the checked closed surface. These are discrete mesh estimates, not converged continuum measurements.

Generation can take several minutes and needs a few GB of memory. The browser loads a compressed connectivity volume and holds a 32 MiB distance array. Current browsers with gzip decompression support are required. The surface loads only when requested.

Original 3D spinodal simulation: source, regeneration and limits

Dimensionless Cahn–Hilliard: ∂c/∂t = M∇²μ, μ = f′(c) − κ∇²c; f = Ac²(1−c)². A = M = κ = 1; grid 256³, spacing 0.25, box length 64, timestep 0.5, 400 steps, final time 200. Seed 20261005; mean-zero Gaussian noise of standard deviation 0.01 about c = 0.5. Stabilized semi-implicit Fourier integration, stabilization S = 2, explicit nonlinear term, no dealiasing. The saved field is unclipped float32.

Connectivity is established for this saved discrete field at thresholds 0.45, 0.50 and 0.55. This does not establish numerical convergence or representativeness. Grid refinement, timestep reduction, multiple seeds and different coarsening times remain necessary robustness studies. Energy decreased at the sampled times; no unconditional-stability claim is made.

python -m pip install numpy scipy numba scikit-image fast-simplification
python bicontinuity_3d.py bicontinuity-3d-output
python connectivity_morphology.py bicontinuity-3d-output/composition.npy connectivity-output

Download the Python notebook ↓ · Read the code in steps → remains available as an optional alternate view; it displays the previously saved witness graphs, not this slice flood.

Download the Python notebook ↓ · Read the code in steps → · Download the Python notebook ↓ · Read the code in steps → · Saved field · New measurements · Flood volume · Slice viewer source · Plotly and pattern-lab source · VPython browser source

References: Hoshen–Kopelman; Newman–Ziff periodic displacement tracking; Fiałkowski–Aksimentiev–Hołyst morphology; scikit-image mesh and digital Euler conventions.