# Hyperphonon 2.0

A website and script collection for spring networks on regular tilings: hyperbolic {p,q} patches in the Poincaré disk and, as a control, the Euclidean tilings {6,3}, {4,4} and {3,6}. Everything runs in JavaScript, in the browser or in Node, with no dependencies.

Version 2 keeps every feature of version 1 and adds  *Angular constraints control rigidity and boundary vibrations in hyperbolic spring networks* :

| New in 2.0 | Where |
| --- | --- |
| Up to 1400 sites in the browser (was 420); no limit from Node | `js/physics.js`, `scripts/` |
| Boundary angular multiplier β | input “Boundary multiplier β” |
| Selective angular springs: all, interior-centered, boundary-centered, none | input “Angular springs kept” |
| Bounded stiffness disorder with a reproducible seed | Analysis settings |
| Strain-energy shares of every mode (bonds, interior angles, boundary angles) | spectrum CSV, mode explorer, “Energy versus displacement” figure |
| Boundary-stiffness sweep with frequency windows and subspace overlaps | “Boundary-stiffness sweep” and “Spectral flow” figures |
| Rigidity counts, Hellmann–Feynman sensitivity check, disorder ensembles | “Rigidity, sensitivity and disorder checks” |
| Local moments with angular springs | moment panel, “Relative angular stiffness η” |
| Euclidean control tilings | preset “Honeycomb · Euclidean control” |
| A script that recomputes every number in the manuscript | `scripts/reproduce-manuscript.mjs` |
| Tests against an independent NumPy implementation | `tests/control.test.mjs` |

## TO DO

Add comments, clean the code further :/

## Files

```text
index.html, style.css     entry point and layout
offline.html              generated single-file edition
js/physics.js             geometry, constraint rows, dynamical matrix, eigensolver, mode observables
js/control.js             lifted-group windows, β sweep, overlaps, rigidity, sensitivity, disorder
js/moments.js             moment sources, sparse recurrences, fits and intervals
js/cheng.js               Cheng (2022) representation bands
js/plots.js, export.js    SVG figures; CSV, ZIP and PNG export
js/app.js, analysis-ui.js interface
js/worker.js              background calculations
scripts/                  manuscript reproduction
results/                  output of the reproduction script
tests/                    automated tests and reference data
validation/               independent NumPy implementation, figure scripts, earlier comparison study
examples/                 example inputs
deploy/                   GitHub Pages workflow
```

## Open it

**Offline.** Open `offline.html` in a current Chrome, Edge, Firefox or Safari. This single file contains the application, styles, numerical routines and worker. It needs no installation, server or network.

**From a server** (for development):

```sh
python3 -m http.server 4173      # then open http://localhost:4173
```

`index.html` loads the modules in `js/`. After editing any source file, regenerate the single-file edition with `node build-offline.mjs`.

**GitHub Pages.** Copy `deploy/github-pages.yml` to `.github/workflows/` at the repository root, keep this folder as `hyperphonon-site/`, and select *GitHub Actions* as the Pages source. The workflow rebuilds `offline.html`, runs the tests and publishes the static files.

## Model

Curvature is −1 for hyperbolic tilings (bond length `a = 2 acosh[cos(π/p)/sin(π/q)]`) and 0 for Euclidean ones (`a = 1`). Each site carries two displacement components in an intrinsic orthonormal tangent frame.

```text
K = k CᵀC + η k a² AᵀWA        D = K / m        D u = ω² u
```

- `C` differentiates geodesic bond lengths.
- `A` differentiates every elementary sector of opening 2π/q whose two bonds are present; the derivative follows from the hyperbolic or Euclidean cosine rule.
- `W` is diagonal: 1 for sectors centered on interior sites, β for sectors centered on the outer shell, times `1 + ξ` with ξ uniform on [−d, d] when disorder is switched on.
- The outer shell is the last construction layer. “Full faces” adds, per layer, every polygon touching the previous layer; “Graph distance” adds graph neighbors.

For a mode with eigenvalue λ the energy shares are `Σ_r w_r (row_r · u)² / λ` over the rows of each class. Because `D` is linear in β,

```text
∂ ln ω / ∂ ln β = f_b / 2,
```

with `f_b` the share stored in boundary-centered angles. The sensitivity check compares this with centered differences over complete multiplets.

The eigensolver is a float64 Householder reduction followed by implicit-shift QL. Its work array is stored transposed, so all inner loops run over contiguous memory; a 1321-site patch (2642 coordinates) takes about 50 s in Node 22.

## Inputs

| Input | Meaning |
| --- | --- |
| p, q | Tiling {p,q}; (p−2)(q−2) > 4 hyperbolic, = 4 Euclidean. p ≤ 12, q ≤ 14. |
| Layers, shell construction, center | Patch growth; vertex- or face-centered. |
| Model | Vector (two coordinates per site) or scalar (graph Laplacian). |
| k, m, η | Bond stiffness, site mass, relative angular stiffness κ = η k a². |
| Boundary multiplier β | Multiplies angular springs centered on the outer shell. |
| Angular springs kept | all / interior / boundary / none. |
| Disorder ±d, seed | Bounded random factors on boundary-centered angular stiffness. |
| Boundary | Free, or clamped on the outer shell. |
| Zero threshold | A mode is a numerical zero when \|ω²\| ≤ threshold. |

Saved inputs and sessions from version 1 still load; missing fields take the defaults β = 1, all angles, no disorder.

## Figures and tables

Lattice, spectrum, density of states, IPR, mode explorer, radial profile, integrated density of states and η sweep are unchanged from version 1. New:

| Figure | Content | CSV |
| --- | --- | --- |
| Energy versus displacement | Boundary-angle energy share against outer-shell weight, per mode | energy shares of every non-zero mode |
| Boundary-stiffness sweep | Outer-shell weight of the lowest and highest tenths of the lifted group, and of the softest pair, versus β | windows, frequencies, energy shares, overlaps with the reference β |
| Spectral flow | Lifted modes versus β, colored by `f_b` | every lifted mode at every β |
| Sensitivity | Finite-difference ∂ln ω/∂ln β against `f_b/2`, one point per multiplet | all multiplets |
| Rigidity table | Zero modes for each retained angular set | `rigidity.csv` in the ZIP |
| Disorder table | Ranges over the sampled patterns | `disorder.csv` in the ZIP |

The **lifted group** is the set of `2N − E − 3` internal central-force mechanisms that angular springs raise to positive frequency. Its windows contain one tenth of these modes, rounded up and completed to full multiplets (eigenvalue tolerance 10⁻¹⁰). They are selected anew at each β and therefore do not follow individual modes; the overlap columns say how much of a window comes from the reference window and from the whole reference group.

Every figure exports PNG (chosen pixel size and DPI), SVG and CSV. “Export every CSV” bundles all available tables, the eigenvectors and the inputs in one ZIP.

## Moment analysis

The moment panel (under *Validation*) evaluates shifted local moments `H_n = ½ tr[P_c (1 − D/E₀)ⁿ P_c]` and extrapolates `F_n = H_{n−1}/H_n` in 1/n. Sources: bundled 80-digit bulk {3,7} moments, a sparse generated patch (now with optional angular springs), the current finite patch, or an imported table.

The default weights propagate the raw-moment error profile of Sela, Cheng and Sun (2026),

```text
σ_j = 2.65×10⁻⁷ E₀^j (μ_j / E₀^j)^0.55 j⁻²,   σ₀ = 0,
```

with E₀ = 9.1984, orders 8–15 and a quadratic in 1/n; this gives ω_g = 0.79491 ± 0.00397 (99%). The profile corresponds to a relative precision of 3×10⁻⁸ to 4×10⁻⁷ on the moments. Propagated to the ratios it grows from 6×10⁻⁶ at n = 8 to 1.5×10⁻⁴ at n = 15, so the lowest orders carry most of the weight. The interval is conditional on this profile and on the fit model. It does not measure finite-order extrapolation bias: equal weights move the estimate to 0.78992. Equal weights, custom weights and all profile parameters are available in the settings.

With angular springs, `E₀` is checked against a power-iteration estimate of the spectral maximum, and the boundary-independent order is taken as `2(L − 1)` for a graph ball of radius `L`.

The Cheng (2022) representation bands and the finite-size comparison with Sela (2026) are unchanged.

## Scripts

```sh
npm test                    # 82 tests, under a minute
npm run reproduce:quick     # manuscript numbers on patches up to 500 sites, about 2 minutes
npm run reproduce           # everything, including 1321 sites and the {6,3} control, about 15 minutes
```

`scripts/reproduce-manuscript.mjs` writes `results/manuscript.json` and one CSV per analysis: patch sizes, boundary sweeps, spectral flow, rigidity, sensitivity, interior-edge estimates and {3,7} threshold counts. The copies in `results/` were produced by this script with the code in this folder.

## Validation

- `tests/control.test.mjs` compares sweeps, overlaps, energy shares, rigidity counts, sensitivities, honeycomb patches and angular-moment edge estimates with `tests/independent-reference.json`. That reference comes from a separate NumPy implementation written from the manuscript's Methods, sharing no code with this site.
- `tests/physics.test.mjs` and `tests/face-centered.test.mjs` keep the sixteen frozen NumPy spectra of version 1, plus geometry, projection, export and solver checks.
- `tests/moments.test.mjs`, `tests/paper-2026.test.mjs` cover the moment fit, the 802 Cheng band points and the two Sela thresholds.
- `tests/interface.test.mjs` and `tests/offline.test.mjs` drive the page logic with a simulated document and execute the bundled offline worker.

Not covered: a graphical browser run. Layout and click-driven downloads should be checked once after deployment.

`validation/independent-numpy/` contains that second implementation, its outputs and the scripts that draw the manuscript figures; see its README.

`validation/` holds the comparison study of 28 November 2026 with Sela, Cheng and Sun, written before the error profile was identified with the one in their published Supplemental Material; where those notes say “calibrated profile”, they refer to the same formula.

## Scope

These are finite-patch calculations. Gaps, edge weights and zero counts depend on size and termination; the scripts report several sizes and both centers so that this dependence is visible. Individual eigenvectors inside a degenerate multiplet depend on the basis, so reported weights and energies are averaged over complete multiplets or windows.

## License

Copyright (c) 2026 Carlos Nogueira.

Hyperphonon is licensed under the [MIT License](LICENSE).