Terminal crystal structure viewer with ASCII and Unicode rendering
Project description
xtalui
xtalui is a terminal-first crystal structure viewer for atomistic and crystalline structures.
It renders structures directly in the terminal using:
- ASCII, Unicode, and Braille rendering for cell edges, bonds, and atoms
- depth-aware atom glyphs or element labels
- interactive camera controls without launching a GUI
- a single-command CLI:
xtal STRUCTURE_FILE [STRUCTURE_FILE ...]
Features
- Load structures through ASE
- Load self-contained ABACUS
STRUfiles with explicitLATTICE_VECTORS - Load multi-frame structure series supported by ASE
- Accept multiple input files and concatenate all frames into one trajectory series
- Show atoms, bonds, and the unit cell in the terminal
- Toggle between point and sphere atom rendering
- Display chemical formula, lattice vectors, cell lengths and angles, volume, and space group
- Show both lattice-frame
a/b/cand Cartesianx/y/zdirection widgets - Show atomic positions and bond lengths in scrollable overlay panels
- Calibrate the terminal aspect ratio with a Braille circle test pattern
- Toggle labels, bonds, cell frame, color, sphere mode, and direction panels at runtime
- Autoplay continuous rotation directly in the terminal
- Autoplay multi-frame structure series directly in the terminal
- Align the view along
x,y, orzwith one keypress
Installation
Recommended for daily use: install xtal as a standalone uv tool so it is not tied to a project virtual environment.
Once the package is published on PyPI:
uv tool install xtalui
Directly from GitHub:
uv tool install git+https://github.com/bonan-group/xtalui
Standard pip installation from PyPI:
python -m pip install xtalui
Standard pip installation directly from GitHub:
python -m pip install git+https://github.com/bonan-group/xtalui
From a local checkout:
git clone https://github.com/bonan-group/xtalui.git
cd xtalui
uv tool install --editable .
Local editable install with standard pip:
git clone https://github.com/bonan-group/xtalui.git
cd xtalui
python -m pip install -e .
If xtal is not yet on your PATH, run:
uv tool update-shell
Then you can launch the viewer directly:
xtal examples/silicon_diamond.cif
For development work inside the repository:
uv venv --python /usr/bin/python3 .venv
uv sync --extra dev
You can also run it without activating the environment:
uv run xtal --help
uv run python -m xtalui --help
Development
uv sync --extra dev
uv run pytest -q
uv run ruff check .
uv run ruff format --check .
Usage
uv run xtal structure.cif
uv run xtal frame1.xyz frame2.xyz
uv run xtal -n 1: trajectory.xyz
uv run xtal trajectory.xyz@::10 other.xyz@-5:
uv run xtal POSCAR -r 2 2 1
uv run xtal structure.cif -s 1e-3
uv run xtal structure.cif -c
uv run xtal STRU
The repository also ships with generated sample structures:
uv run xtal examples/silicon_diamond.cif
uv run xtal examples/gaas_zincblende.cif
uv run xtal examples/graphite_hexagonal.cif
CLI Options
PATH: one or more structure files to open with ASE- If multiple paths are given, all frames from all files are concatenated into one trajectory series in the order provided
- Append
@SLICEto one filename to select a subset of frames from that file only, for exampletraj.xyz@::5 -n SLICE,--image-number SLICE: pick individual image(s) from each input file using Python slice syntax like0,1:,:10, or::2@SLICEon a filename overrides-n/--image-numberfor that file-r NX NY NZ,--repeat NX NY NZ: repeat the structure along each lattice direction--hide-cell: start with the unit cell hidden-s FLOAT,--symprec FLOAT: set the symmetry tolerance used for space-group detection-c,--color: start with element colors enabled
Controls
Left/Right: rotate around YUp/Down: rotate around X, or scroll the active overlay panel when one is openx/y/z: align the view along the Cartesian axesa: toggle automatic rotationp: toggle the atomic positions overlayB: toggle the bond-length overlayt: toggle automatic frame playback for multi-frame seriesT: toggle calibration moderXYZ: rebuild the displayed structure as an in-appXxYxZsupercell, for exampler222[/]: move backward or forward through a loaded structure seriesj/k: scroll the active overlay panel down or up1: toggle theabc dirspanel2: toggle thexyz dirspanelShift+Left/Shift+Right: pan XShift+Up/Shift+Down: pan Y+/-: zoom in/outm: toggle line mode between Braille and Unicode wireframeb: toggle bondsc: toggle unit cellC: toggle element colorss: toggle sphere mode for atomsLeft/Rightor+/-in calibration mode: decrease or increase the render aspect ratioCtrl-R: reset the view camera and restore the launch repeatl: toggle labelsEsc: cancel an in-progress repeat command?: toggle helpq: quit
Calibration
Press T to enter calibration mode. The main view is replaced by a Braille-rendered circle.
Adjust the aspect ratio with:
Left/Right+/-
until the circle looks round in your terminal and font. The current value is shown in the footer as aspect=....
Press T again to return to the structure view. The calibrated aspect ratio is then used by:
- the main crystal renderer
- the
abc dirspanel - the
xyz dirspanel
Overlay Panels
Press p to show atomic positions for the current frame. The table includes:
- atom index
- element symbol
- Cartesian coordinates
- direct (fractional) coordinates
Press B to show the bond-length overlay. Each row lists:
- the full indices of both atoms in the bond
- the bond length
- the periodic image offset used for that displayed bond
Both overlays are scrollable with:
Up/Downj/k
The overlays are drawn over the main view, so opening them does not rescale the structure display.
Atom Rendering
By default, atoms are shown as points. Press s to switch to sphere mode.
- In Unicode mode, spheres use a constant filled-circle glyph
- In Braille mode, spheres are rasterized on the Braille subcell grid
- In label mode, element labels are still drawn on top of the spheres
Notes
- The Python package name is
xtalui, while the installed CLI command isxtal. - Space-group detection uses
spglibthrough ASE-compatible structure data. - Bond detection follows the ASE GUI heuristic: a periodic neighbor list with a
1.5xcovalent-radius cutoff. - Color mode uses ASE Jmol-style element colors for atoms and atom labels.
- ABACUS
STRUsupport is built in for files that include explicitLATTICE_VECTORS. STRUfiles that rely onLATTICE_PARAMETER(S)pluslatnamefrom a separateINPUTfile are not supported.- Braille mode is the default line renderer because it provides smoother terminal line quality.
- Example CIF files in
examples/are generated with ASE for common crystal prototypes.
Release
Releases are tag-driven:
git tag v0.1.0
git push origin v0.1.0
The GitHub release workflow validates that the tag matches project.version, builds the package, publishes a GitHub Release, and uploads to PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xtalui-0.1.1.tar.gz.
File metadata
- Download URL: xtalui-0.1.1.tar.gz
- Upload date:
- Size: 32.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05e057153be1600838d987cd699d142a95afd39b11a0b59ced5d1dfb46e2c363
|
|
| MD5 |
a8128a2ff7dc30930eb6f0741594535b
|
|
| BLAKE2b-256 |
a01c59dabfa00521f8d94f8fdb136ac01066499f8534da277d99a5479cee8726
|
Provenance
The following attestation bundles were made for xtalui-0.1.1.tar.gz:
Publisher:
release.yml on bonan-group/xtalui
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xtalui-0.1.1.tar.gz -
Subject digest:
05e057153be1600838d987cd699d142a95afd39b11a0b59ced5d1dfb46e2c363 - Sigstore transparency entry: 1191381300
- Sigstore integration time:
-
Permalink:
bonan-group/xtalui@4ef05f269533574e716e75437d3cb7f922eaac4c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/bonan-group
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4ef05f269533574e716e75437d3cb7f922eaac4c -
Trigger Event:
push
-
Statement type:
File details
Details for the file xtalui-0.1.1-py3-none-any.whl.
File metadata
- Download URL: xtalui-0.1.1-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
643063e1b2e152b694504f3502873f27a4e8a103b878f6b5821794251af43818
|
|
| MD5 |
ca61bb1503c160fda4bcc3657de506b6
|
|
| BLAKE2b-256 |
d81a820b8311e2e7e72b53126c28345e40cdb0aecdf116e62243ab3a5fcf01e2
|
Provenance
The following attestation bundles were made for xtalui-0.1.1-py3-none-any.whl:
Publisher:
release.yml on bonan-group/xtalui
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xtalui-0.1.1-py3-none-any.whl -
Subject digest:
643063e1b2e152b694504f3502873f27a4e8a103b878f6b5821794251af43818 - Sigstore transparency entry: 1191381301
- Sigstore integration time:
-
Permalink:
bonan-group/xtalui@4ef05f269533574e716e75437d3cb7f922eaac4c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/bonan-group
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4ef05f269533574e716e75437d3cb7f922eaac4c -
Trigger Event:
push
-
Statement type: