Guide to choosing functions

Which mofography function to call for each task: the recommended defaults, the alternates, and what to avoid.

Mofography exposes hundreds of functions, but only a subset is thoroughly tested and recommended for everyday use. This page is a quick-reference handbook: for each task it lists the functions to reach for, and which alternatives are legacy, deprecated, or experimental. Every function name links to its page in the API reference.

The Status column uses the same tags as the reference:

go-to the recommended default, used throughout the tutorials · alternate valid, but not the default choice · other helper or building block · experimental · legacy kept for comparison or old results · deprecated avoid in new code.

TipThe default path in one line

dgrid_from_atoms_rust → do_periodic_segmentation_rust → get_pore_dia_mgr_winding (LCD, PLD, LIS) → compute_surface_area_mc_winding and compute_void_volume_from_results_winding → rag_from_connections for the pore graph. The Quick start walks through it end to end.

Distance grid

The distance grid is the first step of every workflow. It stores the distance from each grid point to the nearest framework atom (minus the atom radius). For the full comparison of backends see Distance grid methods.

Function Status What it does When to use it
dgrid_from_atoms_rust go-to Rust brute-force distance grid with exact minimum-image distances, thread-parallel. Default for all systems.
dgrid_from_atoms_rtree_rust alternate Rust R-tree neighbor-search distance grid. Large cells or tight memory.
dgrid_from_atoms_rtree_interp_rust alternate Coarse R-tree sampling plus trilinear interpolation to the fine grid. Very large systems where mild smoothing is acceptable.
dgrid_from_atoms_cpu legacy Python distance grid using freud and Dask. Slower, kept for compatibility and debugging.
dgrid_from_atoms legacy Older Python/Dask router. Avoid; use dgrid_from_atoms_rust.
dgrid_from_atoms_aabb_rust deprecated Old name of dgrid_from_atoms_rtree_rust; still works but warns. Deprecated; use dgrid_from_atoms_rtree_rust.
dgrid_from_atoms_exp_rust deprecated Backward-compatible alias of dgrid_from_atoms_rust. Avoid; no separate implementation.
egrid_from_atoms_rust alternate Single-channel Rust energy grid (Lennard-Jones). Energy-interpolation workflows; screening uses the tricubic 8-channel build instead.

Periodic segmentation

Segmentation splits the void space into convex pockets around local distance maxima, handling periodic boundaries. See Region segmentation and PBC considerations.

Function Status What it does When to use it
do_periodic_segmentation_rust go-to Full periodic segmentation: maxima detection, padded watershed, PBC merging, and connections. Returns a results dict (regions, regions_pbc, maxima, connections, dgrid, …). Default and only supported pipeline.
do_periodic_segmentation deprecated Older Python segmentation pipeline. Slow and not kept up to date; avoid.
do_periodic_segmentation_basic deprecated Simplified Python segmentation. Slow and not kept up to date; avoid.

Pore diameters (LCD, PLD, LIS)

Pore diameters come from the distance grid and the percolation results on the pore graph. See Compute pore diameters and PLD and percolation.

Function Status What it does When to use it
get_pore_dia_mgr_winding go-to Winding-number LCD, PLD, and LIS in one call from a segmentation. Default. Set include_dangling=True to include isolated pockets.
get_pore_dia_mgr_winding2 alternate Same as the default, but re-segments with a thicker mask when watershed spill is detected. When the default flags spill.
get_pore_dia_lattice alternate Lattice-based LCD, PLD, and DFSD. Comparison with Zeo++-style results; use variant="v2" for periodic-aware labelling.
get_pore_dia_mgr alternate Lattice v1 variant. Not the default; prefer get_pore_dia_mgr_winding.

Percolation and accessibility

Percolation decides which void regions connect across the cell for a given probe radius. Two accessibility frameworks exist: winding (default; follows the pore graph and handles polymers and flexible frameworks) and lattice (Zeo++-style, kept for comparison). See Accessibility methods.

Function Status What it does When to use it
compute_percolation_history_winding go-to Winding percolation history over probe radii on the pore graph. Default. Integrated into get_pore_dia_mgr_winding and the winding surface-area and volume methods.
compute_percolation_history_from_results_lattice alternate Lattice percolation history (v2) stored as percolation_history_lattice. Lattice comparison; pass variant="v2".
compute_percolation_history_from_results2 alternate Lattice percolation history (v2) from dgrid, regions, and maxima. Lattice comparison.
compute_percolation_history alternate Lattice percolation history (v1). Kept for comparison; use the winding or v2 variants.
percolation_all_axes_periodic other Axis-resolved periodic percolation test on a binary void grid. Low-level; used internally by lattice methods.

Surface area and void volume

Surface areas and void volumes are computed at a probe radius. Two accessibility frameworks (winding and lattice) and two area estimators (Monte Carlo shell and marching-cubes mesh) are available. See Surface area and void volume.

Function Status What it does When to use it
compute_surface_area_mc_winding go-to Monte Carlo shell surface area with winding accessibility. Default and most reliable.
compute_void_volume_from_results_winding go-to Voxel void volume with winding accessibility. Default; pairs with compute_surface_area_mc_winding.
compute_surface_area_mesh_winding go-to Marching-cubes mesh surface area with winding accessibility. Deterministic, but drops boundary-crossing triangles; prefer Monte Carlo for quantitative work.
compute_surface_area_mc_lattice alternate Monte Carlo shell area with lattice accessibility. Zeo++-style comparison.
compute_void_volume_from_results_lattice alternate Voxel void volume with lattice accessibility. Pairs with compute_surface_area_mc_lattice.
compute_surface_area_mesh_lattice alternate Marching-cubes area with lattice accessibility. Zeo++-style comparison.
compute_surface_area_from_results deprecated Router to the mesh helpers. Deprecated; call the mesh functions directly.
compute_surface_area_from_results_mc deprecated Router to the Monte Carlo helpers. Deprecated; call compute_surface_area_mc_winding directly.

The Monte Carlo shell methods use a shell thickness δ. The default δ = 0.5 Å is adequate for 0.5 Å grids. For lattice accessibility, set variant="v2" and percolation_lattice_variant="v2" when results already stores the lattice percolation history.

Pore size distributions

PSDs follow the Gelb–Gubbins approach: the largest sphere that includes each sample point. See Pore size distributions.

Function Status What it does When to use it
compute_psds_pocketwise_rust go-to Per-pocket PSDs from a fixed number of samples per region (Rust). Default for pocket-resolved PSDs and pocket typing. num_samples_per_region defaults to 1000.
compute_accessible_psd_from_results go-to Accessible global PSD from a saved results dict, with winding percolation and pocket weighting. Default for the global accessible PSD.
compute_psd_global_accessible go-to Histogram wrapper around compute_accessible_psd_from_results. When you want binned output directly.
compute_psd_uniform_rust alternate Global PSD from uniform random sampling (Rust). Fast, but not pocket-resolved.
compute_pore_sizes_uniform_rust other Raw, unbinned pore-size samples. Custom binning.
compute_pore_sizes_pocketwise_rust other Raw, unbinned pore-size samples per pocket. Custom binning per pocket.
enrich_segmentation_with_pocket_psds go-to Cache pocket PSDs on the segmentation dict. Run before pocket typing or RAG enrichment.

Pore graph construction

The pore graph (region adjacency graph, RAG) has pockets as nodes and windows as edges. See Pore graph (RAG) and Connections and windows.

Function Status What it does When to use it
rag_from_connections go-to Build the pore graph from connection data and maxima. Returns a networkx graph. Default builder.
add_maxima_to_rag other Add maxima positions and radii as node attributes. Standard step when building a RAG.
add_window_info_to_rag other Store window metadata (location, diameter) on edges. After connections are built.
add_pbc_to_rag other Annotate nodes with periodic-image information. Harmless helper; rarely needed.
add_env_cluster_pocket_types_to_rag go-to Run env_cluster pocket typing and store the labels on graph nodes. Default way to type pockets on a RAG.
add_csd_to_rag_with_pbc legacy Add per-pocket cavity size distributions to nodes. Legacy; env_cluster typing supersedes it.
clustering_grid_from_regions other Map per-node cluster labels back to a 3D label grid. Visualizing pocket types.

Pocket typing

Pocket typing groups pockets into structurally distinct types using geometric and chemical fingerprints. See Pocket type detection.

Function Status What it does When to use it
assign_pocket_types go-to High-level pocket typing on a segmentation; the default method is env_cluster. Default entry point.
assign_pocket_types_env_cluster go-to The env_cluster method itself: multimodal fingerprints from Gelb–Gubbins PSD, SOAP framework environment, and connectivity. When you need the method directly.
pocket_regions_cluster go-to Accessor for the typed region label grid. Colouring surfaces by pocket type.

Plotly visualization

Plotly gives interactive 2D and 3D figures in Jupyter. See Basic structure visualization using Plotly and Advanced structure visualization.

Function Status What it does When to use it
plot_surface_dgrid go-to Distance-grid isosurface at a probe radius, with region colouring and PBC options. Default pore-surface plot.
plot_cell go-to Unit-cell edges. Always useful.
draw_framework go-to Framework atoms and bonds as 3D scatter traces.
plot_maxima go-to Watershed maxima with cage radii.
plot_percolated_cluster_meshes go-to Isosurfaces of percolating void clusters.
plot_rag alternate Pore graph with nodes at pocket centers. Alternate RAG plot.
plot_windows go-to Windows from a raw connections list. Legacy; see the status tag for the replacement.
plot_connections go-to Inter-pocket connections. Legacy; see the status tag for the replacement.
plot_csds go-to Cavity-size distributions stored on RAG nodes.
plot_psds deprecated Renamed to plot_csds. Deprecated.
make_fig_orthographic other Switch a Plotly 3D scene to orthographic projection. Publication-style views.

Three.js visualization

Three.js produces standalone HTML scenes with full camera and GUI control. See Three.js plotting. The _3js functions are Plotly-parity aliases, so the arguments match their Plotly counterparts.

Function Status What it does When to use it
Figure3D go-to Standalone Three.js scene with camera controls and a GUI panel. Build custom scenes.
MovieFigure go-to Keyframe-animated Three.js viewer. Movies and rotations.
build_padded_threejs_scene alternate Padded, transparent segmentation scene export. Script wrapper for a complete scene.
plot_surface_dgrid_3js alternate Distance-grid isosurface in a Three.js scene.
draw_framework_3js alternate Framework atoms and bonds.
plot_maxima_3js alternate Local maxima.
plot_windows_3js alternate Window locations.
plot_percolated_cluster_meshes_3js alternate Percolating cluster isosurfaces.
plot_connections_3js alternate Inter-pocket connection lines.

High-level workflows

Convenience functions that combine several steps.

Function Status What it does When to use it
show_mof_plotly go-to Multi-layer Plotly scene: framework, regions, graph, windows. Default quick look in a notebook.
show_mof_threejs go-to Standalone Three.js scene with the same layers. Saves HTML to share.
show_percolation_threejs go-to Three.js scene with percolating clusters and windows. PLD and percolation visuals.
quick_cluster legacy One-call dgrid, segmentation, and clustering. Legacy; the explicit Rust steps in the Quick start are preferred.

Notes on function stability

  • go-to functions are the recommended defaults and are the ones the tutorials use. They are validated against Zeo++ and PoreBlazer on CoRE MOFs (see the paper).
  • alternate and other functions are stable but have narrower use cases.
  • Functions that appear only in the API reference and not on this page should be treated as experimental: they may have incomplete documentation, untested edge cases, or performance limits.
  • legacy and deprecated functions stay for backward compatibility with existing scripts and saved results dictionaries. New analyses should use the go-to alternatives.
  • For when to prefer winding over lattice accessibility, see Accessibility methods and Face merging vs winding.