CASTEP file reader
For loading atomic structures and simulation trajectories written by the CASTEP ab initio code.
OVITO provides two separate readers for the CASTEP file formats:
one for .cell files, which define the input structure of a calculation, and one for the .md and .geom output
files, which contain the trajectory of a molecular dynamics run or a geometry optimization. The right reader is
selected automatically based on the file contents. Both readers can directly load gzipped files (“.gz” suffix).
To animate a static .cell structure with the trajectory data from a .md or .geom file, select both files
together in the file selection dialog (see Simulation trajectories). OVITO then loads the .cell file as the pipeline’s
data source and inserts a Load trajectory modifier that reads the time-dependent atomic positions
from the trajectory file. Note, however, that the .md/.geom files are self-contained and can also be loaded on their own.
CASTEP .cell files
The .cell reader recognizes a file by the presence of a %BLOCK POSITIONS_FRAC or %BLOCK POSITIONS_ABS block within the first 100 lines.
Keywords are case-insensitive, and comment lines starting with #, ;, !, or COMMENT are ignored.
The reader interprets the following blocks of the file and ignores all others:
- Unit cell
The
%BLOCK LATTICE_CARTblock is read as three Cartesian cell vectors; the%BLOCK LATTICE_ABCblock is read as cell lengths and angles and converted to a triclinic simulation cell, in which the cell vector \(\mathbf{a}\) is aligned with the Cartesian x-axis and \(\mathbf{b}\) lies in the x-y plane. Periodic boundary conditions are enabled in all three directions. The optional unit keyword at the beginning of the block (ang,bohr,nm, etc.) is taken into account, and the cell dimensions are converted to Angstroms.- Atoms
Each line of the
%BLOCK POSITIONS_FRACor%BLOCK POSITIONS_ABSblock is read as one atom. Fractional coordinates are converted to Cartesian coordinates using the lattice block, which may appear before or after the positions block in the file. Absolute coordinates are converted to Angstroms according to the optional unit keyword at the beginning of the block. The file reader creates the following per-atom properties:Position — the Cartesian atomic coordinates.
Particle Type — the species given in the first column of each line. A species label such as
ArorSi:Ais used verbatim as the name of the particle type. If the file specifies an atomic number instead (e.g.8), it is converted to the corresponding element symbol (O). Types are numbered consecutively in the order in which they first appear in the file. OVITO assigns the standard CPK color and display radius to types whose name it recognizes as a chemical element.Velocity — the atomic velocities from the
%BLOCK IONIC_VELOCITIESblock, if present, converted to Angstroms/ps according to the optional unit keyword of the block (ang/ps,bohr/ps,m/s, etc.). The block must contain exactly one vector per atom and must follow the positions block.
Additional per-atom columns behind the coordinates (e.g. SPIN=, LABEL=) as well as all other blocks and keywords of
the .cell file (SPECIES_MASS, SPECIES_POT, KPOINTS_LIST, SYMMETRY_OPS, IONIC_CONSTRAINTS, CELL_CONSTRAINTS, etc.) are ignored.
CASTEP .md and .geom files
The .md/.geom reader recognizes a file by its BEGIN header / END header section at the beginning.
Both formats use the same record-based layout, in which every line is tagged with a marker such as <-- h or <-- R.
The file reader treats each set of three <-- h lines (unit cell) as the beginning of a new trajectory frame and
imports the file as an animation sequence. The following records of each frame are read:
<-- h— the three cell vectors, imported as a simulation cell with periodic boundary conditions in all three directions. The cell may vary from frame to frame.<-- R— the species label and Cartesian coordinates of each atom, imported as the Position and Particle Type properties. As for.cellfiles, the species labels are used verbatim as particle type names.<-- V— the atomic velocities (written to.mdfiles), imported as the Velocity property.<-- F— the atomic forces, imported as the Force property.
CASTEP writes .md and .geom files in atomic units. The file reader converts the cell vectors and atomic
coordinates from Bohr to Angstroms. Velocities and forces are not converted and keep their original atomic units
(\(\text{bohr}/\text{atomic time unit}\) and \(\text{Ha}/\text{bohr}\), respectively).
Limitations
The
.castepoutput log file of CASTEP is not supported. Structures and trajectories must be loaded from.cell,.md, or.geomfiles.The per-frame records
<-- E(energies),<-- T(temperature),<-- P(pressure),<-- S(stress),<-- hv(cell velocities), and the time stamp of each frame in.mdfiles are ignored, as is the<-- cconvergence record of.geomfiles. The file reader does not create any global attributes.The CASTEP formats do not store bonds. You can apply the Create bonds modifier to the loaded structure to generate them.
Options
The two CASTEP file readers have no user-adjustable options.
Python parameters
The CASTEP file readers accept no format-specific keyword parameters in a call to the import_file() or load() Python functions.