mcta
McTa (Meta Crystal Toolkit & Analysis).
Downloads & Community Adoption
Health & Engineering Analysis (5 Pillars)
1. Governance & Community50 / 200 ▾
2. PEP Metadata & Packaging200 / 200 ▾
3. Security & Supply Chain200 / 200 ▾
4. Documentation, SEO & Ecosystem155 / 200 ▾
5. Engineering, CI & Quality65 / 200 ▾
Official Documentation & Usage Guide — mcta
Show full original documentation (English README) ▾
Meta Crystal Toolkit & Analysis (McTa)
- Install (Python ≥ 3.9; core dependencies:
numpy,matplotlib,ase,spglib,paramiko):
pip install mcta # plotting tools only
pip install mcta[seek] # + mt.seek (pymatgen, mp-api, openai); also enables mt.skl
pip install mcta[skl] # + mt.skl (scikit-learn, joblib)
pip install mcta[sqs] # + mt.sqs (sqsgenerator)
pip install mcta[mc] # + mt.mc (numba)
pip install mcta[all] # all: seek + skl + sqs + mc
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]).
mt prints an overview, checks the current directory and suggests the next command.
mt.band / mt.phband: electronic and phonon band structures, with an optional DOS panel
mt.bandreads VASP output from a directory (-i, default: current), preferring it overBAND.dat/PBAND*.dat/PDOS*.dat;-dadds DOS,-r -p Mo-dadds projections,-D -dmakes a spin-polarized mirror plot,-mcalculates effective masses, and two or three directories compare calculations.- Energies are shifted to the Fermi level (
--no-shiftdisables this);-lsets k-path labels (fromKPOINTS/KLABELSor computed automatically) and--export-dat DIRexports vaspkit-style data. For combined SCF-mesh/band-path calculations, only zero-weight path points are plotted (--keep-weightskeeps every k point); vaspkit.datfiles are used unchanged. mt.phbandreadsBAND.datwritten byphonopy-bandplot --gnuplot;-llabels high-symmetry points,-ysets the frequency window,-d [FILE]adds a DOS panel sharing the axis (projected_dos.dat/total_dos.datauto-detected), and-B start endbreaks the axis for optical branches; two or three files are compared side by side.
mt.band # bands of the current directory
mt.band -i calc_PBE -d -z # bands + DOS (DOSCAR or PDOS*.dat)
mt.band -i calc_PBE -r -p Mo-d # projected bands from PROCAR
mt.band -i calc_PBE -D -d # spin-polarized bands + mirror DOS
mt.band -i calc_PBE -m 0.15 # effective masses from EIGENVAL
mt.band -i calc_PBE calc_HSE # compare calculations
mt.phband -i BAND.dat -o BAND.png -l g m k g -d projected_dos.dat -z
mt.phband -B 23 100 -l g m k g -y -2 110 # broken axis
mt.phband -i BAND1.dat BAND2.dat -B 20 100 # several files
mt.dos / mt.phdos: standalone DOS figures for electrons or phonons, energy / frequency on the horizontal axis
mt.dosreadsDOSCAR(needsLORBIT = 11) or vaspkitPDOS*.dat/TDOS*.dat, from a directory or.datfiles via-i;-ppicks projections,-erenames the legend,-xsets the DOS range,-ythe energy window, and-zfills the curves.-nexchanges the axes for themt.band -dorientation, and--no-mirrorkeeps the spin-down DOS positive.mt.phdosreadsprojected_dos.dat/total_dos.dat;-e,-x,-y(frequency),-zwork as above, and-nmatches themt.phband -dorientation.
mt.dos -i calc # DOS from DOSCAR / PDOS*.dat (energy on x)
mt.dos -i calc -p d -x 0 30 # d-orbital PDOS with a fixed DOS range
mt.dos -i calc -o PDOS.png -z # filled curves
mt.dos -i calc -n # energy vertical (mt.band -d orientation)
mt.phdos -i calc -z # filled curves
mt.phdos -i calc -x 0 0.6 # fix the DOS range
mt.phdos -i calc -n # frequency vertical (mt.phband -d orientation)
mt.ph / mt.ph3: phonopy and phono3py workflow helpers
mt.phruns the interactive supercell → force constants → band → DOS workflow;-b -dwritesband.conf+mesh.conf,-Yskips confirmation, and-Ronly prints commands. The unit cell is auto-detected (POSCAR-unitcell→CONTCAR→POSCAR) or set with-c; commands adapt to phonopy v3/v4.mt.ph fscollects force data (onevasprun.xmluses--fc, several files or displacement directories use--sp -f; sources come from names,-n, or-x); other steps includeband,dos,tprop,born,symmetry,qha, andgruneisen(seemt.ph -h).mt.ph3guides supercell generation, force collection, and thermal conductivity, adapting to phono3py v3/v4 with the same-Y/-R;-s/-Sset FC3 / FC2 supercell dimensions,-cthe unit cell, and--rdcreates random-direction displacements.cf3/cf2collect forces,cfsandfs2f2convert force-set formats, and--spwritesphono3py_params.yaml.kapparuns RTA by default (--lbtefor direct LBTE),kaccumwrites cumulative conductivity, andkdeplotshows lifetime distributions;w/Wquery the offline English/Chinese wordbook (w clists setting tags,--pathshows its location,MT_PH_DOCSselects a custom JSON file).
mt.ph # interactive workflow (default: supercell)
mt.ph -b -d # write band.conf + mesh.conf
mt.ph fs 001-003 # collect forces from displacement directories
mt.ph w --dim BAND_LABELS # English original, then Chinese translation
mt.ph3 supercell -s 2 2 2 -S 4 4 4 # separate FC3 and FC2 supercells
mt.ph3 kappa -m 11 11 11 # RTA -> kappa-m111111.hdf5
mt.ph3 kaccum -k kappa-m111111.hdf5 # cumulative conductivity -> kaccum.dat
mt.ph3 w --br --symfc # English original, then Chinese translation
mt.seek / mt.sqs / mt.skl: structure retrieval, SQS generation, and data-driven analysis
mt.seek: Materials Project retrieval and curation, run directly on the server. Retrieves structures and writes one export directory<name>/in the working root — containingREADME.md,manifest.csv,mt.seek.dband one<id>/directory per structure (CIF / POSCAR / JSON, plus INCAR / KPOINTS / job script when requested; POTCAR is concatenated into the POSCAR directory withmt.sh powhen 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).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 usingsqsgenerator; no network access is required.mt.skl: data-driven analysis of exported structures with scikit-learn. Runs two regression tasks (ehullstability andband_gap) with a random forest and 5-fold cross-validation, writing results to<home>/ml/;--home DIRsets the working root (default: current directory).
mkdir -p ~/.config/mcta
echo 'MP_API_KEY=your-key' >> ~/.config/mcta/config
chmod 600 ~/.config/mcta/config
mt.seek -c Ti-C -k 3 -n ti-c # search by chemical system, export top 3
mt.seek -f MoS2 -k 5 -F cif,poscar # search by formula
mt.seek -r -D 8 -o my-pick # deduplicate + pick 8 diverse structures
mt.sqs -c cell.vasp -a "Cu:0.5,Au:0.5" -x 4,4,4 -n cuau-sqs
mt.sqs -c LaAlO3.cif --host La -a "La:0.5,Sr:0.5" -x 2,2,2 # A-site only
mt.sqs -c cell.vasp -a Cu,Au --iterations 1000 --number 5 -R # dry-run: no disk write
mt.skl # analyse <name>/manifest.csv from each export bundle
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.
Structure data comes from the Materials Project: A. Jain et al., APL Materials 1, 011002 (2013).
mt.mc: Monte Carlo simulation of phase transitions in 2D/3D magnetic materials
- 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,-Kswitches to the Heisenberg model. Requiresnumba(pip install mcta[mc]); ASE is needed for structure mode. -x/-X,-y/-Y,-z/-Zset the lattice size or supercell multiplier (default32,-zignored for 2D);-e/-wset equilibration/sampling sweeps,-p/-J/-Kcouplings,-aanisotropy,-iinitial state, and-C/-W/-Scontrol parallel chains, replica exchange and reproducibility.-taccepts a count (35), a range (20 25), start/stop/step (20 26 2), separate temperatures (20 25 30), or chained ranges.- Structure mode (
-s) reads any ASE-supported file, picks magnetic atoms (-A Fe,Coor auto d/f-block), expands the supercell and builds the neighbor table by distance bins (-D);--momsets nominal moments (default2→ S=±1) and--inithe initial state (fm/afm/randomor a ±1 list);-cis ignored with-s. Plots are automatic unless-R, and-o FILE -I pdfre-plots a finished run.
mt.mc -x 128 -y 128 -t 0 40 2 -C 6 -S 42 # 6 parallel chains, reproducible
mt.mc -c triangular -t 0 60 2 -S 42 # triangular lattice
mt.mc -c square -a 0.1 -t 20 40 2 -p 5 -J 4 -K 3 # vector spins with anisotropy
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
mt.mc -o square_Ising_32_32.log -I pdf # re-plot a finished run
mt.sh: run bash helper scripts by short name
mt.sh NAME [args...]runsNAME.shwith bash; local./NAME.shoverrides$MTSH_SCRIPTS, then bundled scripts. Baremt.shlists available scripts.- Strain scans
x|y|xy [POSCAR] [NPOINTS] [STEP]write<factor>/POSCARunderx/,y/, orxy/; defaults are 4 points per side and step 0.01. kb [POSCAR] [a [b [c]]] [OUT]expands the structure with ASE and writesSPOSCARby default; missing multipliers default to 1.sy [POSCAR] [symprec]reports spglib space-group and Wyckoff-site information; the default tolerance is1e-3Å.- Bundled VASP helpers target Linux/WSL; on Windows use Git Bash with
sed/awk/bcavailable.
mt.sh x # x strain: x/0.960 ... x/1.040 (8 points, step 0.01)
mt.sh y POSCAR 2 0.02 # y strain, 2 points per side, step 0.02
mt.sh xy POSCAR # x and y strained together
mt.sh kb POSCAR 2 2 1 # POSCAR -> SPOSCAR (2x2x1)
mt.sh sy POSCAR # space group + Wyckoff sites (symprec 1e-3)
mt.sh sy CONTCAR 0.0001 # tighter tolerance: may lower the symmetry
mt.server: local file service, structure viewer and terminal in the browser
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;-dsets 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.-fruns it in the terminal (Ctrl+Cto stop),-Sstops it, and no log file is written unless-ois given (-oalone writesmcta-server-<port>.log,-o DIR|FILEchooses the location, an existing file is overwritten; with-f -othe startup banner and interactive prompts remain in the terminal while errors go to the log).--statuslists every port where you have a service running, and-S --allstops all of them.-R/--sshconnects to a remote server.SPECacceptsuser@host:22,user@host 22,user host 22,host 22andhost; 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 withgetpass(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;-premains the web port. Legacy servers usingdiffie-hellman-group14-sha1,diffie-hellman-group1-sha1orssh-rsawork with paramiko 3/5 without downgrading: the equivalent of-oKexAlgorithms=+... -oHostKeyAlgorithms=+ssh-rsais registered at runtime. In this mode-dis a directory on the server; an invalid path falls back to the SSH default directory. Directory listings, uploads and downloads use a dedicated SSH/SFTP connection, 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 terminalcdtargets 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.- Remote 3D rendering over a Unix socket (fifth channel). When
-Ris active and the remote host has anmt.serverexecutable onPATH, in~/.local/bin, in a common conda env, or aspython3 -m mcta server— the local server only checks the executable path (keep mcta versions in sync manually) and opens a systemsshtunnel (-L 127.0.0.1:PORT:/path/to/socket, never paramiko) to a remote Unix domain socket and lets the remotemt.serverparse 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 four channels. The remote process runs in the foreground underexecwith 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 mode0700and the socket itself is0600. Override the path with--remote-socket PATHon the local server or the environment variableMCTA_REMOTE_SOCKET;mt.server --socket PATHmakes amt.serveritself 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; setMCTA_REMOTE_RENDER_MIN_MB=Nto 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. - Remote caches. In
-Rmode the working file cache is a per-process temporary directory created bytempfile.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. SetMCTA_RENDER_CACHE_MAX_MB=N(default512) to change its size limit,MCTA_REMOTE_LIST_TTL=N(seconds, default1,0disables) for directory listing cache TTL, andMCTA_RENDER_RETRY_SECONDS=N(default30) for the negative cache after a remote render channel fails. Remote write operations invalidate the affected directory listings. - The tokenized URL (
?t=...) printed at startup is the only credential — do not share it.-N(no token) and-Lon a non-loopback address are dangerous: each asks you to typeyes/YES, using both asks twice, and-L 0.0.0.0prints a warning. - Runs as the current user with no login: browse, edit and download any accessible file, with a real PTY shell (xterm.js) whose
cdthe 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.
mt.server # background on port 9068; the tokenized URL is printed
mt.server -d ./examples # serve a different directory
mt.server -p 8080 # another port
mt.server -L 0.0.0.0 # listen on all interfaces (asks for yes, then prints a warning)
mt.server -f # foreground; Ctrl+C to stop
mt.server -N # no token (asks for yes): open http://127.0.0.1:9068/ directly
mt.server -o run.log # keep the startup output in run.log (overwritten each start)
mt.server -R user@host:22 -d /home/user/project
MCTA_REMOTE_RENDER_MIN_MB=2 mt.server -R user@host # send files >2 MB to the remote renderer
mt.server --socket /tmp/mcta.sock -N -Y -f # Unix socket only, no TCP port
MCTA_RENDER_CACHE_MAX_MB=256 mt.server -R user@host # cap persistent render cache at 256 MB
MCTA_REMOTE_LIST_TTL=0 mt.server -R user@host # always re-read remote directory listings
mt.server -S # stop the service on port 9068
mt.server --status # list every port where mt.server is running
mt.server -S --all # stop all of them