Skip to content

mthiel74/homologyoncosmicfilaments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Persistent Homology on Cosmic Filaments

Rotating 3D view of the log-normal cosmic-web mock with filament edges drawn at the percentile cut where the alpha-complex 1-skeleton first percolates

A from-scratch, pure-Wolfram-Language implementation of persistent homology applied to the cosmic web — the network of galaxy clusters, filaments, sheets and voids that fills the large-scale Universe.

The post takes a 3D galaxy catalogue (a slice of the SDSS DR17 spectroscopic sample plus a log-normal Wolfram-native mock), builds an alpha complex from a Delaunay tetrahedrization, and reduces its boundary matrix to extract persistence pairs in degrees 0, 1 and 2. The resulting bars are the homological signature of the cosmic web:

feature persistent class what it picks out
clusters H₀ (long bar) dense knots where galaxies merge into one component
filament loops H₁ (long bar) wedding-cake-shaped 1-D holes in the filament graph
voids H₂ (long bar) underdense regions enclosed by a sheet of galaxies

What the project does

  1. Pulls a real-data galaxy slice — SDSS DR17 spectroscopic galaxies from the SkyServer SQL service, in a thin redshift / sky window, converted to comoving Mpc/h via a flat-ΛCDM line-of-sight integral.
  2. Generates a Wolfram-native mock — a log-normal density field on a periodic 3D grid (Coles & Jones 1991), Poisson-sampled to give a noise-free "ground truth" cosmic web that the same pipeline can be tested against.
  3. Implements persistent homology from scratch in Wolfram Language:
    • alpha complex via DelaunayMesh + per-simplex circumradius filtration (wolfram/alpha_complex.wl);
    • standard GF(2) column-reduction of the boundary matrix (wolfram/persistence.wl).
  4. Cross-checks the engine against ResourceFunction["PersistentHomology"] and against analytic Betti numbers of reference shapes (circle, sphere, torus, Swiss cheese) in tests/ph_sanity.wls.
  5. Renders the publication figures — 3D galaxy scatter, persistence diagrams, barcodes, Betti curves — and assembles a single Wolfram Community notebook (community/cosmic_ph.nb).

Gallery

3D filament networks built from the alpha-complex 1-skeleton at the percentile cut where the graph first percolates — mock (left) and SDSS DR17 (right):

3D filament graph of the log-normal mock catalogue 3D filament graph of the SDSS DR17 slice

Anatomy of a persistence diagram (left) and side-by-side comparison with the literature filament-scale measurements (right):

Annotated persistence diagram showing birth, death, persistence, and the diagonal Our β₁ peak compared with Cautun, Tempel and Sousbie filament-scale measurements

Two complementary TDA summaries of the same point cloud — the persistence diagram from the alpha complex (left) and the Mapper graph from BuildMapper (right):

Persistence diagram of the log-normal mock with H0, H1 and H2 pairs Mapper graph of the mock with local-density filter, nodes laid out at cluster centroids

Repository layout

homologyoncosmicfilaments/
├── wolfram/                    pure-WL pipeline
│   ├── alpha_complex.wl          PH engine — filtration
│   ├── persistence.wl            PH engine — reduction
│   ├── cosmology.wl              flat-ΛCDM comoving distance
│   ├── load_data.wl              CSV / JSON loaders
│   ├── fetcher_common.wl         URLRead helpers
│   ├── fetch_sdss.wls            SDSS DR17 SkyServer query
│   ├── mock_galaxies.wls         log-normal Poisson mock
│   ├── reference_shapes.wls      teaching figures (sphere / torus / cheese)
│   ├── filaments.wls             PH on the galaxy catalogues
│   ├── fetch_all.wls             one-shot data driver
│   └── run_all.wls               one-shot figure driver
│
├── data/                       tidy CSVs (committed)
│   ├── sdss_slice.csv
│   ├── mock_galaxies.csv
│   ├── persistence_sdss.csv
│   ├── persistence_mock.csv
│   └── raw/                      bulk downloads (git-ignored)
│
├── community/                  publication artefact
│   ├── build_notebook.wls        assembles cosmic_ph.nb + .pdf
│   ├── cosmic_ph_helpers.wl      cell + figure helpers
│   ├── images/                   rasterized embedded figures
│   ├── cosmic_ph.nb              the post
│   └── cosmic_ph.pdf             rendered PDF
│
├── docs/
│   └── images/                   figures referenced from README + notebook
│
└── tests/
    └── ph_sanity.wls             correctness checks

Reproducing

# 1. Fetch the SDSS slice and write the log-normal mock to data/
wolframscript -file wolfram/fetch_all.wls

# 2. Run the full figure pipeline: reference shapes, intuition figs,
#    animation, walkthrough, and PH on both catalogues
wolframscript -file wolfram/run_all.wls

# 3. Sanity tests (circle / sphere / torus + RF cross-check)
wolframscript -file tests/ph_sanity.wls

# 4. Assemble the Wolfram Community notebook
wolframscript -file community/build_notebook.wls

Total wall time on an M-series Mac: ~90 s for steps 1-3 plus ~10 s for the notebook build. The committed CSVs and PNGs make every step optional; the notebook builds even with no internet access.

Pre-rendered figures

The notebook embeds these PNG / GIF figures (under docs/images/):

family files story
intuition intuition_betti.png, intuition_rips_filmstrip.png gentle TDA intro for cosmologists
intuition_alpha_filmstrip.png, intuition_persistence_anatomy.png alpha complex + annotated diagram
intuition_cosmic_web_legend.png cosmic-web slice with structures labelled
animation anim_alpha_growth.gif, anim_alpha_filmstrip.png live alpha filtration with \[Beta]\_1 counter
walkthrough walk_alpha_snapshots.png, walk_matrix.png algorithm steps on a 10-point decagon
ref shapes ref_circle.png, ref_sphere.png, ref_torus.png, ref_cheese.png analytic Betti-number cross-checks
mock mock_density_slice.png, mock_scatter.png, mock_diagram.png log-normal cosmic-web mock
mock_barcode.png, mock_betti.png, mock_hero.png
SDSS sdss_scatter.png, sdss_diagram.png, sdss_barcode.png real galaxy slice from SDSS DR17
sdss_betti.png, sdss_hero.png

Requirements

  • Wolfram Language 14.0+ (built and tested on 15.0).
  • Internet access only for step 1 (SDSS SkyServer). The committed CSVs let everything else run offline.

The maths in a paragraph

Given $n$ 3D galaxy positions, the alpha complex is the sub-complex of the Delaunay triangulation consisting of those simplices whose smallest empty circumscribing ball has squared radius $\le \alpha$. As $\alpha$ grows from $0$ to $\infty$, simplices are added in a filtration, and a topological feature (an H₀ component, an H₁ loop, an H₂ enclosed void) is born when a simplex creating it appears and dies when a simplex filling it in appears. The set of (birth, death) pairs is the persistence diagram; long bars are robust features, short bars are noise. For a comprehensive review of the cosmological context see Pranav et al. 2017 (The topology of the cosmic web in terms of persistent Betti numbers).

Status

Active. Target publication: Wolfram Community before end of May 2026.

Related projects

About

Persistent homology of the cosmic web in pure Wolfram Language — alpha complex + GF(2) reduction on SDSS DR17 and a log-normal mock. Includes Mapper graphs and a standalone CosmicTDA.wl package.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors