mcta 0.0.3__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.
Files changed (82) hide show
  1. mcta-0.0.3/LICENSE +21 -0
  2. mcta-0.0.3/PKG-INFO +208 -0
  3. mcta-0.0.3/README.md +167 -0
  4. mcta-0.0.3/mcta/__init__.py +11 -0
  5. mcta-0.0.3/mcta/__main__.py +7 -0
  6. mcta-0.0.3/mcta/bandplot/dos.py +191 -0
  7. mcta-0.0.3/mcta/bandplot/mass.py +163 -0
  8. mcta-0.0.3/mcta/bandplot/ph.py +920 -0
  9. mcta-0.0.3/mcta/bandplot/phdos.py +179 -0
  10. mcta-0.0.3/mcta/bandplot/plots.py +532 -0
  11. mcta-0.0.3/mcta/bandplot/pplots.py +436 -0
  12. mcta-0.0.3/mcta/bandplot/projected.py +219 -0
  13. mcta-0.0.3/mcta/bandplot/readdata.py +174 -0
  14. mcta-0.0.3/mcta/bandplot/vaspread.py +979 -0
  15. mcta-0.0.3/mcta/bandplot/wrapper.py +819 -0
  16. mcta-0.0.3/mcta/cli.py +302 -0
  17. mcta-0.0.3/mcta/mc/__init__.py +7 -0
  18. mcta-0.0.3/mcta/mc/functions.py +63 -0
  19. mcta-0.0.3/mcta/mc/ising/__init__.py +0 -0
  20. mcta-0.0.3/mcta/mc/ising/bilayer_aa.py +115 -0
  21. mcta-0.0.3/mcta/mc/ising/bilayer_aa_update.py +89 -0
  22. mcta-0.0.3/mcta/mc/ising/bilayer_ab.py +164 -0
  23. mcta-0.0.3/mcta/mc/ising/bilayer_ab_u_3.py +115 -0
  24. mcta-0.0.3/mcta/mc/ising/bilayer_ab_u_3_update.py +116 -0
  25. mcta-0.0.3/mcta/mc/ising/bilayer_ab_update.py +144 -0
  26. mcta-0.0.3/mcta/mc/ising/square.py +117 -0
  27. mcta-0.0.3/mcta/mc/ising/square_update.py +107 -0
  28. mcta-0.0.3/mcta/mc/ising/triangular.py +112 -0
  29. mcta-0.0.3/mcta/mc/ising/triangular_update.py +92 -0
  30. mcta-0.0.3/mcta/mc/plots.py +69 -0
  31. mcta-0.0.3/mcta/mc/single/__init__.py +0 -0
  32. mcta-0.0.3/mcta/mc/single/bilayer_aa.py +127 -0
  33. mcta-0.0.3/mcta/mc/single/bilayer_aa_update.py +163 -0
  34. mcta-0.0.3/mcta/mc/single/bilayer_ab.py +180 -0
  35. mcta-0.0.3/mcta/mc/single/bilayer_ab_u_3.py +127 -0
  36. mcta-0.0.3/mcta/mc/single/bilayer_ab_u_3_update.py +190 -0
  37. mcta-0.0.3/mcta/mc/single/bilayer_ab_update.py +227 -0
  38. mcta-0.0.3/mcta/mc/single/square.py +128 -0
  39. mcta-0.0.3/mcta/mc/single/square_update.py +169 -0
  40. mcta-0.0.3/mcta/mc/single/triangular.py +118 -0
  41. mcta-0.0.3/mcta/mc/single/triangular_update.py +166 -0
  42. mcta-0.0.3/mcta/mc/wrapper.py +168 -0
  43. mcta-0.0.3/mcta/seeker/agent.py +270 -0
  44. mcta-0.0.3/mcta/seeker/cli.py +340 -0
  45. mcta-0.0.3/mcta/seeker/config.py +178 -0
  46. mcta-0.0.3/mcta/seeker/curate.py +615 -0
  47. mcta-0.0.3/mcta/seeker/llm.py +42 -0
  48. mcta-0.0.3/mcta/seeker/ml.py +230 -0
  49. mcta-0.0.3/mcta/seeker/sqs.py +488 -0
  50. mcta-0.0.3/mcta/seeker/state.py +70 -0
  51. mcta-0.0.3/mcta/seeker/tools.py +621 -0
  52. mcta-0.0.3/mcta/sh/cli.py +128 -0
  53. mcta-0.0.3/mcta/sh/scripts/ck.sh +5 -0
  54. mcta-0.0.3/mcta/sh/scripts/cp.sh +3 -0
  55. mcta-0.0.3/mcta/sh/scripts/en.sh +3 -0
  56. mcta-0.0.3/mcta/sh/scripts/ex.sh +6 -0
  57. mcta-0.0.3/mcta/sh/scripts/gr.sh +5 -0
  58. mcta-0.0.3/mcta/sh/scripts/ig.sh +8 -0
  59. mcta-0.0.3/mcta/sh/scripts/il.sh +8 -0
  60. mcta-0.0.3/mcta/sh/scripts/kg.sh +18 -0
  61. mcta-0.0.3/mcta/sh/scripts/md.sh +24 -0
  62. mcta-0.0.3/mcta/sh/scripts/mv.sh +3 -0
  63. mcta-0.0.3/mcta/sh/scripts/po.sh +61 -0
  64. mcta-0.0.3/mcta/sh/scripts/pr.sh +3 -0
  65. mcta-0.0.3/mcta/sh/scripts/re.sh +5 -0
  66. mcta-0.0.3/mcta/sh/scripts/sh.sh +3 -0
  67. mcta-0.0.3/mcta/sh/scripts/su.sh +15 -0
  68. mcta-0.0.3/mcta/sh/scripts/x.sh +22 -0
  69. mcta-0.0.3/mcta/sh/scripts/xy.sh +20 -0
  70. mcta-0.0.3/mcta/sh/scripts/y.sh +19 -0
  71. mcta-0.0.3/mcta/skl/__init__.py +4 -0
  72. mcta-0.0.3/mcta/skl/cli.py +69 -0
  73. mcta-0.0.3/mcta/sqs/__init__.py +4 -0
  74. mcta-0.0.3/mcta/sqs/cli.py +140 -0
  75. mcta-0.0.3/mcta.egg-info/PKG-INFO +208 -0
  76. mcta-0.0.3/mcta.egg-info/SOURCES.txt +81 -0
  77. mcta-0.0.3/mcta.egg-info/dependency_links.txt +1 -0
  78. mcta-0.0.3/mcta.egg-info/entry_points.txt +12 -0
  79. mcta-0.0.3/mcta.egg-info/requires.txt +23 -0
  80. mcta-0.0.3/mcta.egg-info/top_level.txt +1 -0
  81. mcta-0.0.3/pyproject.toml +84 -0
  82. mcta-0.0.3/setup.cfg +7 -0
mcta-0.0.3/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.3/PKG-INFO ADDED
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcta
3
+ Version: 0.0.3
4
+ Summary: Meta Crystal Toolkit & Analysis (mcta).
5
+ Author: Kan
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/lkccrr/mcta
8
+ Keywords: DFT,VASP,DOS,band,plot,Phonon,materials-project,pymatgen,crystal-structure,SQS,Ising,Monte-Carlo,magnetism
9
+ Platform: Unix
10
+ Platform: Windows
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: numpy>=1.22.0
23
+ Requires-Dist: matplotlib>=3.6.0
24
+ Requires-Dist: ase>=3.22.0
25
+ Provides-Extra: seeker
26
+ Requires-Dist: pymatgen>=2024.1.1; extra == "seeker"
27
+ Requires-Dist: mp-api>=0.40; extra == "seeker"
28
+ Requires-Dist: scikit-learn>=1.3; extra == "seeker"
29
+ Requires-Dist: joblib>=1.3; extra == "seeker"
30
+ Requires-Dist: openai>=1.30; extra == "seeker"
31
+ Provides-Extra: skl
32
+ Requires-Dist: scikit-learn>=1.3; extra == "skl"
33
+ Requires-Dist: joblib>=1.3; extra == "skl"
34
+ Provides-Extra: sqs
35
+ Requires-Dist: sqsgenerator>=0.5; extra == "sqs"
36
+ Provides-Extra: mc
37
+ Requires-Dist: numba>=0.54.0; extra == "mc"
38
+ Provides-Extra: all
39
+ Requires-Dist: mcta[mc,seeker,skl,sqs]; extra == "all"
40
+ Dynamic: license-file
41
+
42
+ [![mcta](https://img.shields.io/pypi/v/mcta?style=flat-square)](https://pypi.org/project/mcta/)
43
+ [![mcta](https://img.shields.io/pypi/pyversions/mcta?style=flat-square)](https://pypi.org/project/mcta/)
44
+ [![mcta](https://img.shields.io/pypi/l/mcta?style=flat-square)](https://pypi.org/project/mcta/)
45
+ [![mcta](https://img.shields.io/pypi/dm/mcta?style=flat-square)](https://pypi.org/project/mcta/)
46
+ [![mcta](https://img.shields.io/pypi/wheel/mcta?style=flat-square)](https://pypi.org/project/mcta/)
47
+ [![mcta](https://img.shields.io/github/last-commit/lkccrr/mcta?style=flat-square)](https://github.com/lkccrr/mcta)
48
+ [![mcta](https://img.shields.io/github/release-date/lkccrr/mcta?style=flat-square)](https://github.com/lkccrr/mcta)
49
+
50
+ ### Meta Crystal Toolkit & Analysis (mcta)
51
+
52
+ * Install (Python ≥ 3.9; core dependencies: `numpy`, `matplotlib`, `ase`):
53
+ ```bash
54
+ pip install mcta # plotting tools only
55
+ pip install "mcta[seeker]" # + mt.seeker (pymatgen, mp-api, scikit-learn, joblib, openai)
56
+ pip install "mcta[skl]" # + mt.skl (scikit-learn, joblib)
57
+ pip install "mcta[sqs]" # + mt.sqs (sqsgenerator)
58
+ pip install "mcta[mc]" # + mt.mc (numba)
59
+ pip install "mcta[all]" # all : seeker + skl + sqs + mc
60
+ ```
61
+ Every extra is optional: the core install stays small and only the tools that need them ask for one (`mt.seeker` → `mcta[seeker]`, `mt.skl` → `mcta[skl]`, `mt.sqs` → `mcta[sqs]`, `mt.mc` → `mcta[mc]`).
62
+ ***
63
+ <b style="color:blue;"><i>mt</b></i> prints an overview, checks the current directory and suggests the next command.
64
+ ***
65
+ <b style="color:blue;"><i>mt.band</b></i> — VASP output is the default data source, `vaspkit` is optional
66
+ * `-i` takes a directory (default: current). VASP output (`EIGENVAL` / `DOSCAR` / `PROCAR`) is preferred, otherwise `BAND.dat` / `PBAND*.dat` / `PDOS*.dat` are used.
67
+ * `-i` alone plots bands, `-i -d` adds the DOS panel on the right sharing the vertical energy axis, `-d` alone plots the DOS only (for a standalone figure with energy on the horizontal axis use `mt.dos`); `-r -p Mo-d` adds projected bands (needs `PROCAR`, `LORBIT = 11`); `-D -d` spin-polarized mirror plot (`--no-mirror` to keep both positive); `-m` effective masses from `EIGENVAL`; two or three directories compare calculations.
68
+ * Energies are shifted to the Fermi level (`--no-shift` keeps raw values); k-path labels come from `KPOINTS`/`KLABELS` or are computed automatically; `--export-dat DIR` dumps vaspkit-style `.dat` files.
69
+ * Some runs (e.g. HSE hybrids) do the SCF mesh and the band path in one calculation: in `EIGENVAL` / `vasprun.xml` the mesh k points carry a non-zero weight and the path points a weight of 0. Only the zero-weight path points are plotted (the `PROCAR` projections are re-indexed to match), `--keep-weights` keeps every k point. vaspkit `.dat` files are already cleaned, so they are used as they are.
70
+ ```bash
71
+ mt.band # bands of the current directory
72
+ mt.band -i calc_PBE -l g m k g # given directory, VASP or .dat auto-detected
73
+ mt.band -i calc_PBE -d -z # bands + DOS (DOSCAR or PDOS*.dat)
74
+ mt.band -i calc_PBE -r -p Mo-d # projected bands from PROCAR
75
+ mt.band -i calc_PBE -D -d # spin polarized: up/down panels + mirror DOS
76
+ mt.band -i calc_PBE -m 0.15 # effective masses from EIGENVAL
77
+ mt.band -i calc_PBE calc_HSE # compare calculations
78
+ mt.band -i BAND.dat -d PDOS*.dat # vaspkit .dat route
79
+ mt.band -i calc_HSE --keep-weights # keep the weighted k points as well
80
+ ```
81
+ ***
82
+ <b style="color:blue;"><i>mt.dos</b></i> — DOS / PDOS as a standalone figure, energy on the horizontal axis
83
+ * Same data as `mt.band`: `DOSCAR` (needs `LORBIT = 11`) or vaspkit `PDOS*.dat` / `TDOS*.dat`; `-i` takes a directory or the `.dat` files, default: current directory.
84
+ * Default orientation is **energy on the x axis**, DOS on the y axis. `-n` exchanges the axes (energy vertical), which is the orientation used by the `mt.band -d` panel.
85
+ * `-p` picks the projections (`s p d`, `Mo-d`, `all`), `-e` renames the legend, `-x` sets the DOS range, `-y` the energy window, `-z` fills the curves, `--no-mirror` keeps the spin-down DOS positive.
86
+ ```bash
87
+ mt.dos -i calc # DOS from DOSCAR / PDOS*.dat (energy on x)
88
+ mt.dos -i calc -p d -x 0 30 # d-orbital PDOS with a fixed DOS range
89
+ mt.dos -i calc -o PDOS.png -z # filled curves
90
+ mt.dos -i calc -n # energy vertical (mt.band -d orientation)
91
+ ```
92
+ ***
93
+ <b style="color:blue;"><i>mt.phband</i></b> — phonon band structure (and the DOS panel next to it)
94
+ * `-i` takes `BAND.dat` written by `phonopy-bandplot --gnuplot` (default: `BAND.dat`); `-l` labels the high-symmetry points, `-y` sets the frequency window.
95
+ * `-d [FILE]` adds the phonon DOS panel on the right, sharing the vertical frequency axis (`projected_dos.dat` / `total_dos.dat`, auto-detected when no file is given); for a standalone phonon DOS figure with frequency on the horizontal axis use `mt.phdos`.
96
+ * `-B start end` breaks the axis for the optical branches; two or three files are compared side by side.
97
+ ```bash
98
+ mt.phband -h # all parameters
99
+ mt.phband -i BAND.dat -o BAND.png -l g m k g -d projected_dos.dat -z
100
+ mt.phband -B 23 100 -l g m k g -y -2 110 # broken axis
101
+ mt.phband -i BAND1.dat BAND2.dat -B 20 100 # several files
102
+ ```
103
+ ***
104
+ <b style="color:blue;"><i>mt.phdos</b></i> — phonon DOS as a standalone figure, frequency on the horizontal axis
105
+ * Reads `projected_dos.dat` or `total_dos.dat` (written by `mt.ph dos`); `-i` takes a directory or the `.dat` file, default: current directory.
106
+ * Default orientation is **frequency on the x axis**, DOS on the y axis. `-n` exchanges the axes (frequency vertical), which is the orientation used by the `mt.phband -d` panel.
107
+ * `-e` renames the legend, `-x` sets the DOS range, `-y` the frequency window, `-z` fills the curves.
108
+ ```bash
109
+ mt.phdos # DOS of the current directory
110
+ mt.phdos -i calc -z # filled curves
111
+ mt.phdos -i calc -x 0 0.6 # fix the DOS range
112
+ mt.phdos -i calc -n # frequency vertical (mt.phband -d orientation)
113
+ ```
114
+ ***
115
+ <b style="color:blue;"><i>mt.ph</b></i> — phonopy workflow helper
116
+ * `mt.ph -b -d` writes <b style="color:darkred;"><i>band.conf</i></b> + <b style="color:darkred;"><i>mesh.conf</i></b> (names via `-B` / `-D`). Without `-b`/`-d` it walks the phonopy steps one by one (supercell &rarr; force constants &rarr; band &rarr; DOS), printing and confirming each command; `-Y` runs without asking, `-y` only prints. `B` + Enter goes back one level, `Q` + Enter quits.
117
+ * The unit cell file is auto-detected (`POSCAR-unitcell` &rarr; `CONTCAR` &rarr; `POSCAR`), or give `-c FILE`.
118
+ * By default the <b style="color:blue;">phonopy v4+</b> commands are used (`phonopy-init` for setup steps, `phonopy_params.yaml` for band/DOS); add `-O` to use the legacy (v3) forms instead.
119
+ * `-n` values (for the force-extraction step, implied by `-n` alone) may be directories, `vasprun.xml` suffixes or brace ranges; `dir-{001..003}` stays compact and bash expands it.
120
+ ```bash
121
+ mt.ph # supercell step (default; -s 2 2 1 sets DIM)
122
+ mt.ph -b -d --band "0 0 0 0.5 0 0 0.5 0.5 0.5 0 0 0" --labels "G X M G"
123
+ mt.ph supercell -s 2 2 1 -c POSCAR-unitcell # explicit supercell
124
+ mt.ph -r # force constants from ./vasprun.xml
125
+ mt.ph -n 001-003 # extract forces -> phonopy-init -f vasprun.xml-{001..003}
126
+ mt.ph band # band.conf -> band.yaml -> BAND.dat
127
+ mt.ph dos --total # mesh.conf -> projected_dos.dat (+ total_dos.dat)
128
+ mt.ph -O -y supercell -s 2 2 1 # preview the legacy v3 command only
129
+ ```
130
+
131
+ | Option | Meaning | Default |
132
+ |---|---|---|
133
+ | `-c FILE` | unit cell file | auto-detected |
134
+ | `-s N [N ...]` | supercell `DIM`, 1-3 integers (`2x2x1`, `(2,2,1)` also accepted) | `1 1 1` |
135
+ | `-r [FILE]` | forces source; alone runs `fc`; with `-n` the forces file name inside each directory | `vasprun.xml` |
136
+ | `-n NAME [NAME ...]` | directories / `vasprun.xml` suffixes / ranges for the `f` step | &mdash; |
137
+ | `-b` / `-d` | write `band.conf` / `mesh.conf` only | &mdash; |
138
+ | `-B` / `-D` | names written by `-b` / `-d` | `band.conf` / `mesh.conf` |
139
+ | `--band` / `--labels` / `--points` / `--mp` | `BAND` path, labels, points, mesh used with `-b` / `-d` | built-in, `20 20 20` |
140
+ | `-O` / `-Y` / `-y` | legacy v3 commands / run without asking / print only | &mdash; |
141
+ ***
142
+ <b style="color:blue;"><i>mt.seeker</b></i> — Materials Project retrieval and curation
143
+
144
+ Retrieves crystal structures from the **Materials Project**, writes CIF / POSCAR / JSON and packs them into bundles ready for `scp` to a server (with optional INCAR / KPOINTS / slurm templates). Local structures can be filtered, deduplicated and re-exported. No calculations are executed locally. Special quasirandom structures (SQS) from a custom unit cell is handled by the separate `mt.sqs` tool.
145
+
146
+ Set the API key once (free account at https://next-gen.materialsproject.org):
147
+
148
+ ```bash
149
+ mkdir -p ~/.config/mcta
150
+ echo 'MP_API_KEY=your-key' >> ~/.config/mcta/config
151
+ chmod 600 ~/.config/mcta/config
152
+ # or: export MP_API_KEY=... (lookup order: env -> $MT_SEEKER_CONFIG -> the file above -> ./mcseeker.conf)
153
+ ```
154
+
155
+ Typical usage:
156
+
157
+ ```bash
158
+ mt.seeker --offline # offline self-check, no key needed
159
+ mt.seeker -c Ti-C -k 3 -n ti-c # search by chemsys, export top 3
160
+ mt.seeker -f MoS2 -k 5 -F cif,poscar # search by formula
161
+ mt.seeker -I mp-149 mp-2658 # or give mp_ids directly
162
+ mt.seeker -c Cr-I -k 2 --job-template # + INCAR/KPOINTS/slurm templates
163
+ mt.seeker -t "find 2D candidates in Cr-I" -p deepseek # natural language (needs mcta[seeker])
164
+ mt.seeker -L # list previous bundles
165
+
166
+ # local curation (dedup, filter, diversity, top-up)
167
+ mt.seeker -d # dataset summary
168
+ mt.seeker -w "ehull<=0.05 and is_2d and has('Mn')" # rule filter (-y previews only)
169
+ mt.seeker -r -D 8 -o my-pick # dedup + pick 8 most dissimilar
170
+ mt.seeker -T 5 -c Mn-P-S # download 5 more structures
171
+ ```
172
+
173
+ Each bundle lands in `exports/<name>/` (`structures/<id>/`, `manifest.csv` with 14 columns, `README.md`, `results/`) plus `exports/<name>.tar.gz`. Upload with `scp exports/<name>.tar.gz user@server:~/calc/`.
174
+
175
+ Short options are case-sensitive: `-t` task vs `-T` top-up, `-r` dedup vs `-R` refresh. `mt.seeker -h` prints the full option list; LLM engines (`-p openai/deepseek/qwen/glm/kimi/siliconflow/gemini/openrouter/ollama/vllm`, any OpenAI-compatible endpoint) and all `MT_SEEKER_*` environment variables are documented there and in the code (`mcta/seeker/config.py`).
176
+ ***
177
+ <b style="color:blue;"><i>mt.sqs</b></i> — special quasirandom structures from a custom unit cell
178
+
179
+ mt.sqs reads a POSCAR / CONTCAR / CIF / JSON, expands it to a supercell, and randomises a single sublattice into a quasirandom solid solution with a specified target composition (objective: weighted sum of pair-correlation deviations, smaller = closer to perfect randomness). The engine is `sqsgenerator` (C++ + Python), no network access required.
180
+
181
+ ```bash
182
+ mt.sqs -c cell.vasp -a "Cu:0.5,Au:0.5" -x 4,4,4 -n cuau-sqs
183
+ mt.sqs -c LaAlO3.cif --host La -a "La:0.5,Sr:0.5" -x 2,2,2 # A-site only
184
+ mt.sqs -c cell.vasp -a Cu,Au --iterations 1000 --number 5 -y # dry-run: no disk write
185
+ ```
186
+
187
+ SQS bundles additionally contain `sqs.json` and `sqs_summary.csv`. `mt.sqs -h` lists every flag and default. The algorithm lives in `mcta.seeker.sqs`; the rest of `mt.seeker` no longer pulls in sqsgenerator.
188
+ ***
189
+ <b style="color:blue;"><i>mt.mc</b></i> — Monte Carlo simulation of the phase transition in 2D/3D magnetic materials (merged from `spins2`)
190
+ * `mt.mc` runs a Metropolis Monte Carlo simulation of the Ising model on square, triangular and bilayer lattices (`-c square|triangular|bilayer-aa|bilayer-ab|bilayer-ab-u-3`) and writes a `.log` file with magnetization, susceptibility and specific heat per temperature.
191
+ * `-x/-y/-z` lattice size (default 64&times;64), `-e/-w` equilibration and sampling sweeps (default 1000/1000), `-t` temperature list (default 35), `-p/-j/-k` exchange couplings in meV, `-a` single-ion anisotropy in meV, `-i` initial state (`fm`, `afm1`...`afm5`, `random`), `-n` number of threads, `-r` plot the result when the run finishes, `-o FILE` plot an existing `.log`, `-f` image format (png/pdf/svg/jpg/tif), `-l` legend.
192
+ * The kernels are compiled with `numba`, an optional dependency: `pip install "mcta[mc]"`. Without it `mt.mc` prints how to install it and stops; the other `mt` tools are unaffected.
193
+ ```bash
194
+ mt.mc -h
195
+ mt.mc -x 100 -y 100 -e 200 -w 1000 -t 35 -r
196
+ mt.mc -c bilayer-ab -a 0.1 -t 0 60 2 # 0-60 K in 2 K steps
197
+ mt.mc -o square_Ising_64_64.log -f pdf # re-plot a finished run
198
+ ```
199
+ ***
200
+ <b style="color:blue;"><i>mt.sh</b></i> — run bash helper scripts by short name
201
+ * `mt.sh NAME [args...]` executes script `NAME` with bash and forwards the arguments unchanged, e.g. `mt.sh xy POSCAR` runs `xy.sh POSCAR`. The exit code of the script is returned.
202
+ * Script lookup order: the current directory (`./NAME.sh`, local overrides first) &rarr; directories listed in `$MTSH_SCRIPTS` (colon/semicolon-separated) &rarr; the scripts bundled with the package (`mcta/sh/scripts/`).
203
+ * Bare `mt.sh` (or `mt.sh -l`) lists every script found with a one-line description taken from the first comment line.
204
+ * Bundled scripts (VASP workflow helpers, best run on Linux/WSL; Windows needs Git Bash on PATH and the scripts use `sed`/`awk`/`bc`):
205
+
206
+ ## Citation
207
+
208
+ Structure data comes from the Materials Project: A. Jain et al., *APL Materials* 1, 011002 (2013).
mcta-0.0.3/README.md ADDED
@@ -0,0 +1,167 @@
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`):
12
+ ```bash
13
+ pip install mcta # plotting tools only
14
+ pip install "mcta[seeker]" # + mt.seeker (pymatgen, mp-api, scikit-learn, joblib, openai)
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 : seeker + skl + sqs + mc
19
+ ```
20
+ Every extra is optional: the core install stays small and only the tools that need them ask for one (`mt.seeker` &rarr; `mcta[seeker]`, `mt.skl` &rarr; `mcta[skl]`, `mt.sqs` &rarr; `mcta[sqs]`, `mt.mc` &rarr; `mcta[mc]`).
21
+ ***
22
+ <b style="color:blue;"><i>mt</b></i> prints an overview, checks the current directory and suggests the next command.
23
+ ***
24
+ <b style="color:blue;"><i>mt.band</b></i> — VASP output is the default data source, `vaspkit` is optional
25
+ * `-i` takes a directory (default: current). VASP output (`EIGENVAL` / `DOSCAR` / `PROCAR`) is preferred, otherwise `BAND.dat` / `PBAND*.dat` / `PDOS*.dat` are used.
26
+ * `-i` alone plots bands, `-i -d` adds the DOS panel on the right sharing the vertical energy axis, `-d` alone plots the DOS only (for a standalone figure with energy on the horizontal axis use `mt.dos`); `-r -p Mo-d` adds projected bands (needs `PROCAR`, `LORBIT = 11`); `-D -d` spin-polarized mirror plot (`--no-mirror` to keep both positive); `-m` effective masses from `EIGENVAL`; two or three directories compare calculations.
27
+ * Energies are shifted to the Fermi level (`--no-shift` keeps raw values); k-path labels come from `KPOINTS`/`KLABELS` or are computed automatically; `--export-dat DIR` dumps vaspkit-style `.dat` files.
28
+ * Some runs (e.g. HSE hybrids) do the SCF mesh and the band path in one calculation: in `EIGENVAL` / `vasprun.xml` the mesh k points carry a non-zero weight and the path points a weight of 0. Only the zero-weight path points are plotted (the `PROCAR` projections are re-indexed to match), `--keep-weights` keeps every k point. vaspkit `.dat` files are already cleaned, so they are used as they are.
29
+ ```bash
30
+ mt.band # bands of the current directory
31
+ mt.band -i calc_PBE -l g m k g # given directory, VASP or .dat auto-detected
32
+ mt.band -i calc_PBE -d -z # bands + DOS (DOSCAR or PDOS*.dat)
33
+ mt.band -i calc_PBE -r -p Mo-d # projected bands from PROCAR
34
+ mt.band -i calc_PBE -D -d # spin polarized: up/down panels + mirror DOS
35
+ mt.band -i calc_PBE -m 0.15 # effective masses from EIGENVAL
36
+ mt.band -i calc_PBE calc_HSE # compare calculations
37
+ mt.band -i BAND.dat -d PDOS*.dat # vaspkit .dat route
38
+ mt.band -i calc_HSE --keep-weights # keep the weighted k points as well
39
+ ```
40
+ ***
41
+ <b style="color:blue;"><i>mt.dos</b></i> — DOS / PDOS as a standalone figure, energy on the horizontal axis
42
+ * Same data as `mt.band`: `DOSCAR` (needs `LORBIT = 11`) or vaspkit `PDOS*.dat` / `TDOS*.dat`; `-i` takes a directory or the `.dat` files, default: current directory.
43
+ * Default orientation is **energy on the x axis**, DOS on the y axis. `-n` exchanges the axes (energy vertical), which is the orientation used by the `mt.band -d` panel.
44
+ * `-p` picks the projections (`s p d`, `Mo-d`, `all`), `-e` renames the legend, `-x` sets the DOS range, `-y` the energy window, `-z` fills the curves, `--no-mirror` keeps the spin-down DOS positive.
45
+ ```bash
46
+ mt.dos -i calc # DOS from DOSCAR / PDOS*.dat (energy on x)
47
+ mt.dos -i calc -p d -x 0 30 # d-orbital PDOS with a fixed DOS range
48
+ mt.dos -i calc -o PDOS.png -z # filled curves
49
+ mt.dos -i calc -n # energy vertical (mt.band -d orientation)
50
+ ```
51
+ ***
52
+ <b style="color:blue;"><i>mt.phband</i></b> — phonon band structure (and the DOS panel next to it)
53
+ * `-i` takes `BAND.dat` written by `phonopy-bandplot --gnuplot` (default: `BAND.dat`); `-l` labels the high-symmetry points, `-y` sets the frequency window.
54
+ * `-d [FILE]` adds the phonon DOS panel on the right, sharing the vertical frequency axis (`projected_dos.dat` / `total_dos.dat`, auto-detected when no file is given); for a standalone phonon DOS figure with frequency on the horizontal axis use `mt.phdos`.
55
+ * `-B start end` breaks the axis for the optical branches; two or three files are compared side by side.
56
+ ```bash
57
+ mt.phband -h # all parameters
58
+ mt.phband -i BAND.dat -o BAND.png -l g m k g -d projected_dos.dat -z
59
+ mt.phband -B 23 100 -l g m k g -y -2 110 # broken axis
60
+ mt.phband -i BAND1.dat BAND2.dat -B 20 100 # several files
61
+ ```
62
+ ***
63
+ <b style="color:blue;"><i>mt.phdos</b></i> — phonon DOS as a standalone figure, frequency on the horizontal axis
64
+ * Reads `projected_dos.dat` or `total_dos.dat` (written by `mt.ph dos`); `-i` takes a directory or the `.dat` file, default: current directory.
65
+ * Default orientation is **frequency on the x axis**, DOS on the y axis. `-n` exchanges the axes (frequency vertical), which is the orientation used by the `mt.phband -d` panel.
66
+ * `-e` renames the legend, `-x` sets the DOS range, `-y` the frequency window, `-z` fills the curves.
67
+ ```bash
68
+ mt.phdos # DOS of the current directory
69
+ mt.phdos -i calc -z # filled curves
70
+ mt.phdos -i calc -x 0 0.6 # fix the DOS range
71
+ mt.phdos -i calc -n # frequency vertical (mt.phband -d orientation)
72
+ ```
73
+ ***
74
+ <b style="color:blue;"><i>mt.ph</b></i> — phonopy workflow helper
75
+ * `mt.ph -b -d` writes <b style="color:darkred;"><i>band.conf</i></b> + <b style="color:darkred;"><i>mesh.conf</i></b> (names via `-B` / `-D`). Without `-b`/`-d` it walks the phonopy steps one by one (supercell &rarr; force constants &rarr; band &rarr; DOS), printing and confirming each command; `-Y` runs without asking, `-y` only prints. `B` + Enter goes back one level, `Q` + Enter quits.
76
+ * The unit cell file is auto-detected (`POSCAR-unitcell` &rarr; `CONTCAR` &rarr; `POSCAR`), or give `-c FILE`.
77
+ * By default the <b style="color:blue;">phonopy v4+</b> commands are used (`phonopy-init` for setup steps, `phonopy_params.yaml` for band/DOS); add `-O` to use the legacy (v3) forms instead.
78
+ * `-n` values (for the force-extraction step, implied by `-n` alone) may be directories, `vasprun.xml` suffixes or brace ranges; `dir-{001..003}` stays compact and bash expands it.
79
+ ```bash
80
+ mt.ph # supercell step (default; -s 2 2 1 sets DIM)
81
+ mt.ph -b -d --band "0 0 0 0.5 0 0 0.5 0.5 0.5 0 0 0" --labels "G X M G"
82
+ mt.ph supercell -s 2 2 1 -c POSCAR-unitcell # explicit supercell
83
+ mt.ph -r # force constants from ./vasprun.xml
84
+ mt.ph -n 001-003 # extract forces -> phonopy-init -f vasprun.xml-{001..003}
85
+ mt.ph band # band.conf -> band.yaml -> BAND.dat
86
+ mt.ph dos --total # mesh.conf -> projected_dos.dat (+ total_dos.dat)
87
+ mt.ph -O -y supercell -s 2 2 1 # preview the legacy v3 command only
88
+ ```
89
+
90
+ | Option | Meaning | Default |
91
+ |---|---|---|
92
+ | `-c FILE` | unit cell file | auto-detected |
93
+ | `-s N [N ...]` | supercell `DIM`, 1-3 integers (`2x2x1`, `(2,2,1)` also accepted) | `1 1 1` |
94
+ | `-r [FILE]` | forces source; alone runs `fc`; with `-n` the forces file name inside each directory | `vasprun.xml` |
95
+ | `-n NAME [NAME ...]` | directories / `vasprun.xml` suffixes / ranges for the `f` step | &mdash; |
96
+ | `-b` / `-d` | write `band.conf` / `mesh.conf` only | &mdash; |
97
+ | `-B` / `-D` | names written by `-b` / `-d` | `band.conf` / `mesh.conf` |
98
+ | `--band` / `--labels` / `--points` / `--mp` | `BAND` path, labels, points, mesh used with `-b` / `-d` | built-in, `20 20 20` |
99
+ | `-O` / `-Y` / `-y` | legacy v3 commands / run without asking / print only | &mdash; |
100
+ ***
101
+ <b style="color:blue;"><i>mt.seeker</b></i> — Materials Project retrieval and curation
102
+
103
+ Retrieves crystal structures from the **Materials Project**, writes CIF / POSCAR / JSON and packs them into bundles ready for `scp` to a server (with optional INCAR / KPOINTS / slurm templates). Local structures can be filtered, deduplicated and re-exported. No calculations are executed locally. Special quasirandom structures (SQS) from a custom unit cell is handled by the separate `mt.sqs` tool.
104
+
105
+ Set the API key once (free account at https://next-gen.materialsproject.org):
106
+
107
+ ```bash
108
+ mkdir -p ~/.config/mcta
109
+ echo 'MP_API_KEY=your-key' >> ~/.config/mcta/config
110
+ chmod 600 ~/.config/mcta/config
111
+ # or: export MP_API_KEY=... (lookup order: env -> $MT_SEEKER_CONFIG -> the file above -> ./mcseeker.conf)
112
+ ```
113
+
114
+ Typical usage:
115
+
116
+ ```bash
117
+ mt.seeker --offline # offline self-check, no key needed
118
+ mt.seeker -c Ti-C -k 3 -n ti-c # search by chemsys, export top 3
119
+ mt.seeker -f MoS2 -k 5 -F cif,poscar # search by formula
120
+ mt.seeker -I mp-149 mp-2658 # or give mp_ids directly
121
+ mt.seeker -c Cr-I -k 2 --job-template # + INCAR/KPOINTS/slurm templates
122
+ mt.seeker -t "find 2D candidates in Cr-I" -p deepseek # natural language (needs mcta[seeker])
123
+ mt.seeker -L # list previous bundles
124
+
125
+ # local curation (dedup, filter, diversity, top-up)
126
+ mt.seeker -d # dataset summary
127
+ mt.seeker -w "ehull<=0.05 and is_2d and has('Mn')" # rule filter (-y previews only)
128
+ mt.seeker -r -D 8 -o my-pick # dedup + pick 8 most dissimilar
129
+ mt.seeker -T 5 -c Mn-P-S # download 5 more structures
130
+ ```
131
+
132
+ Each bundle lands in `exports/<name>/` (`structures/<id>/`, `manifest.csv` with 14 columns, `README.md`, `results/`) plus `exports/<name>.tar.gz`. Upload with `scp exports/<name>.tar.gz user@server:~/calc/`.
133
+
134
+ Short options are case-sensitive: `-t` task vs `-T` top-up, `-r` dedup vs `-R` refresh. `mt.seeker -h` prints the full option list; LLM engines (`-p openai/deepseek/qwen/glm/kimi/siliconflow/gemini/openrouter/ollama/vllm`, any OpenAI-compatible endpoint) and all `MT_SEEKER_*` environment variables are documented there and in the code (`mcta/seeker/config.py`).
135
+ ***
136
+ <b style="color:blue;"><i>mt.sqs</b></i> — special quasirandom structures from a custom unit cell
137
+
138
+ mt.sqs reads a POSCAR / CONTCAR / CIF / JSON, expands it to a supercell, and randomises a single sublattice into a quasirandom solid solution with a specified target composition (objective: weighted sum of pair-correlation deviations, smaller = closer to perfect randomness). The engine is `sqsgenerator` (C++ + Python), no network access required.
139
+
140
+ ```bash
141
+ mt.sqs -c cell.vasp -a "Cu:0.5,Au:0.5" -x 4,4,4 -n cuau-sqs
142
+ mt.sqs -c LaAlO3.cif --host La -a "La:0.5,Sr:0.5" -x 2,2,2 # A-site only
143
+ mt.sqs -c cell.vasp -a Cu,Au --iterations 1000 --number 5 -y # dry-run: no disk write
144
+ ```
145
+
146
+ SQS bundles additionally contain `sqs.json` and `sqs_summary.csv`. `mt.sqs -h` lists every flag and default. The algorithm lives in `mcta.seeker.sqs`; the rest of `mt.seeker` no longer pulls in sqsgenerator.
147
+ ***
148
+ <b style="color:blue;"><i>mt.mc</b></i> — Monte Carlo simulation of the phase transition in 2D/3D magnetic materials (merged from `spins2`)
149
+ * `mt.mc` runs a Metropolis Monte Carlo simulation of the Ising model on square, triangular and bilayer lattices (`-c square|triangular|bilayer-aa|bilayer-ab|bilayer-ab-u-3`) and writes a `.log` file with magnetization, susceptibility and specific heat per temperature.
150
+ * `-x/-y/-z` lattice size (default 64&times;64), `-e/-w` equilibration and sampling sweeps (default 1000/1000), `-t` temperature list (default 35), `-p/-j/-k` exchange couplings in meV, `-a` single-ion anisotropy in meV, `-i` initial state (`fm`, `afm1`...`afm5`, `random`), `-n` number of threads, `-r` plot the result when the run finishes, `-o FILE` plot an existing `.log`, `-f` image format (png/pdf/svg/jpg/tif), `-l` legend.
151
+ * The kernels are compiled with `numba`, an optional dependency: `pip install "mcta[mc]"`. Without it `mt.mc` prints how to install it and stops; the other `mt` tools are unaffected.
152
+ ```bash
153
+ mt.mc -h
154
+ mt.mc -x 100 -y 100 -e 200 -w 1000 -t 35 -r
155
+ mt.mc -c bilayer-ab -a 0.1 -t 0 60 2 # 0-60 K in 2 K steps
156
+ mt.mc -o square_Ising_64_64.log -f pdf # re-plot a finished run
157
+ ```
158
+ ***
159
+ <b style="color:blue;"><i>mt.sh</b></i> — run bash helper scripts by short name
160
+ * `mt.sh NAME [args...]` executes script `NAME` with bash and forwards the arguments unchanged, e.g. `mt.sh xy POSCAR` runs `xy.sh POSCAR`. The exit code of the script is returned.
161
+ * Script lookup order: the current directory (`./NAME.sh`, local overrides first) &rarr; directories listed in `$MTSH_SCRIPTS` (colon/semicolon-separated) &rarr; the scripts bundled with the package (`mcta/sh/scripts/`).
162
+ * Bare `mt.sh` (or `mt.sh -l`) lists every script found with a one-line description taken from the first comment line.
163
+ * Bundled scripts (VASP workflow helpers, best run on Linux/WSL; Windows needs Git Bash on PATH and the scripts use `sed`/`awk`/`bc`):
164
+
165
+ ## Citation
166
+
167
+ Structure data comes from the Materials Project: A. Jain et al., *APL Materials* 1, 011002 (2013).
@@ -0,0 +1,11 @@
1
+ """mt —— Meta Crystal Toolkit & Analysis"""
2
+
3
+ import os
4
+ import platform
5
+
6
+ __version__ = "0.0.3"
7
+
8
+
9
+ def version_string() -> str:
10
+ """统一的 -V 输出格式。"""
11
+ return "Meta Crystal Toolkit & Analysis " + __version__ + " from " + os.path.dirname(__file__) + ' (python' + platform.python_version() + ')'
@@ -0,0 +1,7 @@
1
+ """允许 ``python -m mcta`` 直接调用统一入口。"""
2
+
3
+ import sys
4
+
5
+ from mcta.cli import main
6
+
7
+ sys.exit(main())
@@ -0,0 +1,191 @@
1
+ """mt.dos:单独绘制态密度(DOS / PDOS),默认 Energy 为横轴。
2
+
3
+ 与 ``mt.band -d`` 的分工:
4
+ - ``mt.dos`` 独立成图,横轴 Energy、纵轴 DOS(``-n`` 可换回纵轴 Energy)
5
+ - ``mt.band -d`` 把 DOS 画在能带图右侧,与能带共用纵轴 Energy
6
+
7
+ 数据来源与 mt.band 相同:VASP 的 DOSCAR(LORBIT = 11),
8
+ 或 vaspkit 的 PDOS*.dat / TDOS*.dat。
9
+
10
+ 用法:
11
+ mt.dos 当前目录的 DOSCAR 或 PDOS*.dat
12
+ mt.dos -i calc -p d 只画 d 轨道投影
13
+ mt.dos -i calc -o DOS.png 指定输出文件
14
+ mt.dos -n 交换坐标轴(Energy 为纵轴,与 mt.band -d 的面板一致)
15
+ """
16
+ import argparse
17
+ import ast
18
+ import glob
19
+ import os
20
+ import re
21
+
22
+ import matplotlib.pyplot as plt
23
+
24
+ from mcta import version_string
25
+ from mcta.bandplot import plots, readdata
26
+ from mcta.bandplot.wrapper import (cla_fig, _clean_dos_labels,
27
+ _dat_dos_files, _is_vasp_dir)
28
+
29
+ plt.rcParams['xtick.direction'] = 'in'
30
+ plt.rcParams['ytick.direction'] = 'in'
31
+ plt.rcParams['ytick.minor.visible'] = True
32
+ plt.rcParams["mathtext.fontset"] = 'cm'
33
+
34
+ DEFAULT_ENERGY = [-5.0, 5.0]
35
+
36
+
37
+ def _resolve(paths):
38
+ """把 -i 的取值解析成 ``(mode, target)``:``("vasp", dir)`` 或 ``("dat", [files])``。
39
+
40
+ 目录:有 DOSCAR 走 VASP,否则找 PDOS*.dat / TDOS*.dat;文件:按 .dat 处理。
41
+ 出错时返回 ``(None, None)`` 并打印提示。
42
+ """
43
+ dirs, files, missing = [], [], []
44
+ for value in paths:
45
+ if os.path.isdir(value):
46
+ dirs.append(value)
47
+ continue
48
+ hits = [h for h in sorted(glob.glob(value)) if os.path.isfile(h)]
49
+ if hits:
50
+ files += hits
51
+ else:
52
+ missing.append(value)
53
+ if missing:
54
+ print("ERROR: 找不到输入:%s" % ", ".join(missing))
55
+ return None, None
56
+ if dirs and files:
57
+ print("ERROR: 目录与 .dat 文件不能混在一起,请只给一种。")
58
+ return None, None
59
+ if dirs:
60
+ if len(dirs) > 1:
61
+ print("ERROR: mt.dos 一次只画一个体系;对比请分别画图。")
62
+ return None, None
63
+ directory = dirs[0]
64
+ if os.path.exists(os.path.join(directory, "DOSCAR")):
65
+ return "vasp", directory
66
+ dats = _dat_dos_files(directory)
67
+ if dats:
68
+ return "dat", dats
69
+ if _is_vasp_dir(directory):
70
+ print("ERROR: %s 里没有 DOSCAR;计算时请设置 LORBIT = 11。" % directory)
71
+ else:
72
+ print("ERROR: %s 里没有 DOSCAR、PDOS*.dat 或 TDOS*.dat。" % directory)
73
+ return None, None
74
+ if not files:
75
+ print("ERROR: 没有输入文件。")
76
+ return None, None
77
+ return "dat", sorted(files)
78
+
79
+
80
+ def _formula(workdir):
81
+ """从 POSCAR/CONTCAR 拼化学式(如 Cu$_2$O),拿不到就返回空串。"""
82
+ for name in ("POSCAR", "CONTCAR"):
83
+ poscar = os.path.join(workdir, name)
84
+ if not os.path.exists(poscar):
85
+ continue
86
+ symbol, factor = readdata.symbols(poscar)
87
+ formula = ""
88
+ for sym, num in zip(symbol, factor):
89
+ formula += sym
90
+ if num > 1:
91
+ formula += "$_" + str(num) + "$"
92
+ return formula
93
+ return ""
94
+
95
+
96
+ def _expand(values, literal=False):
97
+ """展开 ``x*3`` 形式的取值;literal=True 时把 ``(r,g,b)`` 之类转成元组。"""
98
+ out = []
99
+ for value in values:
100
+ count = value.split('*')
101
+ if len(count) == 2:
102
+ item = count[0]
103
+ if literal and '(' in item and ')' in item:
104
+ out += [ast.literal_eval(item)] * int(count[1])
105
+ else:
106
+ out += [item] * int(count[1])
107
+ else:
108
+ out += [ast.literal_eval(value)] if literal and '(' in value and ')' in value else [value]
109
+ return out
110
+
111
+
112
+ def main(argv=None):
113
+ parser = argparse.ArgumentParser(
114
+ description='Plot the density of states (DOS/PDOS) from VASP output or vaspkit results; '
115
+ 'the energy is on the horizontal axis by default.',
116
+ add_help=False,
117
+ epilog='''
118
+ Example:
119
+ mt.dos # 当前目录的 DOSCAR 或 PDOS*.dat,横轴为 Energy
120
+ mt.dos -i calc # 指定目录,自动识别 DOSCAR / PDOS*.dat
121
+ mt.dos -i calc -p d -x 0 30 # 只画 d 轨道,DOS 范围 0-30
122
+ mt.dos -i calc -o PDOS.png -z # 填充曲线
123
+ mt.dos -i calc -n # 交换坐标轴,纵轴 Energy(同 mt.band -d 面板)
124
+ mt.dos -i PDOS*.dat # 直接给 vaspkit 的 .dat 文件
125
+ ''',
126
+ formatter_class=argparse.RawDescriptionHelpFormatter)
127
+ parser.add_argument('-h', '-H', "--help", action="help", help='show this help message and exit')
128
+ parser.add_argument('-v', '-V', "--version", action="version", version=version_string())
129
+ parser.add_argument('-i', "--input", type=str, nargs='*', default=None, metavar="PATH",
130
+ help="directory with DOSCAR or PDOS*.dat/TDOS*.dat, or .dat files; default: current directory")
131
+ parser.add_argument('-o', "--output", type=str, help="plot figure filename, default: DOS.png", default="DOS.png")
132
+ parser.add_argument('-q', "--dpi", type=int, help="dpi of the figure, default: 500", default=500)
133
+ parser.add_argument('-S', "--size", type=float, nargs=2, help='figure size: width, height', metavar=('width', 'height'))
134
+ parser.add_argument('-y', "--energy", type=float, nargs=2, help="energy (eV) range, default: [-5.0, 5.0]", metavar=('start', 'end'))
135
+ parser.add_argument('-x', "--horizontal", type=float, nargs=2, help="Density of states, electrons/eV range", metavar=('start', 'end'))
136
+ parser.add_argument('-p', "--partial", type=str, nargs='+', default=[], help='the partial DOS to plot, s p d, or symbol-s,p,d')
137
+ parser.add_argument('-e', "--elements", type=str, nargs='+', default=[], help="PDOS labels")
138
+ parser.add_argument('-n', "--exchange", action='store_true', help="exchange the axes: energy vertical (mt.band -d style)")
139
+ parser.add_argument('-G', "--legend", type=str, nargs='+', default=[], help="legend labels")
140
+ parser.add_argument('-A', "--location", type=str.lower, nargs='+', default=[], help="arrange the legend location, default: best", metavar="str")
141
+ parser.add_argument('-C', "--color", type=str, nargs='+', default=[], help="line color: b, blue; g, green; r, red; c, cyan; m, magenta; y, yellow; k, black; or a tuple like (0.1,0.2,0.3); a*3 repeats it 3 times", metavar="str")
142
+ parser.add_argument('-k', "--linestyle", type=str, nargs='+', default=[], help="linestyle: solid, dashed, dashdot, dotted or tuple; default: solid", metavar="str")
143
+ parser.add_argument('-w', "--linewidth", type=str, nargs='+', default=[], help="linewidth, default: 0.8", metavar="0.8")
144
+ parser.add_argument('-z', "--fill", type=float, nargs='?', help='fill a shaded region between PDOS and axis, default: 0.2', default=None, const=0.2, metavar="alpha")
145
+ parser.add_argument('--no-mirror', action='store_true', help='keep the spin-down DOS positive (default: spin-up > 0, spin-down < 0)')
146
+ parser.add_argument('--no-shift', action='store_true', help='keep raw energies (do not shift by E-fermi)')
147
+ parser.add_argument('-f', "--font", type=str, help="font to use", default='STIXGeneral')
148
+ args = parser.parse_args(argv)
149
+
150
+ mode, target = _resolve(list(args.input) if args.input else ["."])
151
+ if mode is None:
152
+ return
153
+
154
+ if mode == "vasp":
155
+ from mcta.bandplot import vaspread
156
+ vd = vaspread.VaspData(target, shift=not args.no_shift)
157
+ darr, dele, s_elements = vd.dos()
158
+ workdir = target
159
+ else:
160
+ darr, dele, s_elements = readdata.dos(target)
161
+ workdir = os.path.dirname(os.path.abspath(target[0]))
162
+
163
+ index_f, labels_elements = readdata.select(s_elements, args.partial)
164
+ if not index_f:
165
+ print("ERROR: 没有匹配的 DOS 列,可用 -p s,p,d 或 -p Mo-d。")
166
+ return
167
+
168
+ elements = args.elements or _clean_dos_labels(labels_elements)
169
+ legend = args.legend or [_formula(workdir) or os.path.basename(os.path.abspath(workdir)) or "."]
170
+
171
+ location = [int(i) if i.isdigit() else i for i in args.location]
172
+ font = args.font
173
+ plt.rcParams['font.family'] = '%s' % font
174
+
175
+ fig_p = cla_fig(output=args.output, size=args.size,
176
+ # vertical 始终表示能量范围;exchange=True 时能量在横轴
177
+ vertical=args.energy or list(DEFAULT_ENERGY),
178
+ horizontal=args.horizontal,
179
+ color=_expand(args.color), linestyle=_expand(args.linestyle),
180
+ linewidth=[float(i) for i in _expand(args.linewidth)],
181
+ location=location, dpi=args.dpi, fill=args.fill,
182
+ mirror=not args.no_mirror,
183
+ # mt.dos 默认能量为横轴:pdosfiles 里 exchange=True 就是这个朝向
184
+ exchange=not args.exchange)
185
+
186
+ plots.pdosfiles(darr, dele, index_f, elements, legend, fig_p)
187
+ print("已保存:" + fig_p.output)
188
+
189
+
190
+ if __name__ == "__main__":
191
+ main()