A fast and precise DFT wavelet code

Time dependent DFT and FEAST solver

A fast and precise DFT wavelet code
Jump to: navigation, search


This lesson has been created for the current stable version. Earlier versions are fully capable of running this tutorial but input files may have to be changed according to possible earlier formats.

Contents

Basic TDDFT calculations : first run with N2 molecule as example

A TDDFT calculation rely on a BigDFT run on the first place. An input file is mandatory since if no input file is given, no TDDFT instructions are set by default.

example run: N2 molecule

The first mandatory input file would be the atomic position, for example the N2 molecule, given by the posinp.xyz file:

2 angstroem
free
N 0. 0. 0.
N 0. 0. 1.11499

The second mandatory file would be the input.yaml file. Create in the directory where posinp.xyz already exists the input file and fill it as follow :


 dft:
   hgrids: 0.4
   rmult: [5.0, 8.0]
   nrepmax: accurate
   norbv: 60
   nvirt: 60
   ncharge: 1
   disablesym: Yes
   inputpsiid: 2
   gnrm_cv: 1.d-5
 geopt: 
   method: LBFGS
   ncount_cluster_x: 500
   frac_fluct: 1.d0 0.
   randdis: 0.d0
   betax: 4.d0
 tddft:
   tddft_approach: TDA
   diagonalization: FEAST


Every parameter belongs to a parameter family (here : DFT, geopt, TDDFT). The DFT and geopt parameters will not be discussed here (report to the first and second tutorial for the explanations). There are two main parameter in the TDDFT family : the TDDFT approach and the diagonalisation type. TDDFT approach as only one entry available but is mandatory to set the calculation up. One should put "TDA" (stands for "Tamn-Dancoff approximation"). Regarding the diagonalisation type, there are two options : "LAPACK" or "FEAST". "LAPACK" option uses the LAPACK librairy to diagonalize the Casida matrix. It returns in the output as much eigenvalues as the size of the Casida matrix.

FEAST option allow to only calculate the eigenvalues in a certain interval. It will further be discussed in this tutorial

Once the calculation is launched, one should get an output file looking like the following :

 ndipoles                              :  80
 orbsocc%norb                          :  5
 orbsvirt%norb                         :  8
 Kbig calculation time (s)             :  68
 FEAST finished for processor          :  0
 number of Matrix-vector product during FEAST:  11564
  #----------------------------------------------------------------- TAMM-DANCOFF APPROXIMATION
 Excitation Energy and Oscillator Strength:
 -  [  1.835E+01,  1.347E-08 ] # 0001
 -  [  1.877E+01,  1.381E-05 ] # 0002
 -  [  1.87E+01,  8.162E-11 ] # 0003
 Transition energies (eV):
 -  [Energy:  18.35459] # 0001
 -  [Energy:  18.76861] # 0002
 -  [Energy:  18.70468,  {Transition:  [  2,  7 ], Coeff:  7.068E-01}, 
  {Transition:  [  2,  7 ], Coeff:  7.068E-01}] # 0003
  #----------------------------------------------------------------- Timing for root process
 Timings for root process:
   CPU time (s)                        :  289.11
   Elapsed time (s)                    :  289.59
 Memory Consumption Report:
   Tot. No. of Allocations             :  17866
   Tot. No. of Deallocations           :  17866
   Remaining Memory (B)                :  0
   Memory occupation:
     Peak Value (MB)                   :  227
     for the array                     : cosinarr
     in the routine                    : cluster

Using parse_log.py to extract the spectrum

The python script parse_log.py (that can be found in the /test/ folder of the root of BigDFT can be used to extract, plot and save the spectrum calcultated with the TDDFT approach. For instance, call

python parse_log.py -d my_log_file

It will open a graphic window where your spectrum will be plotted. You can add another curve for it to be plotted, and save the curves you want using the button "save visible curves". You just have to make sure that the check button in on at the right of the curve you want to save.

Parse log.png

TDDFT calculation with FEAST solver

As said in the previous section, one could chose either "LAPACK" or "FEAST" as diagonalization type. LAPACK uses the standart diagonalisation library and returns the whole spectrum of the Casida matrix where FEAST only returns the eigenvalues within an complex contour. The complex contour as well as other parameters have to be set up in a file called FEAST.yaml. This file as to lie with input.yaml and posinp.xyz. An example of FEAST.yaml file is given :


 edges:
 - {ecc:   -10, z: [      0.67d0,       0.00d0], n:     5}
 - {ecc:   -10, z: [      0.69d0,       0.00d0], n:     5}
 FEAST: 
  max_iter:   100               
  gnrm_cv: 1.000E-05           
  min_subspace_dim:     5               
  max_subspace_dim:   101               
  max_feast_loop:     3               
 GMRES: 
  subspace_dim:    64               
  max_iter:    32               
  gnrm_cv: 1.000E-30  

Edges correspond to the different points position (z) one use to create your contour. Two points are enough to create a contour since FEAST atomaticaly creates other points (the number is set by "n"). "ecc" correspond to the excentricity of the link between two points. an eccentricity of 1 correspond to a circle, 0 for a straight line and a negative eccentricity gives an ellipse.

The "FEAST" part of the file regards the algorithm itself. "gnrm_cv" is the tolerance regarding the convergence : if the residual of every eigenvalue inside the countour is below this tolerance, the calculation terminates.

FEAST is an iterative algorithm. It finds another eignevalues, extends its search space, finds another one etc... The value "min_subspace_dim" is the starting search space dimension, and "max_subspace_dim" the maximum, ie the algorithm wont be able to find more eigenvalue than "max_subspace_dim" (although it may find less). "max_feast_loop" is the number of loop the algorithm can do if the size of the search space is less than 1.5 times the number of eigenvalues within the contour. The less this number is, the fastest the search subspace becomes optimal. Finaly, the parameter "max_iter" is the maximum allowed number of feast loop if the size of the search space is equal or greater than 1.5 the number of eigenvalues within the contour. One could call this parameter "maximum allowed time to reach convergence".

The GMRES part regards the resolution of a lot of little linear systems inside FEAST. Since FEAST is an iterative algorithm, we won't look for a precise resolution of those linear system in one iteration of FEAST. Then the number of GMRES iterations is limited to a few per FEAST loop (here it is 32).

example run: N2 molecule

Running Bigdft with TDDFT active on a N2 molecule and the FEAST.yaml file earlier given, the final results are :


 Begin of the FEAST diagonalization
 FEAST finished for processor          :  0
 number of Matrix-vector product during FEAST:  11564
  #----------------------------------------------------------------- TAMM-DANCOFF APPROXIMATION
 Excitation Energy and Oscillator Strength:
 -  [  1.863E+01,  4.843E-05 ] # 0001
 -  [  1.853E+01,  3.678E-11 ] # 0002
 -  [  1.846E+01,  6.691E-09 ] # 0003
 Transition energies (eV):
 -  [Energy:  18.63009,  {Transition:  [  3,  8 ], Coeff:  1.992E-01}, 
  {Transition:  [  4,  8 ], Coeff:  2.176E-01}, 
  {Transition:  [  3,  8 ], Coeff:  1.992E-01}, 
  {Transition:  [  4,  8 ], Coeff:  2.176E-01}] # 0001
 -  [Energy:  18.53106,  {Transition:  [  3,  8 ], Coeff:  2.265E-01}, 
  {Transition:  [  4,  8 ], Coeff:  2.472E-01}, 
  {Transition:  [  3,  8 ], Coeff:  2.266E-01}, 
  {Transition:  [  4,  8 ], Coeff:  2.472E-01}] # 0002
 -  [Energy:  18.45580,  {Transition:  [  3,  8 ], Coeff:  5.194E-01}, 
  {Transition:  [  4,  8 ], Coeff:  4.761E-01}, 
  {Transition:  [  3,  8 ], Coeff:  5.195E-01}, 
  {Transition:  [  4,  8 ], Coeff:  4.762E-01}] # 0003

N2 FEAST.png

Parallel use of FEAST : C6H6 example

FEAST is also set to run parallel whenever bigdft is called with MPI options. No other options in FEAST.yaml or input.yaml are required. The contour is separated in as many sub contour as there is processors used and thus each processor looks for the eigenvalues in its own contour. :

C6H6 FEAST.png

Personal tools