# 2.14. DFTB repulsive potential¶

Note

The ParAMS graphical user interface does not support SCC-DFTB repulsive potentials, but it does support xTB parametrizations. This tutorial only covers running via the command-line.

This example illustrates how to fit an SCC-DFTB repulsive potential. It is based on the work published in Komissarov et al., J. Chem. Inf. Model. DOI: 10.1021/acs.jcim.1c00333.

Jobs: Lattice optimizations of the wurtzite and rocksalt polymorphs of ZnO

Fig. 2.6 Adapted from Komissarov et al.

Training set: The relative energy between the two polymorphs, and the bulk modulus and optimized lattice parameters of wurtzite. The reference data were calculated with BAND (DFT), using a TZP basis set.

Parameter interface: DFTBSplineRepulsivePotentialParameters



## 2.14.3. Parameter interface¶

SCC-DFTB parameters are stored in Slater-Koster files.

There are two types of parameters: electronic (first part of the file) and repulsive (second part). The SCC-DFTB interface in ParAMS can only reparametrize the repulsive part. The electronic part will be left unchanged.

The repulsive potential is often stored as a set of cubic splines. For example, the O-Zn.skf file from znorg-0-1 ($AMSHOME/atomicdata/DFTB/DFTB.org/znorg-0-1/O-Zn.skf) contains a section starting like this:  603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 Spline 50 4.4 0.9208107239531658 0.04427199498760486 -0.02471259209174629 3.314 3.33572 0.0247126138 -0.04551125961871317 0.02095362795876388 8.70378473121888e-07 3.33572 3.35744 0.0237339943 -0.04460103278835941 0.02095368467262518 -4.351894310757234e-06 3.35744 3.37916 0.0227751449 -0.04369081088530866 0.0209534011031919 6.777854668536314e-06 3.37916 3.40088 0.0218360655 -0.04278058554885637 0.0209538427482021 -3.240842931978331e-06 3.40088 3.4226 0.0209167563 -0.04187035520655911 0.02095363157487665 -3.573820388493532e-06 3.4226 3.44432 0.0200172172 -0.04096013450888582 0.02095339870474014 7.776778418881326e-06 3.44432 3.46604 0.0191374481 -0.04004990786287029 0.02095390543962191 -8.014605506416323e-06 3.46604 3.48776 0.0182774492 -0.03913968155344552 0.02095338320792711 4.762957571541797e-06 3.48776 3.50948 0.0174372203 -0.03822945984599743 0.02095369356224247 -1.277884267468699e-06 3.50948 3.5312 0.0166167615 -0.03731923320621154 0.02095361029530361 3.485827781742504e-07 3.5312 3.55292 0.0158160728 -0.03640900788164298 0.02095363300895743 -1.164502135629478e-07 3.55292 3.57464 0.0150351542 -0.03549878222854298 0.02095362542106152 1.172215182097767e-07 3.57464 3.59636 0.0142740057 -0.03458855657435135 0.02095363305921564 -3.524390511567152e-07 3.59636 3.61808 0.0135326273 -0.03367833125305728 0.02095361009428707 1.292537466393956e-06 3.61808 3.6398 0.012811019 -0.03276810460126522 0.02095369431602838 -4.817712128666492e-06  The third column (from line 606) contains the O-Zn repulsive potential (in Ha) at the distance defined by the first column (in bohr). Columns 4-6 contain the parameters of the cubic splines. With the DFTBSplineRepulsivePotentialParameters interface, the parameters of the cubic splines are not directly fitted. Instead, a Python class represents some analytical repulsive potential. The interface automatically makes the conversion to cubic splines. Here, we will use the TaperedDoubleExponential, which has the analytical form $V^{\text{rep}}(r) = \frac{1}{2}\left(\cos\left(\frac{\pi r}{r_{\text{cut}}}\right)+1\right)\cdot[A_0\exp(-A_1 r) + A_2\exp(-A_2 r)]$ where $$r_{\text{cut}}$$ is a non-fitted parameter (constant), and $$A_0$$, $$A_1$$, $$A_2$$, and $$A_3$$, are parameters changed during the optimization. The names of the fitted parameters in the DFTBSplineRepulsivePotentialParameters class are O-Zn:p0, O-Zn:p1, etc. Note The DFTB repulsive potential cannot be stored in/loaded from a .yaml file. Instead, you must specify the parameters in params.conf.py (see below). ## 2.14.4. Run the parametrization¶ To run the parametrization, run "$AMSBIN/params" optimize


This processes the params.conf.py file, which contains:

import multiprocessing
num_processes = multiprocessing.cpu_count()

#### NOTE: To get scientifically meaningful results, set the kspace quality to 'Good' !
#### It is only set to 'Normal' here for demonstration purposes, so that the calculation is faster.
dftb_s = Settings()
dftb_s.input.dftb.kspace.quality = 'Normal'



## 2.14.6. Modify the analytical repulsive potential¶

To use a different functional form of the repulsive potential, create a new class deriving from RepulsiveFunction, similar to TaperedDoubleExponential:

class TaperedDoubleExponential(RepulsiveFunction):
"""
Tapered double exponential function of the form

0.5*[cos(pi*r/cutoff)+1]*[A*exp(-B*r)+C*exp(-D*r)]

where A, B, C, D are the parameters.
"""
def __init__(self, cutoff=7.0):
super().__init__()
self.cutoff = cutoff
self.npar = 4  # number of parameters
self.default_values = [ 1.0, 1.0, 1.0, 1.0 ]
self.default_ranges = [ (0.,10.), (0.,5.), (0.,10.), (-1.,10.) ]

def __call__(self, x, params):
"""
x : a numpy array containing the values for which to evaluate the function
params : a list or 1D numpy array with self.npar (=4) elements

Returns a numpy array with the same shape as x containing the function value for each evaluated point
"""
assert(len(params) == self.npar)
ret = (0.5*(np.cos(np.pi*x/self.cutoff)+1)) * (params[0]*np.exp(-params[1]*x) + params[2]*np.exp(-params[3]*x))
ret = np.where(x < self.cutoff, ret, 0.0)
return ret

• npar must contain the number of parameters (in this case 4),
• default_values contains some default values of the parameters,
• default_ranges contains some default ranges of the parameters, and
• the __call__() method returns the calculated value (cf the equation).