GPAW

# Mailist

## 2020-12-18 Reference energy

The reference energy is not important while the relative energy matters. One could use separate electrons and nuclei as the reference energy. A better solution is to have isolated atoms as reference.

# Parameters

## PBC

### zero PBC

For the isolated molecules, the cell must be orthogonal if one wants to use pbc=[0, 0, 0].

### 2D PBC

[gpaw-users] 2D PBC: 2D PBC is only implemented in LCAO and FD modes, but ignored in PW mode. Often, the dipole-layer correction isn't that important.

## egg-box effect

gpaw.poisson.BadAxesError: Each axis must be periodic or orthogonal to other axes. But we have pbc=[0 0 0] and orthogonal=[0 0 1]

• use atoms.set_pbc([1, 1, 0]) for non orthogonal cell
• use atoms.set_pbc([0, 0, 0]) and atoms.set_cell([a, b, c]) at the same time

## Eigensolver

• The default eigensolver dav is stable and efficient for most cases.
• The convergence of rmm-diis is very sensitive to the initial guess of the wavefunction.

## Density mixing

$$\rho^{in} _ {i+1} = \sum^{nmaxold} \alpha_i (\rho^{in} _ {i} + \beta (\rho^{out} _ {i} - \rho^{in} _ {i}))$$

## xc

• Within the same mode, the calculator will read wave function in the memory if you switch from one functional to another one. If the mode is changed as well (i.e. from lcao to fd), the calculator will build the wave function from atomic densities.

### vdW functional

optB88-vdW is not so robust in GPAW and less stable than other vdW functionals like (vdW-DF, optPBE-vdW, vdW-DF2). There are two methods to improve the SCF convergence of a optB88-vdW calculation.

• Do a PBE single point calculation first, then switch to optB88-vdW for the structure optimization
• Play with the density mixing scheme mix = Mixer(beta=0.05, nmaxold=5, weight=50), use smaller beta and nmaxold
calc = GPAW(mode='fd', xc='PBE',
basis = 'dzp', kpts=(1, 1, 1),
#mixer=Mixer(beta=0.05, nmaxold=5, weight=50),
txt='gpaw.txt')
atoms.set_calculator(calc)
atoms.get_potential_energy()

atoms.calc.set(xc='optB88-vdW')
opt = BFGS(atoms, trajectory='opt.traj', logfile='opt.log')
opt.run(fmax=0.01)


These strategies are working well for 'fd' mode, but not so well for the plane wave mode. For example, in the case of coronene on a 7x7 2L graphite, optB88-vdW in the following scheme always failed.

• PBE -> optB88-vdW
• revPBE -> optB88-vdW
• vdW-DF(converged) -> optB88-vdW
• (defaul initial wfs) -> optB88-vdW

optB86b-vdW is not supported in GPAW (at least until v20.1.0). In principle, one can add something in xc/init.py and xc/vdw.py to use optB86b-vdW.

# gpaw/xc/__init__.py
...
if name in ['vdW-DF', 'vdW-DF2', 'optPBE-vdW', 'optB88-vdW', 'optB86b-vdW',
'C09-vdW', 'mBEEF-vdW', 'BEEF-vdW']:
from gpaw.xc.vdw import VDWFunctional
return VDWFunctional(name, **kwargs)
...

# gpaw/xc/vdw.py
...
elif name == 'optB88-vdW':
kernel = LibXC('GGA_X_OPTB88_VDW+LDA_C_PW')
elif name == 'optB86b-vdW':
kernel = LibXC('GGA_X_OPTB86B_VDW+LDA_C_PW')
...


However, GGA_X_OPTB86B_VDW is only available after LibXC 5.0.0 which currently has some compatibility issues with GPAW.

### Custom xc

from gpaw.xc.libxc import LibXC
from gpaw.xc.gga import GGA
from gpaw import GPAW
class MyXC(GGA):
def __init__(self, kernel, setup_name, *args, **kwargs):
self.setup_name = setup_name
GGA.__init__(self, kernel, *args, **kwargs)
def get_setup_name(self):
return self.setup_name
calc = GPAW(xc=MyXC(LibXC('GGA_X_OPTB88_VDW+LDA_C_PW'), 'revPBE'))


### install

virtualenv --system-site-packages py3-ase-3.18.2

source /home/tang/python-virtualenv/py3-ase-3.18.2/bin/activate

git clone -b 19.8.1 https://gitlab.com/gpaw/gpaw.git gpaw-py3.6.3-v19.8.1-intel-2019

cd /home/tang/opt/gpaw/gpaw-py3.6.3-v19.8.1-intel-2019
python setup.py build_ext 2>&1 | tee gpaw_compile.txt
pip install .


GPAW v19.8.1 uses the following customize.py

compiler = 'mpicc'
mpicompiler = 'mpicc'

libraries = []
library_dirs = []
include_dirs = []
extra_compile_args = ['-xSSE4.2',
'-O3',
'-ipo',
'-no-prec-div',
'-fPIC']

# Use Intel MKL
libraries += ['mkl_sequential', 'mkl_core', 'mkl_rt', ]

# FFTW3:
fftw = True
if fftw:
libraries += ['fftw3']

# ScaLAPACK (version 2.0.1+ required):
scalapack = True
if scalapack:
libraries += ['mkl_scalapack_lp64', 'mkl_blacs_intelmpi_lp64']
mpi_define_macros += [('GPAW_NO_UNDERSCORE_CBLACS', '1')]
mpi_define_macros += [('GPAW_NO_UNDERSCORE_CSCALAPACK', '1')]

if 0:
xc = '/home/tang/opt/libxc/libxc-4.3.4-intel-2019-gpaw-20.1/'
include_dirs += [xc + 'include']