< prev. lesson Fourth Group >
Troubleshooting >

## Content of this lesson

- Introduction
- The Input-Output File Structure Overview
- Tuning The Input Parameters For Efficient Production Run.
- Exercises

## Material

- Mg7-minhop/input.dft
- Mg7-minhop/input.geopt
- Mg7-minhop/poscur.xyz
- Mg7-minhop/psppar.Mg
- Mg7-minhop/ioput

- Mg7-minhop/mdinput.dft
- Mg7-minhop/mdinput.geopt
- Mg7-minhop/earr.dat
- Mg7-minhop/rand.inp

# Basics of Minima Hopping: Minima Hopping on a Mg7 cluster

## Introduction:

The purpose of this lesson is to get familiar with basic variables needed to run a Minima Hopping calculation on a cluster. At the end of the lesson, one will be able to prepare the inputs required for an efficient production run and understand the important part of the output. This lesson may take 2 hours. If you have already finished the tutorial and facing some problems during the Minima Hopping run see troubleshooting section.

In this tutorial we assume that the user is already familiar with basic BigDFT inputs. We will use Mg7 cluster as an example system in this tutorial. The detailed discussion on the method can be found in the tutorial presentation.

## File Structure Overview

### Input files

- `input.dft` : same as the input file in case of BigDFT
- `mdinput.dft` : same format as `input.dft` but but contains lower accuracy parameters.
- `input.geopt` : same as the input file in case of BigDFT. Geometry optimization method to be used: `BFGS` .
- `mdinput.geopt` : same as the input file in case of BigDFT. Geometry optimization method to be used: `SDCG` .
- `poscur.xyz` : Input coordinates for the starting configuration.
- `psppar.XX` : the pseudo-potential file. See BigDFT manual for explanations.
- `rand.inp` : contains a single integer value which is used as seed to generate random numbers for MD part.

### Input/Output files

These files are updated during the run.

- `earr.dat` : This file contains the energy of all the local minima found in the system. The file has the following structure.

          9        19 # of minima already found, # of minima to be found in consecutive run
      -0.65000000000000000E+01    eref
       0.50000000000000002E-04    accur
       0.50929999999999997E+00  5.0000000000E+00
       0.51510000000000000E+00  6.0000000000E+00
       0.51610000000000000E+00  1.0000000000E+00
       0.51724999999999999E+00  7.0000000000E+00
       0.51775000000000004E+00  4.0000000000E+00
       0.52980000000000005E+00  1.0000000000E+00
       0.55049999999999999E+00  1.0000000000E+00
       0.55710000000000004E+00  1.0000000000E+00
       0.55890000000000006E+00  1.0000000000E+00

  - The 1st line contains two integer numbers indicating the number of minima already found and the number of minima to be found in future run. For a new run the 1st number is " 0 " .
  - Second line is eref: The reference energy. This should be chosen so that the total energy of the system with respect to `eref` is positive.It is also advised to have the value of this energy of the order of one for better accuracy.
  - Third line is accur: the rounding threshold of total energy obtained in the calculation. Minima Hopping will distinguish between two minimum based on this value. This should be chosen properly. Please refer to tutorial presentation for more detail on this topic.
  - From 4th line on the file contains the sorted energies of local minima and the number of times each minimum is visited. So in this example file the energy of the global minima is `0.50929999999999997E+00` and it has been visited 5 times during the run.
- `ioput` : This file contains four parameters: ediff, ekinetic, dt and nsoften. Follow the tutorial to know how to adjust these parameters.

      7.32050000000000149E-03  3.70012497212908811E-02  7.10681330130121025E-01   10 ediff ekinetic dt  nsoften

### Output files

Other than screen output and BigDFT output files, there are two output files of Minima Hopping code.

- `poslow******.xyz` : The coordinates of the local minima found in the system. `poslow000001.xyz` is the global minimum.`poslow000002.xyz` is 1st local minimum.
- `global.mon` : A log file of all the minima visited.

## Preparing The Inputs For A Production Run

We all know that calculations using Density Functional Theory is quite expensive method. When we couple Minima Hopping with BigDFT to search the global minimum on a DFT energy landscape, the calculation becomes even more expensive even for modern super computers. For this reason, a careful selection of input parameters are very important for the performance of the code. A detailed demonstration of the tuning process has been given in the tutorial `presentation`.

Exercise 1: Tuning input.dft file: Prepare an `input.dft` file which will give `expected accuracy` of `0.5E-05` . Start with `input.dft`, `posinp.xyz` and `psppar.Mg` files. Run BigDFT for different values of `hgrid`, `crmult` and `frmult` stored in first two lines of `input.dft` file and note the `expected accuracy in energy` in the output file.

    sandip@phys-carbon-04:~/tutorials/Mg7-minhop/input_dft$ ls
    input.dft  posinp.xyz  psppar.Mg
    sandip@phys-carbon-04:~/tutorials/Mg7-minhop/input_dft$ mpirun -np 7 ~/BigDFT > OUT &
    sandip@phys-carbon-04:~/tutorials/Mg7-minhop/input_dft$ grep expected OUT
     expected accuracy in energy  4.96E-06
     expected accuracy in energy per orbital  7.09E-07

Now in the same way find a low accuracy parameter set for `input.dft` which will produce `expected accuracy in energy` of `0.5E-03` . We will rename this `input.dft` file to `mdinput.dft` to use in our Minima Hopping run.

Exercise 2: Verifying the expected accuracy: After you have found a set of parameters for the `input.dft` file which gives an `expected accuracy` of `0.5E-05` , let's check the accuracy of the energy due to rotation. Use the `rotate_posinp` executable in the `src/tools` folder of the build directory to rotate the input structure arbitrarily and note how they affect the FINAL energy of the system.

    sandip@phys-carbon-04:~/tutorials/Mg7-minhop/input_dft$ grep FINAL OUT
     FINAL iter,total energy,gnrm    18  -5.99066949724724473E+00  9.62E-06
    sandip@phys-carbon-04:~/tutorials/Mg7-minhop/input_dft$ cp ~/tutorial/UTIL/rotate .
    sandip@phys-carbon-04:~/tutorials/Mg7-minhop/input_dft$ ./rotate
    reading atomic positions from file posinp.xyz
     rotations in degrees (0<= Phi <=360):

     around z axis / in xy-plane:
    30
     around y axis / in xz-plane:
    20
     around x axis / in yz-plane:
    10
     writing atomic positions to file rotate_posinp.xyz
    sandip@phys-carbon-04:~/tutorials/Mg7-minhop/input_dft$ mpirun -np 7 ~/BigDFT > OUT1 &
    sandip@phys-carbon-04:~/tutorials/Mg7-minhop/input_dft$ grep FINAL OUT1
     FINAL iter,total energy,gnrm    16  -5.990668764306198470E+00  7.14E-06

Exercise 3: Prepare input.geopt and mdinput.geopt files: `input.geopt` and `mdinput.geopt` has following file format:

    SDCG     Geometry Optimization method
    200      ncount_cluster: max steps during geometry relaxation
    5.d0  1.0E-4   frac_fluct:     geometry optimization stops if force norm less than frac_fluct of noise
    0.d0     randdis:        random amplitude for atoms
    4.0d0     betax: steepest descent step size.

The important task is to determine the step size for steepest descent stores in the last line of the file. To do this one should Use `VSSD` as geometry optimization method and a low initial step-size. One should not use a well relaxed structure for this purpose, so if we already have a well relaxed structure we can use a small value for `randdis` instead of zero. Don't forget to set the value of `randdis` back to zero before using the file for Minima Hopping run. use this `input.geopt` file along with the low accuracy set of `input.dft` file to start a BigDFT run. At the end of the run a <cosde>stepsize will be suggested at the end of `geopt.mon` file.

    sandip@phys-carbon-04:~tutorials/Mg7-minhop/geopt$ tail geopt.mon
       56    55  GEOPT_VSSD  -5.99017990634830E+00  -5.34E-08  1.371E-04  2.00E-04  4.26E-05  8.52E-06  beta= 1.17E+1  last beta= 1.17E+1
       57    56  GEOPT_VSSD  -5.99018030014665E+00  -3.94E-07  4.776E-05  7.88E-05  4.32E-05  8.65E-06  beta= 9.14E+0  last beta= 9.14E+0
       58    57  GEOPT_VSSD  -5.99018035217616E+00  -5.20E-08  3.045E-05  5.79E-05  4.38E-05  8.75E-06  beta= 1.37E+1  last beta= 1.55E+1
       59    58  GEOPT_VSSD  -5.99018039144910E+00  -3.93E-08  1.978E-05  4.30E-05  4.42E-05  8.84E-06  beta= 2.06E+1  last beta= 2.11E+1
       60    59  GEOPT_VSSD  -5.99018042561645E+00  -3.42E-08  1.656E-05  3.54E-05  4.45E-05  8.90E-06  beta= 3.08E+1  last beta= 5.42E+1
     new positions rejected, reduced beta   4.00000000000000
       61    60  GEOPT_VSSD  -5.99018038142169E+00   4.42E-08  1.287E-05  2.75E-05  4.48E-05  8.96E-06  beta= 4.00E+0  last beta= 6.87E+1
       62    61  GEOPT_VSSD  -5.99018042934774E+00  -4.79E-08  1.703E-05  3.45E-05  4.53E-05  9.06E-06  beta= 4.00E+0  last beta= 5.55E+1
    variable stepsize SD FINISHED,iter, force norm,energy   61 0.34E-04 -0.5990180429E+01
    suggested value for stepsize: 0.81E+01

After we find the stepsize we will use this stepsize in both `input.geopt` and `mdinput.geopt` files. Only difference between these two files is for `input.geopt` we will use `BFGS` and for `mdinput.geopt` ,we will use `SDCG` as geometry optimization method.

Exercise 4: Minima-Hopping run for Mg7: If you have followed last three exercises then you already have prepared `input.dft` , `input.geopt` , `psppar.Mg` ,`mdinput.dft` and `mdinput.geopt`. As discussed in the tutorial presentation ,we can choose

    5.0E-03 5.0E-03 1.0 10 ediff,ekinetic dt nsoften

as parameters in `ioput` file. The other two files, `rand.inp` and `earr.dat` should be straight forward to understand if you follow the tutorial presentation. The atomic coordinates of the starting configuration can be used from `poscur.xyz` file. With these files start the minima hopping run for Mg7 cluster. Running Minima Hopping is done using the `global` executable in a standard Unix way, the output being by default the standard output, it must redirected to a file.

    sandip@phys-carbon-04:~/tutorials/Mg7$ ls
    earr.dat global  input.dft  input.geopt  ioput  mdinput.dft  mdinput.geopt  poscur.xyz  psppar.Mg  rand.inp
    sandip@phys-carbon-04:~/tutorials/Mg7$ mpirun -np 7 ./global>OUTmh &
    sandip@phys-carbon-04:~/tutorials/Mg7$ tail -100f OUTmh

    ...