Skip to content

Recipes: how do I … ​

Thirty task-oriented recipes. Each row names the operation and the entry point on the four surfaces; the CLI column is runnable as written, and the Python, WASM and Rust names are the exported symbols from the parity matrix. Format hints are optional when the content is a CIF, POSCAR, XYZ or structure JSON.

#How do I …CLIPythonWASMRust
1read a structurextalforge info a.cifxtalforge.read_structure(text)read_structure(text, hint)xtalforge::read(path)
2write POSCARxtalforge convert a.cif --format poscar --out a.vaspxtalforge.write(path, text)convert_structure(text, "", "poscar")xtalforge::write(path, &s)
3detect the space groupxtalforge symmetry detect a.cifdetect_symmetry(text)detect_symmetry(text, 0.001)symmetry::detect_symmetry
4expand to P1xtalforge symmetry p1 a.cifto_p1(text)to_p1_info(text)symmetry::to_p1
5make a 2x2x2 supercellxtalforge supercell a.cif 2 2 2supercell(text, 2, 2, 2)supercell_info(text, 2, 2, 2)Structure::supercell
6cut a (1 1 1) slabxtalforge slab a.cif 1 1 1 --layers 3slab(text, 1, 1, 1, 3, 15)slab_info(text, 1, 1, 1, 3, 15)core::make_slab
7compute bonds and ringsxtalforge bonds a.cifbonds(text)bonds(text)Structure::bond_graph
8measure a distancextalforge distance a.cif 0 1distance(text, 0, 1)distance(text, 0, 1)core::distance
9compute PXRDxtalforge pxrd a.cifpxrd(text)pxrd_info(text)analysis::calculate_pxrd
10run UFF energyxtalforge ff energy a.cifff_energy(text)ff_energy(text)UffCalculator::energy
11optimise with UFFxtalforge ff optimize a.cifff_optimize(text)ff_optimize_text(text)ff::minimize
12compute chargesxtalforge ff charges a.cif --method eeqff_charges(text, "eeq")ff_charges_info(text, "eeq")ff::eeq_charges
13compare two structuresxtalforge compare a.cif b.cifmatch_structures(a, b)match_structures(a, b, "", "{}")symmetry::match_structures
14group a listxtalforge group a.cif b.cif c.cifgroup_structures([...])group_structures([...], "", "{}")symmetry::group_structures
15apply a strainxtalforge deform a.cif --voigt 0.01,0,0,0,0,0deform(text, voigt=[...])deform(text, "", options)core::strain
16rattle with a seedxtalforge features rattle a.cif --seed 7rattle(text, seed=7)rattle(text, "", "{\"seed\":7}")core::rattle
17interpolate two framesxtalforge features interpolate a.cif b.cif --images 5interpolate(a, b, 5)interpolate(a, b, 5, "", "{}")symmetry::interpolate_matched
18make a cubic supercellxtalforge features optimal-supercell a.cif 8optimal_supercell(text, 8)optimal_supercell(text, 8, "")core::optimal_supercell
19compute Voronoi cellsxtalforge features voronoi a.cifvoronoi(text)voronoi(text, "", 6.0)core::voronoi
20get a coordination shellxtalforge features coordination a.cif 0coordination(text, 0)coordination(text, "", 0, "voronoi", 5.0, 0.1)core::coordination
21compute oxidation statesxtalforge features oxidation a.cifoxidation_states(text)oxidation_states(text, "", 5.0)analysis::oxidation_states
22compute an RDFxtalforge features rdf a.cifradial_distribution(text)radial_distribution(text, "", 10, 0.05, 0)core::radial_distribution
23list unique Miller indicesxtalforge features miller a.cifunique_miller_indices(text)unique_miller_indices(text, "", "{}")analysis::unique_miller_indices
24build a Wulff shapextalforge features wulff a.cif --surface 1,0,0,1.0wulff(text, [[1,0,0,1.0]])wulff(text, "", options)core::wulff
25find adsorption sitesxtalforge features adsorption a.cifadsorption_sites(text)adsorption_sites(text, "", 0.05)core::adsorption_sites
26check a MOFxtalforge mof check a.cifmof_check(text)mof_check(text, "")mof::check_mof
27compute MOFidxtalforge mof mofid a.cifmof_mofid(text)mof_mofid(text, "")mof::mofid
28compute PLD/LCD/ASAxtalforge mof pores a.cifmof_pores(text)mof_pores(text, "", "{}")mof::pore_descriptors
29run Widom insertionxtalforge mof adsorption widom a.cif --guest CO2mof_widom(text)mof_widom(text, "", "{}")mof::widom_insertion
30build a polymerxtalforge build polymer c1ccc(cc1)C=C 10build_polymer("c1ccc(cc1)C=C", 10)build_polymer_text(...)build::build_polymer

Pipelining ​

The CLI reads standard input with - and writes a structure document to standard output with --out -:

bash
xtalforge supercell a.cif 2 2 2 --out - \
  | xtalforge slab - 1 1 1 --layers 3 --out slab.cif

The input format is sniffed from the content, so no temporary files or format flags are needed.

Keyword conventions ​

The naming table in docs/api/naming.md lists the canonical option names on every surface. When a name differs, the 1.x alias is kept and documented; see deprecation.md.