# mo_basis

Molecular orbitals are expressed as

\[\phi_k({\bf r}) = \sum_i C_{ik} \chi_k({\bf r})\]

where \(\chi_k\) are normalized atomic basis functions.

The current set of MOs has a label `mo_label`. When the orbitals are modified, the label should also be updated to keep everything consistent.

When saving the MOs, the `mo_basis` directory of the EZFIO database is copied in the `save` directory, named by the current `mo_label`. All this is done with the script named `save_current_mos.sh` in the `$QP_ROOT/scripts` directory.

## EZFIO parameters

`mo_num```

  Total number of MOs

`mo_coef```

  Coefficient of the i-th AO on the j-th MO

`mo_label```

  Label characterizing the MOS (Local, Canonical, Natural, etc)

`mo_occ```

  MO occupation numbers

`mo_class```

  [ Core | Inactive | Active | Virtual | Deleted ], as defined by qp_set_mo_class

`ao_md5```

  MD5 checksum characterizing the AO basis set.

## Providers

`mo_coef`

  File : `mo_basis/mos.irp.f`

      double precision, allocatable   :: mo_coef      (ao_num,mo_num)

  Molecular orbital coefficients on AO basis set

  mo_coef(i,j) = coefficient of the i-th AO on the jth mo

  mo_label : Label characterizing the MOS (local, canonical, natural, etc)

  Needs:

  `ao_num` `ao_ortho_canonical_coef` | `ezfio_filename` `mo_num` | `mpi_master`

  Needed by:

  `eigenvectors_fock_matrix_mo` `fock_matrix_mo_alpha` `fock_matrix_mo_beta` `fps_spf_matrix_mo` `mo_coef_in_ao_ortho_basis` `mo_coef_transp` `mo_dipole_x` `mo_integrals_n_e` | `mo_integrals_n_e_per_atom` `mo_kinetic_integrals` `mo_overlap` `mo_pseudo_integrals` `mo_spread_x` `mo_two_e_int_erf_jj_from_ao` `mo_two_e_integral_jj_from_ao` `mo_two_e_integrals_erf_in_map` | `mo_two_e_integrals_in_map` `mo_two_e_integrals_vv_from_ao` `one_e_dm_ao_alpha` `one_e_spin_density_ao` `psi_det` `s_mo_coef` `scf_density_matrix_ao_alpha` `scf_density_matrix_ao_beta`

`mo_coef_begin_iteration`

  File : `mo_basis/track_orb.irp.f`

      double precision, allocatable   :: mo_coef_begin_iteration      (ao_num,mo_num)

  Void provider to store the coefficients of the MO basis at the beginning of the SCF iteration

  Usefull to track some orbitals

  Needs:

  `ao_num` | `mo_num` |

`mo_coef_in_ao_ortho_basis`

  File : `mo_basis/mos.irp.f`

      double precision, allocatable   :: mo_coef_in_ao_ortho_basis    (ao_num,mo_num)

  MO coefficients in orthogonalized AO basis

  \(C^{-1}.C_{mo}\)

  Needs:

  `ao_num` `ao_ortho_canonical_coef_inv` | `mo_coef` | `mo_num`

`mo_coef_transp`

  File : `mo_basis/mos.irp.f`

      double precision, allocatable   :: mo_coef_transp       (mo_num,ao_num)

  MO coefficients on AO basis set

  Needs:

  `ao_num` | `mo_coef` | `mo_num`

  Needed by:

  `mo_two_e_int_erf_jj_from_ao` `mo_two_e_integral_jj_from_ao` | `mo_two_e_integrals_erf_in_map` `mo_two_e_integrals_in_map` | `mo_two_e_integrals_vv_from_ao`

`mo_label`

  File : `mo_basis/mos.irp.f`

      character*(64)  :: mo_label

  MO coefficients on AO basis set

  mo_coef(i,j) = coefficient of the i-th AO on the j-th MO

  mo_label : Label characterizing the MOs (local, canonical, natural, etc)

  Needs:

  `ezfio_filename` | `mpi_master` |

  Needed by:

  `n_det` | `psi_coef` | `psi_det`

`mo_num`

  File : `mo_basis/mos.irp.f`

      integer :: mo_num

  Number of MOs

  Needs:

  `ao_ortho_canonical_coef` | `ezfio_filename` | `mpi_master`

  Needed by:

  `ao_ortho_canonical_nucl_elec_integrals` `ao_ortho_lowdin_nucl_elec_integrals` `big_array_coulomb_integrals` `core_fock_operator` `core_fock_operator_erf` `data_one_e_dm_alpha_mo` `data_one_e_dm_beta_mo` `eigenvectors_fock_matrix_mo` `fock_matrix_ao` `fock_matrix_mo` `fock_matrix_mo_alpha` `fock_matrix_mo_beta` `fock_operator_closed_shell_ref_bitmask` `fock_wee_closed_shell` `fps_spf_matrix_mo` `full_ijkl_bitmask` `int_erf_3_index` `list_core_inact_act` `list_inact` `mo_class` | `mo_coef` `mo_coef_begin_iteration` `mo_coef_in_ao_ortho_basis` `mo_coef_transp` `mo_dipole_x` `mo_integrals_cache_min` `mo_integrals_erf_cache_min` `mo_integrals_erf_map` `mo_integrals_map` `mo_integrals_n_e` `mo_integrals_n_e_per_atom` `mo_kinetic_integrals` `mo_occ` `mo_one_e_integrals` `mo_overlap` `mo_pseudo_integrals` `mo_spread_x` `mo_two_e_int_erf_jj` `mo_two_e_int_erf_jj_from_ao` `mo_two_e_integral_jj_from_ao` | `mo_two_e_integrals_erf_in_map` `mo_two_e_integrals_in_map` `mo_two_e_integrals_jj` `mo_two_e_integrals_vv_from_ao` `n_core_orb` `n_int` `one_e_dm_ao_alpha` `one_e_dm_dagger_mo_spin_index` `one_e_dm_mo` `one_e_dm_mo_alpha` `one_e_dm_mo_alpha_average` `one_e_dm_mo_diff` `one_e_dm_mo_spin_index` `one_e_spin_density_ao` `one_e_spin_density_mo` `psi_energy_h_core` `s_mo_coef` `singles_alpha_csc_idx` `singles_beta_csc_idx`

`mo_occ`

  File : `mo_basis/mos.irp.f`

      double precision, allocatable   :: mo_occ       (mo_num)

  MO occupation numbers

  Needs:

  `elec_alpha_num` `elec_beta_num` | `ezfio_filename` `mo_num` | `mpi_master`

## Subroutines / functions

`ao_ortho_cano_to_ao:`()

  File : `mo_basis/mos.irp.f`

      subroutine ao_ortho_cano_to_ao(A_ao,LDA_ao,A,LDA)

  Transform A from the AO basis to the orthogonal AO basis

  $C^{-1}.A_{ao}.C^{dagger-1}$

  Needs:

  `ao_num` | `ao_ortho_canonical_coef_inv` |

  Calls:

  `dgemm()` |  |

`ao_to_mo:`()

  File : `mo_basis/mos.irp.f`

      subroutine ao_to_mo(A_ao,LDA_ao,A_mo,LDA_mo)

  Transform A from the AO basis to the MO basis

  $C^dagger.A_{ao}.C$

  Needs:

  `ao_num` | `mo_num` | `mo_coef`

  Called by:

  `fock_matrix_mo_alpha` `fock_matrix_mo_beta` `fps_spf_matrix_mo` | `mo_dipole_x` `mo_integrals_n_e` `mo_integrals_n_e_per_atom` | `mo_kinetic_integrals` `mo_pseudo_integrals` `mo_spread_x`

  Calls:

  `dgemm()` |  |

`give_all_mos_and_grad_and_lapl_at_r:`()

  File : `mo_basis/mos_in_r.irp.f`

      subroutine give_all_mos_and_grad_and_lapl_at_r(r,mos_array,mos_grad_array,mos_lapl_array)

  Needs:

  `ao_num` | `mo_num` | `mo_coef`

  Calls:

  `give_all_aos_and_grad_and_lapl_at_r()` |  |

`give_all_mos_and_grad_at_r:`()

  File : `mo_basis/mos_in_r.irp.f`

      subroutine give_all_mos_and_grad_at_r(r,mos_array,mos_grad_array)

  Needs:

  `ao_num` | `mo_num` | `mo_coef`

  Calls:

  `give_all_aos_and_grad_at_r()` |  |

`give_all_mos_at_r:`()

  File : `mo_basis/mos_in_r.irp.f`

      subroutine give_all_mos_at_r(r,mos_array)

  Needs:

  `ao_num` | `mo_num` | `mo_coef_transp`

  Calls:

  `dgemv()` | `give_all_aos_at_r()` |

`initialize_mo_coef_begin_iteration:`()

  File : `mo_basis/track_orb.irp.f`

      subroutine initialize_mo_coef_begin_iteration

  Initialize `mo_coef_begin_iteration` to the current `mo_coef`

  Needs:

  `mo_coef_begin_iteration` | `mo_coef` |

  Called by:

  `damping_scf()` | `roothaan_hall_scf()` |

`mix_mo_jk:`()

  File : `mo_basis/mos.irp.f`

      subroutine mix_mo_jk(j,k)

  Rotates the j-th MO with the k-th MO to give two new MOs that are

  - $+ = frac{1}{sqrt{2}} (|jrangle + |krangle)$
  - $- = frac{1}{sqrt{2}} (|jrangle - |krangle)$

  by convention, the ‘+’ MO is in the lowest index (min(j,k)) by convention, the ‘-‘ MO is in the highest index (max(j,k))

  Needs:

  `ao_num` | `mo_coef` |

`mo_as_eigvectors_of_mo_matrix:`()

  File : `mo_basis/utils.irp.f`

      subroutine mo_as_eigvectors_of_mo_matrix(matrix,n,m,label,sign,output)

  Needs:

  `mo_label` `ao_num` | `mo_num` | `mo_coef`

  Called by:

  `create_guess()` `damping_scf()` | `hcore_guess()` | `roothaan_hall_scf()`

  Calls:

  `dgemm()` | `lapack_diag()` | `write_time()`

`mo_as_svd_vectors_of_mo_matrix:`()

  File : `mo_basis/utils.irp.f`

      subroutine mo_as_svd_vectors_of_mo_matrix(matrix,lda,m,n,label)

  Needs:

  `mo_label` `ao_num` | `mo_num` | `mo_coef`

  Calls:

  `dgemm()` | `svd()` | `write_time()`

`mo_as_svd_vectors_of_mo_matrix_eig:`()

  File : `mo_basis/utils.irp.f`

      subroutine mo_as_svd_vectors_of_mo_matrix_eig(matrix,lda,m,n,eig,label)

  Needs:

  `mo_label` `ao_num` | `mo_num` | `mo_coef`

  Called by:

  `set_natural_mos()` |  |

  Calls:

  `dgemm()` | `svd()` | `write_time()`

`reorder_core_orb:`()

  File : `mo_basis/track_orb.irp.f`

      subroutine reorder_core_orb

  routines that takes the current `mo_coef` and reorder the core orbitals (see `list_core` and `n_core_orb`) according to the overlap with `mo_coef_begin_iteration`

  Needs:

  `mo_num` `mo_coef_begin_iteration` `mo_coef` | `ao_overlap` `n_core_orb` | `ao_num` `list_inact`

  Called by:

  `damping_scf()` | `roothaan_hall_scf()` |

  Calls:

  `dsort()` |  |

`save_mos:`()

  File : `mo_basis/utils.irp.f`

      subroutine save_mos

  Needs:

  `mo_occ` `ao_md5` `ezfio_filename` | `mo_num` `mo_coef` | `ao_num` `mo_label`

  Called by:

  `damping_scf()` `hcore_guess()` | `huckel_guess()` `roothaan_hall_scf()` | `save_natural_mos()` `save_ortho_mos()`

  Calls:

  `ezfio_set_mo_basis_ao_md5()` `ezfio_set_mo_basis_mo_coef()` | `ezfio_set_mo_basis_mo_label()` `ezfio_set_mo_basis_mo_num()` | `ezfio_set_mo_basis_mo_occ()` `system()`

`save_mos_truncated:`()

  File : `mo_basis/utils.irp.f`

      subroutine save_mos_truncated(n)

  Needs:

  `mo_occ` `ao_md5` | `ezfio_filename` `mo_coef` | `ao_num` `mo_label`

  Calls:

  `ezfio_set_mo_basis_ao_md5()` `ezfio_set_mo_basis_mo_coef()` | `ezfio_set_mo_basis_mo_label()` `ezfio_set_mo_basis_mo_num()` | `ezfio_set_mo_basis_mo_occ()` `system()`