Skip to main content

Aperiodic hat monotile tiling and percolation library

Project description

hat-amp

Python tools for aperiodic tilings and percolation experiments.

hat-amp generates exact hat monotile coordinates from Craig Kaplan's hatviz substitution system, 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.

Hat monotile level 2 patch Penrose level 4 patch


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

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

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 H/T/P/F metatile substitution and full patch generation.
  • 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.
  • .npz result persistence with pydantic metadata.
  • SVG output and optional PNG export.

Reference

  • Kaplan's hatvizhat.js · geometry.js
    • geometry.js: affine transforms as 6-element arrays [a,b,tx,c,d,ty]
    • hat.js: metatile definitions, 28 substitution rules, recursive inflation
  • Aperiodic-Monotile-Percolationgithub.com/aaryashBharadwaj/Aperiodic-Monotile-Percolation for reference percolation workflows and numerical cross-validation in tests.
  • Smith, Myers, Kaplan, Goodman-Strauss. An aperiodic monotile. Combinatorial Theory 4 (2024). arXiv:2303.10798

Acknowledgments

Tiling generation ported from Craig Kaplan's hatviz (BSD-3-Clause).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hat_amp-0.1.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hat_amp-0.1.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file hat_amp-0.1.0.tar.gz.

File metadata

  • Download URL: hat_amp-0.1.0.tar.gz
  • Upload date:
  • Size: 15.5 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

Hashes for hat_amp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 923b3ead925bf83b9a32945e57ef60b19b67ed1035d6e10cf7580efa509c523a
MD5 402038353affa54b2faf6eaf298395e8
BLAKE2b-256 55ede148dab1613d901d05cff30ee1274631da80545261276f3f6e680ff961fd

See more details on using hashes here.

File details

Details for the file hat_amp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hat_amp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 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

Hashes for hat_amp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ec467fdcd6e8f4c6eb7a7681c933ce44b962971196a7ba1f570bcb2addb9dd5
MD5 9329023d41192de62d419a1361541b91
BLAKE2b-256 2342cda2df46b28dcb09ae3ce49825b4c00eb1604170a3f199e90dde7c2b2138

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page