8.3.1.3. SCC-DFTB repulsive potential
*************************************

Important:

  This class cannot be stored in ".yaml" format and so cannot be used
  through the ParAMS GUI nor with the ParAMSJob Python class.

The "DFTBSplineRepulsivePotentialParameters" class provides an
interface to reading and writing the two-body repulsive potential
contained in the SCC-DFTB Slater-Koster parameter files. An analytical
form of the repulsive function is represented, for example, by a
"TaperedDoubleExponential" instance, or any other instance inheriting
from "RepulsiveFunction".

Note:

  Some DFTB parameter sets (e.g., QUASINANO2015) in the Amsterdam
  Modeling Suite are encrypted. The encrypted parameters cannot be
  reparameterized with ParAMS.

See also: Tutorial: DFTB repulsive potential

To use this interface, the Slater-Koster files must already contain
the electronic parameters, as well as some repulsive function
represented by cubic splines. When writing a parameter set, the
"DFTBSplineRepulsivePotentialParameters" instance will write out all
Slater-Koster files, keeping the electronic parts but overwriting the
repulsive potentials.

The names of parameters are of the form "Element1-Element2:p0", e.g.,
"O-Zn:p0" is the first parameter of the analytical repulsive function
written as splines to "O-Zn.skf", "O-Zn:p1" is the second parameter,
etc. For a "TaperedDoubleExponential", there are four parameters per
element pair. **Note**: The element names **must** be sorted
alphabetically. The function defined for the element pair "O-Zn" will
also be written to "Zn-O.skf". The parameters "Zn-O:p0" etc. are
ignored.

Slater-Koster files that have no active parameters associated with
them will be copied, i.e., the original repulsive potential is used.

Example:

   from scm.params import *
   import numpy as np

   # Make an interface to the SCC-DFTB repulsive potential parameterization.
   interface = DFTBSplineRepulsivePotentialParameters(
     folder='/amshome/atomicdata/DFTB/DFTB.org/znorg-0-1', # use electronic parameters from znorg-0-1
     repulsive_function=TaperedDoubleExponential(cutoff=5.67), #repulsive potential defined by four parameters
     r_range=np.arange(0., 5.87, 0.1), # distances (in bohr) for which to center the cubic splines
     other_settings=dftb_s # Settings object defining e.g. k-point sampling
   )

   # Refit only the O-Zn and Zn-O repulsive potential parameters
   # All other repulsive potentials from znorg-0-1 (e.g. as defined in C-C.skf)
   # will be kept in their original form
   for p in interface:
       p.is_active = p.name.startswith('O-Zn')


8.3.1.3.1. DFTBSplineRepulsivePotentialParameters API
=====================================================

class DFTBSplineRepulsivePotentialParameters(folder, repulsive_function, r_range, other_settings=None)

   Interface to the parameterization of the SCC-DFTB two-body
   repulsive potential in the AMS DFTB engine.

   __init__(folder, repulsive_function, r_range, other_settings=None)

      Create a new instance based on the parameterization in *folder*.

      Parameters:

      folder : str
         The folder from which the original .skf files are read. They
         must include Spline repulsive potentials. The electronic
         parts of the .skf files will be copied to the new
         (reparametrized) .skf files. The repulsive potential part
         will be overwritten. Note: The repulsive function to be
         parametrized is not initialized from the .skf files.

      repulsive_function: RepulsiveFunction  (e.g.
      TaperedDoubleExponential)
         An analytical repulsive function containing parmeters to be
         optimized.

      r_range : list of floats corresponding to distances for which to
      write cubic splines
         The unit must be bohr

      other_settings : Settings
         A settings instance with other settings to be used for the
         engine. Should start at normal root level of Settings
         instances used with the AMS driver, i.e. DFTB engine input
         should be in "other_settings.input.dftb".

   yaml_store(*args, **kwargs)

      Overrides the base class method to do nothing. This parameter
      interface cannot be written to YAML.

   _get_spline_string_list(repulsive_function, params, r_range)

      return a list of strings that can be written as the Spline
      repulsive potential in a .skf file

   write(folder, parameters=None)

      Writes the current parameterization to disk.

      If *folder* does not exist, it will be created. If *folder*
      exists the files in it will be overwritten if necessary.

   pickle_dump(fname)

      Stores the parameter interface instance in a binary format to
      *fname*. Loading it with "pickle_load()" will restore values,
      ranges and active settings. If *fname* does not end with the
      *.pkl* extension, it will be added.

   classmethod pickle_load(fname)

      Loads the parameter interface from a binary file stored with
      "pickle_dump()".

   get_engine(parameters=None, path=None, write=True)

      Returns:
         "Engine" for an SCC-DFTB engine matching the passed *params*.

      If *path* is not set (should be a directory), the parameter
      files will be created in a temporary directory that is deleted
      when the returned "Engine" is garbage collected.


8.3.1.3.2. TaperedDoubleExponential API
=======================================

class TaperedDoubleExponential(cutoff=7.0)

   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.

   __init__(cutoff=7.0)

   __call__(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
