Atomic Orbitals
1. Introduction
The atomic basis set is defined as a list of shells. Each shell is centered on a nucleus , possesses a given angular momentum and a radial function . The radial function is a linear combination of primitive functions that can be of type Slater () or Gaussian ():
In the case of Gaussian functions, is always zero. The normalization factor ensures that all the functions of the shell are normalized (integrate) to unity. Usually, basis sets are given a combination of normalized primitives, so the normalization coefficients of the primitives, , need also to be provided.
Atomic orbitals (AOs) are defined as
where returns the shell on which the AO is expanded, and denotes which angular function is chosen and are the generating functions of the given angular momentum . Here, the parameter is an extra parameter which allows the normalization of the different functions of the same shell to be different, as in GAMESS for example.
In this section we describe first how the basis set is stored in the context, and then we present the kernels used to compute the values, gradients and Laplacian of the atomic basis functions.
2. Context
2.1. Constant data
The following arrays are stored in the context, and need to be set when initializing the library:
| Variable | Type | Description |
|---|---|---|
type |
char |
Gaussian ('G') or Slater ('S') |
shell_num |
int64_t |
Number of shells |
prim_num |
int64_t |
Total number of primitives |
nucleus_index |
int64_t[nucl_num] |
Index of the first shell of each nucleus |
nucleus_shell_num |
int64_t[nucl_num] |
Number of shells per nucleus |
r_power |
int32_t[shell_num] |
Power of r in Slater type orbitals () |
shell_ang_mom |
int32_t[shell_num] |
Angular momentum of each shell |
shell_prim_num |
int64_t[shell_num] |
Number of primitives in each shell |
shell_prim_index |
int64_t[shell_num] |
Address of the first primitive of each shell in the EXPONENT array |
shell_factor |
double[shell_num] |
Normalization factor for each shell |
exponent |
double[prim_num] |
Array of exponents |
coefficient |
double[prim_num] |
Array of coefficients |
prim_factor |
double[prim_num] |
Normalization factors of the primtives |
ao_num |
int64_t |
Number of AOs |
ao_cartesian |
bool |
If true, use polynomials. Otherwise, use spherical harmonics. The reference kernels always use polynomials and ignore this flag |
ao_factor |
double[ao_num] |
Normalization factor of the AO |
The following data is computed when the basis is finalized:
| Variable | Type | Description |
|---|---|---|
nucleus_prim_index |
int64_t[nucl_num+1] |
Index of the first primitive of each nucleus |
nucleus_max_ang_mom |
int32_t[nucl_num] |
Maximum angular momentum of each nucleus |
coefficient_normalized~ |
double[prim_num] |
Array of normalized coefficients |
ao_ang_mom |
int32_t[ao_num] |
Angular momentum of the shell to which the AO belongs |
ao_nucl |
int64_t[ao_num] |
Nucleus on which the AO is centered |
nucleus_range |
double[nucl_num] |
Used to compute the distance beyond which all Gaussian AOs are zero, depending on the precision |
For H2 with the following basis set,
we have:
A scalar variable $V$ present in this table can be set or get by
calling the functions:
For array variables, use the rule:
2.1.1. Initialization functions
size_max is the dimension of the input array, which should be
equal of larger than the value given in the table of section 2.
2.1.1.1. C interface
To set the basis set, all the following functions need to be called.
qmckl_exit_code
qmckl_set_ao_basis_type (qmckl_context context,
const char basis_type);
qmckl_exit_code
qmckl_set_ao_basis_shell_num (qmckl_context context,
const int64_t shell_num);
qmckl_exit_code
qmckl_set_ao_basis_prim_num (qmckl_context context,
const int64_t prim_num);
qmckl_exit_code
qmckl_set_ao_basis_nucleus_shell_num (qmckl_context context,
const int64_t* nucleus_shell_num,
const int64_t size_max);
qmckl_exit_code
qmckl_set_ao_basis_nucleus_index (qmckl_context context,
const int64_t* nucleus_index,
const int64_t size_max);
qmckl_exit_code
qmckl_set_ao_basis_shell_ang_mom (qmckl_context context,
const int32_t* shell_ang_mom,
const int64_t size_max);
qmckl_exit_code
qmckl_set_ao_basis_shell_prim_num (qmckl_context context,
const int64_t* shell_prim_num,
const int64_t size_max);
qmckl_exit_code
qmckl_set_ao_basis_shell_prim_index (qmckl_context context,
const int64_t* shell_prim_index,
const int64_t size_max);
qmckl_exit_code
qmckl_set_ao_basis_shell_factor (qmckl_context context,
const double* shell_factor,
const int64_t size_max);
qmckl_exit_code
qmckl_set_ao_basis_exponent (qmckl_context context,
const double* exponent,
const int64_t size_max);
qmckl_exit_code
qmckl_set_ao_basis_coefficient (qmckl_context context,
const double* coefficient,
const int64_t size_max);
qmckl_exit_code
qmckl_set_ao_basis_prim_factor (qmckl_context context,
const double* prim_factor,
const int64_t size_max);
qmckl_exit_code
qmckl_set_ao_basis_ao_num (qmckl_context context,
const int64_t ao_num);
qmckl_exit_code
qmckl_set_ao_basis_ao_factor (qmckl_context context,
const double* ao_factor,
const int64_t size_max);
qmckl_exit_code
qmckl_set_ao_basis_r_power (qmckl_context context,
const int32_t* r_power,
const int64_t size_max);
qmckl_exit_code
qmckl_set_ao_basis_cartesian (qmckl_context context,
const bool cartesian);
2.1.1.2. Fortran interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_type (context, &
basis_type) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
character(c_char) , intent(in) , value :: basis_type
end function qmckl_set_ao_basis_type
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_shell_num(context, &
num) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: num
end function qmckl_set_ao_basis_shell_num
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_prim_num(context, &
num) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: num
end function qmckl_set_ao_basis_prim_num
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_nucleus_index(context, &
idx, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(in) :: idx(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_set_ao_basis_nucleus_index
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_nucleus_shell_num(context, &
shell_num, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(in) :: shell_num(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_set_ao_basis_nucleus_shell_num
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_r_power(context, &
r_power, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int32_t) , intent(in) :: r_power(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_set_ao_basis_r_power
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_shell_ang_mom(context, &
shell_ang_mom, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int32_t) , intent(in) :: shell_ang_mom(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_set_ao_basis_shell_ang_mom
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_shell_prim_num(context, &
shell_prim_num, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(in) :: shell_prim_num(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_set_ao_basis_shell_prim_num
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_shell_prim_index(context, &
shell_prim_index, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(in) :: shell_prim_index(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_set_ao_basis_shell_prim_index
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_shell_factor(context, &
shell_factor, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
real (c_double) , intent(in) :: shell_factor(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_set_ao_basis_shell_factor
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_exponent(context, &
exponent, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
real (c_double) , intent(in) :: exponent(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_set_ao_basis_exponent
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_coefficient(context, &
coefficient, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
real (c_double) , intent(in) :: coefficient(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_set_ao_basis_coefficient
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_prim_factor(context, &
prim_factor, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
real (c_double) , intent(in) :: prim_factor(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_set_ao_basis_prim_factor
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_ao_num(context, &
num) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: num
end function qmckl_set_ao_basis_ao_num
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_cartesian(context, &
cartesian) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
logical (c_bool) , intent(in) , value :: cartesian
end function qmckl_set_ao_basis_cartesian
end interface
interface
integer(c_int32_t) function qmckl_set_ao_basis_ao_factor(context, &
ao_factor, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
real (c_double) , intent(in) :: ao_factor(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_set_ao_basis_ao_factor
end interface
2.1.2. Access functions
size_max is the dimension of the input array, which should be
equal of larger than the value given in the table of section 2.
2.1.2.1. C interface
qmckl_exit_code
qmckl_get_ao_basis_type (const qmckl_context context,
char* const basis_type);
qmckl_exit_code
qmckl_get_ao_basis_shell_num (const qmckl_context context,
int64_t* const shell_num);
qmckl_exit_code
qmckl_get_ao_basis_prim_num (const qmckl_context context,
int64_t* const prim_num);
qmckl_exit_code
qmckl_get_ao_basis_nucleus_shell_num (const qmckl_context context,
int64_t* const nucleus_shell_num,
const int64_t size_max);
qmckl_exit_code
qmckl_get_ao_basis_nucleus_index (const qmckl_context context,
int64_t* const nucleus_index,
const int64_t size_max);
qmckl_exit_code
qmckl_get_ao_basis_r_power (const qmckl_context context,
int32_t* const r_power,
const int64_t size_max);
qmckl_exit_code
qmckl_get_ao_basis_shell_ang_mom (const qmckl_context context,
int32_t* const shell_ang_mom,
const int64_t size_max);
qmckl_exit_code
qmckl_get_ao_basis_shell_prim_num (const qmckl_context context,
int64_t* const shell_prim_num,
const int64_t size_max);
qmckl_exit_code
qmckl_get_ao_basis_shell_prim_index (const qmckl_context context,
int64_t* const shell_prim_index,
const int64_t size_max);
qmckl_exit_code
qmckl_get_ao_basis_shell_factor (const qmckl_context context,
double* const shell_factor,
const int64_t size_max);
qmckl_exit_code
qmckl_get_ao_basis_exponent (const qmckl_context context,
double* const exponent,
const int64_t size_max);
qmckl_exit_code
qmckl_get_ao_basis_coefficient (const qmckl_context context,
double* const coefficient,
const int64_t size_max);
qmckl_exit_code
qmckl_get_ao_basis_prim_factor (const qmckl_context context,
double* const prim_factor,
const int64_t size_max);
qmckl_exit_code
qmckl_get_ao_basis_ao_num (const qmckl_context context,
int64_t* const ao_num);
qmckl_exit_code
qmckl_get_ao_basis_cartesian (const qmckl_context context,
bool* const cartesian);
qmckl_exit_code
qmckl_get_ao_basis_ao_factor (const qmckl_context context,
double* const ao_factor,
const int64_t size_max);
When all the data for the AOs have been provided, the following
function returns true.
bool qmckl_ao_basis_provided (const qmckl_context context);
2.1.2.2. Fortran interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_type (context, &
basis_type) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
character(c_char) , intent(out) :: basis_type
end function qmckl_get_ao_basis_type
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_shell_num(context, &
num) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(out) :: num
end function qmckl_get_ao_basis_shell_num
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_prim_num(context, &
num) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(out) :: num
end function qmckl_get_ao_basis_prim_num
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_nucleus_shell_num(context, &
shell_num, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(out) :: shell_num(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_get_ao_basis_nucleus_shell_num
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_nucleus_index(context, &
idx, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(out) :: idx(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_get_ao_basis_nucleus_index
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_r_power(context, &
r_power, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int32_t) , intent(out) :: r_power(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_get_ao_basis_r_power
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_shell_ang_mom(context, &
shell_ang_mom, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int32_t) , intent(out) :: shell_ang_mom(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_get_ao_basis_shell_ang_mom
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_shell_prim_num(context, &
shell_prim_num, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(out) :: shell_prim_num(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_get_ao_basis_shell_prim_num
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_shell_prim_index(context, &
shell_prim_index, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(out) :: shell_prim_index(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_get_ao_basis_shell_prim_index
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_shell_factor(context, &
shell_factor, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
real (c_double) , intent(out) :: shell_factor(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_get_ao_basis_shell_factor
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_exponent(context, &
exponent, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
real (c_double) , intent(out) :: exponent(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_get_ao_basis_exponent
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_coefficient(context, &
coefficient, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
real (c_double) , intent(out) :: coefficient(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_get_ao_basis_coefficient
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_prim_factor(context, &
prim_factor, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
real (c_double) , intent(out) :: prim_factor(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_get_ao_basis_prim_factor
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_ao_num(context, &
num) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(out) :: num
end function qmckl_get_ao_basis_ao_num
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_cartesian(context, &
cartesian) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
logical (c_bool) , intent(out) :: cartesian
end function qmckl_get_ao_basis_cartesian
end interface
interface
integer(c_int32_t) function qmckl_get_ao_basis_ao_factor(context, &
ao_factor, size_max) bind(C)
use qmckl_constants
import
implicit none
integer (c_int64_t) , intent(in) , value :: context
real (c_double) , intent(out) :: ao_factor(*)
integer (c_int64_t) , intent(in) , value :: size_max
end function qmckl_get_ao_basis_ao_factor
end interface
2.2. Computed data
The following data is computed as described in the next sections:
| Variable | Type | Description |
|---|---|---|
primitive_vgl |
double[point_num][5][prim_num] |
Value, gradients, Laplacian of the primitives at current positions |
primitive_vgl_date |
uint64_t |
Last modification date of Value, gradients, Laplacian of the primitives at current positions |
shell_vgl |
double[point_num][5][shell_num] |
Value, gradients, Laplacian of the primitives at current positions |
shell_vgl_date |
uint64_t |
Last modification date of Value, gradients, Laplacian of the AOs at current positions |
ao_vgl |
double[point_num][5][ao_num] |
Value, gradients, Laplacian of the AOs at current positions |
ao_vgl_date |
uint64_t |
Last modification date of Value, gradients, Laplacian of the AOs at current positions |
ao_value |
double[point_num][ao_num] |
Values of the AOs at current positions |
ao_value_date |
uint64_t |
Last modification date of the values of the AOs at current positions |
2.2.1. After initialization
When the basis set is completely entered, extra data structures may be computed to accelerate the calculations. The primitives within each contraction are sorted in ascending order of their exponents, such that as soon as a primitive is zero all the following functions vanish. Also, it is possible to compute a nuclear radius beyond which all the primitives are zero up to the numerical accuracy defined in the context.
2.2.2. HPC-specific data structures
With HAVE_HPC, the basis is rearranged by nucleus so that the radial
part of each shell is a dot product over the primitives of its nucleus.
The context stores:
prim_num_per_nucleus[inucl], the number of primitives of the nucleus once the duplicates are removed- in
coef_per_nucleus(iprim, ishell, inucl), the coefficient of the primitive in the shell of nucleus - in
expo_per_nucleus(iprim, inucl), the exponent of the primitive of nucleus
The exponents of a nucleus are sorted in increasing order, so the loop over primitives stops at the first one whose exceeds the cutoff. When two primitives of the same nucleus share an exponent, they are merged and their coefficients added.
For a Gaussian shell the radial part is then
The exponentials are evaluated once per point and per nucleus, then reused by all the shells of that nucleus.
2.2.3. Access functions
qmckl_exit_code
qmckl_get_ao_basis_primitive_vgl (qmckl_context context,
double* const primitive_vgl,
const int64_t size_max);
Returns the array of values, gradients and Laplacian of primitive basis functions evaluated at the current coordinates. See section 3.3.
qmckl_exit_code
qmckl_get_ao_basis_shell_vgl (qmckl_context context,
double* const shell_vgl,
const int64_t size_max);
Returns the array of values, gradients and Laplacian of contracted shells evaluated at the current coordinates. See section 3.4.
qmckl_exit_code
qmckl_get_ao_basis_ao_vgl (qmckl_context context,
double* const ao_vgl,
const int64_t size_max);
Returns the array of values, gradients and Laplacian of the atomic orbitals evaluated at the current coordinates. See section 5.
Computes the VGL into ao_vgl, which must have room for
point.num * 5 * ao_num doubles. The array cached in the context is
left untouched; a getter called afterwards returns the cached values if
they are still valid and recomputes them otherwise.
qmckl_exit_code
qmckl_get_ao_basis_ao_vgl_inplace (qmckl_context context,
double* const ao_vgl,
const int64_t size_max);
qmckl_exit_code
qmckl_get_ao_basis_ao_value (qmckl_context context,
double* const ao_value,
const int64_t size_max);
Returns the array of values of the atomic orbitals evaluated at the current coordinates. See section 5.
Computes the values into ao_value, which must have room for
point.num * ao_num doubles. The array cached in the context is left
untouched; a getter called afterwards returns the cached values if they
are still valid and recomputes them otherwise.
qmckl_exit_code
qmckl_get_ao_basis_ao_value_inplace (qmckl_context context,
double* const ao_value,
const int64_t size_max);
3. Radial part
3.1. General functions for Gaussian basis functions
qmckl_ao_gaussian_vgl computes the values, gradients and
Laplacians at a given point of n Gaussian functions centered at
the same point:
| Variable | Type | Description |
|---|---|---|
context |
qmckl_context |
Global state |
X(3) |
double[3] |
Array containing the coordinates of the points |
R(3) |
double[3] |
Array containing the x,y,z coordinates of the center |
n |
int64_t |
Number of computed Gaussians |
A(n) |
double[n] |
Exponents of the Gaussians |
VGL(ldv,5) |
double[5][ldv] |
Value, gradients and Laplacian of the Gaussians |
ldv |
int64_t |
Leading dimension of array VGL |
Requirements:
contextis notQMCKL_NULL_CONTEXTn> 0ldv >= nA(i)> 0 for alliXis allocated with at least bytesRis allocated with at least bytesAis allocated with at least bytesVGLis allocated with at least bytes
qmckl_exit_code
qmckl_ao_gaussian_vgl(const qmckl_context context,
const double *X,
const double *R,
const int64_t n,
const double *A,
double *VGL,
const int64_t ldv);
function qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv) &
bind(C) result(info)
use qmckl_constants
implicit none
integer (qmckl_context) , intent(in) , value :: context
real (c_double) , intent(in) :: X(3), R(3)
integer (c_int64_t) , intent(in) , value :: n
integer (c_int64_t) , intent(in) , value :: ldv
real (c_double) , intent(in) :: A(n)
real (c_double) , intent(out) :: VGL(ldv,5)
integer (qmckl_exit_code) :: info
integer*8 :: i,j
double precision :: Y(3), r2, t, u, v
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (n <= 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if (ldv < n) then
info = QMCKL_INVALID_ARG_7
return
endif
do i=1,3
Y(i) = X(i) - R(i)
end do
r2 = Y(1)*Y(1) + Y(2)*Y(2) + Y(3)*Y(3)
do i=1,n
VGL(i,1) = dexp(-A(i) * r2)
end do
do i=1,n
VGL(i,5) = A(i) * VGL(i,1)
end do
t = -2.d0 * ( X(1) - R(1) )
u = -2.d0 * ( X(2) - R(2) )
v = -2.d0 * ( X(3) - R(3) )
do i=1,n
VGL(i,2) = t * VGL(i,5)
VGL(i,3) = u * VGL(i,5)
VGL(i,4) = v * VGL(i,5)
end do
t = 4.d0 * r2
do i=1,n
VGL(i,5) = (t * A(i) - 6.d0) * VGL(i,5)
end do
end function qmckl_ao_gaussian_vgl
3.2. General functions for Slater basis functions
qmckl_ao_slater_vgl computes the values, gradients and Laplacians
at a given point of n Slater-type orbitals centered at the same
point:
These expressions are singular at . For the routine returns when and otherwise, with zero gradients and Laplacian.
| Variable | Type | Description |
|---|---|---|
context |
qmckl_context |
Global state |
X(3) |
double[3] |
Array containing the coordinates of the points |
R(3) |
double[3] |
Array containing the x,y,z coordinates of the center |
num_slater |
int64_t |
Number of computed Slater orbitals |
A(num_slater) |
double[num_slater] |
Exponents of the Slater orbitals |
N(num_slater) |
int64_t[num_slater] |
Principal quantum numbers of the Slater orbitals |
VGL(ldv,5) |
double[5][ldv] |
Value, gradients and Laplacian of the Slater orbitals |
ldv |
int64_t |
Leading dimension of array VGL |
Requirements:
contextis notQMCKL_NULL_CONTEXTnum_slater> 0ldv >= num_slaterA(i)> 0 for alliN(i)> 0 for alliXis allocated with at least bytesRis allocated with at least bytesAis allocated with at least bytesNis allocated with at least bytesVGLis allocated with at least bytes
qmckl_exit_code
qmckl_ao_slater_vgl(const qmckl_context context,
const double *X,
const double *R,
const int64_t num_slater,
const int64_t *N,
const double *A,
double *VGL,
const int64_t ldv);
function qmckl_ao_slater_vgl(context, X, R, num_slater, N, A, VGL, ldv) &
bind(C) result(info)
use qmckl_constants
implicit none
integer (qmckl_context) , intent(in) , value :: context
real (c_double) , intent(in) :: X(3), R(3)
integer (c_int64_t) , intent(in) , value :: num_slater
integer (c_int64_t) , intent(in) , value :: ldv
integer (c_int64_t) , intent(in) :: N(num_slater)
real (c_double) , intent(in) :: A(num_slater)
real (c_double) , intent(out) :: VGL(ldv,5)
integer (qmckl_exit_code) :: info
integer*8 :: i
double precision :: Y_vec(3), radius, r_inv, r_inv_2, x_over_r, y_over_r, z_over_r
double precision :: alpha, n_val, rn, exp_alpha_r
double precision :: grad_coef, lapl_coef
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (num_slater <= 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if (ldv < num_slater) then
info = QMCKL_INVALID_ARG_8
return
endif
! Compute distance vector and radius
do i=1,3
Y_vec(i) = X(i) - R(i)
end do
radius = dsqrt(Y_vec(1)*Y_vec(1) + Y_vec(2)*Y_vec(2) + Y_vec(3)*Y_vec(3))
! Handle r = 0 case
if (radius < 1.d-15) then
do i=1,num_slater
if (N(i) == 1) then
VGL(i,1) = 1.d0
else
VGL(i,1) = 0.d0
end if
VGL(i,2) = 0.d0
VGL(i,3) = 0.d0
VGL(i,4) = 0.d0
VGL(i,5) = 0.d0
end do
return
end if
r_inv = 1.d0 / radius
r_inv_2 = r_inv * r_inv
x_over_r = Y_vec(1) * r_inv
y_over_r = Y_vec(2) * r_inv
z_over_r = Y_vec(3) * r_inv
! Compute values, gradients and Laplacians for each Slater orbital
do i=1,num_slater
alpha = A(i)
n_val = dble(N(i))
! Compute r^n * exp(-alpha * r)
if (N(i) == 1) then
rn = radius
else
rn = radius**N(i)
end if
exp_alpha_r = dexp(-alpha * radius)
! Value: r^n * exp(-alpha * r)
VGL(i,1) = rn * exp_alpha_r
! Gradient coefficients
grad_coef = (n_val * r_inv - alpha) * VGL(i,1)
VGL(i,2) = grad_coef * x_over_r
VGL(i,3) = grad_coef * y_over_r
VGL(i,4) = grad_coef * z_over_r
! Laplacian: 1/r² [ n² - 2nar + ar(ar-2) + n] * v
lapl_coef = r_inv*r_inv * (n_val*n_val - 2.d0 * n_val * alpha*radius + &
alpha*radius * (alpha*radius - 2.d0) + n_val)
VGL(i,5) = lapl_coef * VGL(i,1)
end do
end function qmckl_ao_slater_vgl
qmckl_exit_code
qmckl_ao_slater_vgl_hpc(const qmckl_context context,
const double *X,
const double *R,
const int64_t *num_slater,
const int64_t *N,
const double *A,
double *VGL,
const int64_t ldv);
3.3. Computation of primitives
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
prim_num |
int64_t |
in | Number of primitives |
point_num |
int64_t |
in | Number of points considered |
nucl_num |
int64_t |
in | Number of nuclei |
nucleus_prim_index |
int64_t[nucl_num+1] |
in | Index of the 1st primitive of each nucleus |
coord |
double[3][point_num] |
in | Coordinates |
nucl_coord |
double[3][nucl_num] |
in | Nuclear coordinates |
expo |
double[prim_num] |
in | Exponents of the primitives |
primitive_vgl |
double[point_num][5][prim_num] |
out | Value, gradients and Laplacian of the primitives |
function qmckl_compute_ao_basis_primitive_gaussian_vgl &
(context, prim_num, point_num, nucl_num, nucleus_prim_index, coord, nucl_coord, expo, primitive_vgl) &
bind(C) result(info)
use qmckl_constants
use qmckl, only: qmckl_get_numprec_epsilon
implicit none
integer (qmckl_context), intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: prim_num
integer (c_int64_t) , intent(in) , value :: point_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) :: nucleus_prim_index(nucl_num+1)
real (c_double ) , intent(in) :: coord(point_num,3)
real (c_double ) , intent(in) :: nucl_coord(nucl_num,3)
real (c_double ) , intent(in) :: expo(prim_num)
real (c_double ) , intent(out) :: primitive_vgl(prim_num,5,point_num)
integer(qmckl_exit_code) :: info
integer*8 :: inucl, iprim, ipoint
double precision :: x, y, z, two_a, ar2, r2, v, cutoff
info = QMCKL_SUCCESS
! Don't compute exponentials when the result will be almost zero.
cutoff = -dlog(qmckl_get_numprec_epsilon(context))
do inucl=1,nucl_num
! C is zero-based, so shift bounds by one
do iprim = nucleus_prim_index(inucl)+1, nucleus_prim_index(inucl+1)
do ipoint = 1, point_num
x = coord(ipoint,1) - nucl_coord(inucl,1)
y = coord(ipoint,2) - nucl_coord(inucl,2)
z = coord(ipoint,3) - nucl_coord(inucl,3)
r2 = x*x + y*y + z*z
ar2 = expo(iprim)*r2
if (ar2 > cutoff) cycle
v = dexp(-ar2)
two_a = -2.d0 * expo(iprim) * v
primitive_vgl(iprim, 1, ipoint) = v
primitive_vgl(iprim, 2, ipoint) = two_a * x
primitive_vgl(iprim, 3, ipoint) = two_a * y
primitive_vgl(iprim, 4, ipoint) = two_a * z
primitive_vgl(iprim, 5, ipoint) = two_a * (3.d0 - 2.d0*ar2)
end do
end do
end do
end function qmckl_compute_ao_basis_primitive_gaussian_vgl
3.4. Computation of shells
3.4.1. Gaussians
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
prim_num |
int64_t |
in | Number of primitives |
shell_num |
int64_t |
in | Number of shells |
point_num |
int64_t |
in | Number of points |
nucl_num |
int64_t |
in | Number of nuclei |
nucleus_shell_num |
int64_t[nucl_num] |
in | Number of shells for each nucleus |
nucleus_index |
int64_t[nucl_num] |
in | Index of the 1st shell of each nucleus |
nucleus_range |
double[nucl_num] |
in | Range of the nucleus |
shell_prim_index |
int64_t[shell_num] |
in | Index of the 1st primitive of each shell |
shell_prim_num |
int64_t[shell_num] |
in | Number of primitives per shell |
coord |
double[3][point_num] |
in | Coordinates |
nucl_coord |
double[3][nucl_num] |
in | Nuclear coordinates |
expo |
double[prim_num] |
in | Exponents of the primitives |
coef_normalized |
double[prim_num] |
in | Coefficients of the primitives |
shell_vgl |
double[point_num][5][shell_num] |
out | Value, gradients and Laplacian of the shells |
function qmckl_compute_ao_basis_shell_gaussian_vgl( &
context, prim_num, shell_num, point_num, nucl_num, &
nucleus_shell_num, nucleus_index, nucleus_range, &
shell_prim_index, shell_prim_num, coord, nucl_coord, &
expo, coef_normalized, shell_vgl) &
bind(C) result(info)
use qmckl_constants
use qmckl, only: qmckl_get_numprec_epsilon
implicit none
integer (qmckl_context), intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: prim_num
integer (c_int64_t) , intent(in) , value :: shell_num
integer (c_int64_t) , intent(in) , value :: point_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) :: nucleus_shell_num(nucl_num)
integer (c_int64_t) , intent(in) :: nucleus_index(nucl_num)
real (c_double ) , intent(in) :: nucleus_range(nucl_num)
integer (c_int64_t) , intent(in) :: shell_prim_index(shell_num)
integer (c_int64_t) , intent(in) :: shell_prim_num(shell_num)
real (c_double ) , intent(in) :: coord(point_num,3)
real (c_double ) , intent(in) :: nucl_coord(nucl_num,3)
real (c_double ) , intent(in) :: expo(prim_num)
real (c_double ) , intent(in) :: coef_normalized(prim_num)
real (c_double ) , intent(out) :: shell_vgl(shell_num,5,point_num)
integer(qmckl_exit_code) :: info
integer*8 :: inucl, iprim, ipoint, ishell
integer*8 :: ishell_start, ishell_end
integer*8 :: iprim_start , iprim_end
double precision :: x, y, z, two_a, ar2, r2, v, cutoff
info = QMCKL_SUCCESS
! Don't compute exponentials when the result will be almost zero.
cutoff = -dlog(qmckl_get_numprec_epsilon(context))
do ipoint = 1, point_num
do inucl=1,nucl_num
x = coord(ipoint,1) - nucl_coord(inucl,1)
y = coord(ipoint,2) - nucl_coord(inucl,2)
z = coord(ipoint,3) - nucl_coord(inucl,3)
r2 = x*x + y*y + z*z
if (r2 > cutoff*nucleus_range(inucl)) then
cycle
end if
! C is zero-based, so shift bounds by one
ishell_start = nucleus_index(inucl) + 1
ishell_end = nucleus_index(inucl) + nucleus_shell_num(inucl)
do ishell=ishell_start, ishell_end
shell_vgl(ishell, 1, ipoint) = 0.d0
shell_vgl(ishell, 2, ipoint) = 0.d0
shell_vgl(ishell, 3, ipoint) = 0.d0
shell_vgl(ishell, 4, ipoint) = 0.d0
shell_vgl(ishell, 5, ipoint) = 0.d0
iprim_start = shell_prim_index(ishell) + 1
iprim_end = shell_prim_index(ishell) + shell_prim_num(ishell)
do iprim = iprim_start, iprim_end
ar2 = expo(iprim)*r2
if (ar2 > cutoff) then
cycle
end if
v = coef_normalized(iprim) * dexp(-ar2)
two_a = -2.d0 * expo(iprim) * v
shell_vgl(ishell, 1, ipoint) = &
shell_vgl(ishell, 1, ipoint) + v
shell_vgl(ishell, 2, ipoint) = &
shell_vgl(ishell, 2, ipoint) + two_a * x
shell_vgl(ishell, 3, ipoint) = &
shell_vgl(ishell, 3, ipoint) + two_a * y
shell_vgl(ishell, 4, ipoint) = &
shell_vgl(ishell, 4, ipoint) + two_a * z
shell_vgl(ishell, 5, ipoint) = &
shell_vgl(ishell, 5, ipoint) + two_a * (3.d0 - 2.d0*ar2)
end do
end do
end do
end do
end function qmckl_compute_ao_basis_shell_gaussian_vgl
3.4.2. Slater
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
prim_num |
int64_t |
in | Number of primitives |
shell_num |
int64_t |
in | Number of shells |
point_num |
int64_t |
in | Number of points |
nucl_num |
int64_t |
in | Number of nuclei |
nucleus_shell_num |
int64_t[nucl_num] |
in | Number of shells per nucleus |
nucleus_index |
int64_t[nucl_num] |
in | Index of the first shell of each nucleus |
nucleus_range |
double[nucl_num] |
in | Range beyond which all shells are zero |
shell_prim_index |
int64_t[shell_num] |
in | Index of the first primitive of each shell |
shell_prim_num |
int64_t[shell_num] |
in | Number of primitives per shell |
r_power |
int32_t[shell_num] |
in | Power of r prefix |
coord |
double[3][point_num] |
in | Coordinates of the points |
nucl_coord |
double[3][nucl_num] |
in | Nuclear coordinates |
expo |
double[prim_num] |
in | Exponents of the primitives |
coef_normalized |
double[prim_num] |
in | Coefficients of the primitives |
shell_vgl |
double[point_num][5][shell_num] |
out | Value, gradients and Laplacian of the shells |
function qmckl_compute_ao_basis_shell_slater_vgl( &
context, prim_num, shell_num, point_num, nucl_num, &
nucleus_shell_num, nucleus_index, nucleus_range, &
shell_prim_index, shell_prim_num, r_power, &
coord, nucl_coord, expo, coef_normalized, shell_vgl) &
bind(C) result(info)
use qmckl_constants
use qmckl, only: qmckl_get_numprec_epsilon
implicit none
integer (qmckl_context), intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: prim_num
integer (c_int64_t) , intent(in) , value :: shell_num
integer (c_int64_t) , intent(in) , value :: point_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) :: nucleus_shell_num(nucl_num)
integer (c_int64_t) , intent(in) :: nucleus_index(nucl_num)
real (c_double ) , intent(in) :: nucleus_range(nucl_num)
integer (c_int64_t) , intent(in) :: shell_prim_index(shell_num)
integer (c_int64_t) , intent(in) :: shell_prim_num(shell_num)
integer (c_int32_t) , intent(in) :: r_power(shell_num)
real (c_double ) , intent(in) :: coord(point_num,3)
real (c_double ) , intent(in) :: nucl_coord(nucl_num,3)
real (c_double ) , intent(in) :: expo(prim_num)
real (c_double ) , intent(in) :: coef_normalized(prim_num)
real (c_double ) , intent(out) :: shell_vgl(shell_num,5,point_num)
integer(qmckl_exit_code) :: info
integer*8 :: inucl, iprim, ipoint, ishell
integer*8 :: ishell_start, ishell_end
integer*8 :: iprim_start , iprim_end
double precision :: x, y, z, r, r_inv, ar, n_val, v, cutoff
double precision :: grad_coef, lapl_coef
info = QMCKL_SUCCESS
! Don't compute exponentials when the result will be almost zero.
cutoff = -dlog(qmckl_get_numprec_epsilon(context))
do ipoint = 1, point_num
do inucl=1,nucl_num
x = coord(ipoint,1) - nucl_coord(inucl,1)
y = coord(ipoint,2) - nucl_coord(inucl,2)
z = coord(ipoint,3) - nucl_coord(inucl,3)
r = dsqrt(x*x + y*y + z*z)
if (r > cutoff*nucleus_range(inucl)) then
cycle
end if
! C is zero-based, so shift bounds by one
ishell_start = nucleus_index(inucl) + 1
ishell_end = nucleus_index(inucl) + nucleus_shell_num(inucl)
do ishell=ishell_start, ishell_end
shell_vgl(ishell, 1, ipoint) = 0.d0
shell_vgl(ishell, 2, ipoint) = 0.d0
shell_vgl(ishell, 3, ipoint) = 0.d0
shell_vgl(ishell, 4, ipoint) = 0.d0
shell_vgl(ishell, 5, ipoint) = 0.d0
iprim_start = shell_prim_index(ishell) + 1
iprim_end = shell_prim_index(ishell) + shell_prim_num(ishell)
! Handle r = 0 case for Slater orbitals
if (r < 1.d-15) then
do iprim = iprim_start, iprim_end
n_val = dble(r_power(ishell) + 1) ! Principal quantum number
if (n_val == 1.d0) then
shell_vgl(ishell, 1, ipoint) = shell_vgl(ishell, 1, ipoint) + coef_normalized(iprim)
end if
! Gradients and Laplacian are zero at r=0 for all n>1
end do
cycle
end if
r_inv = 1.d0 / r
do iprim = iprim_start, iprim_end
ar = expo(iprim) * r
if (ar > cutoff) then
cycle
end if
n_val = dble(r_power(ishell)) ! Principal quantum number for Slater orbitals
! Compute r^n * exp(-a*r)
v = coef_normalized(iprim) * (r ** r_power(ishell)) * dexp(-ar)
! Value
shell_vgl(ishell, 1, ipoint) = shell_vgl(ishell, 1, ipoint) + v
! Gradient coefficient: (n/r - a)
grad_coef = (n_val * r_inv - expo(iprim)) * v
! Gradients: gradient_coefficient * (x/r, y/r, z/r)
shell_vgl(ishell, 2, ipoint) = shell_vgl(ishell, 2, ipoint) + grad_coef * x * r_inv
shell_vgl(ishell, 3, ipoint) = shell_vgl(ishell, 3, ipoint) + grad_coef * y * r_inv
shell_vgl(ishell, 4, ipoint) = shell_vgl(ishell, 4, ipoint) + grad_coef * z * r_inv
! Laplacian: 1/r² [ n² - 2nar + ar(ar-2) + n] * v
lapl_coef = r_inv*r_inv * ( &
n_val*n_val - 2.d0 * n_val * ar + &
ar * (ar - 2.d0) + n_val)
shell_vgl(ishell, 5, ipoint) = shell_vgl(ishell, 5, ipoint) + lapl_coef * v
end do
end do
end do
end do
end function qmckl_compute_ao_basis_shell_slater_vgl
3.5. Hessian
Computes the Hessian of the shells. The shell_hessian[:][:][3][:] component is reserved for the derivative of the Laplacian of the shells.
3.5.1. Get
qmckl_exit_code
qmckl_get_ao_basis_shell_hessian (qmckl_context context,
double* const shell_hessian,
const int64_t size_max);
3.5.2. Computation of shell Hessians with Gaussian functions
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
prim_num |
int64_t |
in | Number of primitives |
shell_num |
int64_t |
in | Number of shells |
point_num |
int64_t |
in | Number of points |
nucl_num |
int64_t |
in | Number of nuclei |
nucleus_shell_num |
int64_t[nucl_num] |
in | Number of shells for each nucleus |
nucleus_index |
int64_t[nucl_num] |
in | Index of the 1st shell of each nucleus |
nucleus_range |
double[nucl_num] |
in | Range of the nucleus |
shell_prim_index |
int64_t[shell_num] |
in | Index of the 1st primitive of each shell |
shell_prim_num |
int64_t[shell_num] |
in | Number of primitives per shell |
coord |
double[3][point_num] |
in | Coordinates |
nucl_coord |
double[3][nucl_num] |
in | Nuclear coordinates |
expo |
double[prim_num] |
in | Exponents of the primitives |
coef_normalized |
double[prim_num] |
in | Coefficients of the primitives |
shell_hessian |
double[point_num][3][4][shell_num] |
out | Hessian of the shells |
function qmckl_compute_ao_basis_shell_gaussian_hessian( &
context, prim_num, shell_num, point_num, nucl_num, &
nucleus_shell_num, nucleus_index, nucleus_range, &
shell_prim_index, shell_prim_num, coord, nucl_coord, &
expo, coef_normalized, shell_hessian) &
bind(C) result(info)
use qmckl_constants
use qmckl, only: qmckl_get_numprec_epsilon
implicit none
integer (qmckl_context), intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: prim_num
integer (c_int64_t) , intent(in) , value :: shell_num
integer (c_int64_t) , intent(in) , value :: point_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) :: nucleus_shell_num(nucl_num)
integer (c_int64_t) , intent(in) :: nucleus_index(nucl_num)
real (c_double ) , intent(in) :: nucleus_range(nucl_num)
integer (c_int64_t) , intent(in) :: shell_prim_index(shell_num)
integer (c_int64_t) , intent(in) :: shell_prim_num(shell_num)
real (c_double ) , intent(in) :: coord(point_num,3)
real (c_double ) , intent(in) :: nucl_coord(nucl_num,3)
real (c_double ) , intent(in) :: expo(prim_num)
real (c_double ) , intent(in) :: coef_normalized(prim_num)
real (c_double ) , intent(out) :: shell_hessian(shell_num,4,3,point_num)
integer(qmckl_exit_code) :: info
double precision :: xyz(3)
integer*8 :: inucl, iprim, ipoint, ishell
integer*8 :: ishell_start, ishell_end
integer*8 :: iprim_start , iprim_end, i, j
double precision :: x, y, z, two_a, ar2, r2, v, cutoff
info = QMCKL_SUCCESS
! Don't compute exponentials when the result will be almost zero.
cutoff = -dlog(qmckl_get_numprec_epsilon(context))
do ipoint = 1, point_num
do inucl=1,nucl_num
xyz(1) = coord(ipoint,1) - nucl_coord(inucl,1)
xyz(2) = coord(ipoint,2) - nucl_coord(inucl,2)
xyz(3) = coord(ipoint,3) - nucl_coord(inucl,3)
r2 = xyz(1)*xyz(1) + xyz(2)*xyz(2) + xyz(3)*xyz(3)
if (r2 > cutoff*nucleus_range(inucl)) then
cycle
end if
! C is zero-based, so shift bounds by one
ishell_start = nucleus_index(inucl) + 1
ishell_end = nucleus_index(inucl) + nucleus_shell_num(inucl)
do ishell=ishell_start, ishell_end
do i = 1, 4
do j = 1, 3
shell_hessian(ishell, i, j, ipoint) = 0.d0
end do
end do
iprim_start = shell_prim_index(ishell) + 1
iprim_end = shell_prim_index(ishell) + shell_prim_num(ishell)
do iprim = iprim_start, iprim_end
ar2 = expo(iprim)*r2
if (ar2 > cutoff) then
cycle
end if
v = coef_normalized(iprim) * dexp(-ar2)
two_a = 2.d0 * expo(iprim)
do i = 1, 3
do j = 1, 3
if (i == j) then
shell_hessian(ishell, i, j, ipoint) = &
shell_hessian(ishell, i, j, ipoint) - two_a * v
end if
shell_hessian(ishell, i, j, ipoint) = &
shell_hessian(ishell, i, j, ipoint) + two_a * two_a * xyz(i) * xyz(j) * v
end do
shell_hessian(ishell,4,i,ipoint) = shell_hessian(ishell,4,i,ipoint) &
+ (5.d0 * two_a * two_a * xyz(i) &
- two_a * two_a * two_a * r2 * xyz(i)) * v
end do
end do
end do
end do
end do
end function qmckl_compute_ao_basis_shell_gaussian_hessian
3.5.3. Computation of shell Hessians with Slater functions
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
prim_num |
int64_t |
in | Number of primitives |
shell_num |
int64_t |
in | Number of shells |
point_num |
int64_t |
in | Number of points |
nucl_num |
int64_t |
in | Number of nuclei |
nucleus_shell_num |
int64_t[nucl_num] |
in | Number of shells per nucleus |
nucleus_index |
int64_t[nucl_num] |
in | Index of the first shell of each nucleus |
nucleus_range |
double[nucl_num] |
in | Range beyond which all shells are zero |
shell_prim_index |
int64_t[shell_num] |
in | Index of the first primitive of each shell |
shell_prim_num |
int64_t[shell_num] |
in | Number of primitives per shell |
r_power |
int32_t[shell_num] |
in | Power of the r prefix |
coord |
double[3][point_num] |
in | Coordinates of the points |
nucl_coord |
double[3][nucl_num] |
in | Nuclear coordinates |
expo |
double[prim_num] |
in | Exponents of the primitives |
coef_normalized |
double[prim_num] |
in | Coefficients of the primitives |
shell_hessian |
double[point_num][3][4][shell_num] |
out | Hessian of the shells |
function qmckl_compute_ao_basis_shell_slater_hessian( &
context, prim_num, shell_num, point_num, nucl_num, &
nucleus_shell_num, nucleus_index, nucleus_range, &
shell_prim_index, shell_prim_num, r_power, &
coord, nucl_coord, expo, coef_normalized, shell_hessian) &
bind(C) result(info)
use qmckl_constants
use qmckl, only: qmckl_get_numprec_epsilon
implicit none
integer (qmckl_context), intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: prim_num
integer (c_int64_t) , intent(in) , value :: shell_num
integer (c_int64_t) , intent(in) , value :: point_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) :: nucleus_shell_num(nucl_num)
integer (c_int64_t) , intent(in) :: nucleus_index(nucl_num)
real (c_double ) , intent(in) :: nucleus_range(nucl_num)
integer (c_int64_t) , intent(in) :: shell_prim_index(shell_num)
integer (c_int64_t) , intent(in) :: shell_prim_num(shell_num)
integer (c_int32_t) , intent(in) :: r_power(shell_num)
real (c_double ) , intent(in) :: coord(point_num,3)
real (c_double ) , intent(in) :: nucl_coord(nucl_num,3)
real (c_double ) , intent(in) :: expo(prim_num)
real (c_double ) , intent(in) :: coef_normalized(prim_num)
real (c_double ) , intent(out) :: shell_hessian(shell_num,4,3,point_num)
integer(qmckl_exit_code) :: info
integer*8 :: inucl, iprim, ipoint, ishell
integer*8 :: ishell_start, ishell_end
integer*8 :: iprim_start , iprim_end
double precision :: x, y, z, r, r_inv, r_inv2, ar, n_val, v, cutoff
double precision :: alpha, grad_coef, hess_diag, hess_off
info = QMCKL_SUCCESS
! Don't compute exponentials when the result will be almost zero.
cutoff = -dlog(qmckl_get_numprec_epsilon(context))
do ipoint = 1, point_num
do inucl=1,nucl_num
x = coord(ipoint,1) - nucl_coord(inucl,1)
y = coord(ipoint,2) - nucl_coord(inucl,2)
z = coord(ipoint,3) - nucl_coord(inucl,3)
r = dsqrt(x*x + y*y + z*z)
if (r > nucleus_range(inucl)) then
cycle
end if
! C is zero-based, so shift bounds by one
ishell_start = nucleus_index(inucl) + 1
ishell_end = nucleus_index(inucl) + nucleus_shell_num(inucl)
do ishell=ishell_start, ishell_end
! Initialize Hessian components to zero
shell_hessian(ishell, 1, 1, ipoint) = 0.d0 ! d²/dx²
shell_hessian(ishell, 1, 2, ipoint) = 0.d0 ! d²/dy²
shell_hessian(ishell, 1, 3, ipoint) = 0.d0 ! d²/dz²
shell_hessian(ishell, 2, 1, ipoint) = 0.d0 ! d²/dxdy
shell_hessian(ishell, 2, 2, ipoint) = 0.d0 ! d²/dxdz
shell_hessian(ishell, 2, 3, ipoint) = 0.d0 ! d²/dydz
shell_hessian(ishell, 3, 1, ipoint) = 0.d0
shell_hessian(ishell, 3, 2, ipoint) = 0.d0
shell_hessian(ishell, 3, 3, ipoint) = 0.d0
shell_hessian(ishell, 4, 1, ipoint) = 0.d0
shell_hessian(ishell, 4, 2, ipoint) = 0.d0
shell_hessian(ishell, 4, 3, ipoint) = 0.d0
iprim_start = shell_prim_index(ishell) + 1
iprim_end = shell_prim_index(ishell) + shell_prim_num(ishell)
! Handle r = 0 case for Slater orbitals
if (r < 1.d-15) then
! Hessian is zero at r=0 for Slater orbitals
cycle
end if
r_inv = 1.d0 / r
r_inv2 = r_inv * r_inv
do iprim = iprim_start, iprim_end
alpha = expo(iprim)
ar = alpha * r
if (ar > cutoff) then
cycle
end if
n_val = dble(r_power(ishell) + 1)
! Compute r^n * exp(-a*r)
v = coef_normalized(iprim) * (r ** int(n_val)) * dexp(-ar)
! For Slater orbitals: f = r^n * exp(-a*r)
! Hessian components involve second derivatives
! Diagonal Hessian terms: d²f/dx²
! v * (n^2 x^2+n (r^2-2 \[Alpha] r x^2-2 x^2)+\[Alpha] r (-r^2+\[Alpha] r x^2+x^2))/r^4
shell_hessian(ishell, 1, 1, ipoint) = shell_hessian(ishell, 1, 1, ipoint) + &
v * r_inv2 * r_inv2 * ( &
n_val*n_val*x*x + n_val*(r*r-2.d0*alpha*r*x*x-2.d0*x*x) + &
alpha*r*(-r*r+alpha*r*x*x+x*x))
shell_hessian(ishell, 1, 2, ipoint) = shell_hessian(ishell, 1, 2, ipoint) + &
v * r_inv2 * r_inv2 * ( &
n_val*n_val*y*y + n_val*(r*r-2.d0*alpha*r*y*y-2.d0*y*y) + &
alpha*r*(-r*r+alpha*r*y*y+y*y))
shell_hessian(ishell, 1, 3, ipoint) = shell_hessian(ishell, 1, 3, ipoint) + &
v * r_inv2 * r_inv2 * ( &
n_val*n_val*z*z + n_val*(r*r-2.d0*alpha*r*z*z-2.d0*z*z) + &
alpha*r*(-r*r+alpha*r*z*z+z*z))
! Off-diagonal Hessian terms: d²f/dxdy, etc.
hess_off = -v * r_inv2 * r_inv2 * (n_val*n_val - 2.d0*n_val * (alpha*r+1.d0) + &
alpha*r*(alpha*r+1.d0))
shell_hessian(ishell, 2, 1, ipoint) = shell_hessian(ishell, 2, 1, ipoint) + &
hess_off * x * y
shell_hessian(ishell, 2, 2, ipoint) = shell_hessian(ishell, 2, 2, ipoint) + &
hess_off * x * z
shell_hessian(ishell, 2, 3, ipoint) = shell_hessian(ishell, 2, 3, ipoint) + &
hess_off * y * z
end do
end do
end do
end do
end function qmckl_compute_ao_basis_shell_slater_hessian
4. Polynomial part
Going from the atomic basis set to AOs implies a systematic construction of all the angular functions of each shell. We consider two cases for the angular functions: the real-valued spherical harmonics, and the polynomials in Cartesian coordinates. In the case of spherical harmonics, the AOs are ordered in increasing magnetic quantum number (), and in the case of polynomials we choose the canonical ordering, i.e
4.1. General functions for Powers of
The qmckl_ao_power function computes all the powers of the n
input data up to the given maximum value given in input for each of
the points:
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
n |
int64_t |
in | Number of values |
X |
double[n] |
in | Array containing the input values |
LMAX |
int32_t[n] |
in | Array containing the maximum power for each value |
P |
double[n][ldp] |
out | Array containing all the powers of X |
ldp |
int64_t |
in | Leading dimension of array P |
Requirements:
contextis notQMCKL_NULL_CONTEXTn> 0Xis allocated with at least bytesLMAXis allocated with at least bytesPis allocated with at least bytesLDP>=LMAX[i]
qmckl_exit_code qmckl_ao_power (
const qmckl_context context,
const int64_t n,
const double* X,
const int32_t* LMAX,
double* const P,
const int64_t ldp );
function qmckl_ao_power(context, n, X, LMAX, P, ldp) &
bind(C) result(info)
use qmckl_constants
implicit none
integer (qmckl_context), intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: n
integer (c_int64_t) , intent(in) , value :: ldp
real (c_double ) , intent(in) :: X(n)
integer (c_int32_t) , intent(in) :: LMAX(n)
real (c_double ) , intent(out) :: P(ldp,n)
integer(qmckl_exit_code) :: info
integer(c_int64_t) :: i,k
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (n <= ldp) then
info = QMCKL_INVALID_ARG_2
return
endif
k = MAXVAL(LMAX)
if (LDP < k) then
info = QMCKL_INVALID_ARG_6
return
endif
if (k <= 0) then
info = QMCKL_INVALID_ARG_4
return
endif
do i=1,n
P(1,i) = X(i)
do k=2,LMAX(i)
P(k,i) = P(k-1,i) * X(i)
end do
end do
end function qmckl_ao_power
4.2. General functions for Value, Gradient and Laplacian of a polynomial
A polynomial is centered on a nucleus
The gradients with respect to electron coordinates are
and the Laplacian is
qmckl_ao_polynomial_vgl computes the values, gradients and
Laplacians at a given point in space, of all polynomials with an
angular momentum up to lmax.
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
X |
double[3] |
in | Array containing the coordinates of the points |
R |
double[3] |
in | Array containing the x,y,z coordinates of the center |
lmax |
int32_t |
in | Maximum angular momentum |
n |
int64_t |
inout | Number of computed polynomials |
L |
int32_t[n][ldl] |
out | Contains a,b,c for all n results |
ldl |
int64_t |
in | Leading dimension of L |
VGL |
double[n][ldv] |
out | Value, gradients and Laplacian of the polynomials |
ldv |
int64_t |
in | Leading dimension of array VGL |
Requirements:
contextis notQMCKL_NULL_CONTEXTn> 0lmax>= 0ldl>= 3ldv>= 5Xis allocated with at least bytesRis allocated with at least bytesn>=(lmax+1)(lmax+2)(lmax+3)/6Lis allocated with at least bytesVGLis allocated with at least bytes- On output,
nshould be equal to(lmax+1)(lmax+2)(lmax+3)/6 - On output, the powers are given in the following order (l=a+b+c):
- Increasing values of
l - Within a given value of
l, alphabetical order of the string made by a*"x" + b*"y" + c*"z" (in Python notation). For example, with a=0, b=2 and c=1 the string is "yyz"
- Increasing values of
qmckl_exit_code qmckl_ao_polynomial_vgl (
Type Variable,
const qmckl_context context,
const double* X,
const double* R,
const int32_t lmax,
int64_t* n,
int32_t* const L,
const int64_t ldl,
double* const VGL,
const int64_t ldv );
qmckl_exit_code qmckl_ao_polynomial_vgl_doc (
Type Variable,
const qmckl_context context,
const double* X,
const double* R,
const int32_t lmax,
int64_t* n,
int32_t* const L,
const int64_t ldl,
double* const VGL,
const int64_t ldv );
function qmckl_ao_polynomial_vgl_doc (context, &
X, R, lmax, n, L, ldl, VGL, ldv) &
bind(C) result(info)
use qmckl_constants
implicit none
integer (qmckl_context), intent(in) , value :: context
real (c_double ) , intent(in) :: X(3)
real (c_double ) , intent(in) :: R(3)
integer (c_int32_t) , intent(in) , value :: lmax
integer (c_int64_t) , intent(inout) :: n
integer (c_int64_t) , intent(in) , value :: ldl
integer (c_int64_t) , intent(in) , value :: ldv
integer (c_int32_t) , intent(out) :: L(ldl,(lmax+1)*(lmax+2)*(lmax+3)/6)
real (c_double ) , intent(out) :: VGL(ldv,(lmax+1)*(lmax+2)*(lmax+3)/6)
integer(qmckl_exit_code) :: info
integer*8 :: i,j
integer :: a,b,c,d
double precision :: Y(3)
double precision :: pows(-2:lmax,3)
double precision :: xy, yz, xz
double precision :: da, db, dc, dd
info = 0
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (lmax < 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if (ldl < 3) then
info = QMCKL_INVALID_ARG_7
return
endif
if (ldv < 5) then
info = QMCKL_INVALID_ARG_9
return
endif
! The shift below is such that polynomials will not make the AO equal to zero at the nodes of the orbitals
do i=1,3
Y(i) = (X(i) - R(i)) + 1.d-20
end do
if (lmax == 0) then
VGL(1,1) = 1.d0
VGL(2,1) = 0.d0
VGL(3,1) = 0.d0
VGL(4,1) = 0.d0
VGL(5,1) = 0.d0
l(1,1) = 0
l(2,1) = 0
l(3,1) = 0
n=1
else if (lmax > 0) then
pows(-2:0,1:3) = 1.d0
do i=1,lmax
pows(i,1) = pows(i-1,1) * Y(1)
pows(i,2) = pows(i-1,2) * Y(2)
pows(i,3) = pows(i-1,3) * Y(3)
end do
VGL(1:5,1:4) = 0.d0
VGL(1,1) = 1.d0
VGL(1,2) = pows(1,1)
VGL(2,2) = 1.d0
VGL(1,3) = pows(1,2)
VGL(3,3) = 1.d0
VGL(1,4) = pows(1,3)
VGL(4,4) = 1.d0
l (1:3,1:4) = 0
l (1,2) = 1
l (2,3) = 1
l (3,4) = 1
n=4
endif
! l>=2
dd = 2.d0
do d=2,lmax
da = dd
do a=d,0,-1
db = dd-da
do b=d-a,0,-1
c = d - a - b
dc = dd - da - db
n = n+1
l(1,n) = a
l(2,n) = b
l(3,n) = c
xy = pows(a,1) * pows(b,2)
yz = pows(b,2) * pows(c,3)
xz = pows(a,1) * pows(c,3)
VGL(1,n) = xy * pows(c,3)
xy = dc * xy
xz = db * xz
yz = da * yz
VGL(2,n) = pows(a-1,1) * yz
VGL(3,n) = pows(b-1,2) * xz
VGL(4,n) = pows(c-1,3) * xy
VGL(5,n) = &
(da-1.d0) * pows(a-2,1) * yz + &
(db-1.d0) * pows(b-2,2) * xz + &
(dc-1.d0) * pows(c-2,3) * xy
db = db - 1.d0
end do
da = da - 1.d0
end do
dd = dd + 1.d0
end do
info = QMCKL_SUCCESS
end function qmckl_ao_polynomial_vgl_doc
qmckl_exit_code qmckl_ao_polynomial_transp_vgl (
Type Variable,
const qmckl_context context,
const double* X,
const double* R,
const int32_t lmax,
int64_t* n,
int32_t* const L,
const int64_t ldl,
double* const VGL,
const int64_t ldv );
qmckl_exit_code qmckl_ao_polynomial_transp_vgl_doc (
Type Variable,
const qmckl_context context,
const double* X,
const double* R,
const int32_t lmax,
int64_t* n,
int32_t* const L,
const int64_t ldl,
double* const VGL,
const int64_t ldv );
qmckl_exit_code qmckl_ao_polynomial_transp_vgl_hpc (
const qmckl_context context,
const double* X,
const double* R,
const int32_t lmax,
int64_t* n,
int32_t* const L,
const int64_t ldl,
double* const VGL,
const int64_t ldv );
function qmckl_ao_polynomial_transp_vgl_doc (context, &
X, R, lmax, n, L, ldl, VGL, ldv) &
bind(C) result(info)
use qmckl_constants
implicit none
integer (qmckl_context), intent(in) , value :: context
real (c_double ) , intent(in) :: X(3)
real (c_double ) , intent(in) :: R(3)
integer (c_int32_t) , intent(in) , value :: lmax
integer (c_int64_t) , intent(inout) :: n
integer (c_int64_t) , intent(in) , value :: ldl
integer (c_int64_t) , intent(in) , value :: ldv
integer (c_int32_t) , intent(out) :: L(ldl,(lmax+1)*(lmax+2)*(lmax+3)/6)
real (c_double ) , intent(out) :: VGL(ldv,5)
integer(qmckl_exit_code) :: info
integer*8 :: i,j
integer :: a,b,c,d
real*8 :: Y(3)
real*8 :: pows(-2:21,3) ! lmax < 22
double precision :: xy, yz, xz
double precision :: da, db, dc, dd
info = 0
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (lmax < 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if (ldl < 3) then
info = QMCKL_INVALID_ARG_7
return
endif
if (ldv < (lmax+1)*(lmax+2)*(lmax+3)/6) then
info = QMCKL_INVALID_ARG_9
return
endif
if (lmax > 0) then
do i=1,3
Y(i) = X(i) - R(i)
end do
pows(-2:0,1:3) = 1.d0
do i=1,lmax
pows(i,1) = pows(i-1,1) * Y(1)
pows(i,2) = pows(i-1,2) * Y(2)
pows(i,3) = pows(i-1,3) * Y(3)
end do
l (1:3,1:4) = 0
VGL(1:4,1:5) = 0.d0
VGL(1 ,1 ) = 1.d0
l (1,2) = 1
VGL(2,1) = Y(1)
VGL(2,2) = 1.d0
l (2,3) = 1
VGL(3,1) = Y(2)
VGL(3,3) = 1.d0
l (3,4) = 1
VGL(4,1) = Y(3)
VGL(4,4) = 1.d0
n=4
else
VGL(1,1) = 1.d0
VGL(1,2:5) = 0.d0
l(1:3,1) = 0
n=1
return
endif
! l>=2
dd = 2.d0
do d=2,lmax
da = dd
do a=d,0,-1
db = dd-da
do b=d-a,0,-1
c = d - a - b
dc = dd - da - db
n = n+1
xy = pows(a,1) * pows(b,2)
yz = pows(b,2) * pows(c,3)
xz = pows(a,1) * pows(c,3)
l(1,n) = a
l(2,n) = b
l(3,n) = c
VGL(n,1) = xy * pows(c,3)
xy = dc * xy
xz = db * xz
yz = da * yz
VGL(n,2) = pows(a-1,1) * yz
VGL(n,3) = pows(b-1,2) * xz
VGL(n,4) = pows(c-1,3) * xy
VGL(n,5) = &
(da-1.d0) * pows(a-2,1) * yz + &
(db-1.d0) * pows(b-2,2) * xz + &
(dc-1.d0) * pows(c-2,3) * xy
db = db - 1.d0
end do
da = da - 1.d0
end do
dd = dd + 1.d0
end do
info = QMCKL_SUCCESS
end function qmckl_ao_polynomial_transp_vgl_doc
4.3. Hessian
Compute the Hessian of the polynomial part of the atomic orbitals. Similarly to the shells, the hessian[:][3][:] component is reserved for the derivative of the Laplacian.
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
X |
double[3] |
in | Array containing the coordinates of the points |
R |
double[3] |
in | Array containing the x,y,z coordinates of the center |
lmax |
int32_t |
in | Maximum angular momentum |
n |
int64_t |
inout | Number of computed polynomials |
hessian |
double[ldv][4][3] |
out | Hessian of the polynomials |
function qmckl_compute_ao_polynomial_hessian_doc (context, &
X, R, lmax, n, hessian) &
bind(C) result(info)
use qmckl_constants
implicit none
integer (qmckl_context), intent(in) , value :: context
real (c_double ) , intent(in) :: X(3)
real (c_double ) , intent(in) :: R(3)
integer (c_int32_t) , intent(in) , value :: lmax
integer (c_int64_t) , intent(inout) :: n
real (c_double ) , intent(out) :: hessian(3,4,(lmax+1)*(lmax+2)*(lmax+3)/6)
integer(qmckl_exit_code) :: info
integer :: i,j,m,k
integer :: a,b,c,d
double precision :: Y(3)
double precision :: pows(-2:lmax,3)
double precision :: xy, yz, xz
double precision :: da, db, dc, dd
info = 0
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (lmax < 0) then
info = QMCKL_INVALID_ARG_4
return
endif
! The shift below is such that polynomials will not make the AO equal to zero at the nodes of the orbitals
do i=1,3
Y(i) = (X(i) - R(i)) + 1.d-20
end do
if (lmax == 0) then
do k = 1, 3
do m = 1, 3
hessian(k,m,1) = 0.d0
end do
end do
n=1
else if (lmax > 0) then
pows(-2:0,1:3) = 1.d0
do i=1,lmax
pows(i,1) = pows(i-1,1) * Y(1)
pows(i,2) = pows(i-1,2) * Y(2)
pows(i,3) = pows(i-1,3) * Y(3)
end do
hessian(1:3,1:4,1:4) = 0.d0
n=4
endif
! l>=2
dd = 2.d0
do d=2,lmax
da = dd
do a=d,0,-1
db = dd-da
do b=d-a,0,-1
c = d - a - b
dc = dd - da - db
n = n+1
xy = pows(a,1) * pows(b,2)
yz = pows(b,2) * pows(c,3)
xz = pows(a,1) * pows(c,3)
xy = dc * xy
xz = db * xz
yz = da * yz
hessian(1,1,n) = da * (da-1.d0) * pows(a-2,1) * pows(b,2) * pows(c,3)
hessian(2,2,n) = db * (db-1.d0) * pows(a,1) * pows(b-2,2) * pows(c,3)
hessian(3,3,n) = dc * (dc-1.d0) * pows(a,1) * pows(b,2) * pows(c-2,3)
hessian(1,2,n) = da * db * pows(a-1,1) * pows(b-1,2) * pows(c,3)
hessian(2,1,n) = da * db * pows(a-1,1) * pows(b-1,2) * pows(c,3)
hessian(1,3,n) = da * dc * pows(a-1,1) * pows(b,2) * pows(c-1,3)
hessian(3,1,n) = da * dc * pows(a-1,1) * pows(b,2) * pows(c-1,3)
hessian(2,3,n) = db * dc * pows(a,1) * pows(b-1,2) * pows(c-1,3)
hessian(3,2,n) = db * dc * pows(a,1) * pows(b-1,2) * pows(c-1,3)
hessian(1,4,n) = (da * db * (db-1.d0) * pows(a-1,1) * pows(b-2,2) * pows(c,3)) + &
(da * dc * (dc-1.d0) * pows(a-1,1) * pows(b,2) * pows(c-2,3))
hessian(2,4,n) = (db * da * (da-1.d0) * pows(a-2,1) * pows(b-1,2) * pows(c,3)) + &
(db * dc * (dc-1.d0) * pows(a,1) * pows(b-1,2) * pows(c-2,3))
hessian(3,4,n) = (dc * da * (da-1.d0) * pows(a-2,1) * pows(b,2) * pows(c-1,3)) + &
(dc * db * (db-1.d0) * pows(a,1) * pows(b-2,2) * pows(c-1,3))
if (da > 2) then
hessian(1,4,n) = hessian(1,4,n) + (da * (da-1.d0) * (da-2.d0) * &
pows(a-3,1) * pows(b,2) * pows(c,3))
end if
if (db > 2) then
hessian(2,4,n) = hessian(2,4,n) + (db * (db-1.d0) * (db-2.d0) * &
pows(a,1) * pows(b-3,2) * pows(c,3))
end if
if (dc > 2) then
hessian(3,4,n) = hessian(3,4,n) + (dc * (dc-1.d0) * (dc-2.d0) * &
pows(a,1) * pows(b,2) * pows(c-3,3))
end if
db = db - 1.d0
end do
da = da - 1.d0
end do
dd = dd + 1.d0
end do
info = QMCKL_SUCCESS
end function qmckl_compute_ao_polynomial_hessian_doc
5. Combining radial and polynomial parts
5.1. Determination of nucleus ranges
The range of a nucleus is defined as the distance beyond which all the AOs are zero, up to a given precision. For all possible numbers of bits of precision (1-53), a range is given.
function qmckl_compute_nucleus_range_gaussian(context, &
ao_num, shell_num, prim_num, nucl_num, &
nucl_coord, nucleus_index, nucleus_shell_num, &
nucleus_max_ang_mom, shell_prim_index, shell_prim_num, r_power, &
ao_factor, expo, coef_normalized, nucleus_range) &
bind(C) result(info)
use qmckl_constants
use qmckl, only: qmckl_ao_polynomial_vgl, qmckl_get_numprec_epsilon
implicit none
integer (qmckl_context), intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: ao_num
integer (c_int64_t) , intent(in) , value :: shell_num
integer (c_int64_t) , intent(in) , value :: prim_num
integer (c_int64_t) , intent(in) , value :: nucl_num
real (c_double ) , intent(in) :: nucl_coord(nucl_num,3)
integer (c_int64_t) , intent(in) :: nucleus_index(nucl_num)
integer (c_int64_t) , intent(in) :: nucleus_shell_num(nucl_num)
integer (c_int32_t) , intent(in) :: nucleus_max_ang_mom(nucl_num)
integer (c_int64_t) , intent(in) :: shell_prim_index(shell_num)
integer (c_int64_t) , intent(in) :: shell_prim_num(shell_num)
integer (c_int32_t) , intent(in) :: r_power(shell_num)
real (c_double ) , intent(in) :: ao_factor(ao_num)
real (c_double ) , intent(in) :: expo(prim_num)
real (c_double ) , intent(in) :: coef_normalized(prim_num)
real (c_double ) , intent(out) :: nucleus_range(nucl_num,53)
integer(qmckl_exit_code) :: info
double precision :: e_coord(3), n_coord(3)
integer*8 :: n_poly, iprim, iprim_start, iprim_end
integer :: l, il, k, iprecision
integer*8 :: ipoint, inucl, ishell
integer*8 :: ishell_start, ishell_end
integer :: lstart(0:20)
double precision :: shell_vgl(3)
double precision :: x, y, z, r2, ar2, two_a
double precision :: vmax, cutoff, v
double precision, allocatable :: poly_vgl(:,:), ao_vgl(:,:)
integer , allocatable :: powers(:,:), ao_index(:)
allocate(poly_vgl(5,ao_num), powers(3,ao_num), ao_index(ao_num))
! Pre-computed data
do l=0,20
lstart(l) = l*(l+1)*(l+2)/6 +1
end do
k=1
do inucl=1,nucl_num
ishell_start = nucleus_index(inucl) + 1
ishell_end = nucleus_index(inucl) + nucleus_shell_num(inucl)
do ishell = ishell_start, ishell_end
l = r_power(ishell)
ao_index(ishell) = k
k = k + lstart(l+1) - lstart(l)
end do
end do
info = QMCKL_SUCCESS
n_coord(1) = 0.d0
n_coord(2) = 0.d0
n_coord(3) = 0.d0
e_coord(2) = 0.d0
e_coord(3) = 0.d0
nucleus_range = 50.d0
do inucl=1,nucl_num
x = 50.d0
do iprecision = 53,2,-1
cutoff = 2.d0** (1-iprecision)
vmax = 0.d0
do while ( (vmax < cutoff) .and. (x > 0.d0) )
x = x - .1d0
vmax = 0.d0
e_coord(1) = x
r2 = x*x
! Compute polynomials
info = qmckl_ao_polynomial_vgl(context, e_coord, n_coord, &
nucleus_max_ang_mom(inucl), n_poly, powers, 3_8, &
poly_vgl, 5_8)
! Loop over shells
ishell_start = nucleus_index(inucl) + 1
ishell_end = nucleus_index(inucl) + nucleus_shell_num(inucl)
do ishell = ishell_start, ishell_end
shell_vgl(1) = 0.d0
shell_vgl(2) = 0.d0
shell_vgl(3) = 0.d0
iprim_start = shell_prim_index(ishell) + 1
iprim_end = shell_prim_index(ishell) + shell_prim_num(ishell)
do iprim = iprim_start, iprim_end
ar2 = expo(iprim)*r2
v = coef_normalized(iprim) * dexp(-ar2)
two_a = -2.d0 * expo(iprim) * v
shell_vgl(1) = shell_vgl(1) + v
shell_vgl(2) = shell_vgl(2) + two_a * x
shell_vgl(3) = shell_vgl(3) + two_a * (3.d0 - 2.d0*ar2)
end do
k = ao_index(ishell)
l = r_power(ishell)
do il = lstart(l), lstart(l+1)-1
vmax = max(vmax, poly_vgl(1,il) * shell_vgl(1) * ao_factor(k))
vmax = max(vmax, ( poly_vgl(2,il) * shell_vgl(1) + poly_vgl(1,il) * shell_vgl(2) ) * ao_factor(k))
vmax = max(vmax, ( poly_vgl(5,il) * shell_vgl(3) + poly_vgl(1,il) * shell_vgl(3) + &
2.d0 * (poly_vgl(2,il) * shell_vgl(2) ) ) * ao_factor(k) )
k = k+1
end do
end do
end do
nucleus_range(inucl,iprecision) = x
end do
end do
deallocate(poly_vgl, powers)
end function qmckl_compute_nucleus_range_gaussian
5.2. Values only
5.2.1. Unoptimized version
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
ao_num |
int64_t |
in | Number of AOs |
shell_num |
int64_t |
in | Number of shells |
point_num |
int64_t |
in | Number of points |
nucl_num |
int64_t |
in | Number of nuclei |
coord |
double[3][point_num] |
in | Coordinates |
nucl_coord |
double[3][nucl_num] |
in | Nuclear coordinates |
nucleus_index |
int64_t[nucl_num] |
in | Index of the 1st shell of each nucleus |
nucleus_shell_num |
int64_t[nucl_num] |
in | Number of shells per nucleus |
nucleus_range |
double[nucl_num] |
in | Range beyond which all is zero |
nucleus_max_ang_mom |
int32_t[nucl_num] |
in | Maximum angular momentum per nucleus |
shell_ang_mom |
int32_t[shell_num] |
in | Angular momentum of each shell |
ao_factor |
double[ao_num] |
in | Normalization factor of the AOs |
shell_vgl |
double[point_num][5][shell_num] |
in | Value, gradients and Laplacian of the shells |
ao_value |
double[point_num][ao_num] |
out | Values of the AOs |
function qmckl_compute_ao_value_doc(context, &
ao_num, shell_num, point_num, nucl_num, &
coord, nucl_coord, nucleus_index, nucleus_shell_num, &
nucleus_range, nucleus_max_ang_mom, shell_ang_mom, &
ao_factor, shell_vgl, ao_value) &
bind(C) result(info)
use qmckl_constants
use qmckl, only : qmckl_ao_polynomial_vgl, qmckl_get_numprec_epsilon
implicit none
integer (qmckl_context), intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: ao_num
integer (c_int64_t) , intent(in) , value :: shell_num
integer (c_int64_t) , intent(in) , value :: point_num
integer (c_int64_t) , intent(in) , value :: nucl_num
real (c_double ) , intent(in) :: coord(point_num,3)
real (c_double ) , intent(in) :: nucl_coord(nucl_num,3)
integer (c_int64_t) , intent(in) :: nucleus_index(nucl_num)
integer (c_int64_t) , intent(in) :: nucleus_shell_num(nucl_num)
real (c_double ) , intent(in) :: nucleus_range(nucl_num)
integer (c_int32_t) , intent(in) :: nucleus_max_ang_mom(nucl_num)
integer (c_int32_t) , intent(in) :: shell_ang_mom(shell_num)
real (c_double ) , intent(in) :: ao_factor(ao_num)
real (c_double ) , intent(in) :: shell_vgl(shell_num,5,point_num)
real (c_double ) , intent(out) :: ao_value(ao_num,point_num)
integer(qmckl_exit_code) :: info
double precision :: e_coord(3), n_coord(3)
integer*8 :: n_poly
integer :: l, il, k
integer*8 :: ipoint, inucl, ishell
integer*8 :: ishell_start, ishell_end
integer :: lstart(0:20)
double precision :: x, y, z, r2
double precision :: cutoff
double precision, allocatable :: poly_vgl(:,:)
integer , allocatable :: powers(:,:), ao_index(:)
allocate(poly_vgl(5,ao_num), powers(3,ao_num), ao_index(ao_num))
! Pre-computed data
do l=0,20
lstart(l) = l*(l+1)*(l+2)/6 +1
end do
k=1
do inucl=1,nucl_num
ishell_start = nucleus_index(inucl) + 1
ishell_end = nucleus_index(inucl) + nucleus_shell_num(inucl)
do ishell = ishell_start, ishell_end
l = shell_ang_mom(ishell)
ao_index(ishell) = k
k = k + lstart(l+1) - lstart(l)
end do
end do
info = QMCKL_SUCCESS
! Don't compute polynomials when the radial part is zero.
cutoff = -dlog(qmckl_get_numprec_epsilon(context))
do ipoint = 1, point_num
e_coord(1) = coord(ipoint,1)
e_coord(2) = coord(ipoint,2)
e_coord(3) = coord(ipoint,3)
ao_value(:,ipoint) = 0.d0
do inucl=1,nucl_num
n_coord(1) = nucl_coord(inucl,1)
n_coord(2) = nucl_coord(inucl,2)
n_coord(3) = nucl_coord(inucl,3)
! Test if the point is in the range of the nucleus
x = e_coord(1) - n_coord(1)
y = e_coord(2) - n_coord(2)
z = e_coord(3) - n_coord(3)
r2 = x*x + y*y + z*z
if (r2 > cutoff*nucleus_range(inucl)) then
cycle
end if
! Compute polynomials
info = qmckl_ao_polynomial_vgl(context, e_coord, n_coord, &
nucleus_max_ang_mom(inucl), n_poly, powers, 3_8, &
poly_vgl, 5_8)
! Loop over shells
ishell_start = nucleus_index(inucl) + 1
ishell_end = nucleus_index(inucl) + nucleus_shell_num(inucl)
do ishell = ishell_start, ishell_end
k = ao_index(ishell)
l = shell_ang_mom(ishell)
do il = lstart(l), lstart(l+1)-1
! Value
ao_value(k,ipoint) = &
poly_vgl(1,il) * shell_vgl(ishell,1,ipoint) * ao_factor(k)
k = k+1
end do
end do
end do
end do
deallocate(poly_vgl, powers)
end function qmckl_compute_ao_value_doc
5.3. Value, gradients, Laplacian
5.3.1. Reference version
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
ao_num |
int64_t |
in | Number of AOs |
shell_num |
int64_t |
in | Number of shells |
point_num |
int64_t |
in | Number of points |
nucl_num |
int64_t |
in | Number of nuclei |
coord |
double[3][point_num] |
in | Coordinates |
nucl_coord |
double[3][nucl_num] |
in | Nuclear coordinates |
nucleus_index |
int64_t[nucl_num] |
in | Index of the 1st shell of each nucleus |
nucleus_shell_num |
int64_t[nucl_num] |
in | Number of shells per nucleus |
nucleus_range |
double[nucl_num] |
in | Range beyond which all is zero |
nucleus_max_ang_mom |
int32_t[nucl_num] |
in | Maximum angular momentum per nucleus |
shell_ang_mom |
int32_t[shell_num] |
in | Angular momentum of each shell |
ao_factor |
double[ao_num] |
in | Normalization factor of the AOs |
shell_vgl |
double[point_num][5][shell_num] |
in | Value, gradients and Laplacian of the shells |
ao_vgl |
double[point_num][5][ao_num] |
out | Value, gradients and Laplacian of the AOs |
function qmckl_compute_ao_vgl_doc(context, &
ao_num, shell_num, point_num, nucl_num, &
coord, nucl_coord, nucleus_index, nucleus_shell_num, &
nucleus_range, nucleus_max_ang_mom, shell_ang_mom, &
ao_factor, shell_vgl, ao_vgl) &
bind(C) result(info)
use qmckl_constants
use qmckl, only : qmckl_ao_polynomial_vgl, qmckl_get_numprec_epsilon
implicit none
integer (qmckl_context), intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: ao_num
integer (c_int64_t) , intent(in) , value :: shell_num
integer (c_int64_t) , intent(in) , value :: point_num
integer (c_int64_t) , intent(in) , value :: nucl_num
real (c_double ) , intent(in) :: coord(point_num,3)
real (c_double ) , intent(in) :: nucl_coord(nucl_num,3)
integer (c_int64_t) , intent(in) :: nucleus_index(nucl_num)
integer (c_int64_t) , intent(in) :: nucleus_shell_num(nucl_num)
real (c_double ) , intent(in) :: nucleus_range(nucl_num)
integer (c_int32_t) , intent(in) :: nucleus_max_ang_mom(nucl_num)
integer (c_int32_t) , intent(in) :: shell_ang_mom(shell_num)
real (c_double ) , intent(in) :: ao_factor(ao_num)
real (c_double ) , intent(in) :: shell_vgl(shell_num,5,point_num)
real (c_double ) , intent(out) :: ao_vgl(ao_num,5,point_num)
integer(qmckl_exit_code) :: info
double precision :: e_coord(3), n_coord(3)
integer*8 :: n_poly
integer :: l, il, k
integer*8 :: ipoint, inucl, ishell
integer*8 :: ishell_start, ishell_end
integer :: lstart(0:20)
double precision :: x, y, z, r2
double precision :: cutoff
double precision, allocatable :: poly_vgl(:,:)
integer , allocatable :: powers(:,:), ao_index(:)
allocate(poly_vgl(5,ao_num), powers(3,ao_num), ao_index(ao_num))
! Pre-computed data
do l=0,20
lstart(l) = l*(l+1)*(l+2)/6 +1
end do
k=1
do inucl=1,nucl_num
ishell_start = nucleus_index(inucl) + 1
ishell_end = nucleus_index(inucl) + nucleus_shell_num(inucl)
do ishell = ishell_start, ishell_end
l = shell_ang_mom(ishell)
ao_index(ishell) = k
k = k + lstart(l+1) - lstart(l)
end do
end do
info = QMCKL_SUCCESS
! Don't compute polynomials when the radial part is zero.
cutoff = -dlog(qmckl_get_numprec_epsilon(context))
do ipoint = 1, point_num
e_coord(1) = coord(ipoint,1)
e_coord(2) = coord(ipoint,2)
e_coord(3) = coord(ipoint,3)
ao_vgl(:,:,ipoint) = 0.d0
do inucl=1,nucl_num
n_coord(1) = nucl_coord(inucl,1)
n_coord(2) = nucl_coord(inucl,2)
n_coord(3) = nucl_coord(inucl,3)
! Test if the point is in the range of the nucleus
x = e_coord(1) - n_coord(1)
y = e_coord(2) - n_coord(2)
z = e_coord(3) - n_coord(3)
r2 = x*x + y*y + z*z
if (r2 > cutoff*nucleus_range(inucl)) then
cycle
end if
! Compute polynomials
info = qmckl_ao_polynomial_vgl(context, e_coord, n_coord, &
nucleus_max_ang_mom(inucl), n_poly, powers, 3_8, &
poly_vgl, 5_8)
! Loop over shells
ishell_start = nucleus_index(inucl) + 1
ishell_end = nucleus_index(inucl) + nucleus_shell_num(inucl)
do ishell = ishell_start, ishell_end
k = ao_index(ishell)
l = shell_ang_mom(ishell)
do il = lstart(l), lstart(l+1)-1
! Value
ao_vgl(k,1,ipoint) = &
poly_vgl(1,il) * shell_vgl(ishell,1,ipoint) * ao_factor(k)
! Grad_x
ao_vgl(k,2,ipoint) = ( &
poly_vgl(2,il) * shell_vgl(ishell,1,ipoint) + &
poly_vgl(1,il) * shell_vgl(ishell,2,ipoint) &
) * ao_factor(k)
! Grad_y
ao_vgl(k,3,ipoint) = ( &
poly_vgl(3,il) * shell_vgl(ishell,1,ipoint) + &
poly_vgl(1,il) * shell_vgl(ishell,3,ipoint) &
) * ao_factor(k)
! Grad_z
ao_vgl(k,4,ipoint) = ( &
poly_vgl(4,il) * shell_vgl(ishell,1,ipoint) + &
poly_vgl(1,il) * shell_vgl(ishell,4,ipoint) &
) * ao_factor(k)
! Lapl_z
ao_vgl(k,5,ipoint) = ( &
poly_vgl(5,il) * shell_vgl(ishell,1,ipoint) + &
poly_vgl(1,il) * shell_vgl(ishell,5,ipoint) + &
2.d0 * ( &
poly_vgl(2,il) * shell_vgl(ishell,2,ipoint) + &
poly_vgl(3,il) * shell_vgl(ishell,3,ipoint) + &
poly_vgl(4,il) * shell_vgl(ishell,4,ipoint) ) &
) * ao_factor(k)
k = k+1
end do
end do
end do
end do
deallocate(poly_vgl, powers)
end function qmckl_compute_ao_vgl_doc
5.4. AO Hessian
Computes the Hessian of the AOs. For this, it needs the Hessian of the shells, as well as the Hessian of the polynomials.
Component 4 along the third index of ao_hessian holds the derivative of the
Laplacian of the AOs; components 1 to 3 hold the derivatives of the three
components of the gradient.
5.4.1. Get
qmckl_exit_code
qmckl_get_ao_basis_ao_hessian(qmckl_context context,
double* const ao_hessian,
const int64_t size_max);
5.4.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
ao_num |
int64_t |
in | Number of AOs |
shell_num |
int64_t |
in | Number of shells |
point_num |
int64_t |
in | Number of points |
nucl_num |
int64_t |
in | Number of nuclei |
coord |
double[3][point_num] |
in | Coordinates |
nucl_coord |
double[3][nucl_num] |
in | Nuclear coordinates |
nucleus_index |
int64_t[nucl_num] |
in | Index of the 1st shell of each nucleus |
nucleus_shell_num |
int64_t[nucl_num] |
in | Number of shells per nucleus |
nucleus_range |
double[nucl_num] |
in | Range beyond which all is zero |
nucleus_max_ang_mom |
int32_t[nucl_num] |
in | Maximum angular momentum per nucleus |
shell_ang_mom |
int32_t[shell_num] |
in | Angular momentum of each shell |
ao_factor |
double[ao_num] |
in | Normalization factor of the AOs |
shell_vgl |
double[point_num][5][shell_num] |
in | Value, gradients and Laplacian of the shells |
shell_hessian |
double[point_num][3][4][shell_num] |
in | Hessian of the shells |
ao_hessian |
double[3][point_num][4][ao_num] |
out | Hessian of the AOs |
function qmckl_compute_ao_hessian_doc(context, &
ao_num, shell_num, point_num, nucl_num, &
coord, nucl_coord, nucleus_index, nucleus_shell_num, &
nucleus_range, nucleus_max_ang_mom, shell_ang_mom, &
ao_factor, shell_vgl, shell_hessian, ao_hessian) &
bind(C) result(info)
use qmckl_constants
use qmckl, only : qmckl_ao_polynomial_hessian, qmckl_ao_polynomial_vgl, qmckl_get_numprec_epsilon
implicit none
integer (qmckl_context), intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: ao_num
integer (c_int64_t) , intent(in) , value :: shell_num
integer (c_int64_t) , intent(in) , value :: point_num
integer (c_int64_t) , intent(in) , value :: nucl_num
real (c_double ) , intent(in) :: coord(point_num,3)
real (c_double ) , intent(in) :: nucl_coord(nucl_num,3)
integer (c_int64_t) , intent(in) :: nucleus_index(nucl_num)
integer (c_int64_t) , intent(in) :: nucleus_shell_num(nucl_num)
real (c_double ) , intent(in) :: nucleus_range(nucl_num)
integer (c_int32_t) , intent(in) :: nucleus_max_ang_mom(nucl_num)
integer (c_int32_t) , intent(in) :: shell_ang_mom(shell_num)
real (c_double ) , intent(in) :: ao_factor(ao_num)
real (c_double ) , intent(in) :: shell_vgl(shell_num,5,point_num)
real (c_double ) , intent(in) :: shell_hessian(shell_num,4,3,point_num)
real (c_double ) , intent(out) :: ao_hessian(ao_num,4,point_num,3)
integer(qmckl_exit_code) :: info
double precision :: e_coord(3), n_coord(3)
integer*8 :: n_poly
integer :: l, il, k, i, j
integer*8 :: ipoint, inucl, ishell
integer*8 :: ishell_start, ishell_end
integer :: lstart(0:20)
double precision :: x, y, z, r2
double precision :: cutoff
double precision, allocatable :: poly_hessian(:,:,:), poly_vgl(:,:)
integer , allocatable :: powers(:,:), ao_index(:)
allocate(poly_vgl(5,ao_num), poly_hessian(3,4,ao_num), powers(3,ao_num), ao_index(ao_num))
! Pre-computed data
do l=0,20
lstart(l) = l*(l+1)*(l+2)/6 +1
end do
k=1
do inucl=1,nucl_num
ishell_start = nucleus_index(inucl) + 1
ishell_end = nucleus_index(inucl) + nucleus_shell_num(inucl)
do ishell = ishell_start, ishell_end
l = shell_ang_mom(ishell)
ao_index(ishell) = k
k = k + lstart(l+1) - lstart(l)
end do
end do
info = QMCKL_SUCCESS
! Don't compute polynomials when the radial part is zero.
cutoff = -dlog(qmckl_get_numprec_epsilon(context))
!ao_hessian = 0.d0
do ipoint = 1, point_num
e_coord(1) = coord(ipoint,1)
e_coord(2) = coord(ipoint,2)
e_coord(3) = coord(ipoint,3)
ao_hessian(:,:,ipoint,:) = 0.d0
do inucl=1,nucl_num
n_coord(1) = nucl_coord(inucl,1)
n_coord(2) = nucl_coord(inucl,2)
n_coord(3) = nucl_coord(inucl,3)
! Test if the point is in the range of the nucleus
x = e_coord(1) - n_coord(1)
y = e_coord(2) - n_coord(2)
z = e_coord(3) - n_coord(3)
r2 = x*x + y*y + z*z
if (r2 > cutoff*nucleus_range(inucl)) then
!ao_hessian(:,:,ipoint,:) = 0.d0
cycle
end if
! Compute polynomials
info = qmckl_ao_polynomial_hessian(context, e_coord, n_coord, &
nucleus_max_ang_mom(inucl), n_poly, poly_hessian)
info = qmckl_ao_polynomial_vgl(context, e_coord, n_coord, &
nucleus_max_ang_mom(inucl), n_poly, powers, 3_8, &
poly_vgl, 5_8)
! Loop over shells
ishell_start = nucleus_index(inucl) + 1
ishell_end = nucleus_index(inucl) + nucleus_shell_num(inucl)
do ishell = ishell_start, ishell_end
k = ao_index(ishell)
l = shell_ang_mom(ishell)
do il = lstart(l), lstart(l+1)-1
do i = 1, 3
do j = 1, 3
ao_hessian(k,j,ipoint,i) = (&
poly_hessian(j,i,il) * shell_vgl(ishell,1,ipoint) + &
poly_vgl(1,il) * shell_hessian(ishell,j,i,ipoint) + &
poly_vgl(j+1,il) * shell_vgl(ishell,i+1,ipoint) + &
poly_vgl(i+1,il) * shell_vgl(ishell,j+1,ipoint) &
) * ao_factor(k)
end do
ao_hessian(k,4,ipoint,i) = (&
poly_hessian(i,4,il) * shell_vgl(ishell,1,ipoint) + &
poly_vgl(1,il) * shell_hessian(ishell,4,i,ipoint) + &
poly_vgl(5,il) * shell_vgl(ishell,i+1,ipoint) + &
poly_vgl(i+1,il) * shell_vgl(ishell,5,ipoint) + &
2.d0 * (&
poly_hessian(1,i,il) * shell_vgl(ishell,2,ipoint) + &
poly_vgl(2,il) * shell_hessian(ishell,1,i,ipoint) + &
poly_hessian(2,i,il) * shell_vgl(ishell,3,ipoint) + &
poly_vgl(3,il) * shell_hessian(ishell,2,i,ipoint) + &
poly_hessian(3,i,il) * shell_vgl(ishell,4,ipoint) + &
poly_vgl(4,il) * shell_hessian(ishell,3,i,ipoint) &
)) * ao_factor(k)
end do
k = k+1
end do
end do
end do
end do
deallocate(poly_vgl, powers, poly_hessian, ao_index)
end function qmckl_compute_ao_hessian_doc