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/11/02 12:44] – [Selected examples] nholmberhowto:cdft [2018/11/02 12:50] – [Selected examples] nholmber
Line 157: Line 157:
   - Constraint weight function specific settings (Becke/Hirshfeld subsections)    - Constraint weight function specific settings (Becke/Hirshfeld subsections) 
  
-In the above example, a Becke constraint is selected using the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT#TYPE_OF_CONSTRAINT|TYPE_OF_CONSTRAINT]]. The actual constraints are defined using the section [[inp>FORCE_EVAL/DFT/QS/CDFT/ATOM_GROUP|ATOM_GROUP]]. Each repetition of this section defines a new constraint. The constraint atoms are selected with the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/ATOM_GROUP#ATOMS|ATOMS]] and the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/ATOM_GROUP#COEFF|COEFF]] determines how the atoms are summed up to form the constraint. Usually all coefficients are set to +1, but mixing +1 and -1 coefficients would define the constraint as the difference between two groups of atoms. The keywords [[inp>FORCE_EVAL/DFT/QS/CDFT#TARGET|TARGET]] and [[inp>FORCE_EVAL/DFT/QS/CDFT#STRENGTH|STRENGTH]] define the constraint target values and the initial constraint strengths $\vec\lambda$, respectively. The constraint target value should be the desired number of valence electrons on the constraint atoms, suitably multiplied by atomic coefficients in case a relative constraint between two atom groups has been used. The constaint type is selected with the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/ATOM_GROUP#CONSTRAINT_TYPE|CONSTRAINT_TYPE]]. It is also possible to use fragment based constraints [[inp>FORCE_EVAL/DFT/QS/CDFT/ATOM_GROUP#FRAGMENT_CONSTRAINT|FRAGMENT_CONSTRAINT]], in which case the constraint target value is calculated from the superposition of isolated fragment densities according to the scheme in Figure 3+In the above example, a Becke constraint is selected using the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT#TYPE_OF_CONSTRAINT|TYPE_OF_CONSTRAINT]]. The actual constraints are defined using the section [[inp>FORCE_EVAL/DFT/QS/CDFT/ATOM_GROUP|ATOM_GROUP]]. Each repetition of this section defines a new constraint. The constraint atoms are selected with the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/ATOM_GROUP#ATOMS|ATOMS]] and the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/ATOM_GROUP#COEFF|COEFF]] determines how the atoms are summed up to form the constraint. Usually all coefficients are set to +1, but mixing +1 and -1 coefficients would define the constraint as the difference between two groups of atoms. The keywords [[inp>FORCE_EVAL/DFT/QS/CDFT#TARGET|TARGET]] and [[inp>FORCE_EVAL/DFT/QS/CDFT#STRENGTH|STRENGTH]] define the constraint target values and the initial constraint strengths $\vec\lambda$, respectively. The constraint target value should be the desired number of valence electrons on the constraint atoms, suitably multiplied by atomic coefficients in case a relative constraint between two atom groups has been used. The constaint type is selected with the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/ATOM_GROUP#CONSTRAINT_TYPE|CONSTRAINT_TYPE]]. It is also possible to use fragment based constraints [[inp>FORCE_EVAL/DFT/QS/CDFT/ATOM_GROUP#FRAGMENT_CONSTRAINT|FRAGMENT_CONSTRAINT]], in which case the constraint target value is calculated from the superposition of isolated fragment densities according to the scheme in Figure 2
  
 {{ howto:cdft-fragment-constraint.png?350 }} {{ howto:cdft-fragment-constraint.png?350 }}
-**Figure 3.** Using a fragment based CDFT constraint. The system is first divided into two fragments with atomic positions fixed in the same configuration as in the full system. The electron and spin densities of the fragment systems are then saved to cube files and subsequently used as input files for the CDFT calculation, where the constraint target value is calculated from the superimposed fragment densities. +**Figure 2.** Using a fragment based CDFT constraint. The system is first divided into two fragments with atomic positions fixed in the same configuration as in the full system. The electron and spin densities of the fragment systems are then saved to cube files and subsequently used as input files for the CDFT calculation, where the constraint target value is calculated from the superimposed fragment densities. 
  
 The OUTER_SCF section within the CDFT section defines settings for the CDFT SCF loop. 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. The OUTER_SCF section within the CDFT section defines settings for the CDFT SCF loop. 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.
Line 176: Line 176:
  
 {{ howto:cdft-becke-atomicsize.png?400}}{{ howto:cdft-becke.png?400 }}\\ {{ howto:cdft-becke-atomicsize.png?400}}{{ howto:cdft-becke.png?400 }}\\
-**Figure 2.** Comparison of the Voronoi (lines) and Becke partitioning (contours) schemes. At left, the Becke partitioning is performed without atomic size information. At right, the size of the red atom is 30 % larger than the black atoms, and the contours of the red atom extend farther than without atomic size adjustments. +**Figure 3.** Comparison of the Voronoi (lines) and Becke partitioning (contours) schemes. At left, the Becke partitioning is performed without atomic size information. At right, the size of the red atom is 30 % larger than the black atoms, and the contours of the red atom extend farther than without atomic size adjustments. 
  
-The Voronoi and, by extension, the Becke partitioning methods treat each element equally. This leads to unphysical partial charges in most systems. For example, the Becke scheme predicts a positive charge on oxygen and a negative charge on hydrogen in water (see examples for input files). This problem can be remedied by accounting for atomic radii during the partitioning. This behavior is activated by the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/BECKE_CONSTRAINT#ADJUST_SIZE|ADJUST_SIZE]] and the atomic radii are defined with the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/BECKE_CONSTRAINT#ATOMIC_RADII|ATOMIC_RADII]]. The atomic radii should be set to values that reflect the system under simulation, e.g. using additive covalent radii for covalent molecules or Shannon's ionic radii for ionic compounds. An example on how atomic size adjustments affect the Becke cell functions has been visualized above in Figure at right, where the size of the red atom is set to a value 30 % larger than the black atoms causing the red atom's contours to extend farther than without atomic size adjustments.+The Voronoi and, by extension, the Becke partitioning methods treat each element equally. This leads to unphysical partial charges in most systems. For example, the Becke scheme predicts a positive charge on oxygen and a negative charge on hydrogen in water (see examples for input files). This problem can be remedied by accounting for atomic radii during the partitioning. This behavior is activated by the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/BECKE_CONSTRAINT#ADJUST_SIZE|ADJUST_SIZE]] and the atomic radii are defined with the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/BECKE_CONSTRAINT#ATOMIC_RADII|ATOMIC_RADII]]. The atomic radii should be set to values that reflect the system under simulation, e.g. using additive covalent radii for covalent molecules or Shannon's ionic radii for ionic compounds. An example on how atomic size adjustments affect the Becke cell functions has been visualized above in Figure at right, where the size of the red atom is set to a value 30 % larger than the black atoms causing the red atom's contours to extend farther than without atomic size adjustments.
  
 The algorithmic implementation of the Becke density partitioning method has been detailed [[doi>10.1021/acs.jctc.6b01085|here]]. In brief, this involves iterating over each atom pair permutation $\{\mathbf{R}_i, \mathbf{R}_j\}, j\neq i$ at every real space grid point $\mathbf{r}$. This leads to a poor scaling with respect to the system size (cell size and planewave cutoff) and the number of atoms within the system, and is particularly troublesome for  solvated system simulations. The computational cost of the Becke method can be considerably decreased by noting that only the grid points within a cutoff distance $R_{cutoff}$ ([[inp>FORCE_EVAL/DFT/QS/CDFT/BECKE_CONSTRAINT#CUTOFF_TYPE|CUTOFF_TYPE]]) of atoms involved in constraints actually need to be considered. The other grid points can be efficiently screened with constraint atom centered spherical Gaussian functions, activated by the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/BECKE_CONSTRAINT#CAVITY_CONFINE|CAVITY_CONFINE]] and controlled by other keywords of the form CAVITY_*. The exact details of this confinement scheme and why it can be used are explained in the implementation paper. The algorithmic implementation of the Becke density partitioning method has been detailed [[doi>10.1021/acs.jctc.6b01085|here]]. In brief, this involves iterating over each atom pair permutation $\{\mathbf{R}_i, \mathbf{R}_j\}, j\neq i$ at every real space grid point $\mathbf{r}$. This leads to a poor scaling with respect to the system size (cell size and planewave cutoff) and the number of atoms within the system, and is particularly troublesome for  solvated system simulations. The computational cost of the Becke method can be considerably decreased by noting that only the grid points within a cutoff distance $R_{cutoff}$ ([[inp>FORCE_EVAL/DFT/QS/CDFT/BECKE_CONSTRAINT#CUTOFF_TYPE|CUTOFF_TYPE]]) of atoms involved in constraints actually need to be considered. The other grid points can be efficiently screened with constraint atom centered spherical Gaussian functions, activated by the keyword [[inp>FORCE_EVAL/DFT/QS/CDFT/BECKE_CONSTRAINT#CAVITY_CONFINE|CAVITY_CONFINE]] and controlled by other keywords of the form CAVITY_*. The exact details of this confinement scheme and why it can be used are explained in the implementation paper.
Line 321: Line 321:
 <note important>This simulation requires CP2K version 7.0 or later.</note> <note important>This simulation requires CP2K version 7.0 or later.</note>
  
-This tutorial is exactly the same as the Zn dimer example above but using Hirshfeld partitioning based constraints instead of Becke constraints. You can find the input files here. +This tutorial is exactly the same as the Zn dimer example above but using Hirshfeld partitioning based constraints instead of Becke constraints. You can find the input files {{:howto:cdft-tutorial-hirshfeld.zip|here}}
  
 It might be instructive to visualize how the Becke and Hirshfeld weight function schemes differ, in particular, how the methods assign a volume to each atom in the system. You can activate the section [[inp>FORCE_EVAL/DFT/QS/CDFT/PROGRAM_RUN_INFO/WEIGHT_FUNCTION|WEIGHT_FUNCTION]] to output the weight function as a cube file which you can visualize with e.g. VMD. Feel free to modify the water tutorial above to look at the differences between Becke and Hirshfeld constraints in a system with different chemical elements. It might be instructive to visualize how the Becke and Hirshfeld weight function schemes differ, in particular, how the methods assign a volume to each atom in the system. You can activate the section [[inp>FORCE_EVAL/DFT/QS/CDFT/PROGRAM_RUN_INFO/WEIGHT_FUNCTION|WEIGHT_FUNCTION]] to output the weight function as a cube file which you can visualize with e.g. VMD. Feel free to modify the water tutorial above to look at the differences between Becke and Hirshfeld constraints in a system with different chemical elements.
howto/cdft.txt · Last modified: 2024/01/03 13:20 by oschuett