mcta 0.0.34__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.

Potentially problematic release.


This version of mcta might be problematic. Click here for more details.

Files changed (97) hide show
  1. mcta-0.0.34/LICENSE +21 -0
  2. mcta-0.0.34/PKG-INFO +187 -0
  3. mcta-0.0.34/README.md +140 -0
  4. mcta-0.0.34/mcta/__init__.py +11 -0
  5. mcta-0.0.34/mcta/__main__.py +118 -0
  6. mcta-0.0.34/mcta/_flags.py +375 -0
  7. mcta-0.0.34/mcta/bandplot/dos.py +204 -0
  8. mcta-0.0.34/mcta/bandplot/mass.py +164 -0
  9. mcta-0.0.34/mcta/bandplot/ph.py +1437 -0
  10. mcta-0.0.34/mcta/bandplot/ph3.py +893 -0
  11. mcta-0.0.34/mcta/bandplot/ph3doc.py +232 -0
  12. mcta-0.0.34/mcta/bandplot/phdoc.py +256 -0
  13. mcta-0.0.34/mcta/bandplot/phdos.py +193 -0
  14. mcta-0.0.34/mcta/bandplot/phono3py_docs.json +1361 -0
  15. mcta-0.0.34/mcta/bandplot/phonopy_docs.json +3295 -0
  16. mcta-0.0.34/mcta/bandplot/plots.py +576 -0
  17. mcta-0.0.34/mcta/bandplot/pplots.py +439 -0
  18. mcta-0.0.34/mcta/bandplot/projected.py +220 -0
  19. mcta-0.0.34/mcta/bandplot/readdata.py +174 -0
  20. mcta-0.0.34/mcta/bandplot/vaspread.py +1047 -0
  21. mcta-0.0.34/mcta/bandplot/wrapper.py +842 -0
  22. mcta-0.0.34/mcta/mc/engine.py +1137 -0
  23. mcta-0.0.34/mcta/mc/geometry/__init__.py +55 -0
  24. mcta-0.0.34/mcta/mc/geometry/bilayer_aa.py +183 -0
  25. mcta-0.0.34/mcta/mc/geometry/bilayer_ab.py +275 -0
  26. mcta-0.0.34/mcta/mc/geometry/bilayer_ab_u_3.py +211 -0
  27. mcta-0.0.34/mcta/mc/geometry/from_structure.py +328 -0
  28. mcta-0.0.34/mcta/mc/geometry/simple_cubic.py +119 -0
  29. mcta-0.0.34/mcta/mc/geometry/square.py +190 -0
  30. mcta-0.0.34/mcta/mc/geometry/triangular.py +195 -0
  31. mcta-0.0.34/mcta/mc/geometry/xy_geometry.py +238 -0
  32. mcta-0.0.34/mcta/mc/parallel.py +160 -0
  33. mcta-0.0.34/mcta/mc/plots.py +303 -0
  34. mcta-0.0.34/mcta/mc/wrapper.py +287 -0
  35. mcta-0.0.34/mcta/mc/xy_engine.py +393 -0
  36. mcta-0.0.34/mcta/seek/agent.py +283 -0
  37. mcta-0.0.34/mcta/seek/cli.py +359 -0
  38. mcta-0.0.34/mcta/seek/config.py +181 -0
  39. mcta-0.0.34/mcta/seek/curate.py +651 -0
  40. mcta-0.0.34/mcta/seek/llm.py +42 -0
  41. mcta-0.0.34/mcta/seek/ml.py +230 -0
  42. mcta-0.0.34/mcta/seek/sqs.py +504 -0
  43. mcta-0.0.34/mcta/seek/state.py +70 -0
  44. mcta-0.0.34/mcta/seek/tools.py +776 -0
  45. mcta-0.0.34/mcta/server/3Dmol.LICENSE.txt +90 -0
  46. mcta-0.0.34/mcta/server/3dmol-min.js +2 -0
  47. mcta-0.0.34/mcta/server/__init__.py +1415 -0
  48. mcta-0.0.34/mcta/server/_handlers.py +1845 -0
  49. mcta-0.0.34/mcta/server/_page.py +11 -0
  50. mcta-0.0.34/mcta/server/_remote.py +2218 -0
  51. mcta-0.0.34/mcta/server/_structure.py +606 -0
  52. mcta-0.0.34/mcta/server/_terminal.py +233 -0
  53. mcta-0.0.34/mcta/server/_util.py +559 -0
  54. mcta-0.0.34/mcta/server/app.css +589 -0
  55. mcta-0.0.34/mcta/server/app.js +3815 -0
  56. mcta-0.0.34/mcta/server/page.html +418 -0
  57. mcta-0.0.34/mcta/server/viewer.js +5814 -0
  58. mcta-0.0.34/mcta/server/xterm.LICENSE.txt +21 -0
  59. mcta-0.0.34/mcta/server/xterm.css +218 -0
  60. mcta-0.0.34/mcta/server/xterm.js +8 -0
  61. mcta-0.0.34/mcta/sh/cli.py +222 -0
  62. mcta-0.0.34/mcta/sh/scripts/ck.sh +5 -0
  63. mcta-0.0.34/mcta/sh/scripts/cp.sh +3 -0
  64. mcta-0.0.34/mcta/sh/scripts/en.sh +3 -0
  65. mcta-0.0.34/mcta/sh/scripts/ex.sh +6 -0
  66. mcta-0.0.34/mcta/sh/scripts/gr.sh +5 -0
  67. mcta-0.0.34/mcta/sh/scripts/ig.sh +8 -0
  68. mcta-0.0.34/mcta/sh/scripts/il.sh +8 -0
  69. mcta-0.0.34/mcta/sh/scripts/kb.sh +48 -0
  70. mcta-0.0.34/mcta/sh/scripts/kg.sh +18 -0
  71. mcta-0.0.34/mcta/sh/scripts/make_supercell.py +249 -0
  72. mcta-0.0.34/mcta/sh/scripts/md.sh +24 -0
  73. mcta-0.0.34/mcta/sh/scripts/mv.sh +3 -0
  74. mcta-0.0.34/mcta/sh/scripts/po.sh +80 -0
  75. mcta-0.0.34/mcta/sh/scripts/pr.sh +3 -0
  76. mcta-0.0.34/mcta/sh/scripts/re.sh +5 -0
  77. mcta-0.0.34/mcta/sh/scripts/sh.sh +3 -0
  78. mcta-0.0.34/mcta/sh/scripts/su.sh +15 -0
  79. mcta-0.0.34/mcta/sh/scripts/sy.sh +42 -0
  80. mcta-0.0.34/mcta/sh/scripts/symmetry_info.py +266 -0
  81. mcta-0.0.34/mcta/sh/scripts/x.sh +32 -0
  82. mcta-0.0.34/mcta/sh/scripts/xy.sh +36 -0
  83. mcta-0.0.34/mcta/sh/scripts/y.sh +32 -0
  84. mcta-0.0.34/mcta/sh/scripts/z2.sh +44 -0
  85. mcta-0.0.34/mcta/sh/scripts/z2_convert.py +247 -0
  86. mcta-0.0.34/mcta/skl/__init__.py +4 -0
  87. mcta-0.0.34/mcta/skl/cli.py +70 -0
  88. mcta-0.0.34/mcta/sqs/__init__.py +4 -0
  89. mcta-0.0.34/mcta/sqs/cli.py +141 -0
  90. mcta-0.0.34/mcta.egg-info/PKG-INFO +187 -0
  91. mcta-0.0.34/mcta.egg-info/SOURCES.txt +95 -0
  92. mcta-0.0.34/mcta.egg-info/dependency_links.txt +1 -0
  93. mcta-0.0.34/mcta.egg-info/entry_points.txt +14 -0
  94. mcta-0.0.34/mcta.egg-info/requires.txt +25 -0
  95. mcta-0.0.34/mcta.egg-info/top_level.txt +1 -0
  96. mcta-0.0.34/pyproject.toml +98 -0
  97. mcta-0.0.34/setup.cfg +4 -0
mcta-0.0.34/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
mcta-0.0.34/PKG-INFO ADDED
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcta
3
+ Version: 0.0.34
4
+ Summary: McTa (Meta Crystal Toolkit & Analysis).
5
+ Author: Kan
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://lkccrr.github.io/mcta/
8
+ Project-URL: Documentation, https://github.com/lkccrr/mcta#readme
9
+ Project-URL: Repository, https://github.com/lkccrr/mcta
10
+ Keywords: DFT,VASP,DOS,band,plot,Phonon,materials-project,pymatgen,crystal-structure,SQS,Ising,Monte-Carlo,magnetism
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Topic :: Scientific/Engineering :: Physics
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Programming Language :: Python :: 3.15
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: numpy>=1.22.0
27
+ Requires-Dist: matplotlib>=3.6.0
28
+ Requires-Dist: ase>=3.22.0
29
+ Requires-Dist: spglib>=2.0
30
+ Requires-Dist: paramiko>=3.0
31
+ Provides-Extra: seek
32
+ Requires-Dist: pymatgen>=2024.1.1; extra == "seek"
33
+ Requires-Dist: mp-api>=0.40; extra == "seek"
34
+ Requires-Dist: scikit-learn>=1.3; extra == "seek"
35
+ Requires-Dist: joblib>=1.3; extra == "seek"
36
+ Requires-Dist: openai>=1.30; extra == "seek"
37
+ Provides-Extra: skl
38
+ Requires-Dist: scikit-learn>=1.3; extra == "skl"
39
+ Requires-Dist: joblib>=1.3; extra == "skl"
40
+ Provides-Extra: sqs
41
+ Requires-Dist: sqsgenerator>=0.5; extra == "sqs"
42
+ Provides-Extra: mc
43
+ Requires-Dist: numba>=0.54.0; extra == "mc"
44
+ Provides-Extra: all
45
+ Requires-Dist: mcta[mc,seek,skl,sqs]; extra == "all"
46
+ Dynamic: license-file
47
+
48
+ [![mcta](https://img.shields.io/pypi/v/mcta?style=flat-square)](https://pypi.org/project/mcta/)
49
+ [![mcta](https://img.shields.io/pypi/pyversions/mcta?style=flat-square)](https://pypi.org/project/mcta/)
50
+ [![mcta](https://img.shields.io/pypi/l/mcta?style=flat-square)](https://pypi.org/project/mcta/)
51
+ [![mcta](https://img.shields.io/pypi/dm/mcta?style=flat-square)](https://pypi.org/project/mcta/)
52
+ [![mcta](https://img.shields.io/pypi/wheel/mcta?style=flat-square)](https://pypi.org/project/mcta/)
53
+ [![mcta](https://img.shields.io/github/last-commit/lkccrr/mcta?style=flat-square)](https://github.com/lkccrr/mcta)
54
+ [![mcta](https://img.shields.io/github/release-date/lkccrr/mcta?style=flat-square)](https://github.com/lkccrr/mcta)
55
+
56
+ ### Meta Crystal Toolkit & Analysis (McTa)
57
+
58
+ * Install (Python ≥ 3.9; core dependencies: `numpy`, `matplotlib`, `ase`, `spglib`, `paramiko`):
59
+ ```bash
60
+ pip install mcta # plotting tools only
61
+ pip install mcta[seek] # + mt.seek (pymatgen, mp-api, openai); also enables mt.skl
62
+ pip install mcta[skl] # + mt.skl (scikit-learn, joblib)
63
+ pip install mcta[sqs] # + mt.sqs (sqsgenerator)
64
+ pip install mcta[mc] # + mt.mc (numba)
65
+ pip install mcta[all] # all: seek + skl + sqs + mc
66
+ ```
67
+ Every extra is optional; only the tools that need one ask for it (`mt.seek` → `mcta[seek]`, `mt.skl` → `mcta[skl]`, `mt.sqs` → `mcta[sqs]`, `mt.mc` → `mcta[mc]`).
68
+ ***
69
+ <b><i>mt</i></b> prints an overview, checks the current directory and suggests the next command.
70
+ ***
71
+ <b><i>mt.band</i></b> / <b><i>mt.phband</i></b>: electronic and phonon band structures, with an optional DOS panel
72
+ * `mt.band` reads VASP output from a directory (`-i`, default: current), preferring it over `BAND.dat` / `PBAND*.dat` / `PDOS*.dat`; `-d` adds DOS, `-r -p Mo-d` adds projections, `-D -d` makes a spin-polarized mirror plot, `-m` calculates effective masses, and two or three directories compare calculations.
73
+ * Energies are shifted to the Fermi level (`--no-shift` disables this); `-l` sets k-path labels (from `KPOINTS` / `KLABELS` or computed automatically) and `--export-dat DIR` exports vaspkit-style data. For combined SCF-mesh/band-path calculations, only zero-weight path points are plotted (`--keep-weights` keeps every k point); vaspkit `.dat` files are used unchanged.
74
+ * `mt.phband` reads `BAND.dat` written by `phonopy-bandplot --gnuplot`; `-l` labels high-symmetry points, `-y` sets the frequency window, `-d [FILE]` adds a DOS panel sharing the axis (`projected_dos.dat` / `total_dos.dat` auto-detected), and `-B start end` breaks the axis for optical branches; two or three files are compared side by side.
75
+ ```bash
76
+ mt.band # bands of the current directory
77
+ mt.band -i calc_PBE -d -z # bands + DOS (DOSCAR or PDOS*.dat)
78
+ mt.band -i calc_PBE -r -p Mo-d # projected bands from PROCAR
79
+ mt.band -i calc_PBE -D -d # spin-polarized bands + mirror DOS
80
+ mt.band -i calc_PBE -m 0.15 # effective masses from EIGENVAL
81
+ mt.band -i calc_PBE calc_HSE # compare calculations
82
+ mt.phband -i BAND.dat -o BAND.png -l g m k g -d projected_dos.dat -z
83
+ mt.phband -B 23 100 -l g m k g -y -2 110 # broken axis
84
+ mt.phband -i BAND1.dat BAND2.dat -B 20 100 # several files
85
+ ```
86
+ ***
87
+ <b><i>mt.dos</i></b> / <b><i>mt.phdos</i></b>: standalone DOS figures for electrons or phonons, energy / frequency on the horizontal axis
88
+ * `mt.dos` reads `DOSCAR` (needs `LORBIT = 11`) or vaspkit `PDOS*.dat` / `TDOS*.dat`, from a directory or `.dat` files via `-i`; `-p` picks projections, `-e` renames the legend, `-x` sets the DOS range, `-y` the energy window, and `-z` fills the curves. `-n` exchanges the axes for the `mt.band -d` orientation, and `--no-mirror` keeps the spin-down DOS positive.
89
+ * `mt.phdos` reads `projected_dos.dat` / `total_dos.dat`; `-e`, `-x`, `-y` (frequency), `-z` work as above, and `-n` matches the `mt.phband -d` orientation.
90
+ ```bash
91
+ mt.dos -i calc # DOS from DOSCAR / PDOS*.dat (energy on x)
92
+ mt.dos -i calc -p d -x 0 30 # d-orbital PDOS with a fixed DOS range
93
+ mt.dos -i calc -o PDOS.png -z # filled curves
94
+ mt.dos -i calc -n # energy vertical (mt.band -d orientation)
95
+ mt.phdos -i calc -z # filled curves
96
+ mt.phdos -i calc -x 0 0.6 # fix the DOS range
97
+ mt.phdos -i calc -n # frequency vertical (mt.phband -d orientation)
98
+ ```
99
+ ***
100
+ <b><i>mt.ph</i></b> / <b><i>mt.ph3</i></b>: phonopy and phono3py workflow helpers
101
+ * `mt.ph` runs the interactive supercell &rarr; force constants &rarr; band &rarr; DOS workflow; `-b -d` writes `band.conf` + `mesh.conf`, `-Y` skips confirmation, and `-R` only prints commands. The unit cell is auto-detected (`POSCAR-unitcell` &rarr; `CONTCAR` &rarr; `POSCAR`) or set with `-c`; commands adapt to phonopy v3/v4.
102
+ * `mt.ph fs` collects force data (one `vasprun.xml` uses `--fc`, several files or displacement directories use `--sp -f`; sources come from names, `-n`, or `-x`); other steps include `band`, `dos`, `tprop`, `born`, `symmetry`, `qha`, and `gruneisen` (see `mt.ph -h`).
103
+ * `mt.ph3` guides supercell generation, force collection, and thermal conductivity, adapting to phono3py v3/v4 with the same `-Y` / `-R`; `-s` / `-S` set FC3 / FC2 supercell dimensions, `-c` the unit cell, and `--rd` creates random-direction displacements. `cf3` / `cf2` collect forces, `cfs` and `fs2f2` convert force-set formats, and `--sp` writes `phono3py_params.yaml`.
104
+ * `kappa` runs RTA by default (`--lbte` for direct LBTE), `kaccum` writes cumulative conductivity, and `kdeplot` shows lifetime distributions; `w` / `W` query the offline English/Chinese wordbook (`w c` lists setting tags, `--path` shows its location, `MT_PH_DOCS` selects a custom JSON file).
105
+ ```bash
106
+ mt.ph # interactive workflow (default: supercell)
107
+ mt.ph -b -d # write band.conf + mesh.conf
108
+ mt.ph fs 001-003 # collect forces from displacement directories
109
+ mt.ph w --dim BAND_LABELS # English original, then Chinese translation
110
+ mt.ph3 supercell -s 2 2 2 -S 4 4 4 # separate FC3 and FC2 supercells
111
+ mt.ph3 kappa -m 11 11 11 # RTA -> kappa-m111111.hdf5
112
+ mt.ph3 kaccum -k kappa-m111111.hdf5 # cumulative conductivity -> kaccum.dat
113
+ mt.ph3 w --br --symfc # English original, then Chinese translation
114
+ ```
115
+ ***
116
+ <b><i>mt.seek</i></b> / <b><i>mt.sqs</i></b> / <b><i>mt.skl</i></b>: structure retrieval, SQS generation, and data-driven analysis
117
+ * `mt.seek`: Materials Project retrieval and curation, run directly on the server. Retrieves structures and writes one export directory `<name>/` in the working root — containing `README.md`, `manifest.csv`, `mt.seek.db` and one `<id>/` directory per structure (CIF / POSCAR / JSON, plus INCAR / KPOINTS / job script when requested; POTCAR is concatenated into the POSCAR directory with `mt.sh po` when a pseudopotential directory is configured). No tarball, no upload; internal cache/state stay hidden in `.mt.seek/`. Also filters or deduplicates local datasets; no calculations run locally. Set the API key once (free account at https://next-gen.materialsproject.org).
118
+ * `mt.sqs`: special quasirandom structures from a custom unit cell. Reads POSCAR / CONTCAR / CIF / JSON, expands a supercell, and randomises one sublattice toward a target composition using `sqsgenerator`; no network access is required.
119
+ * `mt.skl`: data-driven analysis of exported structures with scikit-learn. Runs two regression tasks (`ehull` stability and `band_gap`) with a random forest and 5-fold cross-validation, writing results to `<home>/ml/`; `--home DIR` sets the working root (default: current directory).
120
+ ```bash
121
+ mkdir -p ~/.config/mcta
122
+ echo 'MP_API_KEY=your-key' >> ~/.config/mcta/config
123
+ chmod 600 ~/.config/mcta/config
124
+ mt.seek -c Ti-C -k 3 -n ti-c # search by chemical system, export top 3
125
+ mt.seek -f MoS2 -k 5 -F cif,poscar # search by formula
126
+ mt.seek -r -D 8 -o my-pick # deduplicate + pick 8 diverse structures
127
+ mt.sqs -c cell.vasp -a "Cu:0.5,Au:0.5" -x 4,4,4 -n cuau-sqs
128
+ mt.sqs -c LaAlO3.cif --host La -a "La:0.5,Sr:0.5" -x 2,2,2 # A-site only
129
+ mt.sqs -c cell.vasp -a Cu,Au --iterations 1000 --number 5 -R # dry-run: no disk write
130
+ mt.skl # analyse <name>/manifest.csv from each export bundle
131
+ ```
132
+ `mt.seek` exports land in `<name>/` directly under the working root (no `exports/`, no `.tar.gz`, no upload): each bundle holds `README.md`, `manifest.csv`, `mt.seek.db`, and one `<id>/` directory per structure containing that id's CIF / POSCAR / JSON (INCAR / KPOINTS / job script are written into the same `<id>/` when requested; POTCAR is generated there by `mt.sh po` only when a pseudopotential directory such as `PBE_PATH` is set and exists). `-I` accepts MP IDs, `-t` accepts natural-language tasks, and `-T` downloads more structures. `mt.sqs` bundles additionally contain `sqs.json` and `sqs_summary.csv`. `mt.seek -h` lists all options, LLM engines, and `MT_SEEK_*` environment variables; short options are case-sensitive; `mt.sqs -h` lists every flag and default.
133
+ > Structure data comes from the Materials Project: A. Jain et al., *APL Materials* 1, 011002 (2013).
134
+ ***
135
+ <b><i>mt.mc</i></b>: Monte Carlo simulation of phase transitions in 2D/3D magnetic materials
136
+ * Runs the Metropolis Ising model on built-in lattices (square, triangular, bilayer, simple-cubic) or any crystal structure (`-s POSCAR -A Fe -D 3.0 3.6 -x 2 -y 2 -z 2`); any of `-a`, `-J`, `-K` switches to the Heisenberg model. Requires `numba` (`pip install mcta[mc]`); ASE is needed for structure mode.
137
+ * `-x/-X`, `-y/-Y`, `-z/-Z` set the lattice size or supercell multiplier (default `32`, `-z` ignored for 2D); `-e/-w` set equilibration/sampling sweeps, `-p/-J/-K` couplings, `-a` anisotropy, `-i` initial state, and `-C` / `-W` / `-S` control parallel chains, replica exchange and reproducibility. `-t` accepts a count (`35`), a range (`20 25`), start/stop/step (`20 26 2`), separate temperatures (`20 25 30`), or chained ranges.
138
+ * Structure mode (`-s`) reads any ASE-supported file, picks magnetic atoms (`-A Fe,Co` or auto d/f-block), expands the supercell and builds the neighbor table by distance bins (`-D`); `--mom` sets nominal moments (default `2` &rarr; S=±1) and `--ini` the initial state (`fm` / `afm` / `random` or a ±1 list); `-c` is ignored with `-s`. Plots are automatic unless `-R`, and `-o FILE -I pdf` re-plots a finished run.
139
+ ```bash
140
+ mt.mc -x 128 -y 128 -t 0 40 2 -C 6 -S 42 # 6 parallel chains, reproducible
141
+ mt.mc -c triangular -t 0 60 2 -S 42 # triangular lattice
142
+ mt.mc -c square -a 0.1 -t 20 40 2 -p 5 -J 4 -K 3 # vector spins with anisotropy
143
+ mt.mc -s POSCAR -A Fe -D 2.7 3.2 -x 2 -y 2 -z 2 -t 10 30 10 -p 5 2 # from crystal
144
+ mt.mc -o square_Ising_32_32.log -I pdf # re-plot a finished run
145
+ ```
146
+ ***
147
+ <b><i>mt.sh</i></b>: run bash helper scripts by short name
148
+ * `mt.sh NAME [args...]` runs `NAME.sh` with bash; local `./NAME.sh` overrides `$MTSH_SCRIPTS`, then bundled scripts. Bare `mt.sh` lists available scripts.
149
+ * Strain scans `x|y|xy [POSCAR] [NPOINTS] [STEP]` write `<factor>/POSCAR` under `x/`, `y/`, or `xy/`; defaults are 4 points per side and step 0.01.
150
+ * `kb [POSCAR] [a [b [c]]] [OUT]` expands the structure with ASE and writes `SPOSCAR` by default; missing multipliers default to 1.
151
+ * `sy [POSCAR] [symprec]` reports spglib space-group and Wyckoff-site information; the default tolerance is `1e-3` &Aring;.
152
+ * Bundled VASP helpers target Linux/WSL; on Windows use Git Bash with `sed` / `awk` / `bc` available.
153
+ ```bash
154
+ mt.sh x # x strain: x/0.960 ... x/1.040 (8 points, step 0.01)
155
+ mt.sh y POSCAR 2 0.02 # y strain, 2 points per side, step 0.02
156
+ mt.sh xy POSCAR # x and y strained together
157
+ mt.sh kb POSCAR 2 2 1 # POSCAR -> SPOSCAR (2x2x1)
158
+ mt.sh sy POSCAR # space group + Wyckoff sites (symprec 1e-3)
159
+ mt.sh sy CONTCAR 0.0001 # tighter tolerance: may lower the symmetry
160
+ ```
161
+ ***
162
+ <b><i>mt.server</i></b>: local file service, structure viewer and terminal in the browser
163
+ * `mt.server` runs a token-protected web service for browsing, editing and downloading files from the `-d` directory, a browser PTY terminal, and a 3Dmol.js viewer for structures, trajectories and VASP charge densities; it listens on port 9068 by default (`-p`), can run in the foreground (`-f`) or over a Unix socket (`-c|--socket`), and is stopped with `-S` (`--status` lists ports, `-S --all` stops them all).
164
+ * With `-R user@host[:port]` it browses and transfers remote files over parallel SSH/SFTP channels using key or prompted-password login (`-i KEY` selects a private key; otherwise ssh-agent and `~/.ssh` defaults are tried), opens a remote `mt.server` for 3D parsing through a Unix-socket tunnel, can forward a remote web service with `-P` or `--socket`, and keeps a persistent per-host cache; `-D [RPORT [LPORT]]` uses SSH's built-in SOCKS5 to share the local network with the remote host (remote port first, local port second, both 9069 by default).
165
+ * XML and `.json` open as read-only highlighted text, Materials Studio `.xsd` opens as a 3D structure by default (read-only XML via "Open text"), and large files are paged on demand (2 MB text windows, 256 MB structures, 512 MB volumetric files, 1000 trajectory frames / 5 million atoms).
166
+ ```bash
167
+ mt.server # background on port 9068; the tokenized URL is printed
168
+ mt.server -d ./examples # serve a different directory
169
+ mt.server -p 8080 # another port
170
+ mt.server -L 0.0.0.0 # listen on all interfaces (asks for yes, then prints a warning)
171
+ mt.server -f # foreground; Ctrl+C to stop
172
+ mt.server -N # no token (asks for yes): open http://127.0.0.1:9068/ directly
173
+ mt.server -o run.log # keep the startup output in run.log (overwritten each start)
174
+ mt.server -R user@host:22 -d /home/user/project
175
+ mt.server -S # stop the service on port 9068
176
+ mt.server --status # list every port where mt.server is running
177
+ mt.server -S --all # stop all of them
178
+ ```
179
+
180
+ ***
181
+ <b><i>Third-party components</i></b>
182
+
183
+ `mt.server` bundles two browser assets, each redistributed under its own license. The full license texts ship with the package:
184
+ * **3Dmol.js** (BSD-3-Clause, based on GLmol / Three.js / jQuery) — `mcta/server/3Dmol.LICENSE.txt`.
185
+ * **xterm.js 5.5.0** (MIT) — `mcta/server/xterm.LICENSE.txt`.
186
+
187
+ McTa itself is licensed under the MIT License (`LICENSE`).
mcta-0.0.34/README.md ADDED
@@ -0,0 +1,140 @@
1
+ [![mcta](https://img.shields.io/pypi/v/mcta?style=flat-square)](https://pypi.org/project/mcta/)
2
+ [![mcta](https://img.shields.io/pypi/pyversions/mcta?style=flat-square)](https://pypi.org/project/mcta/)
3
+ [![mcta](https://img.shields.io/pypi/l/mcta?style=flat-square)](https://pypi.org/project/mcta/)
4
+ [![mcta](https://img.shields.io/pypi/dm/mcta?style=flat-square)](https://pypi.org/project/mcta/)
5
+ [![mcta](https://img.shields.io/pypi/wheel/mcta?style=flat-square)](https://pypi.org/project/mcta/)
6
+ [![mcta](https://img.shields.io/github/last-commit/lkccrr/mcta?style=flat-square)](https://github.com/lkccrr/mcta)
7
+ [![mcta](https://img.shields.io/github/release-date/lkccrr/mcta?style=flat-square)](https://github.com/lkccrr/mcta)
8
+
9
+ ### Meta Crystal Toolkit & Analysis (McTa)
10
+
11
+ * Install (Python &ge; 3.9; core dependencies: `numpy`, `matplotlib`, `ase`, `spglib`, `paramiko`):
12
+ ```bash
13
+ pip install mcta # plotting tools only
14
+ pip install mcta[seek] # + mt.seek (pymatgen, mp-api, openai); also enables mt.skl
15
+ pip install mcta[skl] # + mt.skl (scikit-learn, joblib)
16
+ pip install mcta[sqs] # + mt.sqs (sqsgenerator)
17
+ pip install mcta[mc] # + mt.mc (numba)
18
+ pip install mcta[all] # all: seek + skl + sqs + mc
19
+ ```
20
+ Every extra is optional; only the tools that need one ask for it (`mt.seek` &rarr; `mcta[seek]`, `mt.skl` &rarr; `mcta[skl]`, `mt.sqs` &rarr; `mcta[sqs]`, `mt.mc` &rarr; `mcta[mc]`).
21
+ ***
22
+ <b><i>mt</i></b> prints an overview, checks the current directory and suggests the next command.
23
+ ***
24
+ <b><i>mt.band</i></b> / <b><i>mt.phband</i></b>: electronic and phonon band structures, with an optional DOS panel
25
+ * `mt.band` reads VASP output from a directory (`-i`, default: current), preferring it over `BAND.dat` / `PBAND*.dat` / `PDOS*.dat`; `-d` adds DOS, `-r -p Mo-d` adds projections, `-D -d` makes a spin-polarized mirror plot, `-m` calculates effective masses, and two or three directories compare calculations.
26
+ * Energies are shifted to the Fermi level (`--no-shift` disables this); `-l` sets k-path labels (from `KPOINTS` / `KLABELS` or computed automatically) and `--export-dat DIR` exports vaspkit-style data. For combined SCF-mesh/band-path calculations, only zero-weight path points are plotted (`--keep-weights` keeps every k point); vaspkit `.dat` files are used unchanged.
27
+ * `mt.phband` reads `BAND.dat` written by `phonopy-bandplot --gnuplot`; `-l` labels high-symmetry points, `-y` sets the frequency window, `-d [FILE]` adds a DOS panel sharing the axis (`projected_dos.dat` / `total_dos.dat` auto-detected), and `-B start end` breaks the axis for optical branches; two or three files are compared side by side.
28
+ ```bash
29
+ mt.band # bands of the current directory
30
+ mt.band -i calc_PBE -d -z # bands + DOS (DOSCAR or PDOS*.dat)
31
+ mt.band -i calc_PBE -r -p Mo-d # projected bands from PROCAR
32
+ mt.band -i calc_PBE -D -d # spin-polarized bands + mirror DOS
33
+ mt.band -i calc_PBE -m 0.15 # effective masses from EIGENVAL
34
+ mt.band -i calc_PBE calc_HSE # compare calculations
35
+ mt.phband -i BAND.dat -o BAND.png -l g m k g -d projected_dos.dat -z
36
+ mt.phband -B 23 100 -l g m k g -y -2 110 # broken axis
37
+ mt.phband -i BAND1.dat BAND2.dat -B 20 100 # several files
38
+ ```
39
+ ***
40
+ <b><i>mt.dos</i></b> / <b><i>mt.phdos</i></b>: standalone DOS figures for electrons or phonons, energy / frequency on the horizontal axis
41
+ * `mt.dos` reads `DOSCAR` (needs `LORBIT = 11`) or vaspkit `PDOS*.dat` / `TDOS*.dat`, from a directory or `.dat` files via `-i`; `-p` picks projections, `-e` renames the legend, `-x` sets the DOS range, `-y` the energy window, and `-z` fills the curves. `-n` exchanges the axes for the `mt.band -d` orientation, and `--no-mirror` keeps the spin-down DOS positive.
42
+ * `mt.phdos` reads `projected_dos.dat` / `total_dos.dat`; `-e`, `-x`, `-y` (frequency), `-z` work as above, and `-n` matches the `mt.phband -d` orientation.
43
+ ```bash
44
+ mt.dos -i calc # DOS from DOSCAR / PDOS*.dat (energy on x)
45
+ mt.dos -i calc -p d -x 0 30 # d-orbital PDOS with a fixed DOS range
46
+ mt.dos -i calc -o PDOS.png -z # filled curves
47
+ mt.dos -i calc -n # energy vertical (mt.band -d orientation)
48
+ mt.phdos -i calc -z # filled curves
49
+ mt.phdos -i calc -x 0 0.6 # fix the DOS range
50
+ mt.phdos -i calc -n # frequency vertical (mt.phband -d orientation)
51
+ ```
52
+ ***
53
+ <b><i>mt.ph</i></b> / <b><i>mt.ph3</i></b>: phonopy and phono3py workflow helpers
54
+ * `mt.ph` runs the interactive supercell &rarr; force constants &rarr; band &rarr; DOS workflow; `-b -d` writes `band.conf` + `mesh.conf`, `-Y` skips confirmation, and `-R` only prints commands. The unit cell is auto-detected (`POSCAR-unitcell` &rarr; `CONTCAR` &rarr; `POSCAR`) or set with `-c`; commands adapt to phonopy v3/v4.
55
+ * `mt.ph fs` collects force data (one `vasprun.xml` uses `--fc`, several files or displacement directories use `--sp -f`; sources come from names, `-n`, or `-x`); other steps include `band`, `dos`, `tprop`, `born`, `symmetry`, `qha`, and `gruneisen` (see `mt.ph -h`).
56
+ * `mt.ph3` guides supercell generation, force collection, and thermal conductivity, adapting to phono3py v3/v4 with the same `-Y` / `-R`; `-s` / `-S` set FC3 / FC2 supercell dimensions, `-c` the unit cell, and `--rd` creates random-direction displacements. `cf3` / `cf2` collect forces, `cfs` and `fs2f2` convert force-set formats, and `--sp` writes `phono3py_params.yaml`.
57
+ * `kappa` runs RTA by default (`--lbte` for direct LBTE), `kaccum` writes cumulative conductivity, and `kdeplot` shows lifetime distributions; `w` / `W` query the offline English/Chinese wordbook (`w c` lists setting tags, `--path` shows its location, `MT_PH_DOCS` selects a custom JSON file).
58
+ ```bash
59
+ mt.ph # interactive workflow (default: supercell)
60
+ mt.ph -b -d # write band.conf + mesh.conf
61
+ mt.ph fs 001-003 # collect forces from displacement directories
62
+ mt.ph w --dim BAND_LABELS # English original, then Chinese translation
63
+ mt.ph3 supercell -s 2 2 2 -S 4 4 4 # separate FC3 and FC2 supercells
64
+ mt.ph3 kappa -m 11 11 11 # RTA -> kappa-m111111.hdf5
65
+ mt.ph3 kaccum -k kappa-m111111.hdf5 # cumulative conductivity -> kaccum.dat
66
+ mt.ph3 w --br --symfc # English original, then Chinese translation
67
+ ```
68
+ ***
69
+ <b><i>mt.seek</i></b> / <b><i>mt.sqs</i></b> / <b><i>mt.skl</i></b>: structure retrieval, SQS generation, and data-driven analysis
70
+ * `mt.seek`: Materials Project retrieval and curation, run directly on the server. Retrieves structures and writes one export directory `<name>/` in the working root — containing `README.md`, `manifest.csv`, `mt.seek.db` and one `<id>/` directory per structure (CIF / POSCAR / JSON, plus INCAR / KPOINTS / job script when requested; POTCAR is concatenated into the POSCAR directory with `mt.sh po` when a pseudopotential directory is configured). No tarball, no upload; internal cache/state stay hidden in `.mt.seek/`. Also filters or deduplicates local datasets; no calculations run locally. Set the API key once (free account at https://next-gen.materialsproject.org).
71
+ * `mt.sqs`: special quasirandom structures from a custom unit cell. Reads POSCAR / CONTCAR / CIF / JSON, expands a supercell, and randomises one sublattice toward a target composition using `sqsgenerator`; no network access is required.
72
+ * `mt.skl`: data-driven analysis of exported structures with scikit-learn. Runs two regression tasks (`ehull` stability and `band_gap`) with a random forest and 5-fold cross-validation, writing results to `<home>/ml/`; `--home DIR` sets the working root (default: current directory).
73
+ ```bash
74
+ mkdir -p ~/.config/mcta
75
+ echo 'MP_API_KEY=your-key' >> ~/.config/mcta/config
76
+ chmod 600 ~/.config/mcta/config
77
+ mt.seek -c Ti-C -k 3 -n ti-c # search by chemical system, export top 3
78
+ mt.seek -f MoS2 -k 5 -F cif,poscar # search by formula
79
+ mt.seek -r -D 8 -o my-pick # deduplicate + pick 8 diverse structures
80
+ mt.sqs -c cell.vasp -a "Cu:0.5,Au:0.5" -x 4,4,4 -n cuau-sqs
81
+ mt.sqs -c LaAlO3.cif --host La -a "La:0.5,Sr:0.5" -x 2,2,2 # A-site only
82
+ mt.sqs -c cell.vasp -a Cu,Au --iterations 1000 --number 5 -R # dry-run: no disk write
83
+ mt.skl # analyse <name>/manifest.csv from each export bundle
84
+ ```
85
+ `mt.seek` exports land in `<name>/` directly under the working root (no `exports/`, no `.tar.gz`, no upload): each bundle holds `README.md`, `manifest.csv`, `mt.seek.db`, and one `<id>/` directory per structure containing that id's CIF / POSCAR / JSON (INCAR / KPOINTS / job script are written into the same `<id>/` when requested; POTCAR is generated there by `mt.sh po` only when a pseudopotential directory such as `PBE_PATH` is set and exists). `-I` accepts MP IDs, `-t` accepts natural-language tasks, and `-T` downloads more structures. `mt.sqs` bundles additionally contain `sqs.json` and `sqs_summary.csv`. `mt.seek -h` lists all options, LLM engines, and `MT_SEEK_*` environment variables; short options are case-sensitive; `mt.sqs -h` lists every flag and default.
86
+ > Structure data comes from the Materials Project: A. Jain et al., *APL Materials* 1, 011002 (2013).
87
+ ***
88
+ <b><i>mt.mc</i></b>: Monte Carlo simulation of phase transitions in 2D/3D magnetic materials
89
+ * Runs the Metropolis Ising model on built-in lattices (square, triangular, bilayer, simple-cubic) or any crystal structure (`-s POSCAR -A Fe -D 3.0 3.6 -x 2 -y 2 -z 2`); any of `-a`, `-J`, `-K` switches to the Heisenberg model. Requires `numba` (`pip install mcta[mc]`); ASE is needed for structure mode.
90
+ * `-x/-X`, `-y/-Y`, `-z/-Z` set the lattice size or supercell multiplier (default `32`, `-z` ignored for 2D); `-e/-w` set equilibration/sampling sweeps, `-p/-J/-K` couplings, `-a` anisotropy, `-i` initial state, and `-C` / `-W` / `-S` control parallel chains, replica exchange and reproducibility. `-t` accepts a count (`35`), a range (`20 25`), start/stop/step (`20 26 2`), separate temperatures (`20 25 30`), or chained ranges.
91
+ * Structure mode (`-s`) reads any ASE-supported file, picks magnetic atoms (`-A Fe,Co` or auto d/f-block), expands the supercell and builds the neighbor table by distance bins (`-D`); `--mom` sets nominal moments (default `2` &rarr; S=±1) and `--ini` the initial state (`fm` / `afm` / `random` or a ±1 list); `-c` is ignored with `-s`. Plots are automatic unless `-R`, and `-o FILE -I pdf` re-plots a finished run.
92
+ ```bash
93
+ mt.mc -x 128 -y 128 -t 0 40 2 -C 6 -S 42 # 6 parallel chains, reproducible
94
+ mt.mc -c triangular -t 0 60 2 -S 42 # triangular lattice
95
+ mt.mc -c square -a 0.1 -t 20 40 2 -p 5 -J 4 -K 3 # vector spins with anisotropy
96
+ mt.mc -s POSCAR -A Fe -D 2.7 3.2 -x 2 -y 2 -z 2 -t 10 30 10 -p 5 2 # from crystal
97
+ mt.mc -o square_Ising_32_32.log -I pdf # re-plot a finished run
98
+ ```
99
+ ***
100
+ <b><i>mt.sh</i></b>: run bash helper scripts by short name
101
+ * `mt.sh NAME [args...]` runs `NAME.sh` with bash; local `./NAME.sh` overrides `$MTSH_SCRIPTS`, then bundled scripts. Bare `mt.sh` lists available scripts.
102
+ * Strain scans `x|y|xy [POSCAR] [NPOINTS] [STEP]` write `<factor>/POSCAR` under `x/`, `y/`, or `xy/`; defaults are 4 points per side and step 0.01.
103
+ * `kb [POSCAR] [a [b [c]]] [OUT]` expands the structure with ASE and writes `SPOSCAR` by default; missing multipliers default to 1.
104
+ * `sy [POSCAR] [symprec]` reports spglib space-group and Wyckoff-site information; the default tolerance is `1e-3` &Aring;.
105
+ * Bundled VASP helpers target Linux/WSL; on Windows use Git Bash with `sed` / `awk` / `bc` available.
106
+ ```bash
107
+ mt.sh x # x strain: x/0.960 ... x/1.040 (8 points, step 0.01)
108
+ mt.sh y POSCAR 2 0.02 # y strain, 2 points per side, step 0.02
109
+ mt.sh xy POSCAR # x and y strained together
110
+ mt.sh kb POSCAR 2 2 1 # POSCAR -> SPOSCAR (2x2x1)
111
+ mt.sh sy POSCAR # space group + Wyckoff sites (symprec 1e-3)
112
+ mt.sh sy CONTCAR 0.0001 # tighter tolerance: may lower the symmetry
113
+ ```
114
+ ***
115
+ <b><i>mt.server</i></b>: local file service, structure viewer and terminal in the browser
116
+ * `mt.server` runs a token-protected web service for browsing, editing and downloading files from the `-d` directory, a browser PTY terminal, and a 3Dmol.js viewer for structures, trajectories and VASP charge densities; it listens on port 9068 by default (`-p`), can run in the foreground (`-f`) or over a Unix socket (`-c|--socket`), and is stopped with `-S` (`--status` lists ports, `-S --all` stops them all).
117
+ * With `-R user@host[:port]` it browses and transfers remote files over parallel SSH/SFTP channels using key or prompted-password login (`-i KEY` selects a private key; otherwise ssh-agent and `~/.ssh` defaults are tried), opens a remote `mt.server` for 3D parsing through a Unix-socket tunnel, can forward a remote web service with `-P` or `--socket`, and keeps a persistent per-host cache; `-D [RPORT [LPORT]]` uses SSH's built-in SOCKS5 to share the local network with the remote host (remote port first, local port second, both 9069 by default).
118
+ * XML and `.json` open as read-only highlighted text, Materials Studio `.xsd` opens as a 3D structure by default (read-only XML via "Open text"), and large files are paged on demand (2 MB text windows, 256 MB structures, 512 MB volumetric files, 1000 trajectory frames / 5 million atoms).
119
+ ```bash
120
+ mt.server # background on port 9068; the tokenized URL is printed
121
+ mt.server -d ./examples # serve a different directory
122
+ mt.server -p 8080 # another port
123
+ mt.server -L 0.0.0.0 # listen on all interfaces (asks for yes, then prints a warning)
124
+ mt.server -f # foreground; Ctrl+C to stop
125
+ mt.server -N # no token (asks for yes): open http://127.0.0.1:9068/ directly
126
+ mt.server -o run.log # keep the startup output in run.log (overwritten each start)
127
+ mt.server -R user@host:22 -d /home/user/project
128
+ mt.server -S # stop the service on port 9068
129
+ mt.server --status # list every port where mt.server is running
130
+ mt.server -S --all # stop all of them
131
+ ```
132
+
133
+ ***
134
+ <b><i>Third-party components</i></b>
135
+
136
+ `mt.server` bundles two browser assets, each redistributed under its own license. The full license texts ship with the package:
137
+ * **3Dmol.js** (BSD-3-Clause, based on GLmol / Three.js / jQuery) — `mcta/server/3Dmol.LICENSE.txt`.
138
+ * **xterm.js 5.5.0** (MIT) — `mcta/server/xterm.LICENSE.txt`.
139
+
140
+ McTa itself is licensed under the MIT License (`LICENSE`).
@@ -0,0 +1,11 @@
1
+ """McTa —— Meta Crystal Toolkit & Analysis"""
2
+
3
+ import os
4
+ import platform
5
+
6
+ __version__ = "0.0.34"
7
+
8
+
9
+ def version_string() -> str:
10
+ """统一的 -V 输出格式。"""
11
+ return "McTa (Meta Crystal Toolkit & Analysis) " + __version__ + " from " + os.path.dirname(__file__) + ' (python' + platform.python_version() + ')'
@@ -0,0 +1,118 @@
1
+ """mt:命令统一入口,负责说明用途并把参数原样转给对应的工具。
2
+
3
+ mt < band | dos | phband | phdos | ph | ph3 | seek | skl | sqs | mc | sh | server > [参数]
4
+ 等价于 mt.band | mt.dos | mt.phband | mt.phdos | mt.ph | mt.ph3 | mt.seek mt.skl | mt.sqs | mt.sh | mt.server [参数]
5
+
6
+ 环境变量(也可写入 ~/.config/mcta/config,KEY=VALUE;环境变量优先):
7
+
8
+ 绘图(mt.band / mt.dos / mt.phband / mt.phdos / mt.mc):
9
+ MT_FONT_FAMILY 字体族,默认 STIXGeneral
10
+ MT_MATHTEXT_FONTSET 数学文本字体集,默认 cm
11
+ MT_RESOL 图片 DPI,默认 500
12
+ MT_XTICK_DIRECTION x 轴刻度方向,默认 in
13
+ MT_YTICK_DIRECTION y 轴刻度方向,默认 in
14
+
15
+ 结构检索与描述符分析(mt.seek / mt.sqs / mt.skl 共用工作目录与配置文件设置):
16
+ MP_API_KEY Materials Project 密钥(在线检索必填)
17
+ MT_SEEK_HOME 工作根目录,默认当前目录
18
+ MT_SEEK_CONFIG 配置文件路径,默认 ~/.config/mcta/config
19
+ MT_SEEK_API_KEY LLM 密钥(所有引擎统一使用,自然语言模式)
20
+ MT_SEEK_PROVIDER LLM 引擎,默认 openai;可选 deepseek/qwen/glm/kimi/siliconflow/gemini/openrouter/ollama/vllm
21
+ MT_SEEK_BASE_URL 覆盖所选 LLM 引擎的 API 端点
22
+ MT_SEEK_MODEL 覆盖所选 LLM 引擎的模型
23
+ MT_SEEK_MAX_TURNS LLM 最大交互轮数,默认 30
24
+ MT_SEEK_MAX_CAND LLM 最大候选结构数,默认 20
25
+
26
+ 本地文件与终端服务(mt.server):
27
+ MCTA_REMOTE_SOCKET 远端 mt.server Unix socket 路径,默认 ~/.config/mcta/sock/mcta-render.sock
28
+ MCTA_REMOTE_RENDER_MIN_MB -R 下启用远端 3D 解析的大小阈值 MB,默认 8
29
+ MCTA_REMOTE_LIST_TTL 远端目录列表缓存秒数,默认 1,0 表示关闭
30
+ MCTA_RENDER_CACHE_MAX_MB 3D 渲染缓存容量上限 MB,默认 512
31
+ MCTA_CACHE_FRESH_SECONDS 渲染缓存淘汰保护窗口秒数,默认 30
32
+ MCTA_RENDER_RETRY_SECONDS 远端渲染通道失败后的重试间隔秒数,默认 30
33
+ MCTA_RENDER_TOTAL_SECONDS 单次远端渲染总时长上限秒数,默认 60
34
+ MCTA_XFER_CHANNELS 传输通道数,默认 3(第 3 条只传小文件)
35
+ MCTA_XFER_LARGE_MB 大文件阈值 MB,默认 4
36
+ XDG_CACHE_HOME 缓存根目录(3D 渲染与 -R 文件缓存),默认 ~/.cache
37
+
38
+ 其他工具:
39
+ MT_PH_DOCS mt.ph 自定义词库 JSON 路径
40
+ MT_PH3_DOCS mt.ph3 自定义词库 JSON 路径
41
+ MTSH_SCRIPTS mt.sh 自定义脚本目录(本地 ./NAME.sh 优先)
42
+ PBE_PATH PBE 赝势目录(mt.sh/po.sh,优先)
43
+ LDA_PATH LDA 赝势目录(mt.sh/po.sh)
44
+ GGA_PATH GGA 赝势目录(mt.sh/po.sh)
45
+ """
46
+
47
+ import sys
48
+
49
+ from mcta import version_string
50
+ from mcta._flags import TOOLS, _tool, overview, which
51
+
52
+
53
+ def _run(key, argv):
54
+ """在进程内调用对应入口,参数与 ``<命令> [参数]`` 完全一致。
55
+
56
+ 只导入目标命令所需模块:绘图命令才依赖 matplotlib,其他命令在缺少
57
+ 绘图依赖时也应可用(例如 ``mt seek -h`` / ``mt server``)。
58
+ """
59
+ entry = {}
60
+ if key in ("band", "dos", "phband", "phdos", "ph", "ph3"):
61
+ from mcta.bandplot import dos, ph, ph3, phdos, wrapper
62
+ entry.update({"band": wrapper.main, "dos": dos.main, "phband": wrapper.pmain,
63
+ "phdos": phdos.main, "ph": ph.main, "ph3": ph3.main})
64
+ if key == "seek":
65
+ from mcta.seek import cli as seek_cli
66
+ entry["seek"] = seek_cli.main
67
+ elif key == "skl":
68
+ from mcta.skl import cli as skl_cli
69
+ entry["skl"] = skl_cli.main
70
+ elif key == "sqs":
71
+ from mcta.sqs import cli as sqs_cli
72
+ entry["sqs"] = sqs_cli.main
73
+ elif key == "sh":
74
+ from mcta.sh import cli as sh_cli
75
+ entry["sh"] = sh_cli.main
76
+ elif key == "mc":
77
+ from mcta.mc import wrapper as mc_wrapper
78
+ entry["mc"] = mc_wrapper.main
79
+ elif key == "server":
80
+ from mcta.server import main as server_main
81
+ entry["server"] = server_main
82
+ name = _tool(key)["name"]
83
+ saved = sys.argv
84
+ sys.argv = [name] + list(argv)
85
+ try:
86
+ return entry[key]()
87
+ finally:
88
+ sys.argv = saved
89
+
90
+
91
+ def main(argv=None):
92
+ args = list(sys.argv[1:] if argv is None else argv)
93
+ if not args:
94
+ overview()
95
+ return 0
96
+
97
+ head, rest = args[0], args[1:]
98
+ if head in ("-h", "-H", "--help", "help"):
99
+ print((__doc__ or "").strip())
100
+ print("\n<命令 " + " | ".join(t["key"] for t in TOOLS) + " >")
101
+ print("\nmt <命令> -h 查看该命令的参数;mt -v 版本;mt which 查看安装位置")
102
+ return 0
103
+ if head in ("-v", "-V", "--version", "version"):
104
+ print(version_string())
105
+ return 0
106
+ if head in ("which", "where"):
107
+ return which()
108
+
109
+ if _tool(head) is None:
110
+ print("ERROR: 未知命令 %r。" % head)
111
+ print("可用:mt / mt band / mt dos / mt phband / mt phdos / mt ph / mt ph3 / mt seek / mt skl / mt sqs / mt sh / mt mc / mt which / mt -v/-V")
112
+ return 2
113
+ result = _run(head, rest)
114
+ return result if isinstance(result, int) else 0
115
+
116
+
117
+ if __name__ == "__main__":
118
+ sys.exit(main())