Castep and QE Densities compared

This example shows how c2x can be used to compare the charge densities calculated by Castep and Quantum Espresso, although the same could be done for any other pair of codes which c2x supports. Ethene is used as the example system. The minimum version of c2x for this example is 2.40.

Running the codes

First Castep was run using the .cell file found on the molecules page.

Then a directory of QE input files was prepared:

$ c2x --qe ../castep/ethene.cell
$ curl -o C.UPF
$ curl -o H.UPF

The QE input file lacks an energy cut-off, so one was added by hand, using data from

$ c2x  -v --null ../castep/ethene.check
Requested cut-off energy 462.594 eV
$ c2x --calc '462.594/Ry'

(QE uses Rydbergs by default in its input.)

Then QE was run

$ pw.x -in > ethene.log


Castep and QE will have chosen different grid sizes for their 3D data, and c2x needs all the data on the same sized grid. The simplest way of achieving this is to ask c2x to interpolate to a size of 0x0x0, at which point it will pick the finer of the two grids for each dimension.

$ c2x -cv --diff --null -i=0x0x0  QE/pwscf.xml castep/ethene.check
QE binary reader called
QE density file with 1 spins
grid extent in file -28:28,-28:28,-24:24
Castep version 20.100
Spins=1  nbands=10
Interpolating Density from castep/ethene.check
Moving from 50x50x45 to 60x60x50 recip grid
Subtracting Density from castep/ethene.check from Charge
First FFT grid     60 60 50
spins=1   spinors=1
Found 3D data for Charge
  min=-0.469022 max=0.100171 sum=9.27044e-06 int=2.30731e-08
  (integral is e per cell for charge and spin densities)

and rather reassuringly reversing the order of the two input files produces very similar results, save that the end reads

  min=-0.100171 max=0.469022 sum=-9.27044e-06 int=-2.30731e-08

as the sign of the dataset has been inverted.

If one visualises the dataset, e.g.

$ c2x -cv --diff -i=0x0x0  QE/pwscf.xml castep/ethene.check diff.xsf

then it can be seen that the differences are highly localised around each atom. Unsurprising, as different pseudopotentials were used, so the densities within their core radii are not expected to be the same.