CHAMP Jastrow Factor
1. Introduction
The Jastrow factor depends on the electronic () and nuclear () coordinates. It is defined as , where
In the following, we use the notations and .
contains electron-nucleus terms:
contains electron-electron terms:
and contains electron-electron-nucleus terms:
are non-zero only when is even.
The scaling functions and are defined as
The terms and are shifts to ensure that and have an asymptotic value of zero.
The eN and eeN parameters are shared by all nuclei of the same type. Note that nucleus types are zero-based.
Derivatives are taken with respect to the coordinates of one electron, the other particles being fixed. For the electron-electron distance this gives .
Each of the three terms has its own set of routines, which deliver the value, the gradient and the Laplacian with respect to the electron coordinates, and the derivatives with respect to the parameters of the term. The last section combines them into the total Jastrow factor and its derivatives.
1.1. Reformulation of the three-body part
To accelerate the computation of the three-body part, the Jastrow factor is re-expressed as follows, with :
The computation of scales as , and the computation of scales as .
2. Context
The following data stored in the context:
| Variable | Type | Description |
|---|---|---|
uninitialized |
int32_t |
Keeps bits set for uninitialized data |
rescale_factor_ee |
double |
Rescale factor for the electron-electron distances |
rescale_factor_en |
double[type_nucl_num] |
Rescale factors for the electron-nucleus distances, by nucleus type |
aord_num |
int64_t |
Number of a coefficients |
bord_num |
int64_t |
Number of b coefficients |
cord_num |
int64_t |
Number of c coefficients |
type_nucl_num |
int64_t |
Number of nucleus types |
type_nucl_vector |
int64_t[nucl_num] |
Type of each nucleus, zero-based |
a_vector |
double[aord_num + 1][type_nucl_num] |
Coefficients of the a polynomial |
b_vector |
double[bord_num + 1] |
Coefficients of the b polynomial |
c_vector |
double[dim_c_vector][type_nucl_num] |
Coefficients of the c polynomial |
spin_independent |
int32_t |
If 1, use the same parameters for parallel and antiparallel spin pairs |
Computed data:
| Variable | Type | Description |
|---|---|---|
dim_c_vector |
int64_t |
Number of unique C coefficients |
dim_c_vector_date |
uint64_t |
Last modification of the number of unique C coefficients |
asymp_jasa |
double[type_nucl_num] |
Asymptotic values of the electron-nucleus term |
asymp_jasa_date |
uint64_t |
Last modification of the electron-nucleus asymptotic values |
asymp_jasa_pderiv |
double[type_nucl_num][aord_num+1] |
Parameter derivatives of the electron-nucleus asymptotic values |
asymp_jasa_pderiv_date |
uint64_t |
Last modification of the electron-nucleus asymptotic parameter derivatives |
asymp_jasb |
double[2] |
Asymptotic values for parallel and antiparallel spin pairs |
asymp_jasb_date |
uint64_t |
Last modification of the electron-electron asymptotic values |
asymp_jasb_pderiv |
double[2][bord_num+1] |
Parameter derivatives of the electron-electron asymptotic values |
asymp_jasb_pderiv_date |
uint64_t |
Last modification of the electron-electron asymptotic parameter derivatives |
c_vector_full |
double[dim_c_vector][nucl_num] |
C coefficients expanded over all nuclei |
c_vector_full_date |
uint64_t |
Last modification of the expanded C coefficients |
lkpm_combined_index |
int64_t[4][dim_c_vector] |
Combined l, k, p and m indices of each C coefficient |
lkpm_combined_index_date |
uint64_t |
Last modification of the combined indices |
tmp_c |
double[walk_num][cord_num][cord_num+1][nucl_num][elec_num] |
Temporary array P of the three-body sums |
tmp_c_date |
uint64_t |
Last modification of the temporary array P |
dtmp_c |
double[walk_num][cord_num][cord_num+1][nucl_num][4][elec_num] |
Temporary array for the three-body derivative sums |
dtmp_c_date |
uint64_t |
Last modification of the temporary derivative array |
ee_distance_rescaled |
double[walk_num][elec_num][elec_num] |
Rescaled electron-electron distances |
ee_distance_rescaled_date |
uint64_t |
Last modification of the rescaled electron-electron distances |
ee_distance_rescaled_gl |
double[walk_num][elec_num][elec_num][4] |
Derivatives of the rescaled electron-electron distances |
ee_distance_rescaled_gl_date |
uint64_t |
Last modification of the derivatives of the rescaled electron-electron distances |
en_distance_rescaled |
double[walk_num][nucl_num][elec_num] |
Rescaled electron-nucleus distances |
en_distance_rescaled_date |
uint64_t |
Last modification of the rescaled electron-nucleus distances |
en_distance_rescaled_gl |
double[walk_num][nucl_num][elec_num][4] |
Derivatives of the rescaled electron-nucleus distances |
en_distance_rescaled_gl_date |
uint64_t |
Last modification of the derivatives of the rescaled electron-nucleus distances |
een_rescaled_e |
double[walk_num][cord_num+1][elec_num][elec_num] |
Rescaled electron-electron distances raised to the powers defined by cord |
een_rescaled_e_date |
uint64_t |
Last modification of the rescaled electron-electron distances of the three-body term |
een_rescaled_e_gl |
double[walk_num][cord_num+1][elec_num][4][elec_num] |
Derivatives of the rescaled electron-electron distances of the three-body term |
een_rescaled_e_gl_date |
uint64_t |
Last modification of the derivatives of the three-body electron-electron distances |
een_rescaled_n |
double[walk_num][cord_num+1][nucl_num][elec_num] |
Rescaled electron-nucleus distances raised to the powers defined by cord |
een_rescaled_n_date |
uint64_t |
Last modification of the rescaled electron-nucleus distances of the three-body term |
een_rescaled_n_gl |
double[walk_num][cord_num+1][nucl_num][4][elec_num] |
Derivatives of the rescaled electron-nucleus distances of the three-body term |
een_rescaled_n_gl_date |
uint64_t |
Last modification of the derivatives of the three-body electron-nucleus distances |
factor_ee |
double[walk_num] |
Value of the electron-electron term |
factor_ee_date |
uint64_t |
Last modification of the electron-electron term |
factor_ee_pderiv |
double[bord_num+1] |
Parameter derivatives of the electron-electron term |
factor_ee_pderiv_date |
uint64_t |
Last modification of the electron-electron parameter derivatives |
factor_en |
double[walk_num] |
Value of the electron-nucleus term |
factor_en_date |
uint64_t |
Last modification of the electron-nucleus term |
factor_en_pderiv |
double[type_nucl_num][aord_num+1] |
Parameter derivatives of the electron-nucleus term |
factor_en_pderiv_date |
uint64_t |
Last modification of the electron-nucleus parameter derivatives |
factor_een |
double[walk_num] |
Value of the electron-electron-nucleus term |
factor_een_date |
uint64_t |
Last modification of the electron-electron-nucleus term |
factor_een_pderiv |
double[type_nucl_num][dim_c_vector] |
Parameter derivatives of the electron-electron-nucleus term |
factor_een_pderiv_date |
uint64_t |
Last modification of the electron-electron-nucleus parameter derivatives |
factor_ee_gl |
double[walk_num][4][elec_num] |
Gradient and Laplacian of the electron-electron term |
factor_ee_gl_date |
uint64_t |
Last modification of the electron-electron gradient |
factor_ee_gl_pderiv |
double[bord_num+1][elec_num][4] |
Parameter derivatives of the electron-electron gradient |
factor_ee_gl_pderiv_date |
uint64_t |
Last modification of the electron-electron gradient parameter derivatives |
factor_en_gl |
double[walk_num][4][elec_num] |
Gradient and Laplacian of the electron-nucleus term |
factor_en_gl_date |
uint64_t |
Last modification of the electron-nucleus gradient |
factor_en_gl_pderiv |
double[type_nucl_num][aord_num+1][elec_num][4] |
Parameter derivatives of the electron-nucleus gradient |
factor_en_gl_pderiv_date |
uint64_t |
Last modification of the electron-nucleus gradient parameter derivatives |
factor_een_gl |
double[walk_num][4][elec_num] |
Gradient and Laplacian of the electron-electron-nucleus term |
factor_een_gl_date |
uint64_t |
Last modification of the electron-electron-nucleus gradient |
factor_een_grad |
double[walk_num][3][elec_num] |
Gradient of the electron-electron-nucleus term |
factor_een_grad_date |
uint64_t |
Last modification of the electron-electron-nucleus gradient |
factor_een_gl_pderiv |
double[type_nucl_num][dim_c_vector][elec_num][4] |
Parameter derivatives of the electron-electron-nucleus gradient |
factor_een_gl_pderiv_date |
uint64_t |
Last modification of the electron-electron-nucleus gradient parameter derivatives |
value |
double[walk_num] |
Value of the Jastrow factor |
value_date |
uint64_t |
Last modification of the value |
gl |
double[walk_num][4][elec_num] |
Gradient and Laplacian of the Jastrow factor |
gl_date |
uint64_t |
Last modification of the gradient and Laplacian |
grad |
double[walk_num][3][elec_num] |
Gradient of the Jastrow factor |
grad_date |
uint64_t |
Last modification of the gradient |
2.1. Data structure
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.
2.2. Initialization functions
To prepare for the Jastrow and its derivative, all the following functions need to be called.
qmckl_exit_code qmckl_set_jastrow_champ_rescale_factor_ee (qmckl_context context, const double kappa_ee);
qmckl_exit_code qmckl_set_jastrow_champ_rescale_factor_en (qmckl_context context, const double* kappa_en, const int64_t size_max);
qmckl_exit_code qmckl_set_jastrow_champ_aord_num (qmckl_context context, const int64_t aord_num);
qmckl_exit_code qmckl_set_jastrow_champ_bord_num (qmckl_context context, const int64_t bord_num);
qmckl_exit_code qmckl_set_jastrow_champ_cord_num (qmckl_context context, const int64_t cord_num);
qmckl_exit_code qmckl_set_jastrow_champ_type_nucl_num (qmckl_context context, const int64_t type_nucl_num);
qmckl_exit_code qmckl_set_jastrow_champ_type_nucl_vector (qmckl_context context, const int64_t* type_nucl_vector, const int64_t size_max);
qmckl_exit_code qmckl_set_jastrow_champ_a_vector (qmckl_context context, const double * a_vector, const int64_t size_max);
qmckl_exit_code qmckl_set_jastrow_champ_b_vector (qmckl_context context, const double * b_vector, const int64_t size_max);
qmckl_exit_code qmckl_set_jastrow_champ_c_vector (qmckl_context context, const double * c_vector, const int64_t size_max);
qmckl_exit_code qmckl_set_jastrow_champ_spin_independent (qmckl_context context, const int32_t spin_independent);
When the required information is completely entered, other data structures are computed to accelerate the calculations. The intermediates factors are precontracted using BLAS LEVEL 3 operations.
2.2.0.1. Fortran interface
interface
integer(qmckl_exit_code) function qmckl_set_jastrow_champ_rescale_factor_ee (context, &
kappa_ee) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
real(c_double), intent(in), value :: kappa_ee
end function qmckl_set_jastrow_champ_rescale_factor_ee
integer(qmckl_exit_code) function qmckl_set_jastrow_champ_rescale_factor_en (context, &
kappa_en, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer(c_int64_t), intent(in), value :: size_max
real(c_double), intent(in) :: kappa_en(size_max)
end function qmckl_set_jastrow_champ_rescale_factor_en
integer(qmckl_exit_code) function qmckl_set_jastrow_champ_aord_num (context, &
aord_num) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer(c_int64_t), intent(in), value :: aord_num
end function qmckl_set_jastrow_champ_aord_num
integer(qmckl_exit_code) function qmckl_set_jastrow_champ_bord_num (context, &
bord_num) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer(c_int64_t), intent(in), value :: bord_num
end function qmckl_set_jastrow_champ_bord_num
integer(qmckl_exit_code) function qmckl_set_jastrow_champ_cord_num (context, &
cord_num) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer(c_int64_t), intent(in), value :: cord_num
end function qmckl_set_jastrow_champ_cord_num
integer(qmckl_exit_code) function qmckl_set_jastrow_champ_type_nucl_num (context, &
type_nucl_num) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer(c_int64_t), intent(in), value :: type_nucl_num
end function qmckl_set_jastrow_champ_type_nucl_num
integer(qmckl_exit_code) function qmckl_set_jastrow_champ_type_nucl_vector (context, &
type_nucl_vector, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer(c_int64_t), intent(in), value :: size_max
integer(c_int64_t), intent(in) :: type_nucl_vector(size_max)
end function qmckl_set_jastrow_champ_type_nucl_vector
integer(qmckl_exit_code) function qmckl_set_jastrow_champ_a_vector(context, &
a_vector, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer(c_int64_t), intent(in), value :: size_max
real(c_double), intent(in) :: a_vector(size_max)
end function qmckl_set_jastrow_champ_a_vector
integer(qmckl_exit_code) function qmckl_set_jastrow_champ_b_vector(context, &
b_vector, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer(c_int64_t), intent(in), value :: size_max
real(c_double), intent(in) :: b_vector(size_max)
end function qmckl_set_jastrow_champ_b_vector
integer(qmckl_exit_code) function qmckl_set_jastrow_champ_c_vector(context, &
c_vector, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer(c_int64_t), intent(in), value :: size_max
real(c_double), intent(in) :: c_vector(size_max)
end function qmckl_set_jastrow_champ_c_vector
integer(qmckl_exit_code) function qmckl_set_jastrow_champ_spin_independent(context, &
spin_independent) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer(qmckl_context) , intent(in) , value :: context
integer(c_int32_t), intent(in), value :: spin_independent
end function qmckl_set_jastrow_champ_spin_independent
end interface
2.3. Access functions
Along with these core functions, calculation of the jastrow factor requires the following additional information to be set:
When all the data for the AOs have been provided, the following
function returns true.
bool qmckl_jastrow_champ_provided (const qmckl_context context);
2.3.0.1. Fortran interface
interface
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_rescale_factor_ee (context, &
kappa_ee) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
real(c_double), intent(out) :: kappa_ee
end function qmckl_get_jastrow_champ_rescale_factor_ee
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_rescale_factor_en (context, &
kappa_en, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in), value :: context
integer(c_int64_t), intent(in), value :: size_max
real(c_double), intent(out) :: kappa_en(size_max)
end function qmckl_get_jastrow_champ_rescale_factor_en
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_aord_num (context, &
aord_num) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in), value :: context
integer(c_int64_t), intent(out) :: aord_num
end function qmckl_get_jastrow_champ_aord_num
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_bord_num (context, &
bord_num) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in), value :: context
integer(c_int64_t), intent(out) :: bord_num
end function qmckl_get_jastrow_champ_bord_num
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_cord_num (context, &
cord_num) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in), value :: context
integer(c_int64_t), intent(out) :: cord_num
end function qmckl_get_jastrow_champ_cord_num
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_type_nucl_num (context, &
type_nucl_num) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in), value :: context
integer(c_int64_t), intent(out) :: type_nucl_num
end function qmckl_get_jastrow_champ_type_nucl_num
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_type_nucl_vector (context, &
type_nucl_vector, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context), intent(in), value :: context
integer(c_int64_t), intent(in), value :: size_max
integer(c_int64_t), intent(out) :: type_nucl_vector(size_max)
end function qmckl_get_jastrow_champ_type_nucl_vector
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_a_vector(context, &
a_vector, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in), value :: context
integer(c_int64_t), intent(in), value :: size_max
real(c_double), intent(out) :: a_vector(size_max)
end function qmckl_get_jastrow_champ_a_vector
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_b_vector(context, &
b_vector, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer(c_int64_t), intent(in), value :: size_max
real(c_double), intent(out) :: b_vector(size_max)
end function qmckl_get_jastrow_champ_b_vector
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_c_vector(context, &
c_vector, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer(c_int64_t), intent(in), value :: size_max
real(c_double), intent(out) :: c_vector(size_max)
end function qmckl_get_jastrow_champ_c_vector
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_spin_independent(context, &
spin_independent) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer(qmckl_context) , intent(in) , value :: context
integer(c_int32_t), intent(out) :: spin_independent
end function qmckl_get_jastrow_champ_spin_independent
end interface
3. Computation
The computed data is stored in the context so that it can be reused by different kernels. To ensure that the data is valid, for each computed data the date of the context is stored when it is computed. To know if some data needs to be recomputed, we check if the date of the dependencies are more recent than the date of the data to compute. If it is the case, then the data is recomputed and the current date is stored.
3.1. Electron-electron component
3.1.1. Asymptotic component
Calculate the asymptotic component asymp_jasb to be subtracted from the
electron-electron jastrow factor . Two values are
computed. The first one is for parallel spin pairs, and the
second one for antiparallel spin pairs.
If the spin_independent variable is set to 1, then
is always equal to one.
3.1.1.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_asymp_jasb(qmckl_context context,
double* const asymp_jasb,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_asymp_jasb(context, & asymp_jasb, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: asymp_jasb(size_max) end function qmckl_get_jastrow_champ_asymp_jasb end interface
3.1.1.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
bord_num |
int64_t |
in | Order of the b polynomial |
b_vector |
double[bord_num+1] |
in | Values of b |
rescale_factor_ee |
double |
in | Factor to rescale ee distances |
spin_independent |
int32_t |
in | If 1, use the same parameters for parallel and antiparallel spin pairs |
asymp_jasb |
double[2] |
out | Asymptotic values for parallel and antiparallel spin pairs |
function qmckl_compute_jastrow_champ_asymp_jasb_doc(context, &
bord_num, b_vector, rescale_factor_ee, spin_independent, asymp_jasb) &
bind(C) result(info)
use qmckl
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: bord_num
real (c_double ) , intent(in) :: b_vector(bord_num+1)
real (c_double ) , intent(in) , value :: rescale_factor_ee
integer (c_int32_t) , intent(in) , value :: spin_independent
real (c_double ) , intent(out) :: asymp_jasb(2)
integer(qmckl_exit_code) :: info
integer*8 :: i, p
double precision :: kappa_inv, x, asym_one
kappa_inv = 1.0d0 / rescale_factor_ee
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (bord_num < 0) then
info = QMCKL_INVALID_ARG_2
return
endif
asym_one = b_vector(1) * kappa_inv / (1.0d0 + b_vector(2) * kappa_inv)
if (spin_independent == 1) then
asymp_jasb(:) = (/asym_one, asym_one/)
else
asymp_jasb(:) = (/0.5d0*asym_one, asym_one/)
end if
x = kappa_inv
do p = 2, bord_num
x = x * kappa_inv
do i = 1, 2
asymp_jasb(i) = asymp_jasb(i) + b_vector(p + 1) * x
end do
end do
end function qmckl_compute_jastrow_champ_asymp_jasb_doc
3.1.2. Electron-electron rescaled distances
ee_distance_rescaled stores the matrix of the rescaled distances between all
pairs of electrons:
where is the matrix of electron-electron distances.
3.1.2.1. Get
qmckl_exit_code qmckl_get_jastrow_champ_ee_distance_rescaled(qmckl_context context,
double* const distance_rescaled,
int64_t const size_max);
3.1.2.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
elec_num |
int64_t |
in | Number of electrons |
rescale_factor_ee |
double |
in | Factor to rescale ee distances |
walk_num |
int64_t |
in | Number of walkers |
coord |
double[3][walk_num][elec_num] |
in | Electron coordinates |
ee_distance |
double[walk_num][elec_num][elec_num] |
out | Electron-electron rescaled distances |
function qmckl_compute_ee_distance_rescaled_doc(context, &
elec_num, rescale_factor_ee, walk_num, &
coord, ee_distance_rescaled) &
bind(C) result(info)
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: elec_num
real (c_double ) , intent(in) , value :: rescale_factor_ee
integer (c_int64_t) , intent(in) , value :: walk_num
real (c_double ) , intent(in) :: coord(elec_num,walk_num,3)
real (c_double ) , intent(out) :: ee_distance_rescaled(elec_num,elec_num,walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: k
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
do k=1,walk_num
info = qmckl_distance_rescaled(context, 'T', 'T', elec_num, elec_num, &
coord(1,k,1), elec_num * walk_num, &
coord(1,k,1), elec_num * walk_num, &
ee_distance_rescaled(1,1,k), elec_num, rescale_factor_ee)
if (info /= QMCKL_SUCCESS) then
exit
endif
end do
end function qmckl_compute_ee_distance_rescaled_doc
3.1.3. Electron-electron rescaled distance gradients and Laplacian with respect to electron coordinates
The rescaled distances, represented by
are differentiated with respect to the electron coordinates.
This information is stored in the tensor
ee_distance_rescaled_gl. The initial three sequential
elements of this three-dimensional tensor provide the , , and
direction derivatives, while the fourth index corresponds to the Laplacian.
3.1.3.1. Get
qmckl_exit_code qmckl_get_jastrow_champ_ee_distance_rescaled_gl(qmckl_context context,
double* const distance_rescaled_gl,
const int64_t size_max);
3.1.3.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
elec_num |
int64_t |
in | Number of electrons |
rescale_factor_ee |
double |
in | Factor to rescale ee distances |
walk_num |
int64_t |
in | Number of walkers |
coord |
double[3][walk_num][elec_num] |
in | Electron coordinates |
ee_distance_rescaled_gl |
double[walk_num][elec_num][elec_num][4] |
out | Electron-electron rescaled distance derivatives |
function qmckl_compute_ee_distance_rescaled_gl_doc(context, &
elec_num, rescale_factor_ee, walk_num, coord, ee_distance_rescaled_gl) &
bind(C) result(info)
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: elec_num
real (c_double ) , intent(in) , value :: rescale_factor_ee
integer (c_int64_t) , intent(in) , value :: walk_num
real (c_double ) , intent(in) :: coord(elec_num,walk_num,3)
real (c_double ) , intent(out) :: ee_distance_rescaled_gl(4,elec_num,elec_num,walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: k
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
do k=1,walk_num
info = qmckl_distance_rescaled_gl(context, 'T', 'T', elec_num, elec_num, &
coord(1,k,1), elec_num*walk_num, &
coord(1,k,1), elec_num*walk_num, &
ee_distance_rescaled_gl(1,1,1,k), elec_num, rescale_factor_ee)
if (info /= QMCKL_SUCCESS) then
exit
endif
end do
end function qmckl_compute_ee_distance_rescaled_gl_doc
3.1.4. Electron-electron component
Calculate the electron-electron jastrow component factor_ee using the asymp_jasb
component and the electron-electron rescaled distances ee_distance_rescaled.
If the spin_independent variable is set to 1, then
is always equal to one.
is the spin factor, is the vector of parameters, is the array of rescaled distances.
can be rewritten as:
3.1.4.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_factor_ee(qmckl_context context,
double* const factor_ee,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_ee (context, & factor_ee, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: factor_ee(size_max) end function qmckl_get_jastrow_champ_factor_ee end interface
3.1.4.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
up_num |
int64_t |
in | Number of alpha electrons |
bord_num |
int64_t |
in | Number of b coefficients |
b_vector |
double[bord_num+1] |
in | Values of b |
ee_distance_rescaled |
double[walk_num][elec_num][elec_num] |
in | Rescaled electron-electron distances |
asymp_jasb |
double[2] |
in | Asymptotic values subtracted from the electron-electron term |
factor_ee |
double[walk_num] |
out |
function qmckl_compute_jastrow_champ_factor_ee_doc(context, &
walk_num, elec_num, up_num, bord_num, b_vector, &
ee_distance_rescaled, asymp_jasb, spin_independent, factor_ee) &
bind(C) result(info)
use qmckl
implicit none
integer (qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in), value :: walk_num
integer (c_int64_t) , intent(in), value :: elec_num
integer (c_int64_t) , intent(in), value :: up_num
integer (c_int64_t) , intent(in), value :: bord_num
real (c_double ) , intent(in) :: b_vector(bord_num+1)
real (c_double ) , intent(in) :: ee_distance_rescaled(elec_num,elec_num,walk_num)
real (c_double ) , intent(in) :: asymp_jasb(2)
integer (c_int32_t) , intent(in), value :: spin_independent
real (c_double ) , intent(out) :: factor_ee(walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, j, k, nw
double precision :: x, xk
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (bord_num < 0) then
info = QMCKL_INVALID_ARG_4
return
endif
do nw =1, walk_num
factor_ee(nw) = 0.0d0
do j=1,elec_num
do i=1,j-1
x = ee_distance_rescaled(i,j,nw)
if (spin_independent == 1) then
factor_ee(nw) = factor_ee(nw) + b_vector(1) * x / (1.d0 + b_vector(2) * x) - asymp_jasb(2)
else
if ( (j <= up_num).or.(i > up_num) ) then
factor_ee(nw) = factor_ee(nw) + 0.5d0 * b_vector(1) * x / (1.d0 + b_vector(2) * x) - asymp_jasb(1)
else
factor_ee(nw) = factor_ee(nw) + b_vector(1) * x / (1.d0 + b_vector(2) * x) - asymp_jasb(2)
endif
endif
xk = x
do k=2,bord_num
xk = xk * x
factor_ee(nw) = factor_ee(nw) + b_vector(k+1)* xk
end do
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_ee_doc
3.1.5. Derivative
The derivative of factor_ee is computed using the ee_distance_rescaled and
the electron-electron rescaled distances derivatives
ee_distance_rescaled_gl.
There are four components, the gradient which has 3 components in the
directions and the laplacian as the last component.
3.1.5.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_factor_ee_gl(qmckl_context context,
double* const factor_ee_gl,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_ee_gl (context, & factor_ee_gl, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: factor_ee_gl(size_max) end function qmckl_get_jastrow_champ_factor_ee_gl end interface
3.1.5.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
up_num |
int64_t |
in | Number of alpha electrons |
bord_num |
int64_t |
in | Number of b coefficients |
b_vector |
double[bord_num+1] |
in | Values of b |
ee_distance_rescaled |
double[walk_num][elec_num][elec_num] |
in | Rescaled electron-electron distances |
ee_distance_rescaled_gl |
double[walk_num][elec_num][elec_num][4] |
in | Derivatives of the rescaled electron-electron distances |
spin_independent |
int32_t |
in | If 1, same parameters for parallel and antiparallel spins |
factor_ee_gl |
double[walk_num][4][elec_num] |
out | Gradient and Laplacian of the electron-electron term |
function qmckl_compute_jastrow_champ_factor_ee_gl_doc( &
context, walk_num, elec_num, up_num, bord_num, &
b_vector, ee_distance_rescaled, ee_distance_rescaled_gl, &
spin_independent, factor_ee_gl) &
bind(C) result(info)
use qmckl
implicit none
integer (qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: up_num
integer (c_int64_t) , intent(in) , value :: bord_num
real (c_double ) , intent(in) :: b_vector(bord_num+1)
real (c_double ) , intent(in) :: ee_distance_rescaled(elec_num,elec_num,walk_num)
real (c_double ) , intent(in) :: ee_distance_rescaled_gl(4,elec_num,elec_num,walk_num)
integer (c_int32_t) , intent(in) , value :: spin_independent
real (c_double ) , intent(out) :: factor_ee_gl(elec_num,4,walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, j, k, nw, ii
double precision :: x, x1, kf
double precision :: denom, invdenom, invdenom2, f
double precision :: grad_c2
double precision :: dx(4)
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (bord_num < 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if ((spin_independent < 0).or.(spin_independent > 1)) then
info = QMCKL_INVALID_ARG_8
return
endif
do nw =1, walk_num
factor_ee_gl(:,:,nw) = 0.0d0
do j = 1, elec_num
do i = 1, elec_num
if (i == j) cycle
x = ee_distance_rescaled(i,j,nw)
denom = 1.0d0 + b_vector(2) * x
invdenom = 1.0d0 / denom
invdenom2 = invdenom * invdenom
dx(1) = ee_distance_rescaled_gl(1, i, j, nw)
dx(2) = ee_distance_rescaled_gl(2, i, j, nw)
dx(3) = ee_distance_rescaled_gl(3, i, j, nw)
dx(4) = ee_distance_rescaled_gl(4, i, j, nw)
grad_c2 = dx(1)*dx(1) + dx(2)*dx(2) + dx(3)*dx(3)
if (spin_independent == 1) then
f = b_vector(1) * invdenom2
else
if((i <= up_num .and. j <= up_num ) .or. (i > up_num .and. j > up_num)) then
f = 0.5d0 * b_vector(1) * invdenom2
else
f = b_vector(1) * invdenom2
end if
end if
factor_ee_gl(i,1,nw) = factor_ee_gl(i,1,nw) + f * dx(1)
factor_ee_gl(i,2,nw) = factor_ee_gl(i,2,nw) + f * dx(2)
factor_ee_gl(i,3,nw) = factor_ee_gl(i,3,nw) + f * dx(3)
factor_ee_gl(i,4,nw) = factor_ee_gl(i,4,nw) &
+ f * (dx(4) - 2.d0 * b_vector(2) * grad_c2 * invdenom)
kf = 2.d0
x1 = x
x = 1.d0
do k=2, bord_num
f = b_vector(k+1) * kf * x
factor_ee_gl(i,1,nw) = factor_ee_gl(i,1,nw) + f * x1 * dx(1)
factor_ee_gl(i,2,nw) = factor_ee_gl(i,2,nw) + f * x1 * dx(2)
factor_ee_gl(i,3,nw) = factor_ee_gl(i,3,nw) + f * x1 * dx(3)
factor_ee_gl(i,4,nw) = factor_ee_gl(i,4,nw) &
+ f * (x1 * dx(4) + (kf-1.d0) * grad_c2)
x = x*x1
kf = kf + 1.d0
end do
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_ee_gl_doc
3.1.6. Parameter Derivative of the Asymptotic component
Calculate the derivatives of the asymptotic component w.r.t. the
jastrow parameters asymp_jasb_pderiv to be subtracted from the
electron-electron jastrow factor derivatives. Two values are
computed. The first one is for parallel spin pairs, and the
second one for antiparallel spin pairs.
If the spin_independent variable is set to 1, then
is always equal to one.
for
3.1.6.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_asymp_jasb_pderiv(qmckl_context context,
double* const asymp_jasb_pderiv,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_asymp_jasb_pderiv(context, & asymp_jasb_pderiv, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: asymp_jasb_pderiv(size_max) end function qmckl_get_jastrow_champ_asymp_jasb_pderiv end interface
3.1.6.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
bord_num |
int64_t |
in | Order of the b polynomial |
b_vector |
double[bord_num+1] |
in | Values of b |
rescale_factor_ee |
double |
in | Factor to rescale ee distances |
spin_independent |
int32_t |
in | If 1, use the same parameters for parallel and antiparallel spin pairs |
asymp_jasb_pderiv |
double[2][bord_num+1] |
out | Parameter derivatives of the electron-electron asymptotic values |
function qmckl_compute_jastrow_champ_asymp_jasb_pderiv_doc(context, &
bord_num, b_vector, rescale_factor_ee, spin_independent, asymp_jasb_pderiv) &
bind(C) result(info)
use qmckl
implicit none
integer (qmckl_context) , intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: bord_num
real (c_double ) , intent(in) :: b_vector(bord_num+1)
real (c_double ) , intent(in) , value :: rescale_factor_ee
integer (c_int32_t) , intent(in) , value :: spin_independent
real (c_double ) , intent(out) :: asymp_jasb_pderiv(bord_num+1,2)
integer(qmckl_exit_code) :: info
integer*8 :: i, p
double precision :: kappa_inv, x, asym_one, asym_two
kappa_inv = 1.0d0 / rescale_factor_ee
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (bord_num < 0) then
info = QMCKL_INVALID_ARG_2
return
endif
asym_one = kappa_inv / (1.0d0 + b_vector(2) * kappa_inv)
asym_two = -b_vector(1) * kappa_inv**2 / (1.0d0 + b_vector(2) * kappa_inv)**2
if (spin_independent == 1) then
asymp_jasb_pderiv(1,:) = (/asym_one, asym_one/)
asymp_jasb_pderiv(2,:) = (/asym_two, asym_two/)
else
asymp_jasb_pderiv(1,:) = (/0.5d0*asym_one, asym_one/)
asymp_jasb_pderiv(2,:) = (/0.5d0*asym_two, asym_two/)
end if
x = kappa_inv
do p = 2, bord_num
x = x * kappa_inv
do i = 1, 2
asymp_jasb_pderiv(p+1,i) = x
end do
end do
end function qmckl_compute_jastrow_champ_asymp_jasb_pderiv_doc
3.1.7. Parameter Derivative
The derivative of factor_ee with respect to the jastrow parameters
b_vector is computed. These derivatives are computed from the
electron-electron rescaled distances ee_distance_rescaled and the
parameter derivatives of the asymptotic part asymp_jasb_pderiv. If
spin_independent is set to 1, then
is always equal to 1.
is the rescaled distance ee_distance_rescaled, not the
bare distance .
The pair sums are accumulated over all walkers and divided by the number of walkers.
3.1.7.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_factor_ee_pderiv(qmckl_context context,
double* const factor_ee_pderiv,
const int64_t size_max);
interface
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_ee_pderiv (context, &
factor_ee_pderiv, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in), value :: context
integer(c_int64_t), intent(in), value :: size_max
real(c_double), intent(out) :: factor_ee_pderiv(size_max)
end function qmckl_get_jastrow_champ_factor_ee_pderiv
end interface
3.1.7.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
up_num |
int64_t |
in | Number of alpha electrons |
bord_num |
int64_t |
in | Number of b coefficients |
b_vector |
double[bord_num+1] |
in | Values of b |
ee_distance_rescaled |
double[walk_num][elec_num][elec_num] |
in | Rescaled electron-electron distances |
asymp_jasb_pderiv |
double[2][bord_num+1] |
in | Parameter derivatives of the asymptotic values |
spin_independent |
int32_t |
in | If 1, use the same parameters for parallel and antiparallel spin pairs |
factor_ee_pderiv |
double[bord_num+1] |
out |
function qmckl_compute_jastrow_champ_factor_ee_pderiv_doc(context, &
walk_num, elec_num, up_num, bord_num, b_vector, &
ee_distance_rescaled, asymp_jasb_pderiv, spin_independent, factor_ee_pderiv) &
bind(C) result(info)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer (qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in), value :: walk_num
integer (c_int64_t) , intent(in), value :: elec_num
integer (c_int64_t) , intent(in), value :: up_num
integer (c_int64_t) , intent(in), value :: bord_num
real (c_double ) , intent(in) :: b_vector(bord_num+1)
real (c_double ) , intent(in) :: ee_distance_rescaled(elec_num,elec_num,walk_num)
real (c_double ) , intent(in) :: asymp_jasb_pderiv(bord_num+1, 2)
integer (c_int32_t) , intent(in), value :: spin_independent
real (c_double ) , intent(out) :: factor_ee_pderiv(bord_num+1)
integer(qmckl_exit_code) :: info
integer*8 :: i, j, k, nw
double precision :: x, xk
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (bord_num < 0) then
info = QMCKL_INVALID_ARG_4
return
endif
factor_ee_pderiv = 0.0d0
do nw = 1, walk_num
do j = 1, elec_num
do i = 1, j - 1
x = ee_distance_rescaled(i,j,nw)
if (spin_independent == 1) then
factor_ee_pderiv(1) = factor_ee_pderiv(1) + x / (1.d0 + b_vector(2) * x) - asymp_jasb_pderiv(1,2)
factor_ee_pderiv(2) = factor_ee_pderiv(2) - b_vector(1) * x**2 / (1.d0 + b_vector(2) * x)**2 - asymp_jasb_pderiv(2,2)
else
if ( (j <= up_num).or.(i > up_num) ) then
factor_ee_pderiv(1) = factor_ee_pderiv(1) + 0.5d0 * x / (1.d0 + b_vector(2) * x) - asymp_jasb_pderiv(1,1)
factor_ee_pderiv(2) = factor_ee_pderiv(2) - 0.5d0 * b_vector(1) * x**2 / (1.d0 + b_vector(2) * x)**2 &
- asymp_jasb_pderiv(2,1)
else
factor_ee_pderiv(1) = factor_ee_pderiv(1) + x / (1.d0 + b_vector(2) * x) - asymp_jasb_pderiv(2,1)
factor_ee_pderiv(2) = factor_ee_pderiv(2) - b_vector(1) * x**2 / (1.d0 + b_vector(2) * x)**2 &
- asymp_jasb_pderiv(2,2)
endif
endif
xk = x
do k = 2, bord_num
xk = xk * x
factor_ee_pderiv(k+1) = factor_ee_pderiv(k+1) + xk - asymp_jasb_pderiv(k+1, 1)
end do
end do
end do
end do
factor_ee_pderiv = factor_ee_pderiv / dble(walk_num)
end function qmckl_compute_jastrow_champ_factor_ee_pderiv_doc
3.1.8. Parameter Derivative of the gradient and Laplacian
The derivatives of the gradient and Laplacian of factor_ee_gl with
respect to the b coefficients are stored in factor_ee_gl_pderiv,
with the parameter index first, then the electron index, and last the
four coordinate components (x, y, z, Laplacian). The pair weight
is used
for the and derivatives, so that parallel pairs count
half when spin_independent is zero. Writing :
The sums run over all walkers and are divided by walk_num. Note
that in qmckl_compute_jastrow_champ_factor_ee_gl_pderiv the
Laplacian entry of is accumulated with the sign of
its second term inverted.
3.1.8.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_factor_ee_gl_pderiv(qmckl_context context,
double* const factor_ee_gl_pderiv,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_ee_gl_pderiv (context, & factor_ee_gl_pderiv, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: factor_ee_gl_pderiv(size_max) end function qmckl_get_jastrow_champ_factor_ee_gl_pderiv end interface
3.1.8.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
up_num |
int64_t |
in | Number of alpha electrons |
bord_num |
int64_t |
in | Number of b coefficients |
b_vector |
double[bord_num+1] |
in | Values of b |
ee_distance_rescaled |
double[walk_num][elec_num][elec_num] |
in | Rescaled electron-electron distances |
ee_distance_rescaled_gl |
double[walk_num][elec_num][elec_num][4] |
in | Derivatives of the rescaled electron-electron distances |
spin_independent |
int32_t |
in | If 1, same parameters for parallel and antiparallel spins |
factor_ee_gl_pderiv |
double[bord_num+1][elec_num][4] |
out | Parameter derivatives of the gradient and Laplacian |
function qmckl_compute_jastrow_champ_factor_ee_gl_pderiv_doc( &
context, walk_num, elec_num, up_num, bord_num, &
b_vector, ee_distance_rescaled, ee_distance_rescaled_gl, &
spin_independent, factor_ee_gl_pderiv) &
bind(C) result(info)
use qmckl
implicit none
integer (qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: up_num
integer (c_int64_t) , intent(in) , value :: bord_num
real (c_double ) , intent(in) :: b_vector(bord_num+1)
real (c_double ) , intent(in) :: ee_distance_rescaled(elec_num,elec_num,walk_num)
real (c_double ) , intent(in) :: ee_distance_rescaled_gl(4,elec_num,elec_num,walk_num)
integer (c_int32_t) , intent(in) , value :: spin_independent
real (c_double ) , intent(out) :: factor_ee_gl_pderiv(4,elec_num,bord_num+1)
integer(qmckl_exit_code) :: info
integer*8 :: i, j, k, nw, ii
double precision :: x, x1, kf
double precision :: denom, invdenom, invdenom2, invdenom3, f, f1, f2
double precision :: grad_c2
double precision :: dx(4)
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (bord_num < 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if ((spin_independent < 0).or.(spin_independent > 1)) then
info = QMCKL_INVALID_ARG_8
return
endif
factor_ee_gl_pderiv(:,:,:) = 0.0d0
do nw = 1, walk_num
do j = 1, elec_num
do i = 1, elec_num
if (i == j) cycle
x = ee_distance_rescaled(i,j,nw)
denom = 1.0d0 + b_vector(2) * x
invdenom = 1.0d0 / denom
invdenom2 = invdenom * invdenom
invdenom3 = invdenom2 * invdenom
dx(1) = ee_distance_rescaled_gl(1, i, j, nw)
dx(2) = ee_distance_rescaled_gl(2, i, j, nw)
dx(3) = ee_distance_rescaled_gl(3, i, j, nw)
dx(4) = ee_distance_rescaled_gl(4, i, j, nw)
grad_c2 = dx(1)*dx(1) + dx(2)*dx(2) + dx(3)*dx(3)
if (spin_independent == 1) then
f1 = invdenom2
f2 = -2.d0 * b_vector(1) * x * invdenom3
else
if((i <= up_num .and. j <= up_num ) .or. (i > up_num .and. j > up_num)) then
f1 = 0.5d0 * invdenom2
f2 = -1.d0 * b_vector(1) * x * invdenom3
else
f1 = invdenom2
f2 = -2.d0 * b_vector(1) * x * invdenom3
end if
end if
factor_ee_gl_pderiv(1,i,1) = factor_ee_gl_pderiv(1,i,1) + f1 * dx(1)
factor_ee_gl_pderiv(2,i,1) = factor_ee_gl_pderiv(2,i,1) + f1 * dx(2)
factor_ee_gl_pderiv(3,i,1) = factor_ee_gl_pderiv(3,i,1) + f1 * dx(3)
factor_ee_gl_pderiv(4,i,1) = factor_ee_gl_pderiv(4,i,1) + f1 * dx(4) &
+ 2.d0 * b_vector(2) * grad_c2 * f1 * invdenom
factor_ee_gl_pderiv(1,i,2) = factor_ee_gl_pderiv(1,i,2) + f2 * dx(1)
factor_ee_gl_pderiv(2,i,2) = factor_ee_gl_pderiv(2,i,2) + f2 * dx(2)
factor_ee_gl_pderiv(3,i,2) = factor_ee_gl_pderiv(3,i,2) + f2 * dx(3)
factor_ee_gl_pderiv(4,i,2) = factor_ee_gl_pderiv(4,i,2) &
+ 2.d0 * f1 * b_vector(1) * (-invdenom * x * dx(4) - invdenom2 * grad_c2 * (1 - 2.d0 * x * b_vector(2)))
kf = 2.d0
x1 = x
x = 1.d0
do k=3, bord_num + 1
f = kf * x
factor_ee_gl_pderiv(1,i,k) = factor_ee_gl_pderiv(1,i,k) + f * x1 * dx(1)
factor_ee_gl_pderiv(2,i,k) = factor_ee_gl_pderiv(2,i,k) + f * x1 * dx(2)
factor_ee_gl_pderiv(3,i,k) = factor_ee_gl_pderiv(3,i,k) + f * x1 * dx(3)
factor_ee_gl_pderiv(4,i,k) = factor_ee_gl_pderiv(4,i,k) &
+ f * (x1 * dx(4) + (kf-1.d0) * grad_c2)
x = x*x1
kf = kf + 1.d0
end do
end do
end do
end do
factor_ee_gl_pderiv = factor_ee_gl_pderiv / dble(walk_num)
end function qmckl_compute_jastrow_champ_factor_ee_gl_pderiv_doc
3.2. Electron-nucleus component
3.2.1. Asymptotic component
Calculate the asymptotic component asymp_jasa to be subtracted from the final
electron-nucleus jastrow factor . The asymptotic component is calculated
via the a_vector and the electron-nucleus rescale factors rescale_factor_en:
where is the value of rescale_factor_en for the
nucleus type .
3.2.1.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_asymp_jasa(qmckl_context context,
double* const asymp_jasa,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_asymp_jasa(context, & asymp_jasa, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: asymp_jasa(size_max) end function qmckl_get_jastrow_champ_asymp_jasa end interface
3.2.1.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
aord_num |
int64_t |
in | Order of the a polynomial |
type_nucl_num |
int64_t |
in | Number of nucleus types |
a_vector |
double[type_nucl_num][aord_num+1] |
in | Values of a |
rescale_factor_en |
double[type_nucl_num] |
in | Factor to rescale en distances, by nucleus type |
asymp_jasa |
double[type_nucl_num] |
out | Asymptotic values of the electron-nucleus term |
function qmckl_compute_jastrow_champ_asymp_jasa(context, aord_num, type_nucl_num, a_vector, &
rescale_factor_en, asymp_jasa) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: aord_num
integer (c_int64_t) , intent(in) , value :: type_nucl_num
real (c_double ) , intent(in) :: a_vector(aord_num+1,type_nucl_num)
real (c_double ) , intent(in) :: rescale_factor_en(type_nucl_num)
real (c_double ) , intent(out) :: asymp_jasa(type_nucl_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, j, p
double precision :: kappa_inv, x, asym_one
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (aord_num < 0) then
info = QMCKL_INVALID_ARG_2
return
endif
do i=1,type_nucl_num
kappa_inv = 1.0d0 / rescale_factor_en(i)
asymp_jasa(i) = a_vector(1,i) * kappa_inv / (1.0d0 + a_vector(2,i) * kappa_inv)
x = kappa_inv
do p = 2, aord_num
x = x * kappa_inv
asymp_jasa(i) = asymp_jasa(i) + a_vector(p+1, i) * x
end do
end do
end function qmckl_compute_jastrow_champ_asymp_jasa
3.2.2. Electron-nucleus rescaled distances
en_distance_rescaled stores the matrix of the rescaled distances between
electrons and nuclei.
where is the matrix of electron-nucleus distances.
3.2.2.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_en_distance_rescaled(qmckl_context context,
double* const distance_rescaled,
const int64_t size_max);
3.2.2.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
type_nucl_num |
int64_t |
in | Number of nucleus types |
type_nucl_vector |
int64_t[nucl_num] |
in | Type of each nucleus |
rescale_factor_en |
double[type_nucl_num] |
in | Factor to rescale en distances, by nucleus type |
walk_num |
int64_t |
in | Number of walkers |
elec_coord |
double[3][walk_num][elec_num] |
in | Electron coordinates |
nucl_coord |
double[3][nucl_num] |
in | Nuclear coordinates |
en_distance_rescaled |
double[walk_num][nucl_num][elec_num] |
out | Rescaled electron-nucleus distances |
function qmckl_compute_en_distance_rescaled_doc(context, &
elec_num, nucl_num, type_nucl_num, &
type_nucl_vector, rescale_factor_en, walk_num, elec_coord, &
nucl_coord, en_distance_rescaled) &
bind(C) result(info)
use qmckl
implicit none
integer (qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: type_nucl_num
integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num)
real (c_double ) , intent(in) :: rescale_factor_en(type_nucl_num)
integer (c_int64_t) , intent(in) , value :: walk_num
real (c_double ) , intent(in) :: elec_coord(elec_num,walk_num,3)
real (c_double ) , intent(in) :: nucl_coord(nucl_num,3)
real (c_double ) , intent(out) :: en_distance_rescaled(elec_num,nucl_num,walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, k
double precision :: coord(3)
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (nucl_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_5
return
endif
do i=1, nucl_num
coord(1:3) = nucl_coord(i,1:3)
do k=1,walk_num
info = qmckl_distance_rescaled(context, 'T', 'N', elec_num, 1_8, &
elec_coord(1,k,1), elec_num*walk_num, coord, 3_8, &
en_distance_rescaled(1,i,k), elec_num, rescale_factor_en(type_nucl_vector(i)+1))
if (info /= QMCKL_SUCCESS) then
return
endif
end do
end do
end function qmckl_compute_en_distance_rescaled_doc
3.2.3. Electron-nucleus rescaled distance gradients and Laplacian with respect to electron coordinates
The rescaled distances, represented by
are differentiated with respect to the electron coordinates.
This information is stored in the tensor
en_distance_rescaled_gl. The initial three sequential
elements of this three-index tensor provide the , , and
direction derivatives, while the fourth index corresponds to the Laplacian.
3.2.3.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_en_distance_rescaled_gl(qmckl_context context,
double* const distance_rescaled_gl,
const int64_t size_max);
3.2.3.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
type_nucl_num |
int64_t |
in | Number of nucleus types |
type_nucl_vector |
int64_t[nucl_num] |
in | Type of each nucleus |
rescale_factor_en |
double[type_nucl_num] |
in | Factor to rescale en distances, by nucleus type |
walk_num |
int64_t |
in | Number of walkers |
elec_coord |
double[3][walk_num][elec_num] |
in | Electron coordinates |
nucl_coord |
double[3][nucl_num] |
in | Nuclear coordinates |
en_distance_rescaled_gl |
double[walk_num][nucl_num][elec_num][4] |
out | Derivatives of the rescaled electron-nucleus distances |
function qmckl_compute_en_distance_rescaled_gl_doc(context, elec_num, nucl_num, &
type_nucl_num, type_nucl_vector, rescale_factor_en, walk_num, elec_coord, &
nucl_coord, en_distance_rescaled_gl) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in) :: context
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: type_nucl_num
integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num)
real (c_double ) , intent(in) :: rescale_factor_en(nucl_num)
integer (c_int64_t) , intent(in) , value :: walk_num
real (c_double ) , intent(in) :: elec_coord(elec_num,walk_num,3)
real (c_double ) , intent(in) :: nucl_coord(nucl_num,3)
real (c_double ) , intent(out) :: en_distance_rescaled_gl(4,elec_num,nucl_num,walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, k
double precision :: coord(3)
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (nucl_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_5
return
endif
do i=1, nucl_num
coord(1:3) = nucl_coord(i,1:3)
do k=1,walk_num
info = qmckl_distance_rescaled_gl(context, 'T', 'T', elec_num, 1_8, &
elec_coord(1,k,1), elec_num*walk_num, coord, 1_8, &
en_distance_rescaled_gl(1,1,i,k), elec_num, rescale_factor_en(type_nucl_vector(i)+1))
if (info /= QMCKL_SUCCESS) then
return
endif
end do
end do
end function qmckl_compute_en_distance_rescaled_gl_doc
3.2.4. Electron-nucleus component
Calculate the electron-nucleus jastrow component factor_en using the a_vector
coefficients and the electron-nucleus rescaled distances en_distance_rescaled.
Writing for the rescaled distance between electron and
nucleus :
3.2.4.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_factor_en(qmckl_context context,
double* const factor_en,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_en (context, & factor_en, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: factor_en(size_max) end function qmckl_get_jastrow_champ_factor_en end interface
3.2.4.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
type_nucl_num |
int64_t |
in | Number of nucleus types |
type_nucl_vector |
int64_t[nucl_num] |
in | Type of each nucleus |
aord_num |
int64_t |
in | Number of a coefficients |
a_vector |
double[type_nucl_num][aord_num+1] |
in | Values of a |
en_distance_rescaled |
double[walk_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances |
asymp_jasa |
double[type_nucl_num] |
in | Asymptotic values of the electron-nucleus term |
factor_en |
double[walk_num] |
out | Value of the electron-nucleus term |
function qmckl_compute_jastrow_champ_factor_en_doc( &
context, walk_num, elec_num, nucl_num, type_nucl_num, &
type_nucl_vector, aord_num, a_vector, &
en_distance_rescaled, asymp_jasa, factor_en) &
bind(C) result(info)
use qmckl
implicit none
integer (qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: type_nucl_num
integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num)
integer (c_int64_t) , intent(in) , value :: aord_num
real (c_double ) , intent(in) :: a_vector(aord_num+1,type_nucl_num)
real (c_double ) , intent(in) :: en_distance_rescaled(elec_num,nucl_num,walk_num)
real (c_double ) , intent(in) :: asymp_jasa(type_nucl_num)
real (c_double ) , intent(out) :: factor_en(walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, a, p, nw
double precision :: x, power_ser
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (nucl_num <= 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if (type_nucl_num <= 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if (aord_num < 0) then
info = QMCKL_INVALID_ARG_7
return
endif
do nw =1, walk_num
factor_en(nw) = 0.0d0
do a = 1, nucl_num
do i = 1, elec_num
x = en_distance_rescaled(i, a, nw)
factor_en(nw) = factor_en(nw) + a_vector(1, type_nucl_vector(a)+1) * x / &
(1.0d0 + a_vector(2, type_nucl_vector(a)+1) * x) - asymp_jasa(type_nucl_vector(a)+1)
do p = 2, aord_num
x = x * en_distance_rescaled(i, a, nw)
factor_en(nw) = factor_en(nw) + a_vector(p + 1, type_nucl_vector(a)+1) * x
end do
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_en_doc
3.2.5. Derivative
The derivative of the electron-nucleus jastrow component factor_en_gl
with respect to the electron coordinates is calculated in the function
qmckl_compute_jastrow_champ_factor_en_gl, using the
en_distance_rescaled and en_distance_rescaled_gl arrays which are
already calculated previously. Writing for the
rescaled distance between electron and nucleus , the
gradient is:
and the Laplacian is:
3.2.5.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_factor_en_gl(qmckl_context context,
double* const factor_en_gl,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_en_gl (context, & factor_en_gl, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: factor_en_gl(size_max) end function qmckl_get_jastrow_champ_factor_en_gl end interface
3.2.5.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
type_nucl_num |
int64_t |
in | Number of nucleus types |
type_nucl_vector |
int64_t[nucl_num] |
in | Type of each nucleus |
aord_num |
int64_t |
in | Number of a coefficients |
a_vector |
double[type_nucl_num][aord_num+1] |
in | Values of a |
en_distance_rescaled |
double[walk_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances |
en_distance_rescaled_gl |
double[walk_num][nucl_num][elec_num][4] |
in | Derivatives of the rescaled electron-nucleus distances |
factor_en_gl |
double[walk_num][4][elec_num] |
out | Gradient and Laplacian of the electron-nucleus term |
function qmckl_compute_jastrow_champ_factor_en_gl_doc( &
context, walk_num, elec_num, nucl_num, type_nucl_num, &
type_nucl_vector, aord_num, a_vector, &
en_distance_rescaled, en_distance_rescaled_gl, factor_en_gl) &
bind(C) result(info)
use qmckl
implicit none
integer (qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: type_nucl_num
integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num)
integer (c_int64_t) , intent(in) , value :: aord_num
real (c_double ) , intent(in) :: a_vector(aord_num+1,type_nucl_num)
real (c_double ) , intent(in) :: en_distance_rescaled(elec_num,nucl_num,walk_num)
real (c_double ) , intent(in) :: en_distance_rescaled_gl(4, elec_num,nucl_num,walk_num)
real (c_double ) , intent(out) :: factor_en_gl(elec_num,4,walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, a, k, nw, ii
double precision :: x, x1, kf
double precision :: denom, invdenom, invdenom2, f
double precision :: grad_c2
double precision :: dx(4)
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (nucl_num <= 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if (aord_num < 0) then
info = QMCKL_INVALID_ARG_7
return
endif
do nw =1, walk_num
factor_en_gl(:,:,nw) = 0.0d0
do a = 1, nucl_num
do i = 1, elec_num
x = en_distance_rescaled(i,a,nw)
if(abs(x) < 1.d-12) continue
denom = 1.0d0 + a_vector(2, type_nucl_vector(a)+1) * x
invdenom = 1.0d0 / denom
invdenom2 = invdenom*invdenom
dx(1) = en_distance_rescaled_gl(1,i,a,nw)
dx(2) = en_distance_rescaled_gl(2,i,a,nw)
dx(3) = en_distance_rescaled_gl(3,i,a,nw)
dx(4) = en_distance_rescaled_gl(4,i,a,nw)
f = a_vector(1, type_nucl_vector(a)+1) * invdenom2
grad_c2 = dx(1)*dx(1) + dx(2)*dx(2) + dx(3)*dx(3)
factor_en_gl(i,1,nw) = factor_en_gl(i,1,nw) + f * dx(1)
factor_en_gl(i,2,nw) = factor_en_gl(i,2,nw) + f * dx(2)
factor_en_gl(i,3,nw) = factor_en_gl(i,3,nw) + f * dx(3)
factor_en_gl(i,4,nw) = factor_en_gl(i,4,nw) &
+ f * (dx(4) - 2.d0 * a_vector(2, type_nucl_vector(a)+1) * grad_c2 * invdenom)
kf = 2.d0
x1 = x
x = 1.d0
do k=2, aord_num
f = a_vector(k+1,type_nucl_vector(a)+1) * kf * x
factor_en_gl(i,1,nw) = factor_en_gl(i,1,nw) + f * x1 * dx(1)
factor_en_gl(i,2,nw) = factor_en_gl(i,2,nw) + f * x1 * dx(2)
factor_en_gl(i,3,nw) = factor_en_gl(i,3,nw) + f * x1 * dx(3)
factor_en_gl(i,4,nw) = factor_en_gl(i,4,nw) &
+ f * (x1 * dx(4) + (kf-1.d0) * grad_c2)
x = x*x1
kf = kf + 1.d0
end do
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_en_gl_doc
3.2.5.3. Test
3.2.6. Parameter Derivative of the Asymptotic component
The derivatives of the asymptotic component asymp_jasa with respect
to the parameters a_vector are stored in asymp_jasa_pderiv. They
are computed from the a_vector and the electron-nucleus rescale
factors rescale_factor_en. For each nucleus type :
3.2.6.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_asymp_jasa_pderiv(qmckl_context context,
double* const asymp_jasa_pderiv,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_asymp_jasa_pderiv(context, & asymp_jasa_pderiv, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: asymp_jasa_pderiv(size_max) end function qmckl_get_jastrow_champ_asymp_jasa_pderiv end interface
3.2.6.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
aord_num |
int64_t |
in | Order of the a polynomial |
type_nucl_num |
int64_t |
in | Number of nucleus types |
a_vector |
double[type_nucl_num][aord_num+1] |
in | Values of a |
rescale_factor_en |
double[type_nucl_num] |
in | Factor to rescale en distances, by nucleus type |
asymp_jasa_pderiv |
double[type_nucl_num][aord_num+1] |
out | Parameter derivatives of the electron-nucleus asymptotic values |
function qmckl_compute_jastrow_champ_asymp_jasa_pderiv(context, aord_num, type_nucl_num, a_vector, &
rescale_factor_en, asymp_jasa_pderiv) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: aord_num
integer (c_int64_t) , intent(in) , value :: type_nucl_num
real (c_double ) , intent(in) :: a_vector(aord_num+1,type_nucl_num)
real (c_double ) , intent(in) :: rescale_factor_en(type_nucl_num)
real (c_double ) , intent(out) :: asymp_jasa_pderiv(aord_num+1, type_nucl_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, j, p
double precision :: kappa_inv, x, asym_one
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (aord_num < 0) then
info = QMCKL_INVALID_ARG_2
return
endif
do i=1,type_nucl_num
kappa_inv = 1.0d0 / rescale_factor_en(i)
asymp_jasa_pderiv(1,i) = kappa_inv / (1.0d0 + a_vector(2,i) * kappa_inv)
asymp_jasa_pderiv(2,i) = - a_vector(1,i) * kappa_inv**2 / (1.0d0 + a_vector(2,i) * kappa_inv)**2
x = kappa_inv
do p = 2, aord_num
x = x * kappa_inv
asymp_jasa_pderiv(p+1, i) = x
end do
end do
end function qmckl_compute_jastrow_champ_asymp_jasa_pderiv
3.2.7. Parameter Derivative
The parameter derivatives of the electron-nucleus jastrow component
factor_en are stored in factor_en_pderiv. They are computed from
the a_vector coefficients and the electron-nucleus rescaled
distances en_distance_rescaled. Writing for the
rescaled distance between electron and nucleus , and
for the nucleus type:
In these expressions runs only over the nuclei of type . The result is accumulated over the walkers and divided by the number of walkers.
3.2.7.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_factor_en_pderiv(qmckl_context context,
double* const factor_en_pderiv,
const int64_t size_max);
interface
integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_en_pderiv (context, &
factor_en_pderiv, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context) , intent(in), value :: context
integer(c_int64_t), intent(in), value :: size_max
real(c_double), intent(out) :: factor_en_pderiv(size_max)
end function qmckl_get_jastrow_champ_factor_en_pderiv
end interface
3.2.7.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
type_nucl_num |
int64_t |
in | Number of nucleus types |
type_nucl_vector |
int64_t[nucl_num] |
in | Type of each nucleus |
aord_num |
int64_t |
in | Number of a coefficients |
a_vector |
double[type_nucl_num][aord_num+1] |
in | Values of a |
en_distance_rescaled |
double[walk_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances |
asymp_jasa_pderiv |
double[type_nucl_num][aord_num+1] |
in | Parameter derivatives of the asymptotic values |
factor_en_pderiv |
double[type_nucl_num][aord_num+1] |
out | Parameter derivatives of the electron-nucleus term |
function qmckl_compute_jastrow_champ_factor_en_pderiv_doc( &
context, walk_num, elec_num, nucl_num, type_nucl_num, &
type_nucl_vector, aord_num, a_vector, &
en_distance_rescaled, asymp_jasa_pderiv, factor_en_pderiv) &
bind(C) result(info)
use qmckl
implicit none
integer (qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: type_nucl_num
integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num)
integer (c_int64_t) , intent(in) , value :: aord_num
real (c_double ) , intent(in) :: a_vector(aord_num+1,type_nucl_num)
real (c_double ) , intent(in) :: en_distance_rescaled(elec_num,nucl_num,walk_num)
real (c_double ) , intent(in) :: asymp_jasa_pderiv(aord_num+1,type_nucl_num)
real (c_double ) , intent(out) :: factor_en_pderiv(aord_num+1,type_nucl_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, a, p, nw
double precision :: x, power_ser
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (nucl_num <= 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if (type_nucl_num <= 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if (aord_num < 0) then
info = QMCKL_INVALID_ARG_7
return
endif
factor_en_pderiv = 0.0d0
do nw =1, walk_num
do a = 1, nucl_num
do i = 1, elec_num
x = en_distance_rescaled(i, a, nw)
factor_en_pderiv(1,type_nucl_vector(a)+1) = factor_en_pderiv(1,type_nucl_vector(a)+1) + &
x / (1.0d0 + a_vector(2, type_nucl_vector(a)+1) * x) - asymp_jasa_pderiv(1,type_nucl_vector(a)+1)
factor_en_pderiv(2,type_nucl_vector(a)+1) = factor_en_pderiv(2,type_nucl_vector(a)+1) - &
a_vector(1, type_nucl_vector(a)+1) * x**2 / (1.0d0 + a_vector(2, type_nucl_vector(a)+1) * x)**2 &
- asymp_jasa_pderiv(2,type_nucl_vector(a)+1)
do p = 2, aord_num
x = x * en_distance_rescaled(i, a, nw)
factor_en_pderiv(p+1,type_nucl_vector(a)+1) = factor_en_pderiv(p+1,type_nucl_vector(a)+1) + x &
- asymp_jasa_pderiv(p+1,type_nucl_vector(a)+1)
end do
end do
end do
end do
factor_en_pderiv = factor_en_pderiv / dble(walk_num)
end function qmckl_compute_jastrow_champ_factor_en_pderiv_doc
3.2.8. Parameter Derivative of the gradient and Laplacian
The derivatives of the gradient and Laplacian of factor_en_gl with
respect to the a coefficients are stored in
factor_en_gl_pderiv, with the nucleus type first, then the
parameter index, the electron index, and last the four coordinate
components (x, y, z, Laplacian). Writing for the rescaled
distance between electron and nucleus , and , the sums run over the electrons and over the
nuclei of type :
The sums run over all walkers and are divided by walk_num.
3.2.8.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_factor_en_gl_pderiv(qmckl_context context,
double* const factor_en_gl_pderiv,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_en_gl_pderiv (context, & factor_en_gl_pderiv, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: factor_en_gl_pderiv(size_max) end function qmckl_get_jastrow_champ_factor_en_gl_pderiv end interface
3.2.8.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
type_nucl_num |
int64_t |
in | Number of nucleus types |
type_nucl_vector |
int64_t[nucl_num] |
in | Type of each nucleus |
aord_num |
int64_t |
in | Number of a coefficients |
a_vector |
double[type_nucl_num][aord_num+1] |
in | Values of a |
en_distance_rescaled |
double[walk_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances |
en_distance_rescaled_gl |
double[walk_num][nucl_num][elec_num][4] |
in | Derivatives of the rescaled electron-nucleus distances |
factor_en_gl_pderiv |
double[type_nucl_num][aord_num+1][elec_num][4] |
out | Parameter derivatives of the gradient and Laplacian: electron-nucleus part |
function qmckl_compute_jastrow_champ_factor_en_gl_pderiv_doc( &
context, walk_num, elec_num, nucl_num, type_nucl_num, &
type_nucl_vector, aord_num, a_vector, &
en_distance_rescaled, en_distance_rescaled_gl, factor_en_gl_pderiv) &
bind(C) result(info)
use qmckl
implicit none
integer (qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: type_nucl_num
integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num)
integer (c_int64_t) , intent(in) , value :: aord_num
real (c_double ) , intent(in) :: a_vector(aord_num+1,type_nucl_num)
real (c_double ) , intent(in) :: en_distance_rescaled(elec_num,nucl_num,walk_num)
real (c_double ) , intent(in) :: en_distance_rescaled_gl(4, elec_num,nucl_num,walk_num)
real (c_double ) , intent(out) :: factor_en_gl_pderiv(4,elec_num,aord_num+1,type_nucl_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, a, k, nw, ii
double precision :: x, x1, kf
double precision :: denom, invdenom, invdenom2, invdenom3, f
double precision :: grad_c2
double precision :: dx(4)
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (nucl_num <= 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if (type_nucl_num <= 0) then
info = QMCKL_INVALID_ARG_5
return
endif
if (aord_num < 0) then
info = QMCKL_INVALID_ARG_7
return
endif
factor_en_gl_pderiv = 0.0d0
do nw =1, walk_num
do a = 1, nucl_num
do i = 1, elec_num
x = en_distance_rescaled(i,a,nw)
if(abs(x) < 1.d-12) continue
denom = 1.0d0 + a_vector(2, type_nucl_vector(a)+1) * x
invdenom = 1.0d0 / denom
invdenom2 = invdenom*invdenom
invdenom3 = invdenom2*invdenom
dx(1) = en_distance_rescaled_gl(1,i,a,nw)
dx(2) = en_distance_rescaled_gl(2,i,a,nw)
dx(3) = en_distance_rescaled_gl(3,i,a,nw)
dx(4) = en_distance_rescaled_gl(4,i,a,nw)
f = invdenom2
grad_c2 = dx(1)*dx(1) + dx(2)*dx(2) + dx(3)*dx(3)
factor_en_gl_pderiv(1,i,1,type_nucl_vector(a)+1) = factor_en_gl_pderiv(1,i,1,type_nucl_vector(a)+1) + f * dx(1)
factor_en_gl_pderiv(2,i,1,type_nucl_vector(a)+1) = factor_en_gl_pderiv(2,i,1,type_nucl_vector(a)+1) + f * dx(2)
factor_en_gl_pderiv(3,i,1,type_nucl_vector(a)+1) = factor_en_gl_pderiv(3,i,1,type_nucl_vector(a)+1) + f * dx(3)
factor_en_gl_pderiv(4,i,1,type_nucl_vector(a)+1) = factor_en_gl_pderiv(4,i,1,type_nucl_vector(a)+1) &
+ f * (dx(4) - 2.d0 * a_vector(2, type_nucl_vector(a)+1) * grad_c2 * invdenom)
f = -2.d0 * a_vector(1, type_nucl_vector(a)+1) * invdenom3
factor_en_gl_pderiv(1,i,2,type_nucl_vector(a)+1) = factor_en_gl_pderiv(1,i,2,type_nucl_vector(a)+1) + f * x * dx(1)
factor_en_gl_pderiv(2,i,2,type_nucl_vector(a)+1) = factor_en_gl_pderiv(2,i,2,type_nucl_vector(a)+1) + f * x * dx(2)
factor_en_gl_pderiv(3,i,2,type_nucl_vector(a)+1) = factor_en_gl_pderiv(3,i,2,type_nucl_vector(a)+1) + f * x * dx(3)
factor_en_gl_pderiv(4,i,2,type_nucl_vector(a)+1) = factor_en_gl_pderiv(4,i,2,type_nucl_vector(a)+1) &
+ f * (x * dx(4) + invdenom * (grad_c2 - 2 * grad_c2 * x * a_vector(2, type_nucl_vector(a)+1)))
kf = 2.d0
x1 = x
x = 1.d0
do k=3, aord_num+1
f = kf * x
factor_en_gl_pderiv(1,i,k,type_nucl_vector(a)+1) = factor_en_gl_pderiv(1,i,k,type_nucl_vector(a)+1) + f * x1 * dx(1)
factor_en_gl_pderiv(2,i,k,type_nucl_vector(a)+1) = factor_en_gl_pderiv(2,i,k,type_nucl_vector(a)+1) + f * x1 * dx(2)
factor_en_gl_pderiv(3,i,k,type_nucl_vector(a)+1) = factor_en_gl_pderiv(3,i,k,type_nucl_vector(a)+1) + f * x1 * dx(3)
factor_en_gl_pderiv(4,i,k,type_nucl_vector(a)+1) = factor_en_gl_pderiv(4,i,k,type_nucl_vector(a)+1) &
+ f * (x1 * dx(4) + (kf-1.d0) * grad_c2)
x = x*x1
kf = kf + 1.d0
end do
end do
end do
end do
factor_en_gl_pderiv = factor_en_gl_pderiv / dble(walk_num)
end function qmckl_compute_jastrow_champ_factor_en_gl_pderiv_doc
3.3. Electron-electron-nucleus component
3.3.1. Electron-electron rescaled distances in
een_rescaled_e stores the table of the rescaled distances between all
pairs of electrons and raised to the power defined by cord_num:
where is the matrix of electron-electron distances.
3.3.1.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_een_rescaled_e(qmckl_context context,
double* const een_rescaled_e,
const int64_t size_max);
3.3.1.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
cord_num |
int64_t |
in | Order of polynomials |
rescale_factor_ee |
double |
in | Factor to rescale ee distances |
ee_distance |
double[walk_num][elec_num][elec_num] |
in | Electron-electron distances for each walker |
een_rescaled_e |
double[walk_num][0:cord_num][elec_num][elec_num] |
out | Electron-electron rescaled distances for each walker |
function qmckl_compute_een_rescaled_e_doc( &
context, walk_num, elec_num, cord_num, rescale_factor_ee, &
ee_distance, een_rescaled_e) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: cord_num
real (c_double ) , intent(in) , value :: rescale_factor_ee
real (c_double ) , intent(in) :: ee_distance(elec_num,elec_num,walk_num)
real (c_double ) , intent(out) :: een_rescaled_e(elec_num,elec_num,0:cord_num,walk_num)
integer(qmckl_exit_code) :: info
double precision :: x
integer*8 :: i, j, k, l, nw
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (cord_num < 0) then
info = QMCKL_INVALID_ARG_4
return
endif
do nw = 1, walk_num
do l = 0, cord_num
do j = 1, elec_num
do i = 1, elec_num
een_rescaled_e(i, j, l, nw) = dexp(-rescale_factor_ee * ee_distance(i, j, nw))**l
end do
een_rescaled_e(j, j, l, nw) = 0.d0
end do
end do
end do
end function qmckl_compute_een_rescaled_e_doc
3.3.1.3. Test
3.3.2. Electron-electron rescaled distances derivatives in
een_rescaled_e_gl stores the table of the derivatives of the
rescaled distances between all pairs of electrons and raised to the
power defined by cord_num. Here we take its derivatives
required for the een jastrowchamp.
Derivatives are set to zero at to avoid NaNs.
3.3.2.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_een_rescaled_e_gl(qmckl_context context,
double* const een_rescaled_e_gl,
const int64_t size_max);
3.3.2.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
cord_num |
int64_t |
in | Order of polynomials |
rescale_factor_ee |
double |
in | Factor to rescale ee distances |
coord_ee |
double[3][walk_num][elec_num] |
in | Electron coordinates |
ee_distance |
double[walk_num][elec_num][elec_num] |
in | Electron-electron distances |
een_rescaled_e |
double[walk_num][0:cord_num][elec_num][elec_num] |
in | Rescaled electron-electron distances raised to the powers defined by cord |
een_rescaled_e_gl |
double[walk_num][0:cord_num][elec_num][4][elec_num] |
out | Derivatives of the rescaled electron-electron distances |
function qmckl_compute_jastrow_champ_factor_een_rescaled_e_gl_doc( &
context, walk_num, elec_num, cord_num, rescale_factor_ee, &
coord_ee, ee_distance, een_rescaled_e, een_rescaled_e_gl) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer(c_int64_t) , intent(in), value :: walk_num
integer(c_int64_t) , intent(in), value :: elec_num
integer(c_int64_t) , intent(in), value :: cord_num
real(c_double) , intent(in), value :: rescale_factor_ee
real(c_double) , intent(in) :: coord_ee(elec_num,walk_num,3)
real(c_double) , intent(in) :: ee_distance(elec_num,elec_num,walk_num)
real(c_double) , intent(in) :: een_rescaled_e(elec_num,elec_num,0:cord_num,walk_num)
real(c_double) , intent(out) :: een_rescaled_e_gl(elec_num,4,elec_num,0:cord_num,walk_num)
integer(qmckl_exit_code) :: info
double precision, allocatable :: elec_dist_gl(:,:,:)
double precision :: x, kappa_l
integer*8 :: i, j, k, l, nw, ii
double precision :: rij_inv(elec_num)
allocate(elec_dist_gl(elec_num, 4, elec_num))
elec_dist_gl = 0.d0
een_rescaled_e_gl = 0.d0
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (cord_num < 0) then
info = QMCKL_INVALID_ARG_4
return
endif
do nw = 1, walk_num
! Prepare table of exponentiated distances raised to appropriate power
do j = 1, elec_num
do i = 1, j-1
rij_inv(i) = 1.0d0 / ee_distance(i, j, nw)
enddo
rij_inv(j) = 0.0d0
do i = j+1, elec_num
rij_inv(i) = 1.0d0 / ee_distance(i, j, nw)
enddo
do i = 1, elec_num
do ii = 1, 3
elec_dist_gl(i, ii, j) = (coord_ee(i, nw, ii) - coord_ee(j, nw, ii)) * rij_inv(i)
end do
elec_dist_gl(i, 4, j) = 2.0d0 * rij_inv(i)
end do
end do
! Not necessary: should be set to zero by qmckl_malloc
een_rescaled_e_gl(:,:,:,0,nw) = 0.d0
do l = 1, cord_num
kappa_l = -dble(l) * rescale_factor_ee
do j = 1, elec_num
do i = 1, elec_num
if (i /= j) then
een_rescaled_e_gl(i, 1, j, l, nw) = kappa_l * elec_dist_gl(i, 1, j) * een_rescaled_e(i,j,l,nw)
een_rescaled_e_gl(i, 2, j, l, nw) = kappa_l * elec_dist_gl(i, 2, j) * een_rescaled_e(i,j,l,nw)
een_rescaled_e_gl(i, 3, j, l, nw) = kappa_l * elec_dist_gl(i, 3, j) * een_rescaled_e(i,j,l,nw)
een_rescaled_e_gl(i, 4, j, l, nw) = kappa_l * (elec_dist_gl(i, 4, j) + kappa_l) * een_rescaled_e(i,j,l,nw)
else
een_rescaled_e_gl(i, 1, j, l, nw) = 0.d0
een_rescaled_e_gl(i, 2, j, l, nw) = 0.d0
een_rescaled_e_gl(i, 3, j, l, nw) = 0.d0
een_rescaled_e_gl(i, 4, j, l, nw) = 0.d0
end if
end do
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_een_rescaled_e_gl_doc
3.3.3. Electron-nucleus rescaled distances in
een_rescaled_n stores the table of the rescaled distances between
electrons and nuclei raised to the power defined by cord_num:
where is the matrix of electron-nucleus distances.
3.3.3.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_een_rescaled_n(qmckl_context context,
double* const een_rescaled_n,
const int64_t size_max);
3.3.3.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
type_nucl_num |
int64_t |
in | Number of nucleus types |
type_nucl_vector |
int64_t[nucl_num] |
in | Type of each nucleus |
cord_num |
int64_t |
in | Order of polynomials |
rescale_factor_en |
double[type_nucl_num] |
in | Factor to rescale en distances, by nucleus type |
en_distance |
double[walk_num][elec_num][nucl_num] |
in | Electron-nucleus distances |
een_rescaled_n |
double[walk_num][0:cord_num][nucl_num][elec_num] |
out | Rescaled electron-nucleus distances |
function qmckl_compute_een_rescaled_n( &
context, walk_num, elec_num, nucl_num, &
type_nucl_num, type_nucl_vector, cord_num, rescale_factor_en, &
en_distance, een_rescaled_n) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: type_nucl_num
integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num)
integer (c_int64_t) , intent(in) , value :: cord_num
real (c_double ) , intent(in) :: rescale_factor_en(nucl_num)
real (c_double ) , intent(in) :: en_distance(nucl_num,elec_num,walk_num)
real (c_double ) , intent(out) :: een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)
integer(qmckl_exit_code) :: info
double precision :: x
integer*8 :: i, a, k, l, nw
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (nucl_num <= 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if (cord_num < 0) then
info = QMCKL_INVALID_ARG_5
return
endif
do nw = 1, walk_num
! prepare the actual een table
een_rescaled_n(:, :, 0, nw) = 1.0d0
do a = 1, nucl_num
do i = 1, elec_num
een_rescaled_n(i, a, 1, nw) = dexp(-rescale_factor_en(type_nucl_vector(a)+1) * en_distance(a, i, nw))
end do
end do
do l = 2, cord_num
do a = 1, nucl_num
do i = 1, elec_num
een_rescaled_n(i, a, l, nw) = een_rescaled_n(i, a, l - 1, nw) * een_rescaled_n(i, a, 1, nw)
end do
end do
end do
end do
end function qmckl_compute_een_rescaled_n
3.3.4. Electron-nucleus rescaled distances derivatives in
een_rescaled_n_gl stores the table of the derivatives of the
rescaled distances between all electron-nucleus pairs and raised to the
power defined by cord_num. Here we take its derivatives
required for the een jastrowchamp.
3.3.4.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_een_rescaled_n_gl(qmckl_context context,
double* const een_rescaled_n_gl,
const int64_t size_max);
3.3.4.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
type_nucl_num |
int64_t |
in | Number of nucleus types |
type_nucl_vector |
int64_t[nucl_num] |
in | Type of each nucleus |
cord_num |
int64_t |
in | Order of polynomials |
rescale_factor_en |
double[type_nucl_num] |
in | Factor to rescale en distances, by nucleus type |
coord_ee |
double[3][walk_num][elec_num] |
in | Electron coordinates |
coord_n |
double[3][nucl_num] |
in | Nuclear coordinates |
en_distance |
double[walk_num][elec_num][nucl_num] |
in | Electron-nucleus distances |
een_rescaled_n |
double[walk_num][0:cord_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances |
een_rescaled_n_gl |
double[walk_num][0:cord_num][nucl_num][4][elec_num] |
out | Derivatives of the rescaled electron-nucleus distances |
function qmckl_compute_jastrow_champ_factor_een_rescaled_n_gl( &
context, walk_num, elec_num, nucl_num, type_nucl_num, type_nucl_vector, &
cord_num, rescale_factor_en, &
coord_ee, coord_n, en_distance, een_rescaled_n, een_rescaled_n_gl) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: type_nucl_num
integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num)
integer (c_int64_t) , intent(in) , value :: cord_num
real (c_double ) , intent(in) :: rescale_factor_en(nucl_num)
real (c_double ) , intent(in) :: coord_ee(elec_num,walk_num,3)
real (c_double ) , intent(in) :: coord_n(nucl_num,3)
real (c_double ) , intent(in) :: en_distance(nucl_num,elec_num,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(out) :: een_rescaled_n_gl(elec_num,4,nucl_num,0:cord_num,walk_num)
integer(qmckl_exit_code) :: info
double precision,allocatable :: elnuc_dist_gl(:,:,:)
double precision :: x, ria_inv, kappa_l
integer*8 :: i, a, k, l, nw, ii
allocate(elnuc_dist_gl(elec_num, 4, nucl_num))
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_3
return
endif
if (nucl_num <= 0) then
info = QMCKL_INVALID_ARG_4
return
endif
if (cord_num < 0) then
info = QMCKL_INVALID_ARG_5
return
endif
! Prepare table of exponentiated distances raised to appropriate power
een_rescaled_n_gl = 0.0d0
do nw = 1, walk_num
! prepare the actual een table
do a = 1, nucl_num
do i = 1, elec_num
ria_inv = 1.0d0 / en_distance(a, i, nw)
do ii = 1, 3
elnuc_dist_gl(i, ii, a) = (coord_ee(i, nw, ii) - coord_n(a, ii)) * ria_inv
end do
elnuc_dist_gl(i, 4, a) = 2.0d0 * ria_inv
end do
end do
do l = 0, cord_num
do a = 1, nucl_num
kappa_l = - dble(l) * rescale_factor_en(type_nucl_vector(a)+1)
do i = 1, elec_num
een_rescaled_n_gl(i, 1, a, l, nw) = kappa_l * elnuc_dist_gl(i, 1, a)
een_rescaled_n_gl(i, 2, a, l, nw) = kappa_l * elnuc_dist_gl(i, 2, a)
een_rescaled_n_gl(i, 3, a, l, nw) = kappa_l * elnuc_dist_gl(i, 3, a)
een_rescaled_n_gl(i, 4, a, l, nw) = kappa_l * elnuc_dist_gl(i, 4, a)
een_rescaled_n_gl(i, 4, a, l, nw) = een_rescaled_n_gl(i, 4, a, l, nw) &
+ een_rescaled_n_gl(i, 1, a, l, nw) * een_rescaled_n_gl(i, 1, a, l, nw) &
+ een_rescaled_n_gl(i, 2, a, l, nw) * een_rescaled_n_gl(i, 2, a, l, nw) &
+ een_rescaled_n_gl(i, 3, a, l, nw) * een_rescaled_n_gl(i, 3, a, l, nw)
een_rescaled_n_gl(i, 1, a, l, nw) = een_rescaled_n_gl(i, 1, a, l, nw) * &
een_rescaled_n(i, a, l, nw)
een_rescaled_n_gl(i, 2, a, l, nw) = een_rescaled_n_gl(i, 2, a, l, nw) * &
een_rescaled_n(i, a, l, nw)
een_rescaled_n_gl(i, 3, a, l, nw) = een_rescaled_n_gl(i, 3, a, l, nw) * &
een_rescaled_n(i, a, l, nw)
een_rescaled_n_gl(i, 4, a, l, nw) = een_rescaled_n_gl(i, 4, a, l, nw) * &
een_rescaled_n(i, a, l, nw)
end do
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_een_rescaled_n_gl
3.3.5. Temporary arrays for electron-electron-nucleus Jastrow
Prepare c_vector_full and lkpm_combined_index tables required for the
calculation of the three-body jastrow factor_een and its derivative
factor_een_gl.
The array tmp_c corresponds to the tensor defined at the
beginning of this section:
3.3.5.1. Compute dimcvector
Computes the dimension of the vector of parameters.
| Number of parameters | |
| 1 | 0 |
| 2 | 2 |
| 3 | 6 |
| 4 | 13 |
| 5 | 23 |
| 6 | 37 |
| 7 | 55 |
| 8 | 78 |
| 9 | 106 |
| 10 | 140 |
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
cord_num |
int64_t |
in | Order of polynomials |
dim_c_vector |
int64_t |
out | Number of unique C coefficients |
function qmckl_compute_dim_c_vector_doc( &
context, cord_num, dim_c_vector) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: cord_num
integer (c_int64_t) , intent(out) :: dim_c_vector
integer(qmckl_exit_code) :: info
double precision :: x
integer*8 :: i, a, k, l, p, lmax
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (cord_num < 0) then
info = QMCKL_INVALID_ARG_2
return
endif
dim_c_vector = 0
do p = 2, cord_num
do k = p - 1, 0, -1
if (k .ne. 0) then
lmax = p - k
else
lmax = p - k - 2
endif
do l = lmax, 0, -1
if (iand(p - k - l, 1_8) == 1) cycle
dim_c_vector = dim_c_vector + 1
end do
end do
end do
end function qmckl_compute_dim_c_vector_doc
3.3.5.2. Get
3.3.5.3. Compute cvectorfull
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
nucl_num |
int64_t |
in | Number of nuclei |
dim_c_vector |
int64_t |
in | Number of unique C coefficients |
type_nucl_num |
int64_t |
in | Number of nucleus types |
type_nucl_vector |
int64_t[nucl_num] |
in | Type of each nucleus |
c_vector |
double[dim_c_vector][type_nucl_num] |
in | C coefficients, by nucleus type |
c_vector_full |
double[dim_c_vector][nucl_num] |
out | C coefficients expanded over all nuclei |
function qmckl_compute_c_vector_full_doc( &
context, nucl_num, dim_c_vector, type_nucl_num, &
type_nucl_vector, c_vector, c_vector_full) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: dim_c_vector
integer (c_int64_t) , intent(in) , value :: type_nucl_num
integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num)
real (c_double ) , intent(in) :: c_vector(dim_c_vector, type_nucl_num)
real (c_double ) , intent(out) :: c_vector_full(nucl_num,dim_c_vector)
integer(qmckl_exit_code) :: info
double precision :: x
integer*8 :: i, a, k, l, nw
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
if (nucl_num <= 0) info = QMCKL_INVALID_ARG_2
if (dim_c_vector < 0) info = QMCKL_INVALID_ARG_3
if (type_nucl_num <= 0) info = QMCKL_INVALID_ARG_4
if (info /= QMCKL_SUCCESS) return
do a = 1, nucl_num
c_vector_full(a,1:dim_c_vector) = c_vector(1:dim_c_vector, type_nucl_vector(a)+1)
end do
end function qmckl_compute_c_vector_full_doc
3.3.5.4. Compute lkpmcombinedindex
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
cord_num |
int64_t |
in | Order of the c polynomial |
dim_c_vector |
int64_t |
in | Number of unique C coefficients |
lkpm_combined_index |
int64_t[4][dim_c_vector] |
out | Combined l, k, p and m indices of each C coefficient |
function qmckl_compute_lkpm_combined_index_doc( &
context, cord_num, dim_c_vector, lkpm_combined_index) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: cord_num
integer (c_int64_t) , intent(in) , value :: dim_c_vector
integer (c_int64_t) , intent(out) :: lkpm_combined_index(dim_c_vector,4)
integer(qmckl_exit_code) :: info
double precision :: x
integer*8 :: i, a, k, l, kk, p, lmax, m
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
if (cord_num < 0) info = QMCKL_INVALID_ARG_2
if (dim_c_vector < 0) info = QMCKL_INVALID_ARG_3
if (info /= QMCKL_SUCCESS) return
kk = 0
do p = 2, cord_num
do k = p - 1, 0, -1
if (k /= 0) then
lmax = p - k
else
lmax = p - k - 2
end if
do l = lmax, 0, -1
if (iand(p - k - l, 1_8) .eq. 1_8) cycle
m = (p - k - l)/2
kk = kk + 1
lkpm_combined_index(kk, 1) = l
lkpm_combined_index(kk, 2) = k
lkpm_combined_index(kk, 3) = p
lkpm_combined_index(kk, 4) = m
end do
end do
end do
end function qmckl_compute_lkpm_combined_index_doc
3.3.5.5. Compute tmpc
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
cord_num |
int64_t |
in | Order of the c polynomial |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
walk_num |
int64_t |
in | Number of walkers |
een_rescaled_e |
double[walk_num][0:cord_num][elec_num][elec_num] |
in | Rescaled electron-electron distances raised to the powers defined by cord |
een_rescaled_n |
double[walk_num][0:cord_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances raised to the powers defined by cord |
tmp_c |
double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num] |
out | Temporary array P of the three-body sums |
function qmckl_compute_tmp_c_doc( &
context, cord_num, elec_num, nucl_num, &
walk_num, een_rescaled_e, een_rescaled_n, tmp_c) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: cord_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: walk_num
real (c_double ) , intent(in) :: een_rescaled_e(elec_num,elec_num,0:cord_num,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(out) :: tmp_c(elec_num,nucl_num,0:cord_num,0:cord_num-1,walk_num)
integer(qmckl_exit_code) :: info
double precision :: x
integer*8 :: i, j, a, l, kk, p, lmax, nw
character :: TransA, TransB
double precision :: alpha, beta
integer*8 :: M, N, K, LDA, LDB, LDC
TransA = 'N'
TransB = 'N'
alpha = 1.0d0
beta = 0.0d0
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
if (cord_num < 0) info = QMCKL_INVALID_ARG_2
if (elec_num <= 0) info = QMCKL_INVALID_ARG_3
if (nucl_num <= 0) info = QMCKL_INVALID_ARG_4
if (walk_num <= 0) info = QMCKL_INVALID_ARG_5
if (info /= QMCKL_SUCCESS) return
M = elec_num
K = elec_num
N = nucl_num
LDA = size(een_rescaled_e,1)
LDB = size(een_rescaled_n,1)
LDC = size(tmp_c,1)
do nw=1, walk_num
do i=0, cord_num-1
do j=0, cord_num-i
info = qmckl_dgemm(context, TransA, TransB, M, N, K, alpha, &
een_rescaled_e(1,1,i,nw),LDA*1_8, &
een_rescaled_n(1,1,j,nw),LDB*1_8, &
beta, &
tmp_c(1,1,j,i,nw),LDC)
end do
end do
end do
end function qmckl_compute_tmp_c_doc
3.3.5.6. Compute dtmpc
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
cord_num |
int64_t |
in | Order of the c polynomial |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
walk_num |
int64_t |
in | Number of walkers |
een_rescaled_e_gl |
double[walk_num][0:cord_num][elec_num][4][elec_num] |
in | Derivatives of the rescaled electron-electron distances |
een_rescaled_n |
double[walk_num][0:cord_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances raised to the powers defined by cord |
dtmp_c |
double[walk_num][0:cord_num-1][0:cord_num][nucl_num][4][elec_num] |
out | Temporary array for the three-body derivative sums |
function qmckl_compute_dtmp_c_doc( &
context, cord_num, elec_num, nucl_num, &
walk_num, een_rescaled_e_gl, een_rescaled_n, dtmp_c) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: cord_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: walk_num
real (c_double ) , intent(in) :: een_rescaled_e_gl(elec_num,4,elec_num,0:cord_num,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(out) :: dtmp_c(elec_num,4,nucl_num,0:cord_num,0:cord_num-1,walk_num)
integer(qmckl_exit_code) :: info
double precision :: x
integer*8 :: i, j, a, l, kk, p, lmax, nw, ii
character :: TransA, TransB
double precision :: alpha, beta
integer*8 :: M, N, K, LDA, LDB, LDC
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
if (cord_num < 0) info = QMCKL_INVALID_ARG_2
if (elec_num <= 0) info = QMCKL_INVALID_ARG_3
if (nucl_num <= 0) info = QMCKL_INVALID_ARG_4
if (walk_num <= 0) info = QMCKL_INVALID_ARG_5
if (info /= QMCKL_SUCCESS) return
TransA = 'N'
TransB = 'N'
alpha = 1.0d0
beta = 0.0d0
M = 4*elec_num
N = nucl_num
K = elec_num
LDA = 4*size(een_rescaled_e_gl,1)
LDB = size(een_rescaled_n,1)
LDC = 4*size(dtmp_c,1)
do nw=1, walk_num
do i=0, cord_num-1
do j=0, cord_num-i
info = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, &
een_rescaled_e_gl(1,1,1,i,nw),LDA*1_8, &
een_rescaled_n(1,1,j,nw),LDB*1_8, &
beta, &
dtmp_c(1,1,1,j,i,nw),LDC)
end do
end do
end do
end function qmckl_compute_dtmp_c_doc
3.3.6. Electron-electron-nucleus Jastrow
Evaluates the three-body part of Reformulation of the three-body part
on the tables prepared above, and stores one value per walker in
factor_een.
3.3.6.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_factor_een(qmckl_context context,
double* const factor_een,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_een (context, & factor_een, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: factor_een(size_max) end function qmckl_get_jastrow_champ_factor_een end interface
3.3.6.2. Compute naive
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
cord_num |
int64_t |
in | Order of the c polynomial |
dim_c_vector |
int64_t |
in | Number of unique C coefficients |
c_vector_full |
double[dim_c_vector][nucl_num] |
in | C coefficients expanded over all nuclei |
lkpm_combined_index |
int64_t[4][dim_c_vector] |
in | Combined l, k, p and m indices of each C coefficient |
een_rescaled_e |
double[walk_num][0:cord_num][elec_num][elec_num] |
in | Rescaled electron-electron distances raised to the powers defined by cord |
een_rescaled_n |
double[walk_num][0:cord_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances raised to the powers defined by cord |
factor_een |
double[walk_num] |
out | Value of the electron-electron-nucleus term |
function qmckl_compute_jastrow_champ_factor_een_naive( &
context, walk_num, elec_num, nucl_num, cord_num,&
dim_c_vector, c_vector_full, lkpm_combined_index, &
een_rescaled_e, een_rescaled_n, factor_een) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: cord_num
integer (c_int64_t) , intent(in) , value :: dim_c_vector
real (c_double ) , intent(in) :: c_vector_full(nucl_num,dim_c_vector)
integer (c_int64_t) , intent(in) :: lkpm_combined_index(dim_c_vector,4)
real (c_double ) , intent(in) :: een_rescaled_e(elec_num,elec_num,0:cord_num,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(out) :: factor_een(walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, a, j, l, k, m, n, p, nw
double precision :: cn
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
if (walk_num <= 0) info = QMCKL_INVALID_ARG_2
if (elec_num <= 0) info = QMCKL_INVALID_ARG_3
if (nucl_num <= 0) info = QMCKL_INVALID_ARG_4
if (cord_num < 0) info = QMCKL_INVALID_ARG_5
if (info /= QMCKL_SUCCESS) return
do nw =1, walk_num
factor_een(nw) = 0.d0
do n = 1, dim_c_vector
l = lkpm_combined_index(n, 1)
k = lkpm_combined_index(n, 2)
p = lkpm_combined_index(n, 3)
m = lkpm_combined_index(n, 4)
do a = 1, nucl_num
cn = c_vector_full(a, n)
if (cn == 0.d0) cycle
do j = 1, elec_num
do i = 1, j-1
factor_een(nw) = factor_een(nw) + cn*( &
een_rescaled_e(i,j,k,nw) * &
(een_rescaled_n(i,a,l,nw) + een_rescaled_n(j,a,l,nw)) * &
(een_rescaled_n(i,a,m,nw) * een_rescaled_n(j,a,m,nw)) )
end do
end do
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_een_naive
3.3.6.3. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
cord_num |
int64_t |
in | Order of the c polynomial |
dim_c_vector |
int64_t |
in | Number of unique C coefficients |
c_vector_full |
double[dim_c_vector][nucl_num] |
in | C coefficients expanded over all nuclei |
lkpm_combined_index |
int64_t[4][dim_c_vector] |
in | Combined l, k, p and m indices of each C coefficient |
tmp_c |
double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num] |
in | Temporary array P of the three-body sums |
een_rescaled_n |
double[walk_num][0:cord_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances raised to the powers defined by cord |
factor_een |
double[walk_num] |
out | Value of the electron-electron-nucleus term |
function qmckl_compute_jastrow_champ_factor_een_doc( &
context, walk_num, elec_num, nucl_num, cord_num, &
dim_c_vector, c_vector_full, lkpm_combined_index, &
tmp_c, een_rescaled_n, factor_een) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: cord_num
integer (c_int64_t) , intent(in) , value :: dim_c_vector
real (c_double ) , intent(in) :: c_vector_full(nucl_num,dim_c_vector)
integer (c_int64_t) , intent(in) :: lkpm_combined_index(dim_c_vector,4)
real (c_double ) , intent(in) :: tmp_c(elec_num,nucl_num,0:cord_num,0:cord_num-1,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(out) :: factor_een(walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, a, j, l, k, p, m, n, nw
double precision :: accu, accu2, cn
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
if (walk_num <= 0) info = QMCKL_INVALID_ARG_2
if (elec_num <= 0) info = QMCKL_INVALID_ARG_3
if (nucl_num <= 0) info = QMCKL_INVALID_ARG_4
if (cord_num < 0) info = QMCKL_INVALID_ARG_5
if (info /= QMCKL_SUCCESS) return
factor_een = 0.0d0
if (cord_num == 0) return
do nw =1, walk_num
do n = 1, dim_c_vector
l = lkpm_combined_index(n, 1)
k = lkpm_combined_index(n, 2)
m = lkpm_combined_index(n, 4)
do a = 1, nucl_num
cn = c_vector_full(a, n)
if(cn == 0.d0) cycle
accu = 0.0d0
do j = 1, elec_num
accu = accu + een_rescaled_n(j,a,m,nw) * tmp_c(j,a,m+l,k,nw)
end do
factor_een(nw) = factor_een(nw) + accu * cn
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_een_doc
3.3.7. Electron-electron-nucleus Jastrow derivative
Differentiates the same sum with respect to the position of each electron,
and returns the gradient and the Laplacian in factor_een_gl, an array of
shape [walk_num][4][elec_num] whose fourth entry is the Laplacian.
3.3.7.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_factor_een_gl(qmckl_context context,
double* const factor_een_gl,
const int64_t size_max);
qmckl_exit_code
qmckl_get_jastrow_champ_factor_een_grad(qmckl_context context,
double* const factor_een_grad,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_een_gl (context, & factor_een_gl, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: factor_een_gl(size_max) end function qmckl_get_jastrow_champ_factor_een_gl end interface interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_een_grad (context, & factor_een_grad, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: factor_een_grad(size_max) end function qmckl_get_jastrow_champ_factor_een_grad end interface
3.3.7.2. Compute Naive
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
cord_num |
int64_t |
in | Order of the c polynomial |
dim_c_vector |
int64_t |
in | Number of unique C coefficients |
c_vector_full |
double[dim_c_vector][nucl_num] |
in | C coefficients expanded over all nuclei |
lkpm_combined_index |
int64_t[4][dim_c_vector] |
in | Combined l, k, p and m indices of each C coefficient |
een_rescaled_e |
double[walk_num][0:cord_num][elec_num][elec_num] |
in | Rescaled electron-electron distances raised to the powers defined by cord |
een_rescaled_n |
double[walk_num][0:cord_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances raised to the powers defined by cord |
een_rescaled_e_gl |
double[walk_num][0:cord_num][elec_num][4][elec_num] |
in | Derivatives of the rescaled electron-electron distances |
een_rescaled_n_gl |
double[walk_num][0:cord_num][nucl_num][4][elec_num] |
in | Derivatives of the rescaled electron-nucleus distances |
factor_een_gl |
double[walk_num][4][elec_num] |
out | Gradient and Laplacian of the electron-electron-nucleus term |
function qmckl_compute_jastrow_champ_factor_een_gl_naive( &
context, walk_num, elec_num, nucl_num, cord_num, dim_c_vector, &
c_vector_full, lkpm_combined_index, een_rescaled_e, een_rescaled_n, &
een_rescaled_e_gl, een_rescaled_n_gl, factor_een_gl)&
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: cord_num
integer (c_int64_t) , intent(in) , value :: dim_c_vector
real (c_double ) , intent(in) :: c_vector_full(nucl_num,dim_c_vector)
integer (c_int64_t) , intent(in) :: lkpm_combined_index(dim_c_vector,4)
real (c_double ) , intent(in) :: een_rescaled_e(elec_num,elec_num,0:cord_num,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(in) :: een_rescaled_e_gl(elec_num,4,elec_num,0:cord_num,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n_gl(elec_num,4,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(out) :: factor_een_gl(elec_num,4,walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, a, j, l, k, m, n, nw
double precision :: accu, accu2, cn
double precision :: daccu(1:4), daccu2(1:4)
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
if (walk_num <= 0) info = QMCKL_INVALID_ARG_2
if (elec_num <= 0) info = QMCKL_INVALID_ARG_3
if (nucl_num <= 0) info = QMCKL_INVALID_ARG_4
if (cord_num < 0) info = QMCKL_INVALID_ARG_5
if (info /= QMCKL_SUCCESS) return
factor_een_gl = 0.0d0
do nw =1, walk_num
do n = 1, dim_c_vector
l = lkpm_combined_index(n, 1)
k = lkpm_combined_index(n, 2)
m = lkpm_combined_index(n, 4)
do a = 1, nucl_num
cn = c_vector_full(a, n)
do j = 1, elec_num
accu = 0.0d0
accu2 = 0.0d0
daccu = 0.0d0
daccu2 = 0.0d0
do i = 1, elec_num
accu = accu + een_rescaled_e(i, j, k, nw) * een_rescaled_n(i, a, m, nw)
accu2 = accu2 + een_rescaled_e(i, j, k, nw) * een_rescaled_n(i, a, m + l, nw)
daccu(1:4) = daccu(1:4) + een_rescaled_e_gl(j, 1:4, i, k, nw) * &
een_rescaled_n(i, a, m, nw)
daccu2(1:4) = daccu2(1:4) + een_rescaled_e_gl(j, 1:4, i, k, nw) * &
een_rescaled_n(i, a, m + l, nw)
end do
factor_een_gl(j, 1:4, nw) = factor_een_gl(j, 1:4, nw) + &
(accu * een_rescaled_n_gl(j, 1:4, a, m + l, nw) &
+ daccu(1:4) * een_rescaled_n(j, a, m + l, nw) &
+ daccu2(1:4) * een_rescaled_n(j, a, m, nw) &
+ accu2 * een_rescaled_n_gl(j, 1:4, a, m, nw)) * cn
factor_een_gl(j, 4, nw) = factor_een_gl(j, 4, nw) + 2.0d0 * ( &
daccu (1) * een_rescaled_n_gl(j, 1, a, m + l, nw) + &
daccu (2) * een_rescaled_n_gl(j, 2, a, m + l, nw) + &
daccu (3) * een_rescaled_n_gl(j, 3, a, m + l, nw) + &
daccu2(1) * een_rescaled_n_gl(j, 1, a, m, nw ) + &
daccu2(2) * een_rescaled_n_gl(j, 2, a, m, nw ) + &
daccu2(3) * een_rescaled_n_gl(j, 3, a, m, nw ) ) * cn
end do
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_een_gl_naive
3.3.7.3. Compute GL
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
cord_num |
int64_t |
in | Order of the c polynomial |
dim_c_vector |
int64_t |
in | Number of unique C coefficients |
c_vector_full |
double[dim_c_vector][nucl_num] |
in | C coefficients expanded over all nuclei |
lkpm_combined_index |
int64_t[4][dim_c_vector] |
in | Combined l, k, p and m indices of each C coefficient |
tmp_c |
double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num] |
in | Temporary array P of the three-body sums |
dtmp_c |
double[walk_num][0:cord_num-1][0:cord_num][nucl_num][4][elec_num] |
in | Temporary array for the three-body derivative sums |
een_rescaled_n |
double[walk_num][0:cord_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances raised to the powers defined by cord |
een_rescaled_n_gl |
double[walk_num][0:cord_num][nucl_num][4][elec_num] |
in | Derivatives of the rescaled electron-nucleus distances |
factor_een_gl |
double[walk_num][4][elec_num] |
out | Gradient and Laplacian of the electron-electron-nucleus term |
function qmckl_compute_jastrow_champ_factor_een_gl_doc( &
context, walk_num, elec_num, nucl_num, &
cord_num, dim_c_vector, c_vector_full, lkpm_combined_index, &
tmp_c, dtmp_c, een_rescaled_n, een_rescaled_n_gl, factor_een_gl)&
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: cord_num
integer (c_int64_t) , intent(in) , value :: dim_c_vector
real (c_double ) , intent(in) :: c_vector_full(nucl_num,dim_c_vector)
integer (c_int64_t) , intent(in) :: lkpm_combined_index(dim_c_vector,4)
real (c_double ) , intent(in) :: tmp_c(elec_num,nucl_num,0:cord_num,0:cord_num-1,walk_num)
real (c_double ) , intent(in) :: dtmp_c(elec_num,4,nucl_num,0:cord_num,0:cord_num-1,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n_gl(elec_num,4,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(out) :: factor_een_gl(elec_num,4,walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, a, j, l, k, m, n, nw, ii
double precision :: accu, accu2, cn
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
if (walk_num <= 0) info = QMCKL_INVALID_ARG_2
if (elec_num <= 0) info = QMCKL_INVALID_ARG_3
if (nucl_num <= 0) info = QMCKL_INVALID_ARG_4
if (cord_num < 0) info = QMCKL_INVALID_ARG_5
if (info /= QMCKL_SUCCESS) return
if (cord_num == 0) then
factor_een_gl = 0.0d0
return
end if
do nw =1, walk_num
factor_een_gl(:,:,nw) = 0.0d0
do n = 1, dim_c_vector
l = lkpm_combined_index(n, 1)
k = lkpm_combined_index(n, 2)
m = lkpm_combined_index(n, 4)
do a = 1, nucl_num
cn = c_vector_full(a, n)
if(cn == 0.d0) cycle
do ii = 1, 4
do j = 1, elec_num
factor_een_gl(j,ii,nw) = factor_een_gl(j,ii,nw) + ( &
tmp_c (j, a,m ,k,nw) * een_rescaled_n_gl(j,ii,a,m+l,nw) + &
tmp_c (j, a,m+l,k,nw) * een_rescaled_n_gl(j,ii,a,m ,nw) + &
dtmp_c(j,ii,a,m ,k,nw) * een_rescaled_n (j, a,m+l,nw) + &
dtmp_c(j,ii,a,m+l,k,nw) * een_rescaled_n (j, a,m ,nw) &
) * cn
end do
end do
cn = cn + cn
do j = 1, elec_num
factor_een_gl(j,4,nw) = factor_een_gl(j,4,nw) + ( &
dtmp_c(j,1,a,m ,k,nw) * een_rescaled_n_gl(j,1,a,m+l,nw) + &
dtmp_c(j,2,a,m ,k,nw) * een_rescaled_n_gl(j,2,a,m+l,nw) + &
dtmp_c(j,3,a,m ,k,nw) * een_rescaled_n_gl(j,3,a,m+l,nw) + &
dtmp_c(j,1,a,m+l,k,nw) * een_rescaled_n_gl(j,1,a,m ,nw) + &
dtmp_c(j,2,a,m+l,k,nw) * een_rescaled_n_gl(j,2,a,m ,nw) + &
dtmp_c(j,3,a,m+l,k,nw) * een_rescaled_n_gl(j,3,a,m ,nw) &
) * cn
end do
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_een_gl_doc
3.3.7.4. Compute Gradient only
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
cord_num |
int64_t |
in | Order of the c polynomial |
dim_c_vector |
int64_t |
in | Number of unique C coefficients |
c_vector_full |
double[dim_c_vector][nucl_num] |
in | C coefficients expanded over all nuclei |
lkpm_combined_index |
int64_t[4][dim_c_vector] |
in | Combined l, k, p and m indices of each C coefficient |
tmp_c |
double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num] |
in | Temporary array P of the three-body sums |
dtmp_c |
double[walk_num][0:cord_num-1][0:cord_num][nucl_num][4][elec_num] |
in | Temporary array for the three-body derivative sums |
een_rescaled_n |
double[walk_num][0:cord_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances raised to the powers defined by cord |
een_rescaled_n_gl |
double[walk_num][0:cord_num][nucl_num][4][elec_num] |
in | Derivatives of the rescaled electron-nucleus distances |
factor_een_grad |
double[walk_num][3][elec_num] |
out | Gradient of the electron-electron-nucleus term |
function qmckl_compute_jastrow_champ_factor_een_grad_doc( &
context, walk_num, elec_num, nucl_num, &
cord_num, dim_c_vector, c_vector_full, lkpm_combined_index, &
tmp_c, dtmp_c, een_rescaled_n, een_rescaled_n_gl, factor_een_grad) &
bind(C) result(info)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: cord_num
integer (c_int64_t) , intent(in) , value :: dim_c_vector
real (c_double ) , intent(in) :: c_vector_full(nucl_num,dim_c_vector)
integer (c_int64_t) , intent(in) :: lkpm_combined_index(dim_c_vector,4)
real (c_double ) , intent(in) :: tmp_c(elec_num,nucl_num,0:cord_num,0:cord_num-1,walk_num)
real (c_double ) , intent(in) :: dtmp_c(elec_num,4,nucl_num,0:cord_num,0:cord_num-1,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n_gl(elec_num,4,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(out) :: factor_een_grad(elec_num,3,walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, a, j, l, k, m, n, nw, ii
double precision :: accu, accu2, cn
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
if (walk_num <= 0) info = QMCKL_INVALID_ARG_2
if (elec_num <= 0) info = QMCKL_INVALID_ARG_3
if (nucl_num <= 0) info = QMCKL_INVALID_ARG_4
if (cord_num < 0) info = QMCKL_INVALID_ARG_5
if (info /= QMCKL_SUCCESS) return
if (cord_num == 0) then
factor_een_grad = 0.0d0
return
end if
do nw =1, walk_num
factor_een_grad(:,:,nw) = 0.0d0
do n = 1, dim_c_vector
l = lkpm_combined_index(n, 1)
k = lkpm_combined_index(n, 2)
m = lkpm_combined_index(n, 4)
do a = 1, nucl_num
cn = c_vector_full(a, n)
if(cn == 0.d0) cycle
do ii = 1, 3
do j = 1, elec_num
factor_een_grad(j,ii,nw) = factor_een_grad(j,ii,nw) + ( &
dtmp_c(j,ii,a,m ,k,nw) * een_rescaled_n (j, a,m+l,nw) + &
dtmp_c(j,ii,a,m+l,k,nw) * een_rescaled_n (j, a,m ,nw) + &
tmp_c(j,a,m ,k,nw) * een_rescaled_n_gl(j,ii,a,m+l,nw) + &
tmp_c(j,a,m+l,k,nw) * een_rescaled_n_gl(j,ii,a,m ,nw) &
) * cn
end do
end do
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_een_grad_doc
3.3.8. Electron-electron-nucleus Jastrow Parameter derivatives
Differentiates the three-body sum with respect to each coefficient
, for every nucleus type, and stores the result in
factor_een_pderiv, an array of shape
[type_nucl_num][dim_c_vector].
3.3.8.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_factor_een_pderiv(qmckl_context context,
double* const factor_een_pderiv,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_een_pderiv (context, & factor_een_pderiv, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: factor_een_pderiv(size_max) end function qmckl_get_jastrow_champ_factor_een_pderiv end interface
3.3.8.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
type_nucl_num |
int64_t |
in | Number of nucleus types |
type_nucl_vector |
int64_t[nucl_num] |
in | Type of each nucleus |
cord_num |
int64_t |
in | Order of the c polynomial |
dim_c_vector |
int64_t |
in | Number of unique C coefficients |
c_vector_full |
double[dim_c_vector][nucl_num] |
in | C coefficients expanded over all nuclei |
lkpm_combined_index |
int64_t[4][dim_c_vector] |
in | Combined l, k, p and m indices of each C coefficient |
tmp_c |
double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num] |
in | Temporary array P of the three-body sums |
een_rescaled_n |
double[walk_num][0:cord_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances raised to the powers defined by cord |
factor_een_pderiv |
double[type_nucl_num][dim_c_vector] |
out | Parameter derivatives of the electron-electron-nucleus term |
function qmckl_compute_jastrow_champ_factor_een_pderiv_doc( &
context, walk_num, elec_num, nucl_num, type_nucl_num, &
type_nucl_vector, cord_num, dim_c_vector, c_vector_full, &
lkpm_combined_index, tmp_c, een_rescaled_n, factor_een_pderiv) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: type_nucl_num
integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num)
integer (c_int64_t) , intent(in) , value :: cord_num
integer (c_int64_t) , intent(in) , value :: dim_c_vector
real (c_double ) , intent(in) :: c_vector_full(nucl_num,dim_c_vector)
integer (c_int64_t) , intent(in) :: lkpm_combined_index(dim_c_vector,4)
real (c_double ) , intent(in) :: tmp_c(elec_num,nucl_num,0:cord_num,0:cord_num-1,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(out) :: factor_een_pderiv(dim_c_vector, type_nucl_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, a, j, l, k, p, m, n, nw
double precision :: accu, accu2, cn
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
if (walk_num <= 0) info = QMCKL_INVALID_ARG_2
if (elec_num <= 0) info = QMCKL_INVALID_ARG_3
if (nucl_num <= 0) info = QMCKL_INVALID_ARG_4
if (cord_num < 0) info = QMCKL_INVALID_ARG_5
if (info /= QMCKL_SUCCESS) return
factor_een_pderiv = 0.0d0
if (cord_num == 0) return
do nw =1, walk_num
do n = 1, dim_c_vector
l = lkpm_combined_index(n, 1)
k = lkpm_combined_index(n, 2)
m = lkpm_combined_index(n, 4)
do a = 1, nucl_num
accu = 0.0d0
do j = 1, elec_num
accu = accu + een_rescaled_n(j,a,m,nw) * tmp_c(j,a,m+l,k,nw)
end do
factor_een_pderiv(n, type_nucl_vector(a)+1) = factor_een_pderiv(n, type_nucl_vector(a)+1) + accu
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_een_pderiv_doc
3.3.9. Electron-electron-nucleus Parameter Derivative of the gradient and Laplacian
Differentiates the gradient and the Laplacian of the three-body sum with
respect to each coefficient, and stores the result in
factor_een_gl_pderiv, an array of shape
[type_nucl_num][dim_c_vector][elec_num][4].
3.3.9.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_factor_een_gl_pderiv(qmckl_context context,
double* const factor_een_gl_pderiv,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_factor_een_gl_pderiv (context, & factor_een_gl_pderiv, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: factor_een_gl_pderiv(size_max) end function qmckl_get_jastrow_champ_factor_een_gl_pderiv end interface
3.3.9.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
nucl_num |
int64_t |
in | Number of nuclei |
type_nucl_num |
int64_t |
in | Number of nucleus types |
type_nucl_vector |
int64_t[nucl_num] |
in | Type of each nucleus |
cord_num |
int64_t |
in | Order of the c polynomial |
dim_c_vector |
int64_t |
in | Number of unique C coefficients |
c_vector_full |
double[dim_c_vector][nucl_num] |
in | C coefficients expanded over all nuclei |
lkpm_combined_index |
int64_t[4][dim_c_vector] |
in | Combined l, k, p and m indices of each C coefficient |
tmp_c |
double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num] |
in | Temporary array P of the three-body sums |
dtmp_c |
double[walk_num][0:cord_num-1][0:cord_num][nucl_num][4][elec_num] |
in | Temporary array for the three-body derivative sums |
een_rescaled_n |
double[walk_num][0:cord_num][nucl_num][elec_num] |
in | Rescaled electron-nucleus distances raised to the powers defined by cord |
een_rescaled_n_gl |
double[walk_num][0:cord_num][nucl_num][4][elec_num] |
in | Derivatives of the rescaled electron-nucleus distances |
factor_een_gl_pderiv |
double[type_nucl_num][dim_c_vector][elec_num][4] |
out | Parameter derivatives of the gradient and Laplacian: electron-electron-nucleus part |
function qmckl_compute_jastrow_champ_factor_een_gl_pderiv_doc( &
context, walk_num, elec_num, nucl_num, type_nucl_num, type_nucl_vector, &
cord_num, dim_c_vector, c_vector_full, lkpm_combined_index, &
tmp_c, dtmp_c, een_rescaled_n, een_rescaled_n_gl, factor_een_gl_pderiv)&
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: nucl_num
integer (c_int64_t) , intent(in) , value :: type_nucl_num
integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num)
integer (c_int64_t) , intent(in) , value :: cord_num
integer (c_int64_t) , intent(in) , value :: dim_c_vector
real (c_double ) , intent(in) :: c_vector_full(nucl_num,dim_c_vector)
integer (c_int64_t) , intent(in) :: lkpm_combined_index(dim_c_vector,4)
real (c_double ) , intent(in) :: tmp_c(elec_num,nucl_num,0:cord_num,0:cord_num-1,walk_num)
real (c_double ) , intent(in) :: dtmp_c(elec_num,4,nucl_num,0:cord_num,0:cord_num-1,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(in) :: een_rescaled_n_gl(elec_num,4,nucl_num,0:cord_num,walk_num)
real (c_double ) , intent(out) :: factor_een_gl_pderiv(4,elec_num,dim_c_vector,type_nucl_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, a, j, l, k, m, n, nw, ii
double precision :: accu, accu2, cn
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
if (walk_num <= 0) info = QMCKL_INVALID_ARG_2
if (elec_num <= 0) info = QMCKL_INVALID_ARG_3
if (nucl_num <= 0) info = QMCKL_INVALID_ARG_4
if (cord_num < 0) info = QMCKL_INVALID_ARG_5
if (info /= QMCKL_SUCCESS) return
factor_een_gl_pderiv = 0.0d0
if (cord_num == 0) then
return
end if
do nw =1, walk_num
do n = 1, dim_c_vector
l = lkpm_combined_index(n, 1)
k = lkpm_combined_index(n, 2)
m = lkpm_combined_index(n, 4)
do a = 1, nucl_num
cn = c_vector_full(a, n)
! if(cn == 0.d0) cycle
do ii = 1, 4
do j = 1, elec_num
factor_een_gl_pderiv(ii,j,n,type_nucl_vector(a)+1) = factor_een_gl_pderiv(ii,j,n,type_nucl_vector(a)+1) + ( &
tmp_c (j, a,m ,k,nw) * een_rescaled_n_gl(j,ii,a,m+l,nw) + &
tmp_c (j, a,m+l,k,nw) * een_rescaled_n_gl(j,ii,a,m ,nw) + &
dtmp_c(j,ii,a,m ,k,nw) * een_rescaled_n (j, a,m+l,nw) + &
dtmp_c(j,ii,a,m+l,k,nw) * een_rescaled_n (j, a,m ,nw) &
)
end do
end do
do j = 1, elec_num
factor_een_gl_pderiv(4,j,n,type_nucl_vector(a)+1) = factor_een_gl_pderiv(4,j,n,type_nucl_vector(a)+1) + ( &
dtmp_c(j,1,a,m ,k,nw) * een_rescaled_n_gl(j,1,a,m+l,nw) + &
dtmp_c(j,2,a,m ,k,nw) * een_rescaled_n_gl(j,2,a,m+l,nw) + &
dtmp_c(j,3,a,m ,k,nw) * een_rescaled_n_gl(j,3,a,m+l,nw) + &
dtmp_c(j,1,a,m+l,k,nw) * een_rescaled_n_gl(j,1,a,m ,nw) + &
dtmp_c(j,2,a,m+l,k,nw) * een_rescaled_n_gl(j,2,a,m ,nw) + &
dtmp_c(j,3,a,m+l,k,nw) * een_rescaled_n_gl(j,3,a,m ,nw) &
) * 2
end do
end do
end do
end do
end function qmckl_compute_jastrow_champ_factor_een_gl_pderiv_doc
3.4. Total Jastrow
3.4.1. Value
Value of the total Jastrow factor:
3.4.1.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_value(qmckl_context context,
double* const value,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_value (context, & value, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: value(size_max) end function qmckl_get_jastrow_champ_value end interface
3.4.1.2. Compute
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
f_ee |
double[walk_num] |
in | Value of the electron-electron term |
f_en |
double[walk_num] |
in | Value of the electron-nucleus term |
f_een |
double[walk_num] |
in | Value of the electron-electron-nucleus term |
value |
double[walk_num] |
out | Value of the Jastrow factor |
function qmckl_compute_jastrow_champ_value_doc(context, &
walk_num, f_ee, f_en, f_een, value) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
real (c_double ) , intent(in) :: f_ee(walk_num)
real (c_double ) , intent(in) :: f_en(walk_num)
real (c_double ) , intent(in) :: f_een(walk_num)
real (c_double ) , intent(out) :: value(walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
do i = 1, walk_num
value(i) = f_ee(i) + f_en(i) + f_een(i)
end do
do i = 1, walk_num
! Flush to zero to avoid floating-point exception
if (value(i) < -100.d0) then
value(i) = 0.d0
else
value(i) = dexp(value(i))
endif
end do
end function qmckl_compute_jastrow_champ_value_doc
3.4.2. Derivatives
Gradients and Laplacian of the total Jastrow factor:
3.4.2.1. Get
qmckl_exit_code
qmckl_get_jastrow_champ_gl(qmckl_context context,
double* const gl,
const int64_t size_max);
qmckl_exit_code
qmckl_get_jastrow_champ_grad(qmckl_context context,
double* const grad,
const int64_t size_max);
qmckl_exit_code
qmckl_get_jastrow_champ_grad(qmckl_context context,
double* const grad,
const int64_t size_max);
- Fortran interface
Fortran interface integer(qmckl_exit_code) function qmckl_get_jastrow_champ_gl (context, & gl, size_max) bind(C) use, intrinsic :: iso_c_binding import implicit none integer (qmckl_context) , intent(in), value :: context integer(c_int64_t), intent(in), value :: size_max real(c_double), intent(out) :: gl(size_max) end function qmckl_get_jastrow_champ_gl end interface
3.4.2.2. Compute GL
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
value |
double[walk_num] |
in | Value of the Jastrow factor |
gl_ee |
double[walk_num][4][elec_num] |
in | Gradient and Laplacian of the electron-electron term |
gl_en |
double[walk_num][4][elec_num] |
in | Gradient and Laplacian of the electron-nucleus term |
gl_een |
double[walk_num][4][elec_num] |
in | Gradient and Laplacian of the electron-electron-nucleus term |
gl |
double[walk_num][4][elec_num] |
out | Gradient and Laplacian of the total Jastrow factor |
function qmckl_compute_jastrow_champ_gl_doc(context, &
walk_num, elec_num, value, gl_ee, gl_en, gl_een, gl) &
bind(C) result(info)
use qmckl
use, intrinsic :: iso_c_binding
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
real (c_double ) , intent(in) :: value(walk_num)
real (c_double ) , intent(in) :: gl_ee(elec_num,4,walk_num)
real (c_double ) , intent(in) :: gl_en(elec_num,4,walk_num)
real (c_double ) , intent(in) :: gl_een(elec_num,4,walk_num)
real (c_double ) , intent(out) :: gl(elec_num,4,walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, j, k
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
do k = 1, walk_num
do j=1,4
do i = 1, elec_num
gl(i,j,k) = gl_ee(i,j,k) + gl_en(i,j,k) + gl_een(i,j,k)
end do
end do
do i = 1, elec_num
gl(i,4,k) = gl(i,4,k) + &
gl(i,1,k) * gl(i,1,k) + &
gl(i,2,k) * gl(i,2,k) + &
gl(i,3,k) * gl(i,3,k)
end do
gl(:,:,k) = gl(:,:,k) * value(k)
end do
end function qmckl_compute_jastrow_champ_gl_doc
3.4.2.3. Compute Gradient only
| Variable | Type | In/Out | Description |
|---|---|---|---|
context |
qmckl_context |
in | Global state |
walk_num |
int64_t |
in | Number of walkers |
elec_num |
int64_t |
in | Number of electrons |
value |
double[walk_num] |
in | Value of the Jastrow factor |
gl_ee |
double[walk_num][4][elec_num] |
in | Gradient and Laplacian of the electron-electron term |
gl_en |
double[walk_num][4][elec_num] |
in | Gradient and Laplacian of the electron-nucleus term |
grad_een |
double[walk_num][3][elec_num] |
in | Gradient of the electron-electron-nucleus term |
grad |
double[walk_num][3][elec_num] |
out | Gradient of the total Jastrow factor |
function qmckl_compute_jastrow_champ_grad_doc(context, &
walk_num, elec_num, value, gl_ee, gl_en, grad_een, grad) &
result(info) bind(C)
use, intrinsic :: iso_c_binding
use qmckl
implicit none
integer(qmckl_context), intent(in), value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
real (c_double ) , intent(in) :: value(walk_num)
real (c_double ) , intent(in) :: gl_ee(elec_num,4,walk_num)
real (c_double ) , intent(in) :: gl_en(elec_num,4,walk_num)
real (c_double ) , intent(in) :: grad_een(elec_num,3,walk_num)
real (c_double ) , intent(out) :: grad(elec_num,3,walk_num)
integer(qmckl_exit_code) :: info
integer*8 :: i, j, k
info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT
return
endif
if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_2
return
endif
do k = 1, walk_num
do j=1,3
do i = 1, elec_num
grad(i,j,k) = gl_ee(i,j,k) + gl_en(i,j,k) + grad_een(i,j,k)
end do
end do
grad(:,:,k) = grad(:,:,k) * value(k)
end do
end function qmckl_compute_jastrow_champ_grad_doc