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.
- Documentation: https://jabed-umar.github.io/MoirePy/
- Github Repository: https://github.com/jabed-umar/MoirePy
- PyPI page: https://pypi.org/project/moirepy/
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
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 Distributions
Built Distributions
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 moirepy-0.0.10-cp312-abi3-win_amd64.whl.
File metadata
- Download URL: moirepy-0.0.10-cp312-abi3-win_amd64.whl
- Upload date:
- Size: 113.5 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abbfebc2cbb23cc518ee72241dab74f604288bb78058cf0868576971fd155ed0
|
|
| MD5 |
11a973f6ab2cf6f30ed11f6e31a42746
|
|
| BLAKE2b-256 |
1496a86e06392bc704468f0e200855d04cd39e3717166f0c7c0150bfbd0495a7
|
File details
Details for the file moirepy-0.0.10-cp312-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: moirepy-0.0.10-cp312-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 249.2 kB
- Tags: CPython 3.12+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ae51ceb32b2ee849b81f0e998abbc8df1c3183721c291bd48a260f3f6f03b81
|
|
| MD5 |
0c1aa57f4711c06a6954a942f7947efa
|
|
| BLAKE2b-256 |
8a5c4a5e5a01bca1b4ffb1021850982450a5fb66dd0b872778e83b1f8e93eb50
|
File details
Details for the file moirepy-0.0.10-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: moirepy-0.0.10-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 242.8 kB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e4b814df3391e0a2493a0489ac6a194f95f71bf2a2513fc1a07e0cf02b05ba6
|
|
| MD5 |
f12775afa486dadabb7c2a8c610c3da1
|
|
| BLAKE2b-256 |
7bdd3a0b1e417329dc6b84e39973cb25138b2dd8638b8652d19659ea1e1adc71
|
File details
Details for the file moirepy-0.0.10-cp312-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: moirepy-0.0.10-cp312-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 219.7 kB
- Tags: CPython 3.12+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
734ab414370a0f49ffd4df6475a184bd05b89472e4a0704c7e373f6316e82588
|
|
| MD5 |
e8f69c067e3387a038b95eb65f3e441f
|
|
| BLAKE2b-256 |
c1b48fe9db48004f37c95aeac1dd6853af70ad4850368554cd0887e5ab438f92
|