# MCSCF program

## Exported functions

`ElemCo.DFMCSCF.davidson`

— Function`davidson(H::Matrix, N::Integer, n::Integer, thres::Number, convTrack::Bool=false)`

Calculate one of the eigenvalues and corresponding eigenvector of the matrix H (usually the lowest eigenvalue), N is the size of the matrix H, n is the maximal size of projected matrix, thres is the criterion of convergence, convTrack is to decide whether the tracking of eigenvectors is used

`ElemCo.DFMCSCF.dfmcscf`

— Method`dfmcscf(EC::ECInfo; direct = false, guess=:SAD, IterMax=50)`

Main body of Density-Fitted Multi-Configurational Self-Consistent-Field method

## Internal functions

`ElemCo.DFMCSCF.calc_U`

— Method`calc_U(EC::ECInfo, N_MO::Integer, x::Vector)`

calculate orbital-rotational matrix U (approximately unitary because of the anti-hermitian property of the R which is constructed from `x`

).

`ElemCo.DFMCSCF.calc_g`

— Method`calc_g(A::Matrix, EC::ECInfo)`

Calculate the orbital gradient g by antisymmetrizing the matrix A and rearranging the elements. The order of the elements in g[r,k] is (active|virtual) × (closed-shell|active)

`ElemCo.DFMCSCF.calc_h`

— Method`calc_h(EC::ECInfo, cMO::Matrix, D1::Matrix, D2, fock::Matrix, fockClosed::Matrix, A::Matrix)`

Calculate Hessian matrix `h[rk,sl]`

. `rk`

and `sl`

are combined indices of `r,k`

and `s,l`

, where indexes r,s refer to open orbitals reordered as (active|virtual), and indexes k,l refer to occupied orbitals reordered as (closed-shell|active).

`ElemCo.DFMCSCF.calc_realE`

— Method`calc_realE(EC::ECInfo, fockClosed::Matrix, D1::Matrix, D2, cMO::Matrix)`

Calculate the energy with the given density matrices and (updated) cMO, $E = (h_i^i + ^cf_i^i) + ^1D^t_u ^cf_t^u + 0.5 ^2D^{tv}_{uw} v_{tv}^{uw}$.

`ElemCo.DFMCSCF.checkE_modifyTrust`

— Method`checkE_modifyTrust(E::Number, E_former::Number, E_2o::Number, trust::Number)`

Check if the energy E is lower than the former energy E_former, if not, reject the update of coefficients and modify the trust region. Return reject::Bool and trust.

`ElemCo.DFMCSCF.denMatCreate`

— Method`denMatCreate(EC::ECInfo)`

Calculate the one particle density matrix and two particle density matrix of active electrons for high-spin determinant. D1[t,u] = $^1D^t_u = ⟨Ψ|\hat{E}^t_u|Ψ⟩ = ⟨ Ψ |∑_σ \hat{a}^†_{tσ} \hat{a}_{uσ}|Ψ⟩$, D2[t,u,v,w] = $=^2D^{tv}_{uw}=0.5 ⟨Ψ|\hat{E}^{tv}_{uw}+\hat{E}^{uv}_{tw}|Ψ⟩$, in which $\hat{E}_{tu,vw} = \hat{E}^t_u \hat{E}^v_w - δ_{uv} \hat{E}^t_w = ∑_{στ}\hat{a}^†_{tσ} \hat{a}^†_{vτ} \hat{a}_{wτ} \hat{a}_{uσ}$. Return D1 and D2.

`ElemCo.DFMCSCF.dfACAS`

— Method`dfACAS(EC::ECInfo, cMO::Matrix, D1::Matrix, D2, fock::Matrix, fockClosed::Matrix)`

Calculate the A-intermediate matrix in molecular orbital basis. return matrix A[p,q]

`ElemCo.DFMCSCF.dffockCAS`

— Method`dffockCAS(EC::ECInfo, cMO::Matrix, D1::Matrix)`

Calculate fock matrices in atomic orbital basis. Return matrix fock and fockClosed. fockClosed[μ,ν] = $^cf_μ^ν = h_μ^ν + 2v_{μi}^{νi} - v_{μi}^{iν}$, fock[μ,ν] = $f_μ^ν = ^cf_μ^ν + D^t_u (v_{μt}^{νu} - 0.5 v_{μt}^{uν})$.

`ElemCo.DFMCSCF.projDenFitInt`

— Method`projDenFitInt(EC::ECInfo, cMO::Matrix)`

Read the μνL density fitting integral, project to μjL and μuL with the coefficients cMO, j -> doubly occupied orbital, u -> active orbital, save in "AcL" and "AaL" on disk.

`ElemCo.DFMCSCF.λTuning`

— Method`λTuning(trust::Number, maxit::Integer, λmax::Number, λ::Number, h::Matrix, g::Vector)`

Find the rotation parameters as the vector x in trust region, tuning λ with the norm of x in the iterations. Return λ and x.