Monday, August 21, 2006

Crystal structures in Jmol

The following CML is indicates how unit cell information can be represented. By using the titles 'a', 'b', 'c', 'alpha', 'beta' and 'gamma', Jmol is able to read the unit cell properties:

<?xml version="1.0"?>
<molecule xmlns="http://www.xml-cml.org/schema">
<crystal>
<scalar title="a">8.781</scalar>
<scalar title="b">8.845</scalar>
<scalar title="c">10.171</scalar>
<scalar title="alpha">90.00</scalar>
<scalar title="beta">101.34</scalar>
<scalar title="gamma">90.00</scalar>
</crystal>
<atomArray>
<atom id="Fe1" xFract="1.0" yFract="0.0" zFract="1.0" elementType="Fe"/>
<atom id="N1" xFract="0.7619" yFract="0.0548" zFract="0.9299" elementType="N"/>
</atomArray>
</molecule>

However, if you want to make to of the full power of CML, you would not use the @title attributes on the <crystal>'s <scalar> elements, but use @dictRef instead. Dictionary references allow to make the semantics complete: it would explicitely say what you mean with 'a', or 'beta'. The CML project has setup a simple CML dictionary (namespaced: http://www.xml-cml.org/dict/cmlDict) which contains the concepts for these six unit cell properties. The example then becomes:

<?xml version="1.0"?>
<molecule xmlns="http://www.xml-cml.org/schema">
<crystal xmlns:cmldict="http://www.xml-cml.org/dict/cmlDict">
<scalar dictRef="cmldict:a">8.781</scalar>
<scalar dictRef="cmldict:b">8.845</scalar>
<scalar dictRef="cmldict:c">10.171</scalar>
<scalar dictRef="cmldict:alpha">90.00</scalar>
<scalar dictRef="cmldict:beta">101.34</scalar>
<scalar dictRef="cmldict:gamma">90.00</scalar>
</crystal>
<atomArray>
<atom id="Fe1" xFract="1.0" yFract="0.0" zFract="1.0" elementType="Fe"/>
<atom id="N1" xFract="0.7619" yFract="0.0548" zFract="0.9299" elementType="N"/>
</atomArray>
</molecule>

Jmol currently does not recognize, and thus ignore, this dictionary (bug #1543784).

1 comment:

Peter Murray-Rust said...

Many thanks for this Egon.
I must cngratulate all those who have worked to adapt Jmol and other software to CML. This has sometimes been very difficult, especially with tools such as W3CDOM - the use of XOM makes things a lot easier.

The <crystal> syntax is one of the less happy constructs as it does not easily constrain the 6 element children. This was created in the days of DTDs. The 6 children must be entered in order and must also be in hardcoded units which is messy. This was to allow things like errors and units to be added. A typical examples is shown in:
http://cml.cvs.sourceforge.net/cml/schema25/examples/xsd/crystal1.xml?revision=1.1&view=markup
(note that examples for all CMLElements can be found here).

Peter Murray-Rust