#+TITLE: CFG CIPSI
#+AUTHOR: Vijay Gopal Chilkuri
#+EMAIL: vijay.gopal.c@gmail.com
#+DATE: 2020-12-08 Tue 08:27
#+startup: latexpreview
#+STARTUP: inlineimages


#+LATEX_HEADER: \usepackage{braket}

* Biblio
* Theoretical background

  Here we describe the main theoretical background and definitions of the
  Configuration (CFG) based CIPSI algorithm. The outline of the document is as follows.
  First, we give some definitions of the CFG many-particle basis follwed by the
  definitions of the overlap, one-particle, and two-particle matrix-elements. Finally,
  an algorithm is presented for the sigma-vector (\( \sigma \)-vector defined later) calculation using
  the CFG basis.


** Definitinon of CI basis

    In CFG based CIPSI, the wavefunction is represented in CFG basis
    as shown in Eq: [[Eq:definebasis1]].

    #+LATEX: \newcommand{\Ncfg}{N_{\text{CFG}}}
    #+LATEX: \newcommand{\Ncsf}{N_{\text{CSF}}}
    #+LATEX: \newcommand{\Nsomo}{N_{\text{SOMO}}}
    #+NAME: Eq:definebasis1
    \begin{equation}
    \ket{\Psi} = \sum_{i=1}^{\Ncfg} \sum_{j=1}^{\Ncsf(i)} c_{ij} {^S\ket{\Phi^j_i}}
    \end{equation}


    where the \(\ket{\Phi^j_i}\) represent Configuration State Functions (CSFs)
    which are expanded in terms of Bonded functions (BFs) as shown in
    [[Eq:definebasis2]].
    #+NAME: Eq:definebasis2
    \begin{equation}
    \ket{\Phi^j_i} = \sum_k O^{\Nsomo(i)}_{kj} \ket{^S\phi_k(i,j)}
    \end{equation}
    where the functions \(\ket{^S\phi_k(i,j)}\) represent the BFs for the CFG
    \(\ket{^S\Phi_i}\).
    The coefficients \(O^b_{a,k}\) depend only on the number of SOMOs
    in \(\Phi_i\).

    Each CFG contains a list of CSFs related to it which describes the
    spin part of the wavefunction (see Eq: [[Eq:definebasis3]]) which is
    encoded in the BFs as shown below in Eq: [[Eq:definebasis5]].


    #+NAME: Eq:definebasis3
    \begin{equation}
    \ket{^S\Phi_i} = \left\{ \ket{^S\Phi^1_i}, \ket{^S\Phi^2_i}, \dots, \ket{^s\Phi^{\Ncsf}_i} \right\}
    \end{equation}



    #+NAME: Eq:definebasis4
    \begin{equation}
    \mathbf{c}_i = \left\{ c^1_i, c^2_i, \dots, c^{\Ncsf}_i \right\}
    \end{equation}


    Each of the CSFs belonging to the CFG \(\ket{^S\Phi_i}\) have coefficients
    associated to them as shown in Eq: [[Eq:definebasis4]]. Crucially, the bonded functions
    defined in Eq: [[Eq:definebasis5]] are not northogonal to each other.


    #+NAME: Eq:definebasis5
    \begin{equation}
    \ket{^S\phi_k(i,j)} = (a\bar{a})\dots (b\ c) (d (e
    \end{equation}
    $i$ is the index of the CFG and $j$ determines the coupling.


    The bonded functions are made up of products of slater determinants. There are
    three types of determinants, first, the closed shell pairs \((a\bar{a})\). Second,
    the open-shell singlet pairs \((b\ c)\) which are expanded as
    \((b\ c) = \frac{\ket{b\bar{c}}-\ket{\bar{b}c}}{\sqrt{2}}\). Third, the
    open-shell SOMOs which are coupled parallel and account for the total spin of the
    wavefunction \((l (m \dots\). They are shown as open brackets.

** Overlap of the wavefunction

    Once the wavefunction has been expanded in terms of the CSFs, the most fundamental
    operation is to calculate the overlap between two states. The overlap in the
    basis of CSFs is defined as shown in Eq: [[Eq:defineovlp1]].


    #+NAME: Eq:defineovlp1
    \begin{equation}
    \braket{^S\Phi_i|^S\Phi_j} = \sum_{kl} C_i C_j \braket{^S\Psi^k_i|^S\Psi^l_j}
    \end{equation}


    Where the sum is over the CSFs \(k\) and \(l\) corresponding to the \(i\)
    and \(j\) CFGs respectively. The overlap between the CSFs can be expanded in terms
    of the BFs using the definition given in Eq: [[Eq:definebasis2]] and
    Eq: [[Eq:definebasis3]] as given in Eq: [[Eq:defineovlp2]].


    #+NAME: Eq:defineovlp2
    \begin{equation}
    \braket{^S\Phi^k_i|^S\Phi^l_j} = \sum_m \sum_n \left( O^k_{i,m}\right)^{\dagger} \braket{^S\phi_m(i,k)|^S\phi_n(j,l)} O^l_{j,n}
    \end{equation}


    Therefore, the overlap between two CSFs can be expanded in terms of the overlap
    between the constituent BFs. The overlap matrix \(S_{mn}\) is of dimension \(\left( N^k_{N_{BF}} , N^l_{N_{BF}} \right)\).
    The equation shown above (Eq: [[Eq:defineovlp2]]) can be written in marix-form as
    shown below in Eq: [[Eq:defineovlp3]].

    #+NAME: Eq:defineovlp3
    \begin{equation}
    \braket{^S\Phi_i|^S\Phi_j} = \left( C_{i,1} \right)^{\dagger} \mathbf{O}_i\cdot\mathbf{S}_{ij}\cdot\mathbf{O}_j C_{j,1}
    \end{equation}


    Note that the overlap between two CFGs does not depend on the orbital
    labels. It only depends on the number of Singly Occupied Molecular Orbitals
    (SOMOs) therefore it can be pretabulated. Actually, it is possible to
    redefine the CSFs in terms of a linear combination of BFs such that
    \(S_{ij}\) becomes the identity matrix. In this case, one needs to store the
    orthogonalization matrix \(\mathbf{\tilde{O}}_i\) which is given by
    \(\mathbf{O}_i\cdot S^{1/2}_i\) for a given CFG \(i\). Note that the a CFG
    \(i\) is by definition of an orthonormal set of MOs automatically orthogonal
    to a CFG \(j\) with a different occupation.

** Definition of matrix-elements

    The matrix-element (ME) evaluation follows a similar logic as the evalulation of
    the overlap. However, here the metric is the one-, or two-particle operator \(\hat{E}_{pq}\)
    or \(\hat{E}_{pq}\hat{E}_{rs}\) as shown in Eq: [[Eq:defineme1]] and Eq: [[Eq:defineme2]].

    #+NAME: Eq:defineme1
    \begin{equation}
    \braket{^S\Phi^k_i|\hat{O}_{pq}|^S\Phi^l_j} = \left( C_{i,1} \right)^{\dagger} \mathbf{O}_i\cdot\mathbf{A}^{pq}_{ij}\cdot\mathbf{O}_j C_{j,1}
    \end{equation}

    #+NAME: Eq:defineme2
    \begin{equation}
    \braket{^S\Phi^k_i|\hat{O}_{pq,rs}|^S\Phi^l_j} = \sum_K \left( C_{i,1} \right)^{\dagger} \mathbf{O}_i\cdot\mathbf{A}^{pq}_{ik}\cdot\mathbf{O}_k \mathbf{O}_k\cdot\mathbf{A}^{rs}_{kj}\cdot\mathbf{O}_j  C_{j,1}
    \end{equation}


    Where, \(\hat{O}_{pq}\) and \(hat{O}_{pq,rs}\) represent an arbitrary one-, and
    two-particle operators respectively. Importantly, the one-, and two-particle
    matrix-element evaluation can be recast into an effecient matrix multiplication
    form which is crucial for a fast evaluation of the action of the operators
    \(\hat{O}_{pq}\) and \(hat{O}_{pq,rs}\). The matrix \(\mathbf{A}^{pq}_{ij}\) contains
    the result of the operation \(\braket{^S\Phi^k_i|\hat{O}_{pq}|^S\Phi^l_j}\) in terms
    of BFs and is therefore of size \(NCSF(i) \textit{x} NBF(i)\). In this formulation, the determinant basis is entirely avoided.
    Note that the size and contents of the matrix \(\mathbf{A}^{pq}_{ij}\) depends
    only on the total number of SOMOs and the total spin \(S\), therefore, an optimal
    prototyping scheme can be deviced for a rapid calculaiton of these matrix contractions.
    The resolution of identity (RI) is used to evaluate the two-particle operator since
    this alleviates the necessacity to explicity construct two-particle matrix-elements
    \(\braket{^S\Phi^k_i|\hat{O}_{pq,rs}|^S\Phi^l_j}\) directly.

** Sigma-vector evaluation

    Once the \(\mathbf{A}^{pq}_{ij}\) matrices have been constructed for the given
    selected list of CFGs, the prototype lists for the \(\mathbf{A}^{pq}_{ij}\) matrices
    can be constructed. Following this, one can proceede to the evaluation of the sigma-vector
    as defined in the Eq [[Eq:definesigma1]].


    #+NAME: Eq:definesigma1
    \begin{equation}
    \sigma = \sum_{pq} \tilde{h}_{pq}\hat{E}_{pq}|\ket{^S\Phi^l_j} + \frac{1}{2}\sum_{pq,rs} g_{pq,rs} \hat{E}_{pq}\hat{E}_{rs}|\ket{^S\Phi^l_j}
    \end{equation}

    The one-electron part of the sigma-vector can be calculated as shown in Eq: [[Eq:defineme1]]
    and the two-electron part can be calculated using the RI as shown in Eq: [[Eq:defineme2]].
    The most expensive part involves the two-particle operator as shown on the RHS of Eq: [[Eq:definesigma1]].
    In this CFG formulation, the cost intensive part of the sigma-vector evaluation has been recast
    into an efficient BLAS matrix multiplication operation. Therefore, this formulation is the most efficient
    albeit at the cost of storing the prototype matrices \(\mathbf{A}^{pq}_{ij}\). However, where the total spin
    is small and the largest number of SOMOs does not exceed 14, the \(\mathbf{A}^{pq}_{ij}\) matrices
    can be stored in memory.


