User Tools

Site Tools


howto:cdft

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
howto:cdft [2018/01/09 16:30] – [Structure of input file] nholmberhowto:cdft [2018/07/24 05:38] – Update to CP2K 6.1 nholmber
Line 61: Line 61:
  
 \begin{equation} \begin{equation}
-\vec\lambda_n = \vec\lambda_{n-1} - \alpha \mathbf{J}_n^{-1}[\vec c(\vec\lambda_n)-\vec c(\vec\lambda_n)]+\vec\lambda_n = \vec\lambda_{n-1} - \alpha \mathbf{J}_n^{-1}\vec c(\vec\lambda_{n-1})
 \end{equation} \end{equation}
  
Line 80: Line 80:
  
 Settings for the CDFT SCF loop are controlled by the input section [[inp>FORCE_EVAL/DFT/QS/CDFT]]. An example of a typical CDFT input is given below. These parameter selections should be suitable for most systems. Settings for the CDFT SCF loop are controlled by the input section [[inp>FORCE_EVAL/DFT/QS/CDFT]]. An example of a typical CDFT input is given below. These parameter selections should be suitable for most systems.
 +
 +<note important>The CDFT input structure was altered slightly in CP2K version 6.1. The changes are indicated below. Input files for subsequent example calculations are provided for both versions 5.1 and 6.1, though using the latest available version is always recommended. </note>
  
 <code cp2k> <code cp2k>
Line 100: Line 102:
       ! Optimizer step size       ! Optimizer step size
       STEP_SIZE -1.0       STEP_SIZE -1.0
-      ! Line search settings +      ! Note that the section CDFT_OPT exists in CP2K version >= 6.1 
-      MAX_LS 5 +      ! Remove section for CP2K version 5.1 (keywords are unchanged) 
-      CONTINUE_LS +      &CDFT_OPT ON 
-      FACTOR_LS 0.5 +        ! Line search settings 
-      ! Finite difference settings for calculation of Jacobian matrix +        MAX_LS 5 
-      JACOBIAN_STEP 1.0E-2 +        CONTINUE_LS 
-      JACOBIAN_FREQ 1 1 +        FACTOR_LS 0.5 
-      JACOBIAN_TYPE FD1 +        ! Finite difference settings for calculation of Jacobian matrix 
-      JACOBIAN_RESTART FALSE+        JACOBIAN_STEP 1.0E-2 
 +        JACOBIAN_FREQ 1 1 
 +        JACOBIAN_TYPE FD1 
 +        JACOBIAN_RESTART FALSE 
 +      &END CDFT_OPT
     &END OUTER_SCF     &END OUTER_SCF
   &END CDFT   &END CDFT
Line 114: Line 120:
 </code> </code>
  
-The structure of this input section is quite straightforward. The keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/OUTER_SCF#EPS_SCF|EPS_SCF]] defines the CDFT constraint convergence threshold $\varepsilon$ and [[inp>FORCE_EVAL/DFT/QS/CDFT/OUTER_SCF#OPTIMIZER|OPTIMIZER]] selects the CDFT optimizer. Using Newton or quasi-Newton optimizers (Broyden methods) is recommended for most applications. These optimizers accept additional control settings that define how the Jacobian matrix is calculated (keywords JACOBIAN_*) and how to optimize the step size $\alpha$ (keywords *_LS). MD simulations with a single constraint might benefit from using the bisect optimizer, which avoids building the Jacobian matrix, in case a considerable amount of the total time per MD step is spent in building the Jacobian. Notice, however, that the frequency of Jacobian rebuilds [[inp>FORCE_EVAL/DFT/QS/CDFT/OUTER_SCF#JACOBIAN_FREQ|JACOBIAN_FREQ]] can be controlled on a per MD step and per CDFT SCF step basis. The Broyden optimizers require less frequent rebuilds of the Jacobian matrix because the matrix is [[https://en.wikipedia.org/wiki/Broyden%27s_method|rank-one updated]] every iteration, although the stability of the method with respect to the rebuild frequency needs to be carefully studied.+The structure of this input section is quite straightforward. The keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/OUTER_SCF#EPS_SCF|EPS_SCF]] defines the CDFT constraint convergence threshold $\varepsilon$ and [[inp>FORCE_EVAL/DFT/QS/CDFT/OUTER_SCF#OPTIMIZER|OPTIMIZER]] selects the CDFT optimizer. Using Newton or quasi-Newton optimizers (Broyden methods) is recommended for most applications. These optimizers accept additional control settings that define how the Jacobian matrix is calculated (keywords JACOBIAN_*) and how to optimize the step size $\alpha$ (keywords *_LS). These keywords are available in the [[inp>FORCE_EVAL/DFT/QS/CDFT/OUTER_SCF/CDFT_OPT|CDFT_OPT]] section. MD simulations with a single constraint might benefit from using the bisect optimizer, which avoids building the Jacobian matrix, in case a considerable amount of the total time per MD step is spent in building the Jacobian. Notice, however, that the frequency of Jacobian rebuilds [[inp>FORCE_EVAL/DFT/QS/CDFT/OUTER_SCF/CDFT_OPT#JACOBIAN_FREQ|JACOBIAN_FREQ]] can be controlled on a per MD step and per CDFT SCF step basis. The Broyden optimizers require less frequent rebuilds of the Jacobian matrix because the matrix is [[https://en.wikipedia.org/wiki/Broyden%27s_method|rank-one updated]] every iteration, although the stability of the method with respect to the rebuild frequency needs to be carefully studied.
  
 Above, for instance, the Jacobian is explicitly calculated every CDFT SCF iteration and MD step by perturbing each constraint Lagragian using a first order forward difference stencil with a step size of $10^{-2}$. The Newton step size is optimized with backtracking line search using the update formula $\alpha_n = 0.5*\alpha_{n-1}$ for a maximum of 5 steps as long as the CDFT constraint error decreases. Above, for instance, the Jacobian is explicitly calculated every CDFT SCF iteration and MD step by perturbing each constraint Lagragian using a first order forward difference stencil with a step size of $10^{-2}$. The Newton step size is optimized with backtracking line search using the update formula $\alpha_n = 0.5*\alpha_{n-1}$ for a maximum of 5 steps as long as the CDFT constraint error decreases.
Line 405: Line 411:
 The converged CDFT states are used as input for the mixed CDFT calculation. The calculation does not take long to run as a result. The mixed CDFT input file uses template files to keep the input tidy, as was discussed in the previous section. Find and study the corresponding section in the ''energy.bash'' script file to see how variables in the main mixed CDFT template ''energy_mixed.inp'' are initialized. The converged CDFT states are used as input for the mixed CDFT calculation. The calculation does not take long to run as a result. The mixed CDFT input file uses template files to keep the input tidy, as was discussed in the previous section. Find and study the corresponding section in the ''energy.bash'' script file to see how variables in the main mixed CDFT template ''energy_mixed.inp'' are initialized.
  
-A number of files are generated by the mixed CDFT calculation. The main output from the calculation can be found in file the ''Zn-5A-mixed-cdft.out''. The relevant part of the output is included below. The mixed CDFT analysis is printed after the header lines ''MIXED_CDFT|''. For each unique CDFT state permutation $\{i,j\}, i<j$, the constraint information is first summarized, the overlap and charge transfer energies are printed, and the calculated electronic coupling(s) (and possibly other quantities) are outputted. Here, both tested orthogonalization methods yield an electronic coupling of 5.67 mHa, in agreement with the [[doi>10.1063/1.4867077|5.49 mHa estimate ]] from the more expensive wavefunction based method CASSCF/MRCI+Q.+A number of files are generated by the mixed CDFT calculation. The main output from the calculation can be found in the file ''Zn-5A-mixed-cdft.out''. The relevant part of the output is included below. The mixed CDFT analysis is printed after the header lines ''MIXED_CDFT|''. For each unique CDFT state permutation $\{i,j\}, i<j$, the constraint information is first summarized, the overlap and charge transfer energies are printed, and the calculated electronic coupling(s) (and possibly other quantities) are outputted. Here, both tested orthogonalization methods yield an electronic coupling of 5.67 mHa, in agreement with the [[doi>10.1063/1.4867077|5.49 mHa estimate ]] from the more expensive wavefunction based method CASSCF/MRCI+Q.
  
 <file> <file>
Line 443: Line 449:
 </file> </file>
  
-Other files created during the execution are related to the individual CDFT states. The ''*-r-1.out, *-r-2.out, ...'' files are the main output files for the CDFT simulations of the studied states. Because preconverged solutions were employed, these CDFT simulations terminate immediately after the first SCF step, and any matrices that are subsequently needed in the mixed CDFT analysis are stored in memory. In the input file, the full project name and CDFT state ID number were stored in the variable ''${NAME}'' on a per state basis. This variable was used to prepend the name of any other output files (e.g. the cdftLog files) that are created during the CDFT simulation of the individual CDFT states. The output files from different CDFT states are then straightforward to distinguish. The content of the additional files was discussed in a [[howto:cdft#zn_dimer_cation|previous section]]. +Other files created during the execution are related to the individual CDFT states. The ''*-r-1.out, *-r-2.out, ...'' files are the main output files for the CDFT simulations of the studied states. Because preconverged solutions were employed, these CDFT simulations terminate immediately after the first SCF step, and any matrices that are subsequently needed in the mixed CDFT analysis are stored in memory. In the input file, the full project name and CDFT state ID number were stored in the variable ''${NAME}'' on a per state basis. This variable was used to prepend the name of any other output files (e.g. the cdftLog files) that are created during the CDFT simulation of the individual CDFT states. The output files from different CDFT states are therefore straightforward to distinguish. The content of the additional files was discussed in a [[howto:cdft#zn_dimer_cation|previous section]]. 
howto/cdft.txt · Last modified: 2024/01/03 13:20 by oschuett