CASTEP

Note

If you want to contribute to the documentation of this code, please contact us at support@nris.no

Introduction

CASTEP is a leading code for calculating the properties of materials from first principles. Using density functional theory, it can simulate a wide range of properties of materials proprieties including energetics, structure at the atomic level, vibrational properties, electronic response properties etc. In particular it has a wide range of spectroscopic features that link directly to experiment, such as infra-red and Raman spectroscopies, NMR, and core level spectra.

More information on the CASTEP website.

License and access

The CASTEP Developers’ Group (CDG) and Cambridge Enterprise have announced a cost-free worldwide source code license to CASTEP and NMR CASTEP for academic use.

To get access to CASTEP, you need to follow the procedure described below.

If you, however, wonder if you are in the castep group of users, you can find out by typing:

id | tr "," "\n" | grep castep

If this command comes out with a result, then you are in the group and may use the code - if not, go through the following procedure:

Access to CASTEP is limited by membership in the castep group.
In order to use the software on our infrastructure, first make sure you have access to a valid license.

**When you have access to a valid CASTEP license**
Send an email to
<a href="mailto:contact@sigma2.no?subject=Request for CASTEP access">
contact@sigma2.no</a> with the following information:
* Full name
* E-mail address
* ORCA ID

We will then have to manually verify this information with STFC UK/CASTEP before granting access. As such there may be some waiting time unfortunately.

Citation

For the recommended citation, please consult the CASTEP page.

CASTEP on NRIS machinery

Currently, CASTEP is installed on Fram and Saga. To see available versions when logged on to the machine in question, use the module avail or module spider commands as shown below:

module avail castep

If you are in the castep group of users, you may use CASTEP by typing:

module load CASTEP/<version>
# (eg. module load CASTEP/22.1.1-intel-2022b)

specifying one of the available versions.

Running CASTEP on NRIS machines

Please inspect the job script examples and/or jobscripts before submitting jobs!

Testing CASTEP: Ethene
To test CASTEP, we have borrowed the Ethene-example from [www.mjr19.org.uk/castep/test.html](https://www.mjr19.org.uk/castep/test.html). To perform this test, you need two files;

One file called ethene.cell with the contents

%block LATTICE_ABC
ang
8.000000 8.000000 7.000000
90.000000 90.000000 90.000000
%endblock LATTICE_ABC

%block POSITIONS_ABS
  C 4.698560 4.000000 3.500000
  C 3.301440 4.000000 3.500000
  H 5.270880 4.923920 3.500000
  H 2.729120 3.076080 3.500000
  H 2.729120 4.923920 3.500000
  H 5.270880 3.076080 3.500000
%endblock POSITIONS_ABS

kpoints_mp_grid 1 1 1
kpoints_mp_offset 0.25 0.25 0.25

and one called ethene.param with the contents

cut_off_energy  = 40 ry
iprint          = 1
opt_strategy : speed

Running CASTEP would produce an ethene.castep file (amongst others) within seconds for the running examples provided below. Towards the end of this file, there are final structure energy outputs printed, Final energy, E; values here should be in the range of -378.015eV.

A subset of the benchmark sets, the medium set al3x3 and solid benzene together with the ethene-example used here has been added to the CASTEP home folder on both Fram and Saga. You get them into your working directory by typing

cp /cluster/software/CASTEP/benchmarks/* .
Running CASTEP on Fram
On Fram, you currently run exclusively on nodes by default. Note that means that you are using the nodes exclusively - thus if you ask for less than a full node, you might experience that more than one job is stacked on one node. This is something that you should keep in mind when submitting jobs.
#!/bin/bash -l

#SBATCH --account=nnNNNNk
#SBATCH --job-name=Ethene
#SBATCH --time=0-00:05:00
#SBATCH --nodes=2
#SBATCH --ntasks-per-node=8
#SBATCH --qos=devel
# The above setting is equivalent to the 4GiB/core mem-setting in Saga script

## Recommended safety settings:
set -o errexit # Make bash exit on any error
set -o nounset # Treat unset variables as errors

# make the program and environment visible to this script
module --quiet purge
module load CASTEP/22.1.1-intel-2022b

# Naming the project:
input=ethene

# create the temporary folder
export tempdir=/cluster/work/users/$USER/$SLURM_JOB_ID
mkdir -p $tempdir

# copy input file to temporary folder
cd $SLURM_SUBMIT_DIR
cp *.cell *.param $tempdir
# If you need pseudopotentials, add this line:
# cp *.usp $tempdir

# run the program
cd $tempdir
time mpirun -n 16 castep.mpi $input

# copy result files back to submit directory
cp $input.castep $SLURM_SUBMIT_DIR

# Also rememeber to copy other files if you want to keep them.
# For instance the $input.check file, the $input.bands file etc.
# The $temp folder is eligible for deletion after a certain amount
# since it resides in $USERWORK.

exit 0
Running CASTEP on Saga
On Saga, the nodes have more memory than on Fram and you are allowed to share nodes with others. Thus the specs on memory in runscript example below. Note that, due to the higher memory amount you may be able to use more cores/node on Saga. Note, however, that there is a 256 core limit on Saga.
#!/bin/bash -l

#SBATCH --account=nnNNNNk
#SBATCH --job-name=Ethene
#SBATCH --time=0-00:05:00
#SBATCH --nodes=2
#SBATCH --ntasks-per-node=20
#SBATCH --mem-per-cpu=4G
#SBATCH --qos=devel

## Recommended safety settings:
set -o errexit # Make bash exit on any error
set -o nounset # Treat unset variables as errors

# make the program and environment visible to this script
module --quiet purge
module load CASTEP/22.1.1-intel-2022b

# Naming the project:
input=ethene

# create the temporary folder
export tempdir=/cluster/work/users/$USER/$SLURM_JOB_ID
mkdir -p $tempdir

# copy input file to temporary folder
cd $SLURM_SUBMIT_DIR
cp *.cell *.param $tempdir
# If you need pseudopotentials, add this line:
# cp *.usp $tempdir

# run the program
cd $tempdir
time srun -n 40 castep.mpi $input

# copy result files back to submit directory
cp $input.castep $SLURM_SUBMIT_DIR

# Also rememeber to copy other files if you want to keep them.
# For instance the $input.check file, the $input.bands file etc.
# The $temp folder is eligible for deletion after a certain amount
# since it resides in $USERWORK.

exit 0