Skip to content

CASTEP Operation Guide

Lin Ziyue

I. Basics & Bonding

(Converting cif to cell: First open .cif with MS and export .res file, then input the following command in terminal:

cabal res cell < xxx.res > xxx.cell

Simply inputting cabal will show file types that can be converted, but cannot convert directly from cif to cell.

The .cell file obtained through the above conversion is incomplete.)

The method to obtain a complete .cell file is: Open the .cif file with MS, click the three wavy lines icon - Calculation - Files - Save Files to save results to the working directory without running. The default location is: Documents - Materials Studio Projects - under a saved project. However, the .cell file is a hidden file; you need to click menu - check "Hidden items" to display it.

I. Prepare Files:

  • *.usp #pseudopotential file (can be specified in .cell file in BLOCK SPECIES_POT format below)
  • *.cell
  • *.param
  • castep.pbs.sh #declare seed_name='*' (same as *.cell filename)

1) *.cell

LATTICE_CART and POSITIONS_FRAC sections

Also need to add the following 3 items:

1
2
3
4
5
6
7
8
9
kpoint_mp_grid 12 12 12 or KPOINTS_MP_SPACING : 0.02
#Specify k-point spacing. Note: if structure exported from MS has built-in k-points, don't set this!

SYMMETRY_GENERATE

%BLOCK SPECIES_POT
  F 2|1.0|20|23|26|20:21(qc=8)
  Specify pseudopotential for specific element. If .usp pseudopotential file is provided in same folder, don't add this
%ENDBLOCK SPECIES_POT

2) *.param

Add these two lines in *.param file to output .cell and .cif files:

WRITE_CIF_STRUCTURE : true
WRITE_CELL_STRUCTURE : true

Note: basis_precision cannot coexist with cut_off_energy; can only choose one, otherwise error occurs.

Also: spin_polarized - if this defaults to false, after calculation the error file .err may prompt to change to true. The reason is that spin was added to lattice parameters in .cell file. Note that only magnetic materials add spin, and initial magnetic moments may be unreasonable.

If spin is added in .cell file, write true here; if not added, write false.

II. Submit Script

Notes:

Subsequent steps (band structure, DOS, etc.) can use the following simple script:

#!/bin/bash
#PBS -q CT2                    #set node
#PBS -l nodes=1:ppn=20         #ppn=number of cores
#PBS -j oe
#PBS -V
#PBS -N F_PBE_phonon           #task name
#######################################
####### Basic Parameter Declare #######
cd $PBS_O_WORKDIR
mpirun -n 20 castep phonon > log    #phonon=filename, determined by input filename
#-n 20 ppn times nodes

III. Output Files: OUT.cell, OUT.castep, can be dragged into VESTA to view structure

II. Geometry Optimization (Single Pressure Point Optimization)

1. Prepare Files

1) .cell file

2) .param file

Change task name to geometry optimisation

3) castep.pbs

Can specify pressure in script or cell file

To specify optimization pressure in .cell file, format as follows:

1
2
3
4
5
%BLOCK EXTERNAL_PRESSURE
50 0 0
   50 0
      50
%ENDBLOCK EXTERNAL_PRESSURE

*.param:

1
2
3
4
5
6
7
task : geometry optimisation
xc_functional : PBE
cut_off_energy : 900 eV
fix_occupancy : false          choose true for insulators
opt_strategy : speed
num_dump_cycles : 0
MAX_SCF_CYCLES : 100

Notes:

Can use castep2res XXX.OUT > YYY.res command to convert results to .res file

Possible common error is:

Error check_elec_ground_state : electronic_minimisation of initial cell failed

Increase the value of MAX_SCF_CYCLES, e.g., increase to 100

III. Band Structure

(Before doing band structure, DOS, phonon spectrum with a software, need to first perform structure optimization with that software)

I. Prepare Files:

  • *.cell (if in same folder, try to use different filename from previous files)
  • *.param
  • castep.pbs.sh

1) *.cell

In addition to data in .cell from Basics & Bonding, also need to add Brillouin zone high-symmetry point path:

Specific operations as follows:

Export .cell file using Xftp, open with Vesta, Files – Export Data to output .cif file, then open .cif file with Material Studio, select Build – Symmetry – Find Symmetry in menu bar, click Find Symmetry button. After data appears, click Impose Symmetry in lower left to complete symmetry import.

Then select Tools – Brillouin Zone Path in menu bar, click Create to generate the path shown below:

First from top to bottom, then from left to right, sequentially input in .cell file in the format shown in the image above for Brillouin Zone Path.

Note that duplicate points at corners should be omitted:

1
2
3
4
5
6
7
8
! Specify a path through the IBZ.
%block bs_kpoint_path
  0.500 0.000 0.000 ! X
  0.500 0.500 0.500 ! R
  0.500 0.500 0.000 ! M
  0.000 0.000 0.000 ! G
  0.500 0.500 0.500 ! R
%endblock bs_kpoint_path

2) *.param:

Change task name to bandstructure

xc_functional choose required pseudopotential, basis_precison same principle as before, cannot coexist with cut_off_energy

POPN_BOND_CUTOFF : 5 ang - can add this line if need to set bond length range

3) castep.pbs.sh format

#!/bin/bash
#PBS -q CT2
#PBS -l nodes=1:ppn=20
#PBS -j oe
#PBS -V
#PBS -N F_PBE_DOS
#######################################
####### Basic Parameter Declare #######
cd $PBS_O_WORKDIR
mpirun -n 20 castep F > log

II. Execute castep.pbs

Note that castep.pbs scripts obtained may contain "rm .bands" entry; adding this will automatically delete the output bands file. Remove this entry.

III. Obtain Results and Plot

Plotting Method 1:

After successful run, xxx.bands file will be output

Execute command:

dispersion.pl -xg -bs -symmetry XXX xxx.bands

After -symmetry, specify the symmetry. If no specific symmetry is given, the band structure x-axis will be numbers like -½ 0 ½ (input decimals will be converted to fractions).

How to find structure symmetry:

  1. Convert *.cell to .cif file using Vesta-Export Data, import .cif file to MS, Build-Symmetry-Show Symmetry (first Find Symmetry if symmetry not added) to see

Crystal System in the image above:

The corresponding crystal system Cubic means add -cubic after -symmetry to finally get the band structure diagram shown below:

dispersion.pl -xg -bs -symmetry cubic F.bands

Plotting Method 2:

Origin plotting: See details in Origin Walkthrough

IV. Density of States (DOS) Plot

I. Prepare Files

(Note that band structure results cannot be used for DOS plot; need to submit task again)

1) *.cell

Need to include

LATTICE_CART and POSITIONS_FRAC sections

1
2
3
4
5
6
! Kpoint grid for the Groundstate (SCF) calculation
KPOINTS_MP_SPACING : 0.02
SYMMETRY_GENERATE

! Kpoint grid for a DOS plot
BS_KPOINTS_MP_SPACING : 0.02    K-point spacing for DOS plot

But cannot add high-symmetry Brillouin zone path

2) .param same as bandstructure

II. Submit Script

dos.pl -gp *.bands uses gnuplot to plot

dos.pl -gp F.bands

dos.pl -xg *.bands

Notes:

  1. dispersion.pl and dos.pl followed by -h can list available options
dos.pl -h
  1. Besides dos.pl -gp *.bands or dos.pl -xg *.bands methods to directly plot with xmanager

dos.pl directly followed by *.bands lists data needed for plotting,

dos.pl *.bands > *.txt can output as .txt file that can be plotted with Origin

See details in Origin Walkthrough (figure integrates band structure with DOS plot)

Plot by Origin

V. Phonon Spectrum Calculation

I. Prepare Files

1) *.cell

Need to include

1
2
3
%BLOCK LATTICE_CART
%BLOCK POSITIONS_FRAC    #same as before
%BLOCK SPECIES_POT        #pseudopotential (can use file or direct input)

Also need to add the following content (don't keep previous DOS and density of states parameters)

1.%block phonon_fine_kpoint_path

is the phonon q-vector path, called Dispersion path in newer MS versions

Following is the operation flow to obtain this path:

a. Import symmetry

Export optimized .cell file using Xftp, open with Vesta, Files – Export Data to output .cif file, then open .cif file with Material Studio. Select Build – Symmetry – Find Symmetry in menu bar, click Find Symmetry button. After data appears, click Impose Symmetry in lower left to complete symmetry import.

b. Obtain Brillouin zone path

i) Older Material Studio version (newer version can skip)

(See Li Mingxian CASTEP tutorial page 94, though tutorial uses MS directly for phonon spectrum)

First click three wavy lines icon-Calculation,

Select Phonon dispersion, click More… then select path

Input format see %block phonon_fine_kpoint_path section above

ii) Newer Material Studio version

First click three wavy lines icon-Calculation, then Properties-Phonons

Then click More… below

Then click Path

Input method same as band structure Brillouin zone path above, format see %block phonon_fine_kpoint_path section above

2. Four phonon parameters

1
2
3
4
KPOINTS_MP_SPACING : 0.02
PHONON_FINE_KPOINT_PATH_SPACING 0.02
phonon_kpoint_mp_grid 5 5 5
phonon_kpoint_mp_offset 0.1 0.1 0.1

These four phonon parameters are:

  • Initial K-point spacing (can also be given as mp_grid), same as before
  • High-symmetry point path grid for phonon spectrum calculation, or step size
  • Phonon Brillouin zone grid, set as appropriate, use smaller values initially for calculation
  • Phonon grid offset, reciprocal of twice the previous value. E.g., if Brillouin zone grid is 5, offset is 0.1

2) *.param

task : Phonon
xc_functional : PBE
opt_strategy : speed
num_dump_cycles : 0
cut_off_energy : 900 eV
fix_occupancy : true
metals_method : dm
phonon_sum_rule : true
PHONON_FINE_METHOD : INTERPOLATE
phonon_sum_rule_method : reciprocal
MAX_SCF_CYCLES : 100

Change task to Phonon

Add other phonon-related items. Also remember to add MAX_SCF_CYCLES : 100, otherwise will get previous structure optimization error

3) *.pbs

Use previous simple script

#!/bin/bash
#PBS -q CT2
#PBS -l nodes=1:ppn=20
#PBS -j oe
#PBS -V
#PBS -N F_PBE_phonon
#######################################
####### Basic Parameter Declare #######
cd $PBS_O_WORKDIR
mpirun -n 20 castep F > log

F here is the filename to execute. Note that phonon spectrum input files .cell and .param need to be consistent, i.e., .OUT.cell output from previous structure optimization needs to be renamed to remove .OUT.

Then submit script.

Notes:

Common error:

Error in phonon_calculate: DFPT Linear Response not implemented for ultrasoft pseudopotentials

Ultrasoft pseudopotentials cannot directly calculate phonon spectrum.

Need to change pseudopotential or use supercell method to use ultrasoft pseudopotentials.

Specific supercell method as follows:

*.param file:

task : Phonon
xc_functional : PBE
opt_strategy : speed
num_dump_cycles : 0
cut_off_energy : 900 eV
fix_occupancy : true
metals_method : dm
phonon_sum_rule : true
phonon_sum_rule_method : reciprocal
MAX_SCF_CYCLES : 100
phonon_method : finitedisplacement
phonon_fine_method : SUPERCELL

(Blue items are modifications)

Give supercell matrix in *.cell file:

1
2
3
4
5
%BLOCK PHONON_SUPERCELL_MATRIX
2 0 0
0 2 0
0 0 2
%ENDBLOCK PHONON_SUPERCELL_MATRIX

Specific supercell method as follows:

After dragging .cif file into Material Studio, first import symmetry as described above.

Following is selection of unit cell or primitive cell.

In Build – Symmetry menu you can see:

Primitive Cell Conventional Cell

After selecting unit cell or primitive cell, Brillouin zone path and lattice parameters will differ, and supercell multiplier will also differ.

Then right-click on graphics, view Lattice Parameters (or click Lattice Parameters in image above).

Generally expand each direction to about 10 angstroms.

kpoint_mp_grid : 20 20 20
phonon_fine_kpoint_path_spacing 0.02
#phonon_kpoint_mp_grid 5 5 5
#phonon_kpoint_mp_offset 0.1 0.1 0.1
SUPERCELL_KPOINTS_MP_SPACING 0.1

%BLOCK PHONON_SUPERCELL_MATRIX
2 0 0
0 2 0
0 0 2
%ENDBLOCK PHONON_SUPERCELL_MATRIX

#can add pressure
%BLOCK EXTERNAL_PRESSURE
3000.0000000000 0.0000000000 0.0000000000
                3000.0000000000 0.0000000000
                                3000.0000000000
%ENDBLOCK EXTERNAL_PRESSURE

Plotting: dispersion.pl -xg -symmetry xxx *.phonon

dispersion.pl -xg -symmetry cubic F.phonon

1THz=33.367cm⁻¹

VI. Projected Density of States (PDOS)

I. Prepare Files

1) *.cell

%BLOCK lattice_cart
2.60546639081413    0.190169628654733E-09  0.601727934945543E-09
0.190169041397066E-09  2.60546943044447    -0.120907916653073E-07
0.601729758554163E-09  -0.120907910330159E-07  2.60546869996539
%ENDBLOCK lattice_cart

%BLOCK positions_frac
F    0.000000000117762   0.499999999338523   0.749986558395997
F    0.000000000339613   0.500000000256769  -0.749986558605385
F    0.749987711283413   0.000000000252767   0.499999999798142
F   -0.749987712380392   0.000000000217478   0.500000000505681
F    0.500000000854287   0.749988023424662   0.000000002496860
F    0.500000000234474  -0.749988023462086  -0.000000002382903
F   -0.000000000905482  -0.000000000090146  -0.000000000183659
F    0.500000000456325   0.500000000062032   0.499999999975266
%ENDBLOCK positions_frac

#Above are specific lattice parameters

SYMMETRY_GENERATE

%BLOCK species_pot
%ENDBLOCK species_pot

KPOINTS_MP_SPACING : 0.02            #K-point spacing
SPECTRAL_KPOINTS_MP_SPACING : 0.02   #Plotting spacing

2) *.param

TASK : SPECTRAL
SPECTRAL_TASK : DOS
PDOS_CALCULATE_WEIGHTS : TRUE
IPRINT : 1                    #Note differences in first few lines from DOS
xc_functional : PBE
cut_off_energy : 900 eV
fix_occupancy : false
opt_strategy : speed
num_dump_cycles : 0
MAX_SCF_CYCLES : 100
WRITE_CIF_STRUCTURE : true
WRITE_CELL_STRUCTURE : true

3) *.odi

###########################################################
# OptaDOS example file -- AJ Morris 18/V/11
###########################################################
TASK : pdos

# Decompose into angular momentum channels
# (also try species_ang, species, sites)
PDOS : angular    #Only this part determines PDOS plotting method
                  #Below are all prompts or comments, default is by

# Or choose the projectors by hand...    #angular quantum number; can change to species_ang
                                          #to give pdos by atom and angular quantum number
# The DOS on F atom 1 and the DOS on the s-channel
# of F atom 2 (2 proj)
#PDOS : F1;F2(s)     #Each atom numbered separately, e.g.: F1(s);F2(p);Rb1(s)

# The sum of the s-channels on the two F atoms (1 proj)
#PDOS : sum:F1-2(s)

# The p-channel on each F atom 1. (1 proj)
#PDOS :F1(p)

# Recalculate the Fermi energy using the new DOS
# (discard the CASTEP efermi)
EFERMI : optados

# Sample the DOS at 0.1 eV intervals
DOS_SPACING : 0.1

###########################################################
# A D V A N C E D   K E Y W O R D S
###########################################################
# The keywords below are all at their default value
# They are presented here to indicate the internal
# workings of OptaDOS and allow you to tweak the
# output

# The broadening used, (also try linear, or fixed)
BROADENING : adaptive  # Default

# The broadening parameter, A, when using adaptive smearing,
# set by eye to be similar to the linear smearing method
ADAPTIVE_SMEARING : 0.4  # Default

# The Gaussian broadening parameter for fixed smearing,
# in electron Volts
FIXED_SMEARING : 0.3  # Default

# Set the Fermi energy to zero on the output plots
SET_EFERMI_ZERO : true  # Default

# Normalise the DOS with the volume of the simulation
# cell
DOS_PER_VOLUME : false  # Default

###########################################################
# C O M P A T I B I L I T Y
###########################################################
# Perform numerical integration of the DOS, instead of
# semi-analytic (useful to compare with LinDOS)
NUMERICAL_INTDOS : false  # Default

# When performing numerical integration of the DOS make
# sure that no Gaussians are smaller than the dos_spacing.
# (Should always be true, but useful for comparison with
# LinDOS)
FINITE_BIN_CORRECTION : true  # Default

4) *.pbs

#!/bin/bash
#PBS -q CT6
#PBS -l nodes=1:ppn=36
#PBS -j oe
#PBS -V
#PBS -N F_PDOS
#######################################
####### Basic Parameter Declare #######
cd $PBS_O_WORKDIR
mpirun -n 36 castep F > log 2>&1

II. Submit Script qsub F.pbs (qsub is submit command)

III. Input Command optados F

Obtain output file F.pdos.dat

IV. Plot PDOS: Note in .dat file, first column is x-axis, second and third columns are both y-axis

Plotting method basically same as DOS plot

VII. Multi-Pressure Point Structure Optimization

1) *.cell

Same as single pressure point structure optimization, input lattice parameters (can include pseudopotentials)

2) *.param

Same as single pressure point structure optimization

3) *.pbs.sh

Parts requiring modification:

#!/bin/bash
#PBS -q CT2                            #node name
#PBS -l nodes=1:ppn=20                 #number of cores
#PBS -j oe
#PBS -V
#PBS -N F_Test                         #task name
#######################################
####### Basic Parameter Declare #######
#######################################
declare -r kMpiSoftwarePath='/share/apps/MPI/impi/5.0.1.035/intel64/bin/mpirun'
declare -r kCastepMpiPath='/share/apps/compiler/Castep/castep.mpi'
declare -r kKpointsMpSpacing=0.03     #K-point spacing
declare -i node_num=1
declare -i core_num_per_node=20       #number of cores (same as above)
declare -i max_pressure=4000          #maximum pressure
declare -i min_pressure=3000          #minimum pressure
declare -i init_pressure=3000         #initial pressure (first pressurize from this pressure, then depressurize from this pressure)
declare -i pressure_step=200          #pressure interval
declare seed_name='F'                 #input filename (name here consistent with F.cell, F.param)
((total_core_num=node_num*core_num_per_node))

Complete script in Script folder: castep_multipress.pbs.sh

Notes: CASTEP does not output .res files. If need to perform structure optimization with CASTEP results,

Use command castep2res * > *.res

(* is filename before .castep)