Skip to main content

Simulate moire lattice systems in both real and momentum space and calculate various related observables.

Project description

MoirePy: Twist It, Solve It, Own It!

MoirePy is a FOSS Python library for simulating moire lattices with a clean, highly Pythonic API.

It is designed to be easy to use while remaining fully flexible. You can define custom lattice geometries, program arbitrary hopping functions, and build tight-binding Hamiltonians in both real space and k-space, with support for open (OBC) and periodic (PBC) boundary conditions. Generated Hamiltonians can also be exported to tools like Kwant for further analysis.


Why MoirePy

  • Define anything: No restrictions on lattice geometry or orbitals
  • Pythonic API: If you know Python, MoirePy is intuitive
  • Custom hoppings: Fully programmable intra/inter-layer couplings
  • Real-space + k-space: Both supported natively
  • OBC + PBC: Switch boundary conditions easily
  • Kwant-compatible: Export Hamiltonians for further analysis
  • Fast construction: Efficient neighbour search using KDTree
  • Reproducibility-first: Designed to replicate known results and papers

Installation

pip install moirepy

Quick Example: Twisted Bilayer Graphene

import numpy as np
import matplotlib.pyplot as plt
from moirepy import BilayerMoireLattice, HexagonalLayer

# Define a twisted bilayer moiré lattice
lattice = BilayerMoireLattice(
    latticetype=HexagonalLayer,
    # you choose the next 4 values based on the twist angle using this tool:
    # Angle-Value Calculator: https://jabed-umar.github.io/MoirePy/theory/avc/
    ll1=3, ll2=4, ul1=4, ul2=3,
    n1=1, n2=1,
)

# Visualize the lattice
lattice.plot_lattice()
plt.show()

ham = lattice.generate_hamiltonian(
    tll=1, tuu=1,
    tlu=1, tul=1,
    tlself=0, tuself=0
)  # returns scipy sparse matrix

print(ham.shape)

Philosophy

MoirePy does not try to enforce what is "physically valid".

If you want:

  • unusual lattices
  • non-standard couplings
  • high orbital counts

you are free to do so.

The library gives you control. You decide what makes sense.


Contributing

Contributions are welcome.

  • Report bugs or request features via issues
  • Submit pull requests for improvements
  • Add examples, tutorials, or benchmarks

A detailed contributing guide will be added soon.


Citation

If you use this work in research:

@software{MoirePy2025,
  author = {Mukhopadhyay, Aritra and Umar, Jabed},
  license = {MIT},
  title = {{MoirePy: Python package for efficient atomistic simulation of moiré lattices}},
  url = {https://github.com/jabed-umar/MoirePy}
}

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

moirepy-0.0.16.tar.gz (7.5 MB view details)

Uploaded Source

Built Distributions

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

moirepy-0.0.16-cp311-abi3-win_amd64.whl (328.3 kB view details)

Uploaded CPython 3.11+Windows x86-64

moirepy-0.0.16-cp311-abi3-manylinux_2_34_x86_64.whl (488.2 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ x86-64

moirepy-0.0.16-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (462.6 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

moirepy-0.0.16-cp311-abi3-macosx_10_12_x86_64.whl (451.4 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file moirepy-0.0.16.tar.gz.

File metadata

  • Download URL: moirepy-0.0.16.tar.gz
  • Upload date:
  • Size: 7.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for moirepy-0.0.16.tar.gz
Algorithm Hash digest
SHA256 a8553f91fca187614404a7d284501409943b70fee00ffea9c051e9746e7a39f7
MD5 d6a98763a67bcaf1a5f11d4db1149561
BLAKE2b-256 07cd2d3a7928efbd1fe13a2fcb451320835e37a16637304ad209ce3bcf897ec3

See more details on using hashes here.

File details

Details for the file moirepy-0.0.16-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: moirepy-0.0.16-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 328.3 kB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for moirepy-0.0.16-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f25864284173e5e19354188abbecc39bd317003d584d0edc0f422ccd4c4d3221
MD5 77a7a8a55cd3e6d844d45eaff2929af3
BLAKE2b-256 5158bd7d84c2d088fde6c65a417a72bbaa9519b96da47ec800923308daa6b9c7

See more details on using hashes here.

File details

Details for the file moirepy-0.0.16-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for moirepy-0.0.16-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 eba17e91801aa60170487d1c7443bb7ba4d3e0d6df895927066d82557f24380c
MD5 863d541a76679e4f17491fc04dee7f27
BLAKE2b-256 fa82956e1a67f6021b879b37fe3a8074266a4232e429852754c5bbfc029430bd

See more details on using hashes here.

File details

Details for the file moirepy-0.0.16-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for moirepy-0.0.16-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 779de79ded67de3181bda01faab100f74ce171b32fd8f75eefb082ad04337efa
MD5 c19fa94b3ef5055f98206e1bde2e9e01
BLAKE2b-256 3750af7c0e7dabbf9ea194b7e318457993e2de50e59fb5a7076e2b4444515324

See more details on using hashes here.

File details

Details for the file moirepy-0.0.16-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for moirepy-0.0.16-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9fa2791e5a568fc8d1ba9474e1042ea3d4fcf1f0e448645d4d4b065f8cda0a34
MD5 bd91b5c81f050f2bfc513f64258cda24
BLAKE2b-256 48618a8068f4f4b76215b6b074b00a30f7bb77572986c5a525b1334edc5f2b95

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