Back to main menu

## Format: XYZ

Name: XYZ atomic coordinates file

Extension: xyz

Specification: unformal

Visualization programs: Aten, AViz, gdis, Jmol, OVITO, VESTA, VMD, XMol

#### Restrictions

The XYZ format, although it is broadly used by many programs, has never been formally defined or published. Basically it consists in nothing else than a text file containing the number of atoms, a comment line, and '`atom x y z`' lines:

##### example.xyz

`<NP>
comment
<atom1> <x1> <y1> <z1>
<atom2> <x2> <y2> <z2>
... ... ...
<atomN> <xN> <yN> <zN>
`

Since no standard specification exist, some programs use the atomic number in the first column, while some other programs use the atomic symbol; and the coordinates x, y and z can be either Cartesian or fractional coordinates, depending on the periodicity of the system (cartesian coordinates are usually used for single molecules, while fractional coordinates are used for periodic crystals). Also, the system (or supercell) dimensions are not written in a default XYZ file, contrary to other formats like CFG or XSF.

Atomsk automatically detects if the species or the atomic number is used in the first column, and it also detects if fractional or cartesian coordinates are used. Since no supercell parameters are contained in the default XYZ format, Atomsk automatically creates a bounding box (this is identical to the option `-rebox`) for compatibility with other output formats that require a supercell. Alternatively one can use the option `-properties` to set up the supercell parameters.

When writing an output file to the "default" XYZ format, Atomsk uses the specification described in the OpenBabel Wiki, i.e. it uses the atomic species as a first column and cartesian coordinates.

Atomsk can also read and write the extended XYZ format, described for instance here or here. This format is fully compatible with the default XYZ format, the comment line being replaced by a set of keywords and values, for instance:

##### example.xyz

`<NP>
Lattice="H11 H21 H31 H12 H22 H32 H13 H23 H33" Properties=species:S:1:pos:R:3:aux1:R:1:aux2:R:2...auxM:R:2 Time=0.0
<atom1> <x1> <y1> <z1> <aux11> <aux12> ... <aux1M>
<atom2> <x2> <y2> <z2> <aux21> <aux22> ... <aux2M>
... ... ...
<atomN> <xN> <yN> <zN> <auxN1> <auxN2> ... <auxNM>
`

where the keyword "`Properties`" defines the format of each line by three values: the name of the property, its format (S=string, I=integer, R=real), and the number of columns for that property. For instance "`species:S:1:pos:R:3`" tells that atomic species is a string using 1 column, and atom positions are real numbers using 3 columns.

When reading an extended XYZ file Atomsk only reads the supercell parameters that follow the keyword `Lattice`, and the properties (following the keyword `Properties`). Any other keyword (like the "`Time`" keyword in the example above) is ignored.

When writing extended XYZ files the second line always contains lattice parameters (after the keyword "`Lattice`") and auxiliary properties (following the keyword "`Properties`"). Each auxiliary property takes real values in a single column, so the format looks like "`Properties=species:S:1:pos:R:3:aux1:R:1:aux2:R:1...`". To write extended XYZ files, use `exyz` as a command-line option, for instance:

`atomsk initial.cfg final.xyz exyz`

Finally, Atomsk can deal with yet another specification called here the special XYZ format. It consists of the default XYZ format with (if necessary) auxiliary properties. Also, additional informations are written at the end of the file: a scaling factor (after the keyword "alat"), the supercell parameters (after "supercell" or "conventional"), the atom masses (one line per atom type), a keyword specifying if cartesian or reduced coordinates are used, and the name of auxiliary properties (if any):

##### example.xyz

`<NP>
comment
<atom1> <x1> <y1> <z1> <aux11> <aux12> ... <aux1M>
<atom2> <x2> <y2> <z2> <aux21> <aux22> ... <aux2M>
... ... ...
<atomN> <xN> <yN> <zN> <auxN1> <auxN2> ... <auxNM>
alat
<a0>
supercell
<H(1,1)> <H(1,2)> <H(1,3)>
<H(2,1)> <H(2,2)> <H(2,3)>
<H(3,1)> <H(3,2)> <H(3,3)>
mass <species1> <mass1>
mass <species2> <mass2>
...
mass <speciesN> <massN>
property 1 <name1>
property 2 <name2>
...
property M <nameM>
<cartesian/reduced> coordinates
`

Concerning the supercell parameters, if the keyword "supercell" is used (as in the example above) then the three next lines must contain the supercell vectors; if the keyword "conventional" is used then the two next lines must contain the vectors in conventional notation: "`a b c`" and "`α β γ`" respectively. If auxiliary properties are present, they must appear on each line (as integer or real numbers), and each of them must have a line "`property <i> <name>`" at the end of the file, <i> being the property number and <name> its name. The line "`cartesian coordinates`" (or "`reduced coordinates`") specifies that the coordinates in the file must be interpreted in a cartesian basis (or as reduced coordinates, respectively).

To write coordinates to this special XYZ format, use `sxyz` as a command-line option, e.g.:

`atomsk initial.cfg final.xyz sxyz`

By default Atomsk always writes the coordinates in cartesian basis in all the XYZ formats described above, but this can be changed with the option `-fractional`.

Note that since all these formats use the same extension (.xyz), it is not possible to write to two of these formats at the same time. When specifying both xyz, exyz and/or sxyz as output formats, then only one file with the extended XYZ (exyz) format will be written.

Files in the XYZ (or extended XYZ) format that contain several configurations can be read through the mode one-in-all, or created with the mode all-in-one. Such files can also be read and animated with the visualization program gdis.

#### Examples

- `atomsk system.xsf xyz`

  This will read the XSF file `system.xsf`, and convert it to the file `system.xyz` in normal XYZ format.

- `atomsk system.xsf exyz`

  This will read the XSF file `system.xsf`, and convert it to the file `system.xyz` in extended XYZ format.

- `atomsk system.xsf sxyz`

  This will read the XSF file `system.xsf`, and convert it to the file `system.xyz` in special XYZ format.

- `atomsk initial.xsf -frac final.xyz exyz`

  This will read the XSF file `initial.xsf`, convert atom positions to fractional coordinates, and write the final result to `final.xyz` in extended XYZ format.

- `atomsk --all-in-one myfiles.lst animation.xyz`

  This will read all the files specified in the list `myfiles.lst`, and output all snapshots in the XYZ file `animation.xyz`.

- `atomsk --one-in-all animation.xyz cfg`

  This will read the XYZ file `animation.xyz`, and output each snapshot in a separate file with the CFG format: `animation_1.cfg`, `animation_2.cfg`, etc.

Back to main menu