# MCSCF program

## Exported functions

`ElemCo.DFMCSCF.dfmcscf`

— Method`dfmcscf(EC::ECInfo; direct=false)`

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

## Internal functions

`ElemCo.DFMCSCF.G_risj_calc`

— Method`G_risj_calc(typer::Integer, types::Integer, num_MO, index_MO, fock_MO::Matrix, DFint_MO)`

Calculate the G*risj tensor for the given type of indices r and s. Typer and types are the type of indices r and s, respectively: 1 for doubly occupied orbitals, 2 for singly occupied orbitals, 3 for virtual orbitals. index*MO is the index of the given type of orbitals. DFint*MO is the density fitting integrals in molecular orbital basis. Return G*risj tensor.

`ElemCo.DFMCSCF.G_rtsj_calc`

— Method`function G_rtsj_calc(typer::Integer,types::Integer, num_MO, DFint_MO, D1::Matrix)`

Calculate the G*rtsj tensor for the given type of indices r and s. Return G*rtsj tensor.

`ElemCo.DFMCSCF.G_rtsu_calc`

— Method`G_rtsu_calc(typer::Integer,types::Integer, num_MO, index_MO, DFint_MO, D1::Matrix, D2, fockClosed_MO::Matrix)`

Calculate the G*rtsu tensor for the given type of indices r and s. Return G*rtsu tensor.

`ElemCo.DFMCSCF.H_multiply`

— Method`H_multiply(EC::ECInfo, fock_MO::Matrix, cMO::Matrix, D1::Matrix, v::Vector, num_MO, g::Vector, λ::Number, h_block::NTuple{10, Matrix{Float64}}, HessianType::Symbol)`

Do the H * x calculation Depending on the Hessian type, do the calculation from unsimplified and simplified parts of blocks seperatly Calculate the first element of H*v vector, and the part of H*v from the multiplying of first element of v and g vector(first column of Hessian Matrix) Assembly the matrix the Hessian Matrix is | 0 g*21'*λ g*31'*λ g_22'*λ g*32'*λ | | g*21*λ h 2121 h2131 h2122 h2132 | | g_31*λ h

*3121 h*3131 h

*3122 h*3132 | | g

*22*λ h*2221 h

*2231 h*2222 h

*2232 | | g*32*λ h

*3221 h*3231 h

*3222 h*3232 | Return vector σ in the order of [σ[1];σ21;σ31;σ22;σ32]

`ElemCo.DFMCSCF.Hx_SCI`

— Method`Hx_SCI(EC::ECInfo, fock_MO::Matrix, cMO::Matrix, x::Vector, num_MO, D1::Matrix)`

Calculate the SCI part of σ which are from 3 blocks which are zero from the Hessian caclulation funcion. SO*SCI, SO*SCI_original, SCI Hessians need this function Return vector σ in the order of [σ21;σ31;σ22;σ32]

`ElemCo.DFMCSCF.Hx_SO`

— Method`Hx_SO(h_3131, h_3231, h_3121, x, num_MO)`

Calculate the SO part of σ which are from the 3 non-zero blocks of SO Hessian. Return vector σ in the order of [σ21;σ31;σ22;σ32]

`ElemCo.DFMCSCF.Hx_common`

— Method`Hx_common(h_2121, h_2221, h_3221, h_2231, h_2222, h_3222, h_3232, x)`

Calculate the common part of the σ which are from the 7 non-zero blocks for both SO and other simplified Hessian. Return vector σ in the order of [σ21;σ31;σ22;σ32]

`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(EC::ECInfo, A::Matrix)`

Calculate the orbital gradient g by antisymmetrizing the matrix A and rearranging the elements. The order of the elements in vector g*blockwise is vectorized g21, g31, g22, g32, among which g21 = g[occ1o,occ2], g31 = g[occv,occ2], g22 = g[occ1o,occ1o], g32 = g[occv,occ1o] return vector g*blockwise

`ElemCo.DFMCSCF.calc_h_SCI`

— Function`calc_h_SCI(EC::ECInfo, μjL, μuL, cMO::Matrix, D1::Matrix, D2, fock_MO::Matrix, fockClosed_MO::Matrix, A::Matrix, HessianType::Symbol=:SCI)`

Calculate the SCI Hessian and modified SO*SCI Hessian. Modified SO*SCI method includes fixed part 4 blocks, the SO part 2 blocks, the SCI version of the rest 4 blocks(including h*3232), among which 3(except h*3232) are caculated in H*multiply SCI Hessian includes fixed part 4 blocks, SCI special part 6 blocks, among which 3 blocks are caculated in this function, and 3 are caculated in H*multiply Return h*2121, h*3121, h*3131, h*2221, h*2231, h*2222, h*3221, h*3231, h*3222, h*3232

`ElemCo.DFMCSCF.calc_h_SO`

— Method`calc_h_SO(EC::ECInfo, μjL, μuL, abL, cMO::Matrix, D1::Matrix, D2, fock_MO::Matrix, fockClosed_MO::Matrix, A::Matrix)`

Calculate the Second Order Hessian. Second Order Hessian includes fixed part 4 blocks, 2 SO part blocks, the rest 4 blocks (including H*3232) are calculated as SO special part, which are implemented in this function. Return h*2121, h*3121, h*3131, h*2221, h*2231, h*2222, h*3221, h*3231, h*3222, h_3232

`ElemCo.DFMCSCF.calc_h_SO_SCI_original`

— Method`calc_h_SO_SCI_original(EC::ECInfo, μjL, μuL, abL, cMO::Matrix, D1::Matrix, D2, fock_MO::Matrix, fockClosed_MO::Matrix, A::Matrix)`

Calculate the original SO*SCI Hessian. Original SO*SCI Hessian includes fixed part 4 blocks, the SO part 3 blocks (including h*3232), and the 3 SCI blocks. These 3 SCI blocks are returned as [1,1] zero matrix in this function, the calculation is done in the H*multiply function. Return h*2121, h*3121, h*3131, h*2221, h*2231, h*2222, h*3221, h*3231, h*3222, h*3232

`ElemCo.DFMCSCF.calc_realE`

— Method`calc_realE(EC::ECInfo, μuL, fockClosed_MO::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, μuL, cMO::Matrix, D1::Matrix, D2, fock_MO::Matrix, fockClosed_MO::Matrix)`

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

`ElemCo.DFMCSCF.dffockCAS`

— Method`dffockCAS(EC::ECInfo, μνL, μjL, μuL, cMO::Matrix, D1::Matrix)`

Calculate fock matrices in molecular orbital basis. fockClosed[μ,ν] = $^cf_μ^ν = h_μ^ν + 2v_{μi}^{νi} - v_{μi}^{iν}$, fock[μ,ν] = $f_μ^ν = ^cf_μ^ν + D^t_u (v_{μt}^{νu} - 0.5 v_{μt}^{uν})$. fock*MO and fockClosed*MO are fock and fockClosed transformed into MO basis with coefficients cMO. Return matrix fock*MO and fockClosed*MO.

`ElemCo.DFMCSCF.h_calc_SOpart`

— Method`h_calc_SOpart(num_MO, index_MO, DFint_MO, D1::Matrix, D2, fock_MO::Matrix, fockClosed_MO::Matrix, A::Matrix)`

Calculate the SO version of the h tensor, including h*3221, h*2121. This function is used in SO, SO*SCI*origin, SO*SCI Hessian calculation. Return h*3221, h_2121.

`ElemCo.DFMCSCF.h_calc_fixed`

— Method`h_calc_fixed(num_MO, index_MO, D1::Matrix, D2, fockClosed_MO::Matrix, A::Matrix, DFint_MO)`

Calculate the fixed part of the h tensor, including h*2221, h*2231, h*2222, h*3222. This function is used in all the Hessian calculation. Return h*2221, h*2231, h*2222, h*3222.

`ElemCo.DFMCSCF.print_initial`

— Method`print_initial(Enuc::Float64, HessianType::Symbol)`

Print the information of the Hessian type

`ElemCo.DFMCSCF.λTuning`

— Method`λTuning(EC::ECInfo, trust::Number, maxit4λ::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.