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.14.tar.gz (7.9 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.14-cp312-abi3-win_amd64.whl (311.4 kB view details)

Uploaded CPython 3.12+Windows x86-64

moirepy-0.0.14-cp312-abi3-manylinux_2_34_x86_64.whl (471.1 kB view details)

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

moirepy-0.0.14-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (444.5 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

moirepy-0.0.14-cp312-abi3-macosx_10_12_x86_64.whl (426.9 kB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: moirepy-0.0.14.tar.gz
  • Upload date:
  • Size: 7.9 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.14.tar.gz
Algorithm Hash digest
SHA256 cc15e6c618fb19e003dd70fe392904b8a0546c63fee5a5b090a30116da3bc1c7
MD5 6722ff67df9f3667a652b20471bbe56f
BLAKE2b-256 94596a4946184164fa716bd0af449cc006dc11a5779c401a838097f5916b7c10

See more details on using hashes here.

File details

Details for the file moirepy-0.0.14-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: moirepy-0.0.14-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 311.4 kB
  • Tags: CPython 3.12+, 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.14-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 73c6f32a518329d0aefdc2624b05800d33a73fe4417b9eeb89d4b8702d1a099c
MD5 51bc23561cf5539a718985d068a13b57
BLAKE2b-256 14ba5073810e8f4f0ded33d7ec20f98ca1ba55ba00450b518b294f371c1ddef8

See more details on using hashes here.

File details

Details for the file moirepy-0.0.14-cp312-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for moirepy-0.0.14-cp312-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b36c932db8fe0d6d0a8c1f8f48da16313e312d1c97be93d47ed55b35ac109740
MD5 e60ba1193f7252e457df7e8956e005b0
BLAKE2b-256 351ab737d60575d31861446b445635b3020054c26178e9d7e04be2e4b7e41ecb

See more details on using hashes here.

File details

Details for the file moirepy-0.0.14-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for moirepy-0.0.14-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bc1838be4e38e488546d3c76d28ffd45f07b824557d7b0ff2496cbd63f9091fa
MD5 3cc80bef3227e092f50283bb19b481b8
BLAKE2b-256 78f674057718b8ad94ba9e77960734f95b6978f287fa56891ea9453c3e20d708

See more details on using hashes here.

File details

Details for the file moirepy-0.0.14-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for moirepy-0.0.14-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c036cfe68a50276c34db99799281acba41169c7db1759358e16558a90e657f82
MD5 38147d75c8eb4986850889845ff8a9cc
BLAKE2b-256 875d62ff6753d04648af739227c335221e2beca957b6283645738a1920b1a945

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