MJR's Castep Notes
This page contains some random information about the use of Castep. It is incomplete, but contributions are welcome. It is provided mostly so that I can remember what I have done, and in the hope that it might be of some use to someone else. Also a link to the official online Castep documentation.
Some of the background theory to Castep and DFT can be found in chapter IV of my thesis. A rather more modern and complete approach can be found in Prof Probert's lecture course from York. (Prof Probert is one of the Castep developers.)
(I also have unmaintained notes on the ancient, Fortran77, pre-commercial version of Castep. In the unlikely event that someone wants these, they can still be found here.)
The Castep distribution provides many useful utilities. From the 20.11 academic distribution it includes c2x, a converter for Castep's check files, which can extract charge and spin density, wavefuctions, or simply atomic positions. It can also convert between .cell and .pdb files, and other similar tricks. It also can be built with the spglib crystal symmetry finder for symmetry analysis. C2x also supports other DFT codes, such as Abinit, Elk, Quantum Espresso, Siesta and VASP.
C2x 2.34d (July 2020) is included in the Castep 20.11 academic distribution. To see what functionality more recent versions of c2x would include, view c2x's changelog.
These notes should mostly apply to plane-wave codes in general, not just Castep, but I make no promises.
- Some notes on Bloch's Theorem.
- Some notes on interpolation and real-space integration of functions expressed in reciprocal space. Titled "Castep and Real Space Integrals" for brevity.
- Some notes on competing interpretations of Monkhorst-Pack grids.
- Some notes on Conjugate Gradients, and also EPS files which illustrate and calculate steepest descents and conjugate gradients.
A simple test of Castep on an ethene molecule.
Over-riding FFT grid selection
I often find myself wanting to do this, for various strange reasons. It seems to be undocumented and unsupported, but, in a .param file, a block such as the following seems to work.
%block devel_code STD_GRID=50 50 45 FINE_GRID=60 60 50 %endblock devel_code
Such devel_code blocks tend to have little error-checking, and are not intended to be used saved for by developers, so you have no right to blame anyone should they not behave as expected. For my own convenience, I record here the syntax for changing the Ewald converge tolerance from its default of 100 (should never be necessary). The value below should give wrong answers most of the time. Replacing the "2" with "1000" might give one confidence that the Ewald sum was correctly converged.
%block devel_code EWALD: PREC = 2 :ENDEWALD %endblock devel_code
For on-the-fly norm-conserving pseudopotentials, add to the cell file:
%block species_pot NCP %endblock species_pot
SYS V IPC
The main use of this is that it magically merges MPI messages when run on a machine with multiple shared-memory nodes, and thus improves scaling. In other circumstances it is of little use, but adds C code to what is otherwise a pure Fortran project.
The source file for this which is part of Castep 17.21 (and
earlier) is incompatible with ifort 17.0 (and later) when used with
most versions of OpenMPI. This can be fixed by removing the
line and uncommenting the
line a couple of lines earlier in Source/Utility/FreeIPC.f90.
Depending on how one's compiler is set up, adding
before the first line of Source/Utility/fft.mkl.F90 may make it easier to compile this file.
When using the Intel compilers, Castep will use the option
which case it is compiled with
-msse3. If the
executable is to be used only on the architecture which generated
-xHost is a good option. However, if one
wishes to have a portable executable,
-msse3 will make
no use of AVX instructions. Something
-msse3 -axavx might be better, at the expense
of taking longer to compile and producing a larger executable. See
further notes on ifort and CPU
The Castep build system is flexible, but, for bears of little brain, verging on the incomprehensible. I tend to use a simpler shell script for compilation, an example of which is below. The script will be tied to a particular version of Castep, due to the addition of extra source files as functionality is extended. It is offered with no guarantee of functionality or correctness!
Castep's test suite by default says things like "461 out of 462 tests
passed." This is fine if all tests passed, but unhelpful if one wishes
to know what failed. A find-and-replace of "
-q " by
-v " on
- castep.org, including an on-line manual, and instructions for obtaining Castep for academic use for free.
- Castep at Bitbucket
- JISC hosts a Castep email list
- Commerical Castep, from Biovia.
Castep in TCM
The c2x utility is centrally installed.
Further information about Castep itself in TCM can be found on TCM's internal Castep page.