# 9.7.5 State-Tracking Algorithm

For optimizing excited-state geometries and other applications, it can be important to find and follow electronically excited states of a particular character as the geometry changes. Various state-tracking procedures have been proposed for such cases.347, 171, 1102 One such algorithm, based on the overlap of the attachment/detachment densities at successive steps, in available in Q-Chem (see Section 7.15.1).171 Using the densities avoids any issues that may be introduced by sign changes in the orbitals or configuration-interaction coefficients.

Two parameters are used to influence the choice of the electronic surface. One ($\gamma_{E}$) controls the energy window for states included in the search, and the other ($\gamma_{S}$) controls how well the states must overlap in order to be considered of the same character. These can be set by the user or generated automatically based on the magnitude of the nuclear displacement. The energy window is defined relative to the estimated energy for the current step (i.e., $E_{\rm est}\pm\gamma_{E}$), which in turn is based on the energy, gradient and nuclear displacement of previous steps. This estimated energy is specific to the type of calculation (e.g., geometry optimization).

The similarity metric for the overlap is defined as

 $\mathcal{S}=1-\tfrac{1}{2}\bigl{(}||\Delta\mathbf{A}||+||\Delta\mathbf{D}||% \bigr{)}$ (9.14)

where $\Delta\mathbf{A}=\mathbf{A}_{t+1}-\mathbf{A}_{t}$ is the difference in attachment density matrices (Eq. (7.107)) and $\Delta\mathbf{D}=\mathbf{D}_{t+1}-\mathbf{D}_{t}$ is the difference in detachment density matrices (Eq. (7.105)), at successive steps. Equation (9.14) uses the matrix spectral norm,

 $||\mathbf{M}||=\left(\lambda_{\rm max}\mathbf{M}^{\dagger}\mathbf{M}\right)^{1% /2}$ (9.15)

where $\lambda_{\rm max}$ is the largest eigenvalue of $\mathbf{M}$.

The selected state always satisfies one of the following

1. 1.

It is the only state in the window defined by $\gamma_{E}$.

2. 2.

It is the state with the largest overlap, provided at least one state has $\mathcal{S}\geq\gamma_{S}$.

3. 3.

It is the nearest state energetically if all states in the window have $\mathcal{S}<\gamma_{S}$, or if there are no states in the energy window.

State-following can currently be used with CIS or TDDFT excited states and is initiated with the \$rem variable STATE_FOLLOW. It can be used with geometry optimization, ab initio molecular dynamics,171 or with the freezing/growing-string method. The desired state is specified using SET_STATE_DERIV for optimization or dynamics, or using SET_STATE_REACTANT and SET_STATE_PRODUCT for the freezing- or growing-string methods. The results for geometry optimizations can be affected by the step size (GEOM_OPT_DMAX), and using a step size smaller than the default value can provide better results. Also, it is often challenging to converge the strings in freezing/growing-string calculations.

STATE_FOLLOW
Turns on state following.
TYPE:
LOGICAL
DEFAULT:
FALSE
OPTIONS:
FALSE Do not use state-following. TRUE Use state-following.
RECOMMENDATION:
None.

FOLLOW_ENERGY
Adjusts the energy window for near states
TYPE:
INTEGER
DEFAULT:
0
OPTIONS:
0 Use dynamic thresholds, based on energy difference between steps. $n$ Search over selected state $E_{\rm est}\pm n\times 10^{-6}\;E_{h}$.
RECOMMENDATION:
Use a wider energy window to follow a state diabatically, smaller window to remain on the adiabatic state most of the time.

FOLLOW_OVERLAP
Adjusts the threshold for states of similar character.
TYPE:
INTEGER
DEFAULT:
0
OPTIONS:
0 Use dynamic thresholds, based on energy difference between steps. $n$ Percentage overlap for previous step and current step.
RECOMMENDATION:
Use a higher value to require states have higher degree of similarity to be considered the same (more often selected based on energy).