Skip to content

Quick start ​

Rust ​

rust
use xtalforge::io::read_cif;

let text = std::fs::read_to_string("structure.cif")?;
let structure = xtalforge::io::read_cif(&text)?;
println!("{}", structure.summary()?.formula);
let p1 = structure.p1()?;
let bonds = structure.bond_graph()?;
let rings = xtalforge::core::rings(&structure, 8)?;

Add the facade crate to Cargo.toml:

toml
[dependencies]
xtalforge = "1.1.0"

CLI ​

bash
xtalforge info structure.cif
xtalforge --json info structure.cif
xtalforge cell --params 3 4 5 60 70 80
xtalforge element Fe
xtalforge convert structure.cif --format xyz

The binary reads a path or - for standard input and writes stdout, or a path with --out. --json switches every command to a JSON object.

Python ​

python
import xtalforge

structure = xtalforge.Structure.from_cif(open("structure.cif").read())
summary = structure.summary()
info = xtalforge.element_info("Fe")
volume = xtalforge.cell_volume(3, 4, 5, 60, 70, 80)

Install the stable release with pip install xtalforge==1.1.0; the local development wheel is built with maturin build --release.

WebAssembly ​

js
import init, { read_cif, version } from "xtalforge-wasm";
await init();
const summary = read_cif(cifText); // name, formula, hall, n_sites, volume, ...

The browser demo in Demos runs the same package offline. The package is built with wasm-pack build --release --target web.

Next ​