29 KiB
Molecular Orbitals
The molecular orbitals (MOs) are defined in the basis of AOs along with a AO to MO coefficient matrix \[C\]. Using these coefficients (e.g. from Hartree Fock SCF method) the MOs are defined as follows:
\[ \phi_i(\mathbf{r}) = C_i * \chi_i (\mathbf{r}) \]
In this section we demonstrate how to use the QMCkl specific DGEMM function to calculate the MOs.
Context
The following arrays are stored in the context:
type |
Gaussian ('G' ) or Slater ('S' ) |
|
nucleus_index |
[nucl_num] |
Index of the first shell of each nucleus |
nucleus_shell_num |
[nucl_num] |
Number of shells per nucleus |
ao_num |
Number of AOs | |
ao_cartesian |
If true, use polynomials. Otherwise, use spherical harmonics | |
ao_factor |
[ao_num] |
Normalization factor of the AO |
ao_shell |
[ao_num] |
For each AO, specify to which shell it belongs |
coefficient |
[mo_num, ao_num] |
Orbital coefficients |
Computed data:
mo_vgl |
[5][walk_num][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 |
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;
char type;
} 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.
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);
#+NAME:post
Initialization functions
To set the basis set, all the following functions need to be called.
qmckl_exit_code qmckl_set_mo_basis_type (qmckl_context context, const char t);
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);
#+NAME:pre2
#+NAME:post2
When the basis set is completely entered, other data structures are computed to accelerate the calculations.
Computation
Computation of MOs
Get
qmckl_exit_code qmckl_get_mo_basis_vgl(qmckl_context context, double* const mo_vgl);
Provide
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 |
int64_t |
walk_num |
in | Number of walkers |
double |
coef_normalized[mo_num][ao_num] |
in | AO to MO transformation matrix |
double |
ao_vgl[5][walk_num][elec_num][ao_num] |
in | Value, gradients and Laplacian of the AOs |
double |
mo_vgl[5][walk_num][elec_num][mo_num] |
out | Value, gradients and Laplacian of the MOs |
integer function qmckl_compute_mo_basis_gaussian_vgl_f(context, &
ao_num, mo_num, elec_num, walk_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
integer*8 , intent(in) :: walk_num
double precision , intent(in) :: ao_vgl(ao_num,elec_num,walk_num,5)
double precision , intent(in) :: coef_normalized(ao_num,mo_num)
double precision , intent(out) :: mo_vgl(mo_num,elec_num,walk_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
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 iwalk = 1, walk_num
do ielec = 1, elec_num
! Value
info_qmckl_dgemm_value = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, &
ao_vgl(:, ielec, iwalk, 1), LDA, &
coef_normalized(1:mo_num,1:ao_num),size(coef_normalized,1) * 1_8, &
beta, &
mo_vgl(:,ielec,iwalk,1),LDC)
! Grad_x
info_qmckl_dgemm_Gx = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, &
ao_vgl(:, ielec, iwalk, 2), LDA, &
coef_normalized(1:mo_num,1:ao_num),size(coef_normalized,1) * 1_8, &
beta, &
mo_vgl(:,ielec,iwalk,2),LDC)
! Grad_y
info_qmckl_dgemm_Gy = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, &
ao_vgl(:, ielec, iwalk, 3), LDA, &
coef_normalized(1:mo_num,1:ao_num),size(coef_normalized,1) * 1_8, &
beta, &
mo_vgl(:,ielec,iwalk,3),LDC)
! Grad_z
info_qmckl_dgemm_Gz = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, &
ao_vgl(:, ielec, iwalk, 4), LDA, &
coef_normalized(1:mo_num,1:ao_num),size(coef_normalized,1) * 1_8, &
beta, &
mo_vgl(:,ielec,iwalk,4),LDC)
! Lapl_z
info_qmckl_dgemm_lap = qmckl_dgemm(context, TransA, TransB, M, N, K, alpha, &
ao_vgl(:, ielec, iwalk, 5), LDA, &
coef_normalized(1:mo_num,1:ao_num),size(coef_normalized,1) * 1_8, &
beta, &
mo_vgl(:,ielec,iwalk,5),LDC)
end do
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_gaussian_vgl_f
qmckl_exit_code qmckl_compute_mo_basis_gaussian_vgl (
const qmckl_context context,
const int64_t ao_num,
const int64_t mo_num,
const int64_t elec_num,
const int64_t walk_num,
const double* coef_normalized,
const double* ao_vgl,
double* const mo_vgl );