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.
Syntax
Section titled “Syntax”crystal[<name>]( a=<float>, b=<float>, c=<float>, alpha=<float>, beta=<float>, gamma=<float>, sg=<spacegroup>) { <atoms with @f(x,y,z) fractional coords>}crystalis 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 askey=valuepairs.{atoms}carries the asymmetric unit atoms using fractional coordinates (@f(x,y,z)).
Worked examples
Section titled “Worked examples”Sodium chloride (NaCl)
Section titled “Sodium chloride (NaCl)”
Source
Rendered
crystal[NaCl](a=5.64,b=5.64,c=5.64,alpha=90,beta=90,gamma=90,sg=Fm-3m){
Install the
asciichem gem to see this rendered.
Na@f(0,0,0) Cl@f(0.5,0.5,0.5)}
Install the
asciichem gem to see this rendered.
Silicon (diamond structure)
Section titled “Silicon (diamond structure)”
Source
Rendered
crystal[Si](a=5.43,b=5.43,c=5.43,alpha=90,beta=90,gamma=90,sg=Fd-3m){
Install the
asciichem gem to see this rendered.
Si@f(0,0,0) Si@f(0.25,0.25,0.25)}
Install the
asciichem gem to see this rendered.
Without space group
Section titled “Without space group”
Source
Rendered
crystal[test](a=10,b=10,c=10){
Install the
asciichem gem to see this rendered.
C@f(0.1,0.1,0.1) O@f(0.5,0.5,0.5)}
Install the
asciichem gem to see this rendered.
Unit cell parameters
Section titled “Unit cell parameters”| Parameter | Symbol | Unit | Example |
|---|---|---|---|
a | a-axis length | Å | 5.64 |
b | b-axis length | Å | 5.64 |
c | c-axis length | Å | 5.64 |
alpha | α angle | degrees | 90 |
beta | β angle | degrees | 90 |
gamma | γ angle | degrees | 90 |
sg | Space group (Hermann-Mauguin) | — | Fm-3m |
Fractional coordinates
Section titled “Fractional coordinates”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.
CML wire (v0.9.0+)
Section titled “CML wire (v0.9.0+)”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>Roadmap
Section titled “Roadmap”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