mcta 0.0.30__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.30/LICENSE +21 -0
  2. mcta-0.0.30/PKG-INFO +194 -0
  3. mcta-0.0.30/README.md +147 -0
  4. mcta-0.0.30/mcta/__init__.py +11 -0
  5. mcta-0.0.30/mcta/__main__.py +118 -0
  6. mcta-0.0.30/mcta/_flags.py +373 -0
  7. mcta-0.0.30/mcta/bandplot/dos.py +204 -0
  8. mcta-0.0.30/mcta/bandplot/mass.py +164 -0
  9. mcta-0.0.30/mcta/bandplot/ph.py +1437 -0
  10. mcta-0.0.30/mcta/bandplot/ph3.py +893 -0
  11. mcta-0.0.30/mcta/bandplot/ph3doc.py +232 -0
  12. mcta-0.0.30/mcta/bandplot/phdoc.py +256 -0
  13. mcta-0.0.30/mcta/bandplot/phdos.py +193 -0
  14. mcta-0.0.30/mcta/bandplot/phono3py_docs.json +1361 -0
  15. mcta-0.0.30/mcta/bandplot/phonopy_docs.json +3295 -0
  16. mcta-0.0.30/mcta/bandplot/plots.py +576 -0
  17. mcta-0.0.30/mcta/bandplot/pplots.py +439 -0
  18. mcta-0.0.30/mcta/bandplot/projected.py +220 -0
  19. mcta-0.0.30/mcta/bandplot/readdata.py +174 -0
  20. mcta-0.0.30/mcta/bandplot/vaspread.py +1047 -0
  21. mcta-0.0.30/mcta/bandplot/wrapper.py +842 -0
  22. mcta-0.0.30/mcta/mc/engine.py +1137 -0
  23. mcta-0.0.30/mcta/mc/geometry/__init__.py +55 -0
  24. mcta-0.0.30/mcta/mc/geometry/bilayer_aa.py +183 -0
  25. mcta-0.0.30/mcta/mc/geometry/bilayer_ab.py +275 -0
  26. mcta-0.0.30/mcta/mc/geometry/bilayer_ab_u_3.py +211 -0
  27. mcta-0.0.30/mcta/mc/geometry/from_structure.py +328 -0
  28. mcta-0.0.30/mcta/mc/geometry/simple_cubic.py +119 -0
  29. mcta-0.0.30/mcta/mc/geometry/square.py +190 -0
  30. mcta-0.0.30/mcta/mc/geometry/triangular.py +195 -0
  31. mcta-0.0.30/mcta/mc/geometry/xy_geometry.py +238 -0
  32. mcta-0.0.30/mcta/mc/parallel.py +160 -0
  33. mcta-0.0.30/mcta/mc/plots.py +303 -0
  34. mcta-0.0.30/mcta/mc/wrapper.py +287 -0
  35. mcta-0.0.30/mcta/mc/xy_engine.py +393 -0
  36. mcta-0.0.30/mcta/seek/agent.py +283 -0
  37. mcta-0.0.30/mcta/seek/cli.py +359 -0
  38. mcta-0.0.30/mcta/seek/config.py +181 -0
  39. mcta-0.0.30/mcta/seek/curate.py +651 -0
  40. mcta-0.0.30/mcta/seek/llm.py +42 -0
  41. mcta-0.0.30/mcta/seek/ml.py +230 -0
  42. mcta-0.0.30/mcta/seek/sqs.py +504 -0
  43. mcta-0.0.30/mcta/seek/state.py +70 -0
  44. mcta-0.0.30/mcta/seek/tools.py +776 -0
  45. mcta-0.0.30/mcta/server/3Dmol.LICENSE.txt +90 -0
  46. mcta-0.0.30/mcta/server/3dmol-min.js +2 -0
  47. mcta-0.0.30/mcta/server/__init__.py +843 -0
  48. mcta-0.0.30/mcta/server/_handlers.py +1674 -0
  49. mcta-0.0.30/mcta/server/_page.py +11 -0
  50. mcta-0.0.30/mcta/server/_remote.py +1538 -0
  51. mcta-0.0.30/mcta/server/_structure.py +499 -0
  52. mcta-0.0.30/mcta/server/_terminal.py +233 -0
  53. mcta-0.0.30/mcta/server/_util.py +387 -0
  54. mcta-0.0.30/mcta/server/app.css +574 -0
  55. mcta-0.0.30/mcta/server/app.js +3669 -0
  56. mcta-0.0.30/mcta/server/page.html +420 -0
  57. mcta-0.0.30/mcta/server/viewer.js +5794 -0
  58. mcta-0.0.30/mcta/server/xterm.LICENSE.txt +21 -0
  59. mcta-0.0.30/mcta/server/xterm.css +218 -0
  60. mcta-0.0.30/mcta/server/xterm.js +8 -0
  61. mcta-0.0.30/mcta/sh/cli.py +149 -0
  62. mcta-0.0.30/mcta/sh/scripts/ck.sh +5 -0
  63. mcta-0.0.30/mcta/sh/scripts/cp.sh +3 -0
  64. mcta-0.0.30/mcta/sh/scripts/en.sh +3 -0
  65. mcta-0.0.30/mcta/sh/scripts/ex.sh +6 -0
  66. mcta-0.0.30/mcta/sh/scripts/gr.sh +5 -0
  67. mcta-0.0.30/mcta/sh/scripts/ig.sh +8 -0
  68. mcta-0.0.30/mcta/sh/scripts/il.sh +8 -0
  69. mcta-0.0.30/mcta/sh/scripts/kb.sh +41 -0
  70. mcta-0.0.30/mcta/sh/scripts/kg.sh +18 -0
  71. mcta-0.0.30/mcta/sh/scripts/make_supercell.py +150 -0
  72. mcta-0.0.30/mcta/sh/scripts/md.sh +24 -0
  73. mcta-0.0.30/mcta/sh/scripts/mv.sh +3 -0
  74. mcta-0.0.30/mcta/sh/scripts/po.sh +80 -0
  75. mcta-0.0.30/mcta/sh/scripts/pr.sh +3 -0
  76. mcta-0.0.30/mcta/sh/scripts/re.sh +5 -0
  77. mcta-0.0.30/mcta/sh/scripts/sh.sh +3 -0
  78. mcta-0.0.30/mcta/sh/scripts/su.sh +15 -0
  79. mcta-0.0.30/mcta/sh/scripts/sy.sh +42 -0
  80. mcta-0.0.30/mcta/sh/scripts/symmetry_info.py +266 -0
  81. mcta-0.0.30/mcta/sh/scripts/x.sh +32 -0
  82. mcta-0.0.30/mcta/sh/scripts/xy.sh +36 -0
  83. mcta-0.0.30/mcta/sh/scripts/y.sh +32 -0
  84. mcta-0.0.30/mcta/sh/scripts/z2.sh +44 -0
  85. mcta-0.0.30/mcta/sh/scripts/z2_convert.py +211 -0
  86. mcta-0.0.30/mcta/skl/__init__.py +4 -0
  87. mcta-0.0.30/mcta/skl/cli.py +70 -0
  88. mcta-0.0.30/mcta/sqs/__init__.py +4 -0
  89. mcta-0.0.30/mcta/sqs/cli.py +141 -0
  90. mcta-0.0.30/mcta.egg-info/PKG-INFO +194 -0
  91. mcta-0.0.30/mcta.egg-info/SOURCES.txt +95 -0
  92. mcta-0.0.30/mcta.egg-info/dependency_links.txt +1 -0
  93. mcta-0.0.30/mcta.egg-info/entry_points.txt +14 -0
  94. mcta-0.0.30/mcta.egg-info/requires.txt +25 -0
  95. mcta-0.0.30/mcta.egg-info/top_level.txt +1 -0
  96. mcta-0.0.30/pyproject.toml +98 -0
  97. mcta-0.0.30/setup.cfg +4 -0
mcta-0.0.30/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.30/PKG-INFO ADDED
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcta
3
+ Version: 0.0.30
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 [-d PATH] [-p PORT | --socket PATH] [--remote-socket PATH] [-f] [-L HOST] [-R SPEC] [-S] [-o [PATH]] [--status]`: background on port 9068 by default; `-d` sets the starting directory (defaults to cwd); restarting on the same port replaces the old instance, and the service stops when that terminal closes or exits. `-f` runs it in the terminal (`Ctrl+C` to stop), `-S` stops it, and no log file is written unless `-o` is given (`-o` alone writes `mcta-server-<port>.log`, `-o DIR|FILE` chooses the location, an existing file is overwritten; with `-f -o` the startup banner and interactive prompts remain in the terminal while errors go to the log). `--status` lists every port where you have a service running, and `-S --all` stops all of them.
164
+ * `-R/--ssh` connects to a remote server. `SPEC` accepts `user@host:22`, `user@host 22`, `user host 22`, `host 22` and `host`; the user defaults to the local user and the port to 22. Startup first probes the server non-interactively, then tries ssh-agent and local private keys (`~/.ssh/id_ed25519`, `id_ecdsa`, `id_rsa`, …). If no key is available or key authentication fails, it asks for a password directly (no y/N prompt) and automatically stays in the foreground; the password is read with `getpass` (no echo, 90-second timeout, Ctrl+Z ends the process) and is never written to the command line, environment or log, but is kept in server memory for automatic reconnects. The SSH port belongs in `-R`; `-p` remains the web port. Legacy servers using `diffie-hellman-group14-sha1`, `diffie-hellman-group1-sha1` or `ssh-rsa` work with paramiko 3/5 without downgrading: the equivalent of `-oKexAlgorithms=+... -oHostKeyAlgorithms=+ssh-rsa` is registered at runtime. In this mode `-d` is a directory **on the server**; an invalid path falls back to the SSH default directory. Directory listings use a dedicated SSH/SFTP connection and file transfers use three SSH/SFTP connections by default (transfer channels 1 and 2 accept any size, channel 3 carries small files only), while the terminal is an interactive shell over a separate SSH connection, so large transfers do not block the shell; files are downloaded to a local temporary directory before the text viewer / ASE / 3Dmol reads them. Page paths and terminal `cd` targets are always remote absolute paths; the local cache directory is never shown or sent to the shell. Audio/video is streamed from SFTP on demand with HTTP Range support; only the browser playback buffer is kept locally, never the whole file. If the connection drops, SSH/SFTP and the shell reconnect automatically. In remote mode you can drop local files or folders into the file panel to upload them into the current directory, and select multiple files to download them as a ZIP.
165
+ * **Remote 3D rendering over a Unix socket (fifth channel).** When `-R` is active and the remote host has an `mt.server` executable on `PATH`, in `~/.local/bin`, in a common conda env, or as `python3 -m mcta server` — the local server only checks the executable path (keep mcta versions in sync manually) and opens a system `ssh` tunnel (`-L 127.0.0.1:PORT:/path/to/socket`, never paramiko) to a remote **Unix domain socket** and lets the remote `mt.server` parse structures / downsample VASP volumetric data. Only the 3D structure/volume request (`/api/structure`) uses this channel: the terminal, directory browsing, upload and download keep using the original channels. The remote process runs in the foreground under `exec` with a forced PTY, so it exits together with the SSH connection; it listens on **no TCP port** (SSH 22 excepted). The default socket is `~/.config/mcta/sock/mcta.sock`: its parent directory is created with mode `0700` and the socket itself is `0600`. Override the path with `--remote-socket PATH` on the local server or the environment variable `MCTA_REMOTE_SOCKET`; `mt.server --socket PATH` makes a `mt.server` itself serve HTTP only on a Unix socket (foreground, mutually exclusive with `-p`). Rendering results are cached locally by remote path, mtime and size; opening the same file again does not touch the tunnel, and saving structure edits invalidates that cache. Files below the threshold continue to use SFTP plus local ASE. The threshold is 8 MB for both structures and volumetric data; set `MCTA_REMOTE_RENDER_MIN_MB=N` to change it (lower values send more work to the remote host, which helps on slow networks). At most two render requests per remote host run concurrently. If the remote tool is missing, the tunnel cannot be established, a request times out (30 s), or the remote returns an error, the request automatically falls back to SFTP + local parsing and a message is printed in the terminal; nothing else is affected. Key/agent and password authentication are both supported without extra local tools: with a password, OpenSSH's built-in askpass helper is used (the secret lives only in the process environment and the helper is deleted when the tunnel closes); legacy SHA1 KEX/host-key algorithms are enabled automatically for older sshd servers.
166
+ * **Remote caches.** In `-R` mode the working file cache is a per-process temporary directory created by `tempfile.mkdtemp(prefix="mcta-ssh-")` (for example `/tmp/mcta-ssh-u31_8qyd`); it mirrors remote paths only while the service runs and is deleted when the service exits. ZIP downloads reuse this cache when size/mtime still match, so already previewed or uploaded files are not fetched again. The separate 3D render cache is persistent at `$XDG_CACHE_HOME/mcta/render-cache` (default `~/.cache/mcta/render-cache`), keyed by remote path, mtime, size and frame flag; bodies are gzip-compressed when worthwhile, streamed back without loading the whole file into memory, and pruned by LRU. Set `MCTA_RENDER_CACHE_MAX_MB=N` (default `512`) to change its size limit, `MCTA_CACHE_FRESH_SECONDS=N` (default `30`) to protect recently used entries from pruning, `MCTA_RENDER_TOTAL_SECONDS=N` (default `60`) to cap the total time of one render request, `MCTA_REMOTE_LIST_TTL=N` (seconds, default `1`, `0` disables) for directory listing cache TTL, and `MCTA_RENDER_RETRY_SECONDS=N` (default `30`) for the negative cache after a remote render channel fails. The number of transfer channels is set by `MCTA_XFER_CHANNELS=N` (default `3`, range 2-16): channels 1 and 2 accept any file size while channel 3 and beyond carry small files only. `MCTA_XFER_LARGE_MB=N` (default `4`) sets the large-file threshold; every transfer is routed by size and live load, so concurrent uploads and downloads can switch channels at any time. Remote write operations invalidate the affected directory listings.
167
+ * The tokenized URL (`?t=...`) printed at startup is the only credential — do not share it. `-N` (no token) and `-L` on a non-loopback address are dangerous: each asks you to type `yes` / `YES`, using both asks twice, and `-L 0.0.0.0` prints a warning.
168
+ * Runs as the current user with no login: browse, edit and download any accessible file, with a real PTY shell (xterm.js) whose `cd` the file list follows, image previews, and a 3Dmol.js viewer for structures, trajectories and VASP charge-density files (`CHGCAR`, `CHG`, `LOCPOT`, including spin-polarised pairs). The viewer is orthographic by default with a perspective toggle, fixed-angle rotation (Z-axis 45° default), stepped zoom buttons, reset view, 1x-8x PNG/JPEG/WebP export, vertical sliders for isovalue and opacity (live update while dragging), playback for multi-frame trajectories (capped at 300 frames), and automatic CUBE conversion from ASE so that 3Dmol.js handles all formats uniformly.
169
+ ```bash
170
+ mt.server # background on port 9068; the tokenized URL is printed
171
+ mt.server -d ./examples # serve a different directory
172
+ mt.server -p 8080 # another port
173
+ mt.server -L 0.0.0.0 # listen on all interfaces (asks for yes, then prints a warning)
174
+ mt.server -f # foreground; Ctrl+C to stop
175
+ mt.server -N # no token (asks for yes): open http://127.0.0.1:9068/ directly
176
+ mt.server -o run.log # keep the startup output in run.log (overwritten each start)
177
+ mt.server -R user@host:22 -d /home/user/project
178
+ MCTA_REMOTE_RENDER_MIN_MB=2 mt.server -R user@host # send files >2 MB to the remote renderer
179
+ mt.server --socket /tmp/mcta.sock -N -Y -f # Unix socket only, no TCP port
180
+ MCTA_RENDER_CACHE_MAX_MB=256 mt.server -R user@host # cap persistent render cache at 256 MB
181
+ MCTA_REMOTE_LIST_TTL=0 mt.server -R user@host # always re-read remote directory listings
182
+ mt.server -S # stop the service on port 9068
183
+ mt.server --status # list every port where mt.server is running
184
+ mt.server -S --all # stop all of them
185
+ ```
186
+
187
+ ***
188
+ <b><i>Third-party components</i></b>
189
+
190
+ `mt.server` bundles two browser assets, each redistributed under its own license. The full license texts ship with the package:
191
+ * **3Dmol.js** (BSD-3-Clause, based on GLmol / Three.js / jQuery) — `mcta/server/3Dmol.LICENSE.txt`.
192
+ * **xterm.js 5.5.0** (MIT) — `mcta/server/xterm.LICENSE.txt`.
193
+
194
+ McTa itself is licensed under the MIT License (`LICENSE`).
mcta-0.0.30/README.md ADDED
@@ -0,0 +1,147 @@
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 [-d PATH] [-p PORT | --socket PATH] [--remote-socket PATH] [-f] [-L HOST] [-R SPEC] [-S] [-o [PATH]] [--status]`: background on port 9068 by default; `-d` sets the starting directory (defaults to cwd); restarting on the same port replaces the old instance, and the service stops when that terminal closes or exits. `-f` runs it in the terminal (`Ctrl+C` to stop), `-S` stops it, and no log file is written unless `-o` is given (`-o` alone writes `mcta-server-<port>.log`, `-o DIR|FILE` chooses the location, an existing file is overwritten; with `-f -o` the startup banner and interactive prompts remain in the terminal while errors go to the log). `--status` lists every port where you have a service running, and `-S --all` stops all of them.
117
+ * `-R/--ssh` connects to a remote server. `SPEC` accepts `user@host:22`, `user@host 22`, `user host 22`, `host 22` and `host`; the user defaults to the local user and the port to 22. Startup first probes the server non-interactively, then tries ssh-agent and local private keys (`~/.ssh/id_ed25519`, `id_ecdsa`, `id_rsa`, …). If no key is available or key authentication fails, it asks for a password directly (no y/N prompt) and automatically stays in the foreground; the password is read with `getpass` (no echo, 90-second timeout, Ctrl+Z ends the process) and is never written to the command line, environment or log, but is kept in server memory for automatic reconnects. The SSH port belongs in `-R`; `-p` remains the web port. Legacy servers using `diffie-hellman-group14-sha1`, `diffie-hellman-group1-sha1` or `ssh-rsa` work with paramiko 3/5 without downgrading: the equivalent of `-oKexAlgorithms=+... -oHostKeyAlgorithms=+ssh-rsa` is registered at runtime. In this mode `-d` is a directory **on the server**; an invalid path falls back to the SSH default directory. Directory listings use a dedicated SSH/SFTP connection and file transfers use three SSH/SFTP connections by default (transfer channels 1 and 2 accept any size, channel 3 carries small files only), while the terminal is an interactive shell over a separate SSH connection, so large transfers do not block the shell; files are downloaded to a local temporary directory before the text viewer / ASE / 3Dmol reads them. Page paths and terminal `cd` targets are always remote absolute paths; the local cache directory is never shown or sent to the shell. Audio/video is streamed from SFTP on demand with HTTP Range support; only the browser playback buffer is kept locally, never the whole file. If the connection drops, SSH/SFTP and the shell reconnect automatically. In remote mode you can drop local files or folders into the file panel to upload them into the current directory, and select multiple files to download them as a ZIP.
118
+ * **Remote 3D rendering over a Unix socket (fifth channel).** When `-R` is active and the remote host has an `mt.server` executable on `PATH`, in `~/.local/bin`, in a common conda env, or as `python3 -m mcta server` — the local server only checks the executable path (keep mcta versions in sync manually) and opens a system `ssh` tunnel (`-L 127.0.0.1:PORT:/path/to/socket`, never paramiko) to a remote **Unix domain socket** and lets the remote `mt.server` parse structures / downsample VASP volumetric data. Only the 3D structure/volume request (`/api/structure`) uses this channel: the terminal, directory browsing, upload and download keep using the original channels. The remote process runs in the foreground under `exec` with a forced PTY, so it exits together with the SSH connection; it listens on **no TCP port** (SSH 22 excepted). The default socket is `~/.config/mcta/sock/mcta.sock`: its parent directory is created with mode `0700` and the socket itself is `0600`. Override the path with `--remote-socket PATH` on the local server or the environment variable `MCTA_REMOTE_SOCKET`; `mt.server --socket PATH` makes a `mt.server` itself serve HTTP only on a Unix socket (foreground, mutually exclusive with `-p`). Rendering results are cached locally by remote path, mtime and size; opening the same file again does not touch the tunnel, and saving structure edits invalidates that cache. Files below the threshold continue to use SFTP plus local ASE. The threshold is 8 MB for both structures and volumetric data; set `MCTA_REMOTE_RENDER_MIN_MB=N` to change it (lower values send more work to the remote host, which helps on slow networks). At most two render requests per remote host run concurrently. If the remote tool is missing, the tunnel cannot be established, a request times out (30 s), or the remote returns an error, the request automatically falls back to SFTP + local parsing and a message is printed in the terminal; nothing else is affected. Key/agent and password authentication are both supported without extra local tools: with a password, OpenSSH's built-in askpass helper is used (the secret lives only in the process environment and the helper is deleted when the tunnel closes); legacy SHA1 KEX/host-key algorithms are enabled automatically for older sshd servers.
119
+ * **Remote caches.** In `-R` mode the working file cache is a per-process temporary directory created by `tempfile.mkdtemp(prefix="mcta-ssh-")` (for example `/tmp/mcta-ssh-u31_8qyd`); it mirrors remote paths only while the service runs and is deleted when the service exits. ZIP downloads reuse this cache when size/mtime still match, so already previewed or uploaded files are not fetched again. The separate 3D render cache is persistent at `$XDG_CACHE_HOME/mcta/render-cache` (default `~/.cache/mcta/render-cache`), keyed by remote path, mtime, size and frame flag; bodies are gzip-compressed when worthwhile, streamed back without loading the whole file into memory, and pruned by LRU. Set `MCTA_RENDER_CACHE_MAX_MB=N` (default `512`) to change its size limit, `MCTA_CACHE_FRESH_SECONDS=N` (default `30`) to protect recently used entries from pruning, `MCTA_RENDER_TOTAL_SECONDS=N` (default `60`) to cap the total time of one render request, `MCTA_REMOTE_LIST_TTL=N` (seconds, default `1`, `0` disables) for directory listing cache TTL, and `MCTA_RENDER_RETRY_SECONDS=N` (default `30`) for the negative cache after a remote render channel fails. The number of transfer channels is set by `MCTA_XFER_CHANNELS=N` (default `3`, range 2-16): channels 1 and 2 accept any file size while channel 3 and beyond carry small files only. `MCTA_XFER_LARGE_MB=N` (default `4`) sets the large-file threshold; every transfer is routed by size and live load, so concurrent uploads and downloads can switch channels at any time. Remote write operations invalidate the affected directory listings.
120
+ * The tokenized URL (`?t=...`) printed at startup is the only credential — do not share it. `-N` (no token) and `-L` on a non-loopback address are dangerous: each asks you to type `yes` / `YES`, using both asks twice, and `-L 0.0.0.0` prints a warning.
121
+ * Runs as the current user with no login: browse, edit and download any accessible file, with a real PTY shell (xterm.js) whose `cd` the file list follows, image previews, and a 3Dmol.js viewer for structures, trajectories and VASP charge-density files (`CHGCAR`, `CHG`, `LOCPOT`, including spin-polarised pairs). The viewer is orthographic by default with a perspective toggle, fixed-angle rotation (Z-axis 45° default), stepped zoom buttons, reset view, 1x-8x PNG/JPEG/WebP export, vertical sliders for isovalue and opacity (live update while dragging), playback for multi-frame trajectories (capped at 300 frames), and automatic CUBE conversion from ASE so that 3Dmol.js handles all formats uniformly.
122
+ ```bash
123
+ mt.server # background on port 9068; the tokenized URL is printed
124
+ mt.server -d ./examples # serve a different directory
125
+ mt.server -p 8080 # another port
126
+ mt.server -L 0.0.0.0 # listen on all interfaces (asks for yes, then prints a warning)
127
+ mt.server -f # foreground; Ctrl+C to stop
128
+ mt.server -N # no token (asks for yes): open http://127.0.0.1:9068/ directly
129
+ mt.server -o run.log # keep the startup output in run.log (overwritten each start)
130
+ mt.server -R user@host:22 -d /home/user/project
131
+ MCTA_REMOTE_RENDER_MIN_MB=2 mt.server -R user@host # send files >2 MB to the remote renderer
132
+ mt.server --socket /tmp/mcta.sock -N -Y -f # Unix socket only, no TCP port
133
+ MCTA_RENDER_CACHE_MAX_MB=256 mt.server -R user@host # cap persistent render cache at 256 MB
134
+ MCTA_REMOTE_LIST_TTL=0 mt.server -R user@host # always re-read remote directory listings
135
+ mt.server -S # stop the service on port 9068
136
+ mt.server --status # list every port where mt.server is running
137
+ mt.server -S --all # stop all of them
138
+ ```
139
+
140
+ ***
141
+ <b><i>Third-party components</i></b>
142
+
143
+ `mt.server` bundles two browser assets, each redistributed under its own license. The full license texts ship with the package:
144
+ * **3Dmol.js** (BSD-3-Clause, based on GLmol / Three.js / jQuery) — `mcta/server/3Dmol.LICENSE.txt`.
145
+ * **xterm.js 5.5.0** (MIT) — `mcta/server/xterm.LICENSE.txt`.
146
+
147
+ 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.30"
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.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 渲染缓存根目录,默认 ~/.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())