# Structure and Reactivity¶

## Computational Task¶

The section Task is used to specify the computational task to perform with the DFTB program. This section and its only sub-key, runType, are mandatory therefore.

```
Task
runType type
End
```

Currently the DFTB program supports the following values for `type`

`SinglePoint`

or`SP`

for single point energy calculations`GeometryOptimization`

or`GO`

for geometry optimizations`TransitionState`

or`TS`

for transition state searches`Frequencies`

or`F`

for frequency and`Phonons`

for phonon calculations`MolecularDynamics`

or`MD`

for molecular dynamics simulations

## Geometry Optimization¶

Geometry optimizations are enabled by setting the runType key to “GO”.

```
Task
runType GO
End
```

The actual behavior of the geometry optimization can be specified in more detail by the following input block.

```
Geometry
{Method quasinewton|conjgrads|gdiis}
{CGType fletcherreeves|polakribiere|hestenesstiefel|perry|birginmartinez|
scaled|adaptedscaled1|adaptedscaled2|swartdyn1|swartdyn2}
{SwartIter Niter}
{Optim cartesian|delocal|internal}
{initialHessian swart|unitmatrix}
{Iterations Niter}
{Converge {E=TolE} {Grad=TolG} {Rad=TolR}}
{Step {TrustRadius=MaxRadius}}
{OptimizeLattice [Yes|No]}
End
```

Geometry allows to specify information about the geometry optimization strategy.
The keyword must be specified only for a `runType`

requiring a geometry optimization (`GeometryOptimization`

and `TransitionState`

).

`Method quasinewton|conjgrads|gdiis`

- Selects the optimisation algorithm employed for the geometry relaxation. Currently supported are the Hessian-based Quasi-Newton-type BFGS algorithm and its variant based on the direct inversion of iterative subspace (GDIIS), as well as the purely gradient-based conjugate gradients method. The default is “quasinewton”.
`CGType`

Defines the methodology to compute the \(\beta_n\) value to update the conjugate direction. This keyword is relevant only if the

`Method`

is`conjgrads`

. By default, the Fletcher Reeves methodology is used.`fletcherreeves`

- Uses the Fletcher-Reeves formula \(\beta_{n} = \frac{\Delta x_n^\top \Delta x_n} {\Delta x_{n-1}^\top \Delta x_{n-1}}\).
`polakribiere`

- Uses the Polak-Ribiere formula \(\beta_{n} = \frac{\Delta x_n^\top (\Delta x_n-\Delta x_{n-1})} {\Delta x_{n-1}^\top \Delta x_{n-1}}\).
`hestenesstiefel`

- Uses the Hestenes-Stiefel formula \(\beta_n = -\frac{\Delta x_n^\top (\Delta x_n-\Delta x_{n-1})} {s_{n-1}^\top (\Delta x_n-\Delta x_{n-1})}\).
`perry`

- Uses the Perry formula \(\beta_n = -\frac{\Delta x_n^\top (\Delta x_n-\Delta x_{n-1})} {s_{n-1}^\top (\Delta x_n-\Delta x_{n-1})}\).
`birginmartinez`

- Similar to Perry, with a scaled \((\Delta x_n-\Delta x_{n-1})\) at the numerator by \(\theta = \frac{s_{n-1}^\top{s_{n-1}}}{s_{n-1}^\top (\Delta x_n-\Delta x_{n-1})}\).
`scaled`

- Uses \(\beta_n^{Scaled} = - \frac{\Delta x_n^\top \Delta x_n - \Delta x_{n-1}^\top \Delta x_{n}}{s_{n-1}^\top \Delta x_{n-1}}\).
`adaptedscaled1`

- Same as scaled, with \(\beta = \max\left({1-\beta_n^{Scaled}, \beta_n^{Scaled}}\right)\).
`adaptedscaled2`

- Same as scaled, with \(\beta = 1-\beta_n^{Scaled}\).
`swartdyn1`

- Uses adaptedscaled1 up to a given number of steps (specified as SwartIter), then uses Polak-Ribiere.
`swartdyn2`

- Uses adaptedscaled2 up to a given number of steps (specified as SwartIter), then uses Polak-Ribiere.

`SwartIter`

- Defines the number of steps required for the swartdyn CGTypes to switch methodology. Only relevant when the proper
`CGType`

is used. Default is 300 `Optim cartesian|delocal|internal`

- Optimization in delocalized coordinates (
`delocal`

) can only be used for geometry optimizations or transition state searches of molecular systems with the Quasi-Newton method. `InitialHessian swart|unitmatrix`

- Selects the type of the initial model Hessian when optimizing periodic systems with either the Quasi-Newton or the GDIIS method.
`Iterations Niter`

- The maximum number of geometry iterations allowed to locate the desired structure. The default is 50.
`Converge`

Convergence is monitored for two items: the energy and the Cartesian gradients. Convergence criteria can be specified separately for each of these items:

`TolE`

- The criterion for changes in the energy, in Hartree. Default: 1e-5.
`TolG`

- Applies to gradients, in Hartree/Ångstrom. Default: 1e-3.
`TolR`

- The maximum Cartesian step allowed for a converged geometry, in Ångstrom. Default: 0.001 Ångstrom.

`Step MaxRadius`

- Controls that changes in geometry from one cycle to another are not too large. By default, the trust radius is set to 0.2. Using the key, the user can override this, setting a constant value. A conservative value is 0.2. A large system (e.g., 100 atoms) typically needs a larger trust radius (e.g. 0.8).

`OptimizeLattice`

- Default: No. Enables optimization of the lattice parameters, in addition to the molecular geometry. This can only be applied to periodic systems.

### Constrained Optimization¶

The `Constraints`

keyword allows geometry optimizations with constraints for the distance between two atoms, an angle defined by three atoms, or a dihedral angle defined by four atoms:

```
Constraints
Dist A B Rab
Angle A B C alphaABC
Dihed A B C D dihABDC
end
```

Atoms are specified using their index (starting at 1) based on the order given in the `Atoms`

block. The `Dist`

, `Angle`

, and `Dihed`

constraints do not have to be satisfied at the start of the geometry optimization.

`Dist`

- When specified, the distance between atoms A and B is constrained to the value Rab in Ångstrom.
`Angle`

- When specified, the angle between atoms A, B and C (A-B-C) is constrained to the value alphaABC in degrees.
`Dihed`

- When specified, the dihedral angle between atoms A, B, C and D (A-B-C-D) is restrained to the value dihABCD in degrees. The dihedral angle is projected onto the [0, 2 \(\pi\)] interval, so there is no difference between specifying -30 degrees or 330 degrees.

## Molecular Dynamics¶

```
MD
Steps NSteps
TimeStep TStep
{Restart file=path}
{Checkpoint frequency=ChkFreq}
{Trajectory samplingFreq=SFreq}
{Preserve [TotalMomentum AngularMomentum CenterOfMass All None]}
{InitialVelocities zero|inline|random {temperature=InitTemp}}
{InlineVelocities
velocityVector
End}
{Thermostat type=ThermoType {thermostat options}}
End
```

The DFTB program supports molecular dynamics (with the velocity-Verlet algorithm) with and without thermostats.
This key (used with `runType`

set to `MD`

) allows to specify the details of the molecular dynamics calculation.

`Steps NSteps`

- Specifies the number of steps to be taken in the MD simulation.
It accepts a simple integer number
`NSteps`

. `TimeStep TStep`

- Specifies the time for each step.
By default, the unit is femtoseconds.
Through the
`Units`

key, it can be changed to atomic units of time. `Restart file=path`

- Triggers a restart procedure, recovering the latest known information from the specified file (either a final .rkf file, or a checkpoint .chk file).
When this keyword is present, system, velocity, previous average values and energy transfers will be recovered from the file, ignoring any redundant specification made in the input file.
This is the only situation where the
`System`

keyword can be omitted. `Checkpoint frequency=ChkFreq`

- Sets the frequency (in steps) for checkpoint the current status to a file. This allows to restart from an intermediate configuration in case of a crash of the program or the system. The keyword is optional; if not specified, by default is equal to the number of steps divided by 4. Only the most recent checkpoint is preserved. In case of crash, the checkpoint file may be found in the execution temporary directory, instead of the working path. Checkpoint files can be inspected with the GUI for the latest configuration.
`Trajectory samplingFreq=SFreq`

- Sets the frequency for printing to stdout and storing the molecular configuration on the .rkf file. This keyword is optional, and the default is the number of steps divided by 1000 (minimum one).
`Preserve [TotalMomentum AngularMomentum CenterOfMass All None]`

Constrains the molecular dynamics simulation to preserve different whole-system parameters. Note that this option has poor meaning for periodic systems. The keys can be given as a sequence out of the allowed list, with words separated by spaces

`TotalMomentum`

- Removes the overall velocity of the system from the atomic velocities.
`AngularMomentum`

- Removes the overall angular velocity of the system from the atomic velocities.
`CenterOfMass`

- Keeps the molecular system centered on the current center of mass.
`All`

- Specifying this is equivalent of specifying all of the above keywords
`None`

- None of the above options will be enabled.
This is the default setup if the
`Preserve`

keyword is not specified.

`InitialVelocities zero|inline|random {temperature=InitTemp}`

Specifies the initial velocities to assign to the atoms. Three methods to assign velocities are available:

`zero`

- All atom’s velocities are set to zero
`inline`

- Atom’s velocities are set to the values specified in the key
`InlineVelocities`

(see below) `random temperature=InitTemp`

- Atom’s velocities are set to random values according to the specified temperature
`InitTemp`

(in kelvin). The temperature keyword is mandatory for this choice.

`InlineVelocities`

- This optional key is read when
`InitialVelocities`

inline option is used. It allows to specify the velocities for each atom. Each row must contain three floating point values (corresponding to the x,y,z component of the velocity vector) and a number of rows equal to the number of atoms must be present, given in the same order as the`Atoms`

block. `Thermostat`

The key Thermostat allows to specify the use of a thermostat during the simulation. Depending on the selected thermostat type, different additional options may be needed to characterize the specific thermostat behavior. At the moment, the following choices for the type parameter are available

`None`

- No thermostat applied.
This is the default if no
`Thermostat`

key is present. `Scale`

Applies a scaling of the velocities in agreement to the specified temperature. The following options are required for this thermostat:

`temperature=Temp`

- Specifies the temperature of the thermostat, in kelvin. This parameter is mandatory.
`frequency=NSteps`

- This parameter is optional.
If specified, the thermostat will be applied every
`NSteps`

, using that step’s ensemble temperature and the specified thermostat temperature to compute the scaling factor. If not specified, the thermostat will be applied at every step, using the mean temperature of the ensemble and the specified thermostat temperature to compute the scaling factor.

`Berendsen`

Applies the Berendsen thermostat. The following options are required for this thermostat:

`tau`

- Specifies the initial tau parameter for the Berendsen thermostat, in femtoseconds (can be changed via
`Units`

key). `apply=local|global`

- Defines the scope of application of the scaling correction, either per-atom-velocity (
`local`

) or on the molecular system as a whole (`global`

). `temperature=Temp`

- Specifies the temperature of the thermostat, in kelvin. This parameter is mandatory.