Aperiodic hat monotile tiling and percolation library
Project description
hat-amp
Python tools for aperiodic tilings and percolation experiments.
hat-amp generates exact tile coordinates for the Hat (Tile(1,0)) and Spectre
(Tile(1,1)) aperiodic monotiles via substitution systems ported from Craig Kaplan's
reference implementations, plus Penrose Robinson-triangle patches. It also provides
vertex and tile-dual graph builders, square-window cropping, site/bond percolation
helpers, .npz result persistence, and SVG/PNG rendering.
The Spectre is the strictly chiral companion to the Hat — no reflected copy appears in any valid tiling, making it the first truly chiral aperiodic monotile. The Mystic is a fused Spectre pair (at 30°) that plays the physics role of an "anti-hat" and is the minority tile in every Spectre tiling. Vertex-10 of each Spectre polygon is the Singh–Flicker gold vertex: its inclusion makes the vertex graph bipartite and enables exact dimer/zero-mode analysis.
Installation
uv add hat-amp
Graph and percolation helpers need SciPy:
uv add "hat-amp[graph]"
PNG export needs CairoSVG:
uv add "hat-amp[viz]"
Requires Python >= 3.13.
Quick start
Hat:
from hat_amp.tiling import generate_tiling
hats = generate_tiling(level=3) # list of 1156 arrays, each shape (13, 2)
For the larger finite-window patch used by percolation workflows:
from hat_amp.tiling import generate_patch_tiling
patch_hats = generate_patch_tiling(level=3) # 3603 hat polygons
Spectre:
from hat_amp.spectre import generate_spectre_tiling, generate_spectre_tiling_labeled
# 559 polygons at level 3, each shape (14, 2)
spectres = generate_spectre_tiling(level=3)
# same polygons with per-tile labels: 'S' (standalone) or 'M' (Mystic component)
polygons, labels = generate_spectre_tiling_labeled(level=3)
Vertex-10 of each polygon is the Singh–Flicker gold vertex. Remove it for natural (non-bipartite) graph analysis:
from hat_amp.spectre import strip_gold_vertex
polys_13v = strip_gold_vertex(spectres) # each shape (13, 2)
Full API documentation: docs/API.md.
Example: Graph Crop And Site Percolation
from hat_amp.graph import build_vertex_graph, crop_square
from hat_amp.percolation import BoundarySets, Criterion, run_site_trials
from hat_amp.tiling import generate_patch_tiling
polygons = generate_patch_tiling(level=3)
graph = build_vertex_graph(polygons)
cropped = crop_square(graph, L=100.0)
boundaries = BoundarySets.from_cropped_graph(cropped)
thresholds = run_site_trials(
cropped,
boundaries,
trials=200,
seed=123,
criterion=Criterion.INTERSECTION,
)
print(thresholds.mean())
Example: Render Hat And Penrose SVGs
from hat_amp.penrose import generate_penrose_tiling
from hat_amp.tiling import generate_tiling
from hat_amp.viz import render_svg, save_svg
hat_svg = render_svg(generate_tiling(level=2), stroke="#222222", fill="none")
save_svg(hat_svg, "hat_level_2.svg")
penrose = generate_penrose_tiling(divisions=4, scale=200.0)
penrose_svg = render_svg(penrose.polygons(), stroke="#3366aa", fill="none")
save_svg(penrose_svg, "penrose_level_4.svg")
Features
- Hat (Tile(1,0))
H/T/P/Fmetatile substitution and full patch generation. - Spectre (Tile(1,1)) 9-type substitution system (Delta…Psi + Mystic/Gamma compound).
- Per-polygon chirality labels (
'S'standalone /'M'Mystic component). - Gold-vertex helpers (
strip_gold_vertex/add_gold_vertex) for bipartite graph analysis. - Penrose Robinson-triangle subdivision.
- Vertex graphs and tile-dual graphs from polygon tilings.
- Square-frame cropping with boundary node sets.
- Site and bond percolation with intersection/union crossing criteria.
- Finite-size weighted least-squares extrapolation for
p_c. .npzresult persistence with pydantic metadata.- SVG output and optional PNG export.
Reference
Tiling sources
- Kaplan's hatviz —
hat.js·geometry.jsgeometry.js: affine transforms as 6-element arrays[a,b,tx,c,d,ty]hat.js: metatile definitions, 28 substitution rules, recursive inflation
- Kaplan's Spectre app — cs.uwaterloo.ca/~csk/spectre/
- 9-type substitution system; tile polygon coordinates and placement geometry
spectre.js:buildSupertiles()transform rules ported tospectre.py
Percolation reference
- Aperiodic-Monotile-Percolation — github.com/aaryashBharadwaj/Aperiodic-Monotile-Percolation — reference percolation workflows and numerical cross-validation in tests.
- Bhola, Biswas, Islam, Damle. Site percolation on the Hat tiling. Phys. Rev. X 12, 021058 (2022). [arXiv:2108.12440]
- Bhola, Damle. Percolation on aperiodic tilings. arXiv:2311.05634 (2023).
Primary papers
- Smith, Myers, Kaplan, Goodman-Strauss. An aperiodic monotile. Combinatorial Theory 4 (2024). arXiv:2303.10798
- Smith, Myers, Kaplan, Goodman-Strauss. A chiral aperiodic monotile. (2023). arXiv:2305.17743
- Singh, Flicker. Exact solution of the dimer model on the spectre tiling. Phys. Rev. B 109, L220303 (2024). arXiv:2309.14447
Acknowledgments
Tiling generation ported from Craig Kaplan's hatviz (BSD-3-Clause).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hat_amp-0.2.0.tar.gz.
File metadata
- Download URL: hat_amp-0.2.0.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec8d85ed3b8bb416b40d4c72ff597ddc0a2b8cae5bb70dcfda70fa662441767a
|
|
| MD5 |
2ee655bd3dc0055799b7c2676e3c824d
|
|
| BLAKE2b-256 |
95788bf5680526350a5569a6f1c1d0d1eb77155293bbee79ceb4b0c4d4a3bba6
|
File details
Details for the file hat_amp-0.2.0-py3-none-any.whl.
File metadata
- Download URL: hat_amp-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8dbeb098b0a6655db034aef3d4c47718002fb109f99869f3497dfb5339a5d59e
|
|
| MD5 |
c91d62f7dfa3db0e69d5e1813aec1378
|
|
| BLAKE2b-256 |
bb6ef9d8b4bdcb95fd0bd34b4198fe937e171bd7e938aab152989445eb223688
|