Universal Twisted Electronic Structure Calculation Package
Project description
MoireStudio
MoireStudio is a general-purpose toolkit for twisted / moiré electronic-structure calculations.
It integrates:
- Geometry: commensurate-angle search, moiré supercell generation (POSCAR-based), moiré point visualization
- Relaxation: in-plane and out-of-plane relaxation patterns and relaxed structures (analytic framework integrated)
- Tight-binding / Wannier: twisted TB band structures from POSCAR or Wannier90-like models; dense and sparse workflows
- Continuum k·p: generic and template-based (TBG / tTMD) continuum models; band structures and Chern numbers
- Reproducibility: automatic run metadata logging (e.g.,
outputs/metadata.json) and standardized output files
Table of contents
- Requirements
- Installation
- Quick start
- Command-line interface
- Input file:
input.json - Modes & tasks
- Examples
- Outputs
- Parallelism & performance notes
- How to cite
- Troubleshooting
Requirements
- Python ≥ 3.10
- Core dependencies:
numpy,scipy,matplotlib
For best performance, use a NumPy/SciPy build linked against optimized BLAS/LAPACK (e.g., MKL/OpenBLAS).
Installation
Option A: package install (recommended)
From the repository root:
pip install moirestudio-1.0.0-py3-none-any.whl
Option B: script execution
You can run it directly in the folder where input.json exists
MoireStudio
If you keep a script-style layout, you can run:
python driver.py --input input.json
Quick start
- Prepare an
input.jsonin your working directory. - Put required inputs under
./inputs(default) or setio.input_dir. - Run:
python driver.py --input input.json
The default output directory is ./outputs (override with io.output_dir).
Command-line interface
Typical commands:
python driver.py --input input.json
python driver.py --input input.json --quiet
python driver.py --input input.json --no-color
python driver.py --version
python driver.py --cite
Input file: input.json
MoireStudio uses a JSON file with separate mode and task fields.
{
"mode": "struc | tb | kp | mono",
"task": "gen_struc | find_com | band | chern",
"theta_deg": 1.10,
"io": {},
"struc": {},
"relax": {},
"tb": {},
"kp": {}
}
theta_degis a top-level key.- Only the blocks relevant to the selected
mode/taskare required.
Common IO keys (io)
io.input_dir(default./inputs)io.output_dir(default./outputs)io.fig_band(band figure filename; falls back toio.figure, then<task>.pdf)io.fig_moire(defaultmoire_points.pdf)io.show_plots(defaultfalse)
Heterobilayer helper keys (used when struc.ihetero=true):
io.t_prefix,io.b_prefixio.t_fermi_energy,io.b_fermi_energy
Structure block (struc)
Core selectors:
struc.read_mode:"POSCAR"or"model"struc.read_layer:"bilayer"or"monolayer"struc.ihetero:true/false
POSCAR inputs:
struc.pos_path(defaultio.input_dir)struc.pos_prefix(default"POSCAR")
Interlayer distance (angstrom):
- Use
struc.d_0(default 3.5), or - Provide
struc.d_AAandstruc.d_AB(if missing, falls back tod_0).
Moiré supercell generation (task="gen_struc"):
struc.zero_point(default[0,0])struc.lim(default20)struc.search(default0)struc.accurate(default0.01)struc.if_gen_pos(defaulttrue)struc.write_by_hand(optional manual selection for Lm)
Commensurate-angle scan (task="find_com"):
struc.max_angle(default180)struc.min_angle(default1)struc.lim(default10)struc.step(default0.01)struc.accurate(default0.01)
Relaxation block (relax)
relax.irelax: enable/disable relaxationrelax.order_num: harmonic order (default0)relax.kappa_parallel: in-plane relaxation strength parameterrelax.kappa_perp: out-of-plane relaxation strength parameter- Optional pattern indices:
relax.u_in_idxsrelax.u_out_idxs
TB block (tb)
Band / k-path:
tb.k_path: list of fractional k-pointstb.nk: number of k points along the path (default121)tb.labels: labels for k nodes (optional)tb.ylim: plot energy window (optional)
Compute options:
tb.cores(default1)tb.isparse(defaultfalse)tb.inter_coe(default1)tb.isymmetry(optional)tb.ioutwannier(optional; dense only)
Wannier-like model input:
"tb": {
"wannier": {
"prefix": "wannier90",
"fermi_energy": 0.0
}
}
If fermi_energy is omitted, MoireStudio may try reading inputs/FERMI_ENERGY; otherwise it defaults to 0.
k·p block (kp)
Two usage styles:
- Template mode (recommended for standard models)
kp.system_name:"TBG"or"tTMD"kp.lat_a,kp.valley_idx- For tTMD:
kp.omega,kp.V,kp.psi - For TBG:
kp.u1,kp.u2
- Generic mode (fully explicit)
kp.tr: truncation shell (default3)kp.valley_pos: fractional coordinates (default[2/3, 1/3])kp.mono_lat: 2x2 real-space lattice vectorskp.V_z,kp.m_z: onsite terms- Specify exactly one of:
kp.hv_a(Dirac-like 2-band), orkp.mass: [mx, my](effective-mass 1-band)
Couplings are specified in amplitude + phase form (phases in degrees):
- Interlayer:
kp.inter_idxs,kp.inter_amps,kp.inter_phas - Intralayer top:
kp.intra_t_idxs,kp.intra_t_amps,kp.intra_t_phas - Intralayer bottom:
kp.intra_b_idxs,kp.intra_b_amps,kp.intra_b_phas
Band plotting:
kp.k_path,kp.nk,kp.labels,kp.ylimkp.fermi_shift: number, or"max"/"min"
Chern number (task="chern"):
kp.n_mesh(default25)kp.band_index(default1)
Modes & tasks
-
mode="struc":task="gen_struc": generate moiré supercell (optionally relaxed) and write POSCARtask="find_com": scan commensurate angles and write lists/plots
-
mode="tb":task="band": TB band structure from POSCAR or Wannier model
-
mode="kp":task="band": continuum k·p band structuretask="chern": Chern number on a k-mesh
-
mode="mono":task="band": monolayer band structure from a Wannier model
Examples
A) Geometry: generate moiré structure
{
"mode": "struc",
"task": "gen_struc",
"theta_deg": 21.79,
"struc": {
"lim": 50,
"read_mode": "POSCAR",
"read_layer": "bilayer",
"ihetero": false,
"d_AA": 3.60,
"d_AB": 3.60,
"if_plot": false,
"zero_point": [0, 0]
}
}
B) Geometry: scan commensurate angles
{
"mode":"struc",
"task": "find_com",
"struc":{
"read_mode": "POSCAR",
"step": 0.01,
"lim":30,
"accurate":5e-3,
"max_angle": 23,
"min_angle": 1
}
}
C) TB: band structure
{
"mode": "tb",
"task": "band",
"theta_deg": 21.79,
"io": {
"output_dir": "./outputs",
"input_dir": "./inputs",
"fig_band": "band.pdf"
},
"struc": {
"read_mode": "WANNIER",
"read_layer": "bilayer",
"bilayer_num": 2,
"ihetero": false,
"d_AA": 3.60,
"d_AB": 3.35,
"lim": 80,
"zero_point": [[0.0, 0.0],[0.0,0.0]],
"if_plot": false
},
"tb": {
"wannier": {
"prefix": "wannier90"
},
"cores": 1,
"isparse": false,
"k_path": [[0,0,0],[0.333333,0.333333,0],[0.5,0.0,0],[0,0,0]],
"nk": 121,
"labels": ["G","K","M","G"],
"ylim": [-3, 3]
}
}
D) k·p: generic band structure (Dirac-like)
{
"mode": "kp",
"task": "band",
"theta_deg": 1.05,
"io": { "output_dir": "./outputs", "fig_band": "kp_band.pdf" },
"kp": {
"tr": 5,
"valley_pos": [-0.6666667, -0.3333333],
"mono_lat": [[2.46, 0.0], [1.23, 2.130422493309719]],
"hv_a": 2135.4,
"valley_name": "K",
"inter_idxs": [[0,0],[1,0],[1,1]],
"inter_amps": [[[80,90],[90,80]], [[80,90],[90,80]], [[80,90],[90,80]]],
"inter_phas": [[[0,0],[0,0]], [[0,-120],[120,0]], [[0,120],[-120,0]]],
"k_path": [[0,0],[0.666666,0.333333],[0.5,0.5],[0,0]],
"nk": 201,
"labels": ["G","K","M","G"],
"ylim": [-200, 200]
}
}
E) k·p: Chern number
{
"mode": "kp",
"task": "chern",
"theta_deg": 1.2,
"io": { "output_dir": "./outputs", "fig_band": "kp_band.png" },
"kp": {
"tr": 4,
"valley_pos": [-0.6666667, -0.3333333],
"mono_lat": [[3.46, 0.0], [1.73, 2.996447897094158]],
"mass": [0.62,0.62],
"valley_name": "K",
"V_z": 0.0,
"m_z": 0.0,
"inter_idxs": [[0,0],[1,1],[1,0]],
"inter_amps": [-8.5, -8.5, -8.5],
"inter_phas": [0, 0, 0],
"intra_t_idxs": [[1,0],[1,1],[0,1],[-1,0],[-1,-1],[0,-1]],
"intra_t_amps": [8, 8, 8, 8, 8, 8],
"intra_t_phas": [-89.6, 89.6, -89.6, 89.6, -89.6, 89.6],
"intra_b_idxs": [[1,0],[1,1],[0,1],[-1,0],[-1,-1],[0,-1]],
"intra_b_amps": [8, 8, 8, 8, 8, 8],
"intra_b_phas": [89.6, -89.6, 89.6, -89.6, 89.6, -89.6],
"n_mesh": 21,
"band_index": [1, 2, 3]
}
}
Outputs
Typical outputs under io.output_dir (default ./outputs):
Band / k-path:
BAND.dat(k-distance vs energy; band-by-band blocks)band.txt(raw eigenvalue arrays)k_vec.txt,k_dist.txt,k_node.txtk_labels.txt- band figure (e.g.,
tb_band.pdf,kp_band.pdf)
Geometry:
POSCAR(generated/copy depending on task)- moiré points figure (e.g.,
moire_points.pdf) commensurate_angle.txtandcomm_angles.pdf(fortask="find_com")
Reproducibility:
metadata.json(versions, BLAS backend, platform info, input hash, etc.)
Parallelism & performance notes
- TB parallelism: set
tb.cores > 1. - For batch jobs, set BLAS thread environment variables explicitly (e.g.,
OMP_NUM_THREADS,MKL_NUM_THREADS,OPENBLAS_NUM_THREADS). - For large problems, consider sparse workflows (
tb.isparse=true) where applicable.
How to cite
- Method paper: Phys. Rev. B 111, 075434 (2025), arXiv:2509.13114
Troubleshooting
- Unknown mode/task: ensure
mode∈{struc, tb, kp, mono}andtaskmatches the selected mode. - k·p error about
massvshv_a: you must specify exactly one ofkp.massorkp.hv_a. - No plots: set
io.show_plots=true, or open the saved figure files underoutputs/. - Parallel issues on Windows: try
cores=1first and then increase; prefer WSL for HPC-like usage.
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
Built Distribution
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 moirestudio-1.0.1.tar.gz.
File metadata
- Download URL: moirestudio-1.0.1.tar.gz
- Upload date:
- Size: 88.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cd50648a0f3f81e374ab1fbd00515731ae8f7d1bdfccf37723b92f52c311e87
|
|
| MD5 |
0c66801fa11767746348ba071e7e0b9e
|
|
| BLAKE2b-256 |
a70cef5e1214951d3f4fce27c0b45c71a718e681c57d661f51fa092127434881
|
File details
Details for the file moirestudio-1.0.1-py3-none-any.whl.
File metadata
- Download URL: moirestudio-1.0.1-py3-none-any.whl
- Upload date:
- Size: 89.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a63f4daeae305981dccfcf0112d9820dbfdd63ba5e8af17c5171502c38700f12
|
|
| MD5 |
1c4f688ca8706485f4c977e0e4a3ee7a
|
|
| BLAKE2b-256 |
b5d4777f9193f913e4a79efab6f6c471041bdce446ef2b278a09851fdbfcbf67
|