Skip to main content

Aperiodic hat monotile tiling and percolation library

Project description

hat-amp

Tests

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.1.tar.gz (15.6 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.1-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

Hashes for hat_amp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 38199bffeba4eec6f566c2ba812222dd8433b87ea0de9b24296a1bb900a218dd
MD5 75dfca3a0d686b25238c96f7952ff947
BLAKE2b-256 fe3b3abed01d1492751809ae905df59695f248d8566ea5ea6c90a7563f283a64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hat_amp-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e41f279c7e43d25b8b22904bad2bbef81482b0127733a653ce673d568756ac40
MD5 e4a2603526be7d91c78d5476b32471f2
BLAKE2b-256 53b3520df7ec51ff8b0c8f64054062962dec811b10ee3fee30b0a63e8f437b91

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