Skip to content

Crystallography

Crystallography extends AsciiChem beyond molecules to periodic crystal structures. The crystal keyword captures the unit cell and asymmetric unit in a compact ASCII notation.

crystal[<name>](
a=<float>, b=<float>, c=<float>,
alpha=<float>, beta=<float>, gamma=<float>,
sg=<spacegroup>
) {
<atoms with @f(x,y,z) fractional coords>
}
  • crystal is a keyword (lowercase, doesn’t conflict with element symbols which are uppercase).
  • [name] is an optional crystal name (e.g., the mineral or compound name).
  • (params) carries unit cell parameters as key=value pairs.
  • {atoms} carries the asymmetric unit atoms using fractional coordinates (@f(x,y,z)).
Source Rendered
crystal[NaCl](a=5.64,b=5.64,c=5.64,alpha=90,beta=90,gamma=90,sg=Fm-3m){ Na@f(0,0,0) Cl@f(0.5,0.5,0.5) }
crystal [ NaCl ] a 5.64 b 5.64 c 5.64 α 90 β 90 γ 90 1 Na 2 Cl
Source Rendered
crystal[Si](a=5.43,b=5.43,c=5.43,alpha=90,beta=90,gamma=90,sg=Fd-3m){ Si@f(0,0,0) Si@f(0.25,0.25,0.25) }
crystal [ Si ] a 5.43 b 5.43 c 5.43 α 90 β 90 γ 90 1 Si 2 Si
Source Rendered
crystal[test](a=10,b=10,c=10){ C@f(0.1,0.1,0.1) O@f(0.5,0.5,0.5) }
crystal [ test ] a 10 b 10 c 10 1 C 2 O
ParameterSymbolUnitExample
aa-axis lengthÅ5.64
bb-axis lengthÅ5.64
cc-axis lengthÅ5.64
alphaα angledegrees90
betaβ angledegrees90
gammaγ angledegrees90
sgSpace group (Hermann-Mauguin)—Fm-3m

Atoms inside a crystal use @f(x,y,z) for fractional coordinates (relative to the unit cell). These map to CML xFract/yFract/ zFract attributes.

See Atoms for the full atom annotation syntax.

AsciiChem v0.9.0 migrates Crystal to native CML wire. The output is a <molecule> containing a native <crystal> child plus an <atomArray> with fractional coordinates — readable by any CML-aware tool without needing the AsciiChem extension namespace.

<molecule title="NaCl">
<atomArray>
<atom elementType="Na" xFract="0" yFract="0" zFract="0"/>
<atom elementType="Cl" xFract="0.5" yFract="0.5" zFract="0.5"/>
</atomArray>
<crystal>
<scalar title="a">5.64</scalar>
<scalar title="b">5.64</scalar>
<scalar title="c">5.64</scalar>
<scalar title="alpha">90</scalar>
<scalar title="beta">90</scalar>
<scalar title="gamma">90</scalar>
<symmetry spaceGroup="Fm-3m"/>
</crystal>
</molecule>

Crystallography is Phase 1 of the beyond-formulas expansion. Future phases (documented in TODO.beyond-formulas/) will add:

  • Spectroscopy (NMR, IR, MS)
  • Computational chemistry results
  • Z-Matrix internal coordinates
  • Reaction mechanisms with spectator ions
Play