First off, thank you for considering contributing to MoirePy! Whether you are a condensed matter physicist, a Rustacean, or a Python developer, your help makes this tool better for everyone.
Before you dive into the code, come say hello! We use Discord to coordinate development, discuss physics, and share results.
- Discord Server: Join our Discord
- Action Item: Once you join, please change your nickname to your real name. It helps us keep the collaboration professional and grounded.
We categorize contributors into two primary roles. You don't have to stick to one, but it helps to know where you want to start.
If you have prior experience with the theory of Moiré systems, this is for you. We need people to:
- Replicate Papers using MoirePy: Help us build a gallery of examples where you use MoirePy to replicate key results from popular related papers, or your own papers.
- Write Technical Blogs: Create tutorials or deep-dives into specific related topics to be posted on our website, or social media, mainly used for outreach.
- Refine Documentation: Improve our API docs, add docstrings, or fix typos.
If you don't have a Moiré physics background but are a skilled developer, or if you want to get under the hood and improve the engine, this is your lane. This involves:
- Rust Backend: Optimizing the rust code or the
PyO3bridge, improving the KD-tree neighbor search, or implementing new geometric algorithms in Rust for speed. - Python API: Enhancing the user-facing classes, improving interoperability with the SciPy/Kwant ecosystem, or adding new lattice types.
- Testing & CI: Writing unit tests for the Hamiltonian assembly or improving our GitHub Actions pipeline.
If you are not sure which category you fit into, ping us on Discord! We can help you find the right project or task to get started.
- Find or Create an Issue: Check the Issues tab for "good first issues." Depending upon your path you chose, you can look into the documentation and engine issues. If you have a new idea, open an issue to discuss it before you start coding.
- Fork and Commit: Fork the repo under your GitHub account and create commits there.
- Submit a Pull Request (PR): Describe exactly what you did. Tag the relevant issue.
- Keep it Simple: Per our philosophy, we prefer minimal implementations. Avoid unnecessary complexity or "over-engineering" unless it's for a proven performance gain in the Rust core. Things being slightly slower or using more memory is often acceptable if it keeps the codebase simpler and more maintainable. However, in most cases in my experience, simpler code is also fast.
- n is small: Although we always love to do time complexity analysis, remember that in practice,
nmight not be large enough and constant factors might dominate. So besides time complexity analysis, also benchmark your code to see if it's actually faster in practice. - UX-first: Always consider if your change makes the library more intuitive for a physicist, and the overall user experience better.
Depending on your path, the setup is slightly different:
You don’t need to touch the internal library code; you just need the documentation environment.
- Clone the Repo:
git clone https://github.com/jabed-umar/MoirePy.gitandcd MoirePy. - Environment (Optional): Create and activate your virtual environment.
- Install MoirePy: Run
pip install moirepy. This installs the stable version from PyPI.Note: Do not use the local
moirepyfolder in the repo root. We are using the PyPI version. You can safely ignore (or even delete) the localmoirepyfolder, just don't commit that deletion! - Install Docs Tools:
pip install -r requirements_mkdocs.txt. - Preview Docs: Run
mkdocs serveto see your changes locally.
You need the Rust toolchain to compile the backend.
- Check for Rust: Run
rustc --versionandcargo --version.- If not installed, run:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh(Linux/Mac). - Windows users should see other installation methods.
- If not installed, run:
- Environment (Optional): Create and activate your virtual environment.
- Install Maturin: Run
pip install maturin. - Build and Install: Run
maturin develop --release.Pro Tip: Always use the
--releaseflag. Without it, the Rust backend is slow AF. The compilation time difference is negligible, so there's no reason not to go fast.