UP | HOME

Molecular Orbitals

Table of Contents

1 Context

The following arrays are stored in the context:

mo_num   Number of MOs
coefficient [mo_num][ao_num] Orbital coefficients

Computed data:

mo_vgl [5][elec_num][mo_num] Value, gradients, Laplacian of the MOs at electron positions
mo_vgl_date uint64_t Late modification date of Value, gradients, Laplacian of the MOs at electron positions

1.1 Data structure

typedef struct qmckl_mo_basis_struct {
  int64_t   mo_num;  
  double  * coefficient;

  double  * mo_vgl;
  int64_t   mo_vgl_date;

  int32_t   uninitialized;
  bool      provided;
} qmckl_mo_basis_struct;

The uninitialized integer contains one bit set to one for each initialization function which has not been called. It becomes equal to zero after all initialization functions have been called. The struct is then initialized and provided == true. Some values are initialized by default, and are not concerned by this mechanism.

1.2 Access functions

When all the data for the AOs have been provided, the following function returns true.

bool qmckl_mo_basis_provided (const qmckl_context context);

1.3 Initialization functions

To set the basis set, all the following functions need to be called.

qmckl_exit_code  qmckl_set_mo_basis_mo_num           (qmckl_context context, const int64_t   mo_num);
qmckl_exit_code  qmckl_set_mo_basis_coefficient      (qmckl_context context, const double  * coefficient);

When the basis set is completely entered, other data structures are computed to accelerate the calculations.

2 Computation

2.1 Computation of MOs

2.1.1 Get

qmckl_exit_code qmckl_get_mo_basis_vgl(qmckl_context context, double* const mo_vgl);

2.1.2 Provide

2.1.3 Compute

qmckl_context context in Global state
int64_t ao_num in Number of AOs
int64_t mo_num in Number of MOs
int64_t elec_num in Number of electrons
double coef_normalized[mo_num][ao_num] in AO to MO transformation matrix
double ao_vgl[5][elec_num][ao_num] in Value, gradients and Laplacian of the AOs
double mo_vgl[5][elec_num][mo_num] out Value, gradients and Laplacian of the MOs
integer function qmckl_compute_mo_basis_vgl_f(context, &
     ao_num, mo_num, elec_num, &
     coef_normalized, ao_vgl, mo_vgl) &
     result(info)
  use qmckl
  implicit none
  integer(qmckl_context), intent(in)  :: context
  integer*8             , intent(in)  :: ao_num, mo_num
  integer*8             , intent(in)  :: elec_num
  double precision      , intent(in)  :: ao_vgl(ao_num,elec_num,5)
  double precision      , intent(in)  :: coef_normalized(ao_num,mo_num)
  double precision      , intent(out) :: mo_vgl(mo_num,elec_num,5)
  logical*8                     :: TransA, TransB
  double precision              :: alpha, beta
  integer                       :: info_qmckl_dgemm_value
  integer                       :: info_qmckl_dgemm_Gx   
  integer                       :: info_qmckl_dgemm_Gy   
  integer                       :: info_qmckl_dgemm_Gz   
  integer                       :: info_qmckl_dgemm_lap  
  integer*8                     :: M, N, K, LDA, LDB, LDC, i,j

  integer*8 :: inucl, iprim, iwalk, ielec, ishell
  double precision :: x, y, z, two_a, ar2, r2, v, cutoff
  TransA = .False.
  TransB = .False. 
  alpha = 1.0d0
  beta  = 0.0d0

  info = QMCKL_SUCCESS
  info_qmckl_dgemm_value = QMCKL_SUCCESS
  info_qmckl_dgemm_Gx    = QMCKL_SUCCESS
  info_qmckl_dgemm_Gy    = QMCKL_SUCCESS
  info_qmckl_dgemm_Gz    = QMCKL_SUCCESS
  info_qmckl_dgemm_lap   = QMCKL_SUCCESS

  ! Don't compute exponentials when the result will be almost zero.
  ! TODO : Use numerical precision here
  cutoff = -dlog(1.d-15)
  M = 1_8
  N = mo_num * 1_8
  K = ao_num * 1_8
  LDA = M
  LDB = K
  LDC = M

  do ielec = 1, elec_num
          ! Value
          info_qmckl_dgemm_value = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha,     &
                                         ao_vgl(:, ielec, 1), LDA, &
                                         coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8,    &
                                         beta,                                       &
                                         mo_vgl(:,ielec,1),LDC)
          ! Grad_x
          info_qmckl_dgemm_Gx = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha,     &
                                         ao_vgl(:, ielec, 2), LDA, &
                                         coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8,    &
                                         beta,                                       &
                                         mo_vgl(:,ielec,2),LDC)
          ! Grad_y
          info_qmckl_dgemm_Gy = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha,     &
                                         ao_vgl(:, ielec,  3), LDA, &
                                         coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8,    &
                                         beta,                                       &
                                         mo_vgl(:,ielec,3),LDC)
          ! Grad_z
          info_qmckl_dgemm_Gz = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha,     &
                                         ao_vgl(:, ielec,  4), LDA, &
                                         coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8,    &
                                         beta,                                       &
                                         mo_vgl(:,ielec,4),LDC)
          ! Lapl_z
          info_qmckl_dgemm_lap = qmckl_dgemm(context, TransA, TransB, M, N, K, alpha,     &
                                         ao_vgl(:, ielec,  5), LDA, &
                                         coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8,    &
                                         beta,                                       &
                                         mo_vgl(:,ielec,5),LDC)
  end do

  if(info_qmckl_dgemm_value .eq. QMCKL_SUCCESS .and.  &
     info_qmckl_dgemm_Gx    .eq. QMCKL_SUCCESS .and.  &
     info_qmckl_dgemm_Gy    .eq. QMCKL_SUCCESS .and.  &
     info_qmckl_dgemm_Gz    .eq. QMCKL_SUCCESS .and.  &
     info_qmckl_dgemm_lap   .eq. QMCKL_SUCCESS        ) then
     info = QMCKL_SUCCESS
   else
     info = QMCKL_FAILURE
   end if

end function qmckl_compute_mo_basis_vgl_f
qmckl_exit_code qmckl_compute_mo_basis_vgl (
      const qmckl_context context,
      const int64_t ao_num,
      const int64_t mo_num,
      const int64_t elec_num,
      const double* coef_normalized,
      const double* ao_vgl,
      double* const mo_vgl ); 

2.1.4 Test

Author: TREX CoE

Created: 2021-10-14 Thu 19:59

Validate