MoireStudio 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ Copyright (C) <2026> <Junxi Yu>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,429 @@
1
+ Metadata-Version: 2.4
2
+ Name: MoireStudio
3
+ Version: 1.0.0
4
+ Summary: Universal Twisted Electronic Structure Calculation Package
5
+ Author: Junxi Yu
6
+ License: Copyright (C) <2026> <Junxi Yu>
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: numpy>=1.23
17
+ Requires-Dist: scipy>=1.9
18
+ Requires-Dist: matplotlib>=3.7
19
+ Dynamic: license-file
20
+
21
+ # MoireStudio
22
+
23
+ MoireStudio is a general-purpose toolkit for **twisted / moiré electronic-structure calculations**.
24
+
25
+ It integrates:
26
+
27
+ - **Geometry**: commensurate-angle search, moiré supercell generation (POSCAR-based), moiré point visualization
28
+ - **Relaxation**: in-plane and out-of-plane relaxation patterns and relaxed structures (analytic framework integrated)
29
+ - **Tight-binding / Wannier**: twisted TB band structures from POSCAR or Wannier90-like models; dense and sparse workflows
30
+ - **Continuum k·p**: generic and template-based (TBG / tTMD) continuum models; band structures and Chern numbers
31
+ - **Reproducibility**: automatic run metadata logging (e.g., `outputs/metadata.json`) and standardized output files
32
+
33
+ ## Table of contents
34
+
35
+ - [Requirements](#requirements)
36
+ - [Installation](#installation)
37
+ - [Quick start](#quick-start)
38
+ - [Command-line interface](#command-line-interface)
39
+ - [Input file: `input.json`](#input-file-inputjson)
40
+ - [Modes & tasks](#modes--tasks)
41
+ - [Examples](#examples)
42
+ - [Outputs](#outputs)
43
+ - [Parallelism & performance notes](#parallelism--performance-notes)
44
+ - [How to cite](#how-to-cite)
45
+ - [Troubleshooting](#troubleshooting)
46
+
47
+ ## Requirements
48
+
49
+ - Python ≥ 3.9
50
+ - Core dependencies: `numpy`, `scipy`, `matplotlib`
51
+
52
+ For best performance, use a NumPy/SciPy build linked against optimized BLAS/LAPACK (e.g., MKL/OpenBLAS).
53
+
54
+ ## Installation
55
+
56
+ ### Option A: package install (recommended)
57
+
58
+ From the repository root:
59
+
60
+ ```bash
61
+ pip install moirestudio-1.0.0-py3-none-any.whl
62
+ ```
63
+
64
+ ### Option B: script execution
65
+
66
+ If you keep a script-style layout, you can run:
67
+
68
+ ```bash
69
+ python driver.py --input input.json
70
+ ```
71
+
72
+ ## Quick start
73
+
74
+ 1) Prepare an `input.json` in your working directory.
75
+ 2) Put required inputs under `./inputs` (default) or set `io.input_dir`.
76
+ 3) Run:
77
+
78
+ ```bash
79
+ python driver.py --input input.json
80
+ ```
81
+
82
+ The default output directory is `./outputs` (override with `io.output_dir`).
83
+
84
+ ## Command-line interface
85
+
86
+ Typical commands:
87
+
88
+ ```bash
89
+ python driver.py --input input.json
90
+ python driver.py --input input.json --quiet
91
+ python driver.py --input input.json --no-color
92
+ python driver.py --version
93
+ python driver.py --cite
94
+ ```
95
+
96
+ ## Input file: `input.json`
97
+
98
+ MoireStudio uses a JSON file with **separate `mode` and `task` fields**.
99
+
100
+ ```json
101
+ {
102
+ "mode": "struc | tb | kp | mono",
103
+ "task": "gen_struc | find_com | band | chern",
104
+ "theta_deg": 1.10,
105
+ "io": {},
106
+ "struc": {},
107
+ "relax": {},
108
+ "tb": {},
109
+ "kp": {}
110
+ }
111
+ ```
112
+
113
+ - `theta_deg` is a **top-level** key.
114
+ - Only the blocks relevant to the selected `mode`/`task` are required.
115
+
116
+ ### Common IO keys (`io`)
117
+
118
+ - `io.input_dir` (default `./inputs`)
119
+ - `io.output_dir` (default `./outputs`)
120
+ - `io.fig_band` (band figure filename; falls back to `io.figure`, then `<task>.pdf`)
121
+ - `io.fig_moire` (default `moire_points.pdf`)
122
+ - `io.show_plots` (default `false`)
123
+
124
+ Heterobilayer helper keys (used when `struc.ihetero=true`):
125
+
126
+ - `io.t_prefix`, `io.b_prefix`
127
+ - `io.t_fermi_energy`, `io.b_fermi_energy`
128
+
129
+ ### Structure block (`struc`)
130
+
131
+ Core selectors:
132
+
133
+ - `struc.read_mode`: `"POSCAR"` or `"model"`
134
+ - `struc.read_layer`: `"bilayer"` or `"monolayer"`
135
+ - `struc.ihetero`: `true/false`
136
+
137
+ POSCAR inputs:
138
+
139
+ - `struc.pos_path` (default `io.input_dir`)
140
+ - `struc.pos_prefix` (default `"POSCAR"`)
141
+
142
+ Interlayer distance (angstrom):
143
+
144
+ - Use `struc.d_0` (default 3.5), or
145
+ - Provide `struc.d_AA` and `struc.d_AB` (if missing, falls back to `d_0`).
146
+
147
+ Moiré supercell generation (`task="gen_struc"`):
148
+
149
+ - `struc.zero_point` (default `[0,0]`)
150
+ - `struc.lim` (default `20`)
151
+ - `struc.search` (default `0`)
152
+ - `struc.accurate` (default `0.01`)
153
+ - `struc.if_gen_pos` (default `true`)
154
+ - `struc.write_by_hand` (optional manual selection for Lm)
155
+
156
+ Commensurate-angle scan (`task="find_com"`):
157
+
158
+ - `struc.max_angle` (default `180`)
159
+ - `struc.min_angle` (default `1`)
160
+ - `struc.lim` (default `10`)
161
+ - `struc.step` (default `0.01`)
162
+ - `struc.accurate` (default `0.01`)
163
+
164
+ ### Relaxation block (`relax`)
165
+
166
+ - `relax.irelax`: enable/disable relaxation
167
+ - `relax.order_num`: harmonic order (default `0`)
168
+ - `relax.kappa_parallel`: in-plane relaxation strength parameter
169
+ - `relax.kappa_perp`: out-of-plane relaxation strength parameter
170
+ - Optional pattern indices:
171
+ - `relax.u_in_idxs`
172
+ - `relax.u_out_idxs`
173
+
174
+ ### TB block (`tb`)
175
+
176
+ Band / k-path:
177
+
178
+ - `tb.k_path`: list of fractional k-points
179
+ - `tb.nk`: number of k points along the path (default `121`)
180
+ - `tb.labels`: labels for k nodes (optional)
181
+ - `tb.ylim`: plot energy window (optional)
182
+
183
+ Compute options:
184
+
185
+ - `tb.cores` (default `1`)
186
+ - `tb.isparse` (default `false`)
187
+ - `tb.inter_coe` (default `1`)
188
+ - `tb.isymmetry` (optional)
189
+ - `tb.ioutwannier` (optional; dense only)
190
+
191
+ Wannier-like model input:
192
+
193
+ ```json
194
+ "tb": {
195
+ "wannier": {
196
+ "prefix": "wannier90",
197
+ "fermi_energy": 0.0
198
+ }
199
+ }
200
+ ```
201
+
202
+ If `fermi_energy` is omitted, MoireStudio may try reading `inputs/FERMI_ENERGY`; otherwise it defaults to `0`.
203
+
204
+ ### k·p block (`kp`)
205
+
206
+ Two usage styles:
207
+
208
+ 1) **Template mode** (recommended for standard models)
209
+
210
+ - `kp.system_name`: `"TBG"` or `"tTMD"`
211
+ - `kp.lat_a`, `kp.valley_idx`
212
+ - For tTMD: `kp.omega`, `kp.V`, `kp.psi`
213
+ - For TBG: `kp.u1`, `kp.u2`
214
+
215
+ 2) **Generic mode** (fully explicit)
216
+
217
+ - `kp.tr`: truncation shell (default `3`)
218
+ - `kp.valley_pos`: fractional coordinates (default `[2/3, 1/3]`)
219
+ - `kp.mono_lat`: 2x2 real-space lattice vectors
220
+ - `kp.V_z`, `kp.m_z`: onsite terms
221
+ - Specify **exactly one** of:
222
+ - `kp.hv_a` (Dirac-like 2-band), or
223
+ - `kp.mass: [mx, my]` (effective-mass 1-band)
224
+
225
+ Couplings are specified in **amplitude + phase** form (phases in degrees):
226
+
227
+ - Interlayer: `kp.inter_idxs`, `kp.inter_amps`, `kp.inter_phas`
228
+ - Intralayer top: `kp.intra_t_idxs`, `kp.intra_t_amps`, `kp.intra_t_phas`
229
+ - Intralayer bottom: `kp.intra_b_idxs`, `kp.intra_b_amps`, `kp.intra_b_phas`
230
+
231
+ Band plotting:
232
+
233
+ - `kp.k_path`, `kp.nk`, `kp.labels`, `kp.ylim`
234
+ - `kp.fermi_shift`: number, or `"max"` / `"min"`
235
+
236
+ Chern number (`task="chern"`):
237
+
238
+ - `kp.n_mesh` (default `25`)
239
+ - `kp.band_index` (default `1`)
240
+
241
+ ## Modes & tasks
242
+
243
+ - `mode="struc"`:
244
+ - `task="gen_struc"`: generate moiré supercell (optionally relaxed) and write POSCAR
245
+ - `task="find_com"`: scan commensurate angles and write lists/plots
246
+
247
+ - `mode="tb"`:
248
+ - `task="band"`: TB band structure from POSCAR or Wannier model
249
+
250
+ - `mode="kp"`:
251
+ - `task="band"`: continuum k·p band structure
252
+ - `task="chern"`: Chern number on a k-mesh
253
+
254
+ - `mode="mono"`:
255
+ - `task="band"`: monolayer band structure from a Wannier model
256
+
257
+ ## Examples
258
+
259
+ ### A) Geometry: generate moiré structure
260
+
261
+ ```json
262
+ {
263
+ "mode": "struc",
264
+ "task": "gen_struc",
265
+ "theta_deg": 21.79,
266
+ "struc": {
267
+ "lim": 50,
268
+ "read_mode": "POSCAR",
269
+ "read_layer": "bilayer",
270
+ "ihetero": false,
271
+ "d_AA": 3.60,
272
+ "d_AB": 3.60,
273
+ "if_plot": false,
274
+ "zero_point": [0, 0]
275
+ }
276
+ }
277
+
278
+ ```
279
+
280
+ ### B) Geometry: scan commensurate angles
281
+
282
+ ```json
283
+ {
284
+ "mode":"struc",
285
+ "task": "find_com",
286
+ "struc":{
287
+ "read_mode": "POSCAR",
288
+ "step": 0.01,
289
+ "lim":30,
290
+ "accurate":5e-3,
291
+ "max_angle": 23,
292
+ "min_angle": 1
293
+ }
294
+ }
295
+ ```
296
+
297
+ ### C) TB: band structure
298
+
299
+ ```json
300
+ {
301
+ "mode": "tb",
302
+ "task": "band",
303
+ "theta_deg": 21.79,
304
+ "io": {
305
+ "output_dir": "./outputs",
306
+ "input_dir": "./inputs",
307
+ "fig_band": "band.pdf"
308
+ },
309
+ "struc": {
310
+ "read_mode": "WANNIER",
311
+ "read_layer": "bilayer",
312
+ "bilayer_num": 2,
313
+ "ihetero": false,
314
+ "d_AA": 3.60,
315
+ "d_AB": 3.35,
316
+ "lim": 80,
317
+ "zero_point": [[0.0, 0.0],[0.0,0.0]],
318
+ "if_plot": false
319
+ },
320
+ "tb": {
321
+ "wannier": {
322
+ "prefix": "wannier90"
323
+ },
324
+ "cores": 1,
325
+ "isparse": false,
326
+ "k_path": [[0,0,0],[0.333333,0.333333,0],[0.5,0.0,0],[0,0,0]],
327
+ "nk": 121,
328
+ "labels": ["G","K","M","G"],
329
+ "ylim": [-3, 3]
330
+ }
331
+ }
332
+
333
+ ```
334
+
335
+ ### D) k·p: generic band structure (Dirac-like)
336
+
337
+ ```json
338
+
339
+ {
340
+ "mode": "kp",
341
+ "task": "band",
342
+ "theta_deg": 1.05,
343
+ "io": { "output_dir": "./outputs", "fig_band": "kp_band.pdf" },
344
+ "kp": {
345
+ "tr": 5,
346
+ "valley_pos": [-0.6666667, -0.3333333],
347
+ "mono_lat": [[2.46, 0.0], [1.23, 2.130422493309719]],
348
+ "hv_a": 2135.4,
349
+ "valley_name": "K",
350
+ "inter_idxs": [[0,0],[1,0],[1,1]],
351
+ "inter_amps": [[[80,90],[90,80]], [[80,90],[90,80]], [[80,90],[90,80]]],
352
+ "inter_phas": [[[0,0],[0,0]], [[0,-120],[120,0]], [[0,120],[-120,0]]],
353
+ "k_path": [[0,0],[0.666666,0.333333],[0.5,0.5],[0,0]],
354
+ "nk": 201,
355
+ "labels": ["G","K","M","G"],
356
+ "ylim": [-200, 200]
357
+ }
358
+ }
359
+ ```
360
+
361
+ ### E) k·p: Chern number
362
+
363
+ ```json
364
+ {
365
+ "mode": "kp",
366
+ "task": "chern",
367
+ "theta_deg": 1.10,
368
+ "io": { "output_dir": "./outputs" },
369
+ "kp": {
370
+ "tr": 3,
371
+ "hv_a": 1.0,
372
+ "V_z": 0.0,
373
+ "m_z": 0.0,
374
+ "valley_pos": [0.6666667, 0.3333333],
375
+ "mono_lat": [[2.46, 0.0], [1.23, 2.13162820728]],
376
+ "inter_idxs": [[0,0]],
377
+ "inter_amps": [90],
378
+ "inter_phas": [0],
379
+ "intra_t_idxs": [],
380
+ "intra_t_amps": [],
381
+ "intra_t_phas": [],
382
+ "intra_b_idxs": [],
383
+ "intra_b_amps": [],
384
+ "intra_b_phas": [],
385
+ "n_mesh": 31,
386
+ "band_index": 1
387
+ },
388
+ "relax": { "irelax": false }
389
+ }
390
+ ```
391
+
392
+ ## Outputs
393
+
394
+ Typical outputs under `io.output_dir` (default `./outputs`):
395
+
396
+ Band / k-path:
397
+
398
+ - `BAND.dat` (k-distance vs energy; band-by-band blocks)
399
+ - `band.txt` (raw eigenvalue arrays)
400
+ - `k_vec.txt`, `k_dist.txt`, `k_node.txt`
401
+ - `k_labels.txt`
402
+ - band figure (e.g., `tb_band.pdf`, `kp_band.pdf`)
403
+
404
+ Geometry:
405
+
406
+ - `POSCAR` (generated/copy depending on task)
407
+ - moiré points figure (e.g., `moire_points.pdf`)
408
+ - `commensurate_angle.txt` and `comm_angles.pdf` (for `task="find_com"`)
409
+
410
+ Reproducibility:
411
+
412
+ - `metadata.json` (versions, BLAS backend, platform info, input hash, etc.)
413
+
414
+ ## Parallelism & performance notes
415
+
416
+ - TB parallelism: set `tb.cores > 1`.
417
+ - For batch jobs, set BLAS thread environment variables explicitly (e.g., `OMP_NUM_THREADS`, `MKL_NUM_THREADS`, `OPENBLAS_NUM_THREADS`).
418
+ - For large problems, consider sparse workflows (`tb.isparse=true`) where applicable.
419
+
420
+ ## How to cite
421
+
422
+ - Method paper: **Phys. Rev. B 111, 075434 (2025)**, **arXiv:2509.13114**
423
+
424
+ ## Troubleshooting
425
+
426
+ - **Unknown mode/task**: ensure `mode` ∈ `{struc, tb, kp, mono}` and `task` matches the selected mode.
427
+ - **k·p error about `mass` vs `hv_a`**: you must specify **exactly one** of `kp.mass` or `kp.hv_a`.
428
+ - **No plots**: set `io.show_plots=true`, or open the saved figure files under `outputs/`.
429
+ - **Parallel issues on Windows**: try `tb.cores=1` first and then increase; prefer WSL for HPC-like usage.