1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-12-22 12:23:56 +01:00

Update qmckl_determinant

This commit is contained in:
Anthony Scemama 2022-01-06 01:04:20 +01:00
parent bd36ed0b48
commit d248a53ffa

View File

@ -841,16 +841,18 @@ qmckl_exit_code qmckl_provide_det_vgl_beta(qmckl_context context) {
:END:
#+NAME: qmckl_compute_det_vgl_alpha_args
| ~qmckl_context~ | ~context~ | in | Global state |
| ~int64_t~ | ~det_num_alpha~ | in | Number of determinants |
| ~int64_t~ | ~walk_num~ | in | Number of walkers |
| ~int64_t~ | ~alpha_num~ | in | Number of electrons |
| ~int64_t~ | ~beta_num~ | in | Number of electrons |
| ~int64_t~ | ~elec_num~ | in | Number of electrons |
| ~int64_t~ | ~mo_index_alpha[det_num_alpha][walk_num][alpha_num]~ | in | MO indices for electrons |
| ~int64_t~ | ~mo_num~ | in | Number of MOs |
| ~double~ | ~mo_vgl[5][elec_num][mo_num]~ | in | Value, gradients and Laplacian of the MOs |
| ~double~ | ~det_vgl_alpha[det_num_alpha][walk_num][5][alpha_num][alpha_num]~ | out | Value, gradients and Laplacian of the Det |
| Variable | Type | In/Out | Description |
|------------------+------------------------------------------------------------+--------+-------------------------------------------|
| ~context~ | ~qmckl_context~ | in | Global state |
| ~det_num_alpha~ | ~int64_t~ | in | Number of determinants |
| ~walk_num~ | ~int64_t~ | in | Number of walkers |
| ~alpha_num~ | ~int64_t~ | in | Number of electrons |
| ~beta_num~ | ~int64_t~ | in | Number of electrons |
| ~elec_num~ | ~int64_t~ | in | Number of electrons |
| ~mo_index_alpha~ | ~int64_t[det_num_alpha][walk_num][alpha_num]~ | in | MO indices for electrons |
| ~mo_num~ | ~int64_t~ | in | Number of MOs |
| ~mo_vgl~ | ~double[5][elec_num][mo_num]~ | in | Value, gradients and Laplacian of the MOs |
| ~det_vgl_alpha~ | ~double[det_num_alpha][walk_num][5][alpha_num][alpha_num]~ | out | Value, gradients and Laplacian of the Det |
#+begin_src f90 :comments org :tangle (eval f) :noweb yes
integer function qmckl_compute_det_vgl_alpha_f(context, &
@ -916,20 +918,20 @@ end function qmckl_compute_det_vgl_alpha_f
#+end_src
#+CALL: generate_c_header(table=qmckl_compute_det_vgl_alpha_args,rettyp=get_value("CRetType"),fname="qmckl_compute_det_vgl_alpha"))
#+RESULTS:
#+begin_src c :tangle (eval h_func) :comments org
qmckl_exit_code qmckl_compute_det_vgl_alpha (
const qmckl_context context,
const int64_t det_num_alpha,
const int64_t walk_num,
const int64_t alpha_num,
const int64_t beta_num,
const int64_t elec_num,
const int64_t* mo_index_alpha,
const int64_t mo_num,
const double* mo_vgl,
double* const det_vgl_alpha );
const qmckl_context context,
const int64_t det_num_alpha,
const int64_t walk_num,
const int64_t alpha_num,
const int64_t beta_num,
const int64_t elec_num,
const int64_t* mo_index_alpha,
const int64_t mo_num,
const double* mo_vgl,
double* const det_vgl_alpha );
#+end_src
#+CALL: generate_c_interface(table=qmckl_compute_det_vgl_alpha_args,rettyp=get_value("CRetType"),fname="qmckl_compute_det_vgl_alpha"))
@ -937,17 +939,17 @@ end function qmckl_compute_det_vgl_alpha_f
#+RESULTS:
#+begin_src f90 :tangle (eval f) :comments org :exports none
integer(c_int32_t) function qmckl_compute_det_vgl_alpha &
(context, &
det_num_alpha, &
walk_num, &
alpha_num, &
beta_num, &
elec_num, &
mo_index_alpha, &
mo_num, &
mo_vgl, &
det_vgl_alpha) &
bind(C) result(info)
(context, &
det_num_alpha, &
walk_num, &
alpha_num, &
beta_num, &
elec_num, &
mo_index_alpha, &
mo_num, &
mo_vgl, &
det_vgl_alpha) &
bind(C) result(info)
use, intrinsic :: iso_c_binding
implicit none
@ -965,16 +967,16 @@ end function qmckl_compute_det_vgl_alpha_f
integer(c_int32_t), external :: qmckl_compute_det_vgl_alpha_f
info = qmckl_compute_det_vgl_alpha_f &
(context, &
det_num_alpha, &
walk_num, &
alpha_num, &
beta_num, &
elec_num, &
mo_index_alpha, &
mo_num, &
mo_vgl, &
det_vgl_alpha)
(context, &
det_num_alpha, &
walk_num, &
alpha_num, &
beta_num, &
elec_num, &
mo_index_alpha, &
mo_num, &
mo_vgl, &
det_vgl_alpha)
end function qmckl_compute_det_vgl_alpha
#+end_src
@ -987,16 +989,18 @@ end function qmckl_compute_det_vgl_alpha_f
:END:
#+NAME: qmckl_compute_det_vgl_beta_args
| ~qmckl_context~ | ~context~ | in | Global state |
| ~int64_t~ | ~det_num_beta~ | in | Number of determinants |
| ~int64_t~ | ~walk_num~ | in | Number of walkers |
| ~int64_t~ | ~alpha_num~ | in | Number of electrons |
| ~int64_t~ | ~beta_num~ | in | Number of electrons |
| ~int64_t~ | ~elec_num~ | in | Number of electrons |
| ~int64_t~ | ~mo_index_beta[det_num_beta][walk_num][beta_num]~ | in | Number of electrons |
| ~int64_t~ | ~mo_num~ | in | Number of MOs |
| ~double~ | ~mo_vgl[5][elec_num][mo_num]~ | in | Value, gradients and Laplacian of the MOs |
| ~double~ | ~det_vgl_beta[det_num_beta][walk_num][5][beta_num][beta_num]~ | out | Value, gradients and Laplacian of the Det |
| Variable | Type | In/Out | Description |
|-----------------+---------------------------------------------------------+--------+-------------------------------------------|
| ~context~ | ~qmckl_context~ | in | Global state |
| ~det_num_beta~ | ~int64_t~ | in | Number of determinants |
| ~walk_num~ | ~int64_t~ | in | Number of walkers |
| ~alpha_num~ | ~int64_t~ | in | Number of electrons |
| ~beta_num~ | ~int64_t~ | in | Number of electrons |
| ~elec_num~ | ~int64_t~ | in | Number of electrons |
| ~mo_index_beta~ | ~int64_t[det_num_beta][walk_num][beta_num]~ | in | Number of electrons |
| ~mo_num~ | ~int64_t~ | in | Number of MOs |
| ~mo_vgl~ | ~double[5][elec_num][mo_num]~ | in | Value, gradients and Laplacian of the MOs |
| ~det_vgl_beta~ | ~double[det_num_beta][walk_num][5][beta_num][beta_num]~ | out | Value, gradients and Laplacian of the Det |
#+begin_src f90 :comments org :tangle (eval f) :noweb yes
integer function qmckl_compute_det_vgl_beta_f(context, &
@ -1066,16 +1070,16 @@ end function qmckl_compute_det_vgl_beta_f
#+RESULTS:
#+begin_src c :tangle (eval h_func) :comments org
qmckl_exit_code qmckl_compute_det_vgl_beta (
const qmckl_context context,
const int64_t det_num_beta,
const int64_t walk_num,
const int64_t alpha_num,
const int64_t beta_num,
const int64_t elec_num,
const int64_t* mo_index_beta,
const int64_t mo_num,
const double* mo_vgl,
double* const det_vgl_beta );
const qmckl_context context,
const int64_t det_num_beta,
const int64_t walk_num,
const int64_t alpha_num,
const int64_t beta_num,
const int64_t elec_num,
const int64_t* mo_index_beta,
const int64_t mo_num,
const double* mo_vgl,
double* const det_vgl_beta );
#+end_src
#+CALL: generate_c_interface(table=qmckl_compute_det_vgl_beta_args,rettyp=get_value("CRetType"),fname="qmckl_compute_det_vgl_beta"))
@ -1083,17 +1087,17 @@ end function qmckl_compute_det_vgl_beta_f
#+RESULTS:
#+begin_src f90 :tangle (eval f) :comments org :exports none
integer(c_int32_t) function qmckl_compute_det_vgl_beta &
(context, &
det_num_beta, &
walk_num, &
alpha_num, &
beta_num, &
elec_num, &
mo_index_beta, &
mo_num, &
mo_vgl, &
det_vgl_beta) &
bind(C) result(info)
(context, &
det_num_beta, &
walk_num, &
alpha_num, &
beta_num, &
elec_num, &
mo_index_beta, &
mo_num, &
mo_vgl, &
det_vgl_beta) &
bind(C) result(info)
use, intrinsic :: iso_c_binding
implicit none
@ -1111,16 +1115,16 @@ end function qmckl_compute_det_vgl_beta_f
integer(c_int32_t), external :: qmckl_compute_det_vgl_beta_f
info = qmckl_compute_det_vgl_beta_f &
(context, &
det_num_beta, &
walk_num, &
alpha_num, &
beta_num, &
elec_num, &
mo_index_beta, &
mo_num, &
mo_vgl, &
det_vgl_beta)
(context, &
det_num_beta, &
walk_num, &
alpha_num, &
beta_num, &
elec_num, &
mo_index_beta, &
mo_num, &
mo_vgl, &
det_vgl_beta)
end function qmckl_compute_det_vgl_beta
#+end_src
@ -1761,14 +1765,16 @@ qmckl_exit_code qmckl_provide_det_inv_matrix_beta(qmckl_context context) {
:END:
#+NAME: qmckl_det_inv_matrix_alpha_args
| ~qmckl_context~ | ~context~ | in | Global state |
| ~int64_t~ | ~det_num_alpha~ | in | Number of determinants |
| ~int64_t~ | ~walk_num~ | in | Number of walkers |
| ~int64_t~ | ~alpha_num~ | in | Number of electrons |
| ~double~ | ~det_vgl_alpha[det_num_alpha][walk_num][5][alpha_num][alpha_num]~ | in | determinant matrix Value, gradients and Laplacian of the MOs |
| ~double~ | ~det_value_alpha[det_num_alpha][walk_num]~ | out | value of determinant matrix |
| ~double~ | ~det_adj_matrix_alpha[det_num_alpha][walk_num][alpha_num][alpha_num]~ | out | adjoint of determinant matrix |
| ~double~ | ~det_inv_matrix_alpha[det_num_alpha][walk_num][alpha_num][alpha_num]~ | out | inverse of determinant matrix |
| Variable | Type | In/Out | Description |
|------------------------+------------------------------------------------------------+--------+--------------------------------------------------------------|
| ~context~ | ~qmckl_context~ | in | Global state |
| ~det_num_alpha~ | ~int64_t~ | in | Number of determinants |
| ~walk_num~ | ~int64_t~ | in | Number of walkers |
| ~alpha_num~ | ~int64_t~ | in | Number of electrons |
| ~det_vgl_alpha~ | ~double[det_num_alpha][walk_num][5][alpha_num][alpha_num]~ | in | determinant matrix Value, gradients and Laplacian of the MOs |
| ~det_value_alpha~ | ~double[det_num_alpha][walk_num]~ | out | value of determinant matrix |
| ~det_adj_matrix_alpha~ | ~double[det_num_alpha][walk_num][alpha_num][alpha_num]~ | out | adjoint of determinant matrix |
| ~det_inv_matrix_alpha~ | ~double[det_num_alpha][walk_num][alpha_num][alpha_num]~ | out | inverse of determinant matrix |
#+begin_src f90 :comments org :tangle (eval f) :noweb yes
integer function qmckl_compute_det_inv_matrix_alpha_f(context, &
@ -1814,14 +1820,23 @@ integer function qmckl_compute_det_inv_matrix_alpha_f(context, &
LDA = alpha_num
do idet = 1, det_num_alpha
do iwalk = 1, walk_num
! Value
matA(1:alpha_num,1:alpha_num) = det_vgl_alpha(1:alpha_num, 1:alpha_num, 1, iwalk, idet)
res = qmckl_adjugate(context, alpha_num, LDA, matA, det_l)
det_adj_matrix_alpha(1:alpha_num, 1:alpha_num, iwalk, idet) = matA
det_inv_matrix_alpha(1:alpha_num, 1:alpha_num, iwalk, idet) = matA/det_l
det_value_alpha(iwalk, idet) = det_l
end do
do iwalk = 1, walk_num
! Value
matA(1:alpha_num,1:alpha_num) = &
det_vgl_alpha(1:alpha_num, 1:alpha_num, 1, iwalk, idet)
res = qmckl_adjugate(context, &
alpha_num, matA, LDA, &
det_adj_matrix_alpha(1, 1, iwalk, idet), &
int(size(det_adj_matrix_alpha,1),8), &
det_l)
det_inv_matrix_alpha(1:alpha_num, 1:alpha_num, iwalk, idet) = &
(1.d0/det_l) * &
det_adj_matrix_alpha(1:alpha_num, 1:alpha_num, iwalk, idet)
det_value_alpha(iwalk, idet) = det_l
end do
end do
deallocate(matA)
@ -1833,14 +1848,14 @@ end function qmckl_compute_det_inv_matrix_alpha_f
#+RESULTS:
#+begin_src c :tangle (eval h_func) :comments org
qmckl_exit_code qmckl_compute_det_inv_matrix_alpha (
const qmckl_context context,
const int64_t det_num_alpha,
const int64_t walk_num,
const int64_t alpha_num,
const double* det_vgl_alpha,
double* const det_value_alpha,
double* const det_adj_matrix_alpha,
double* const det_inv_matrix_alpha );
const qmckl_context context,
const int64_t det_num_alpha,
const int64_t walk_num,
const int64_t alpha_num,
const double* det_vgl_alpha,
double* const det_value_alpha,
double* const det_adj_matrix_alpha,
double* const det_inv_matrix_alpha );
#+end_src
#+CALL: generate_c_interface(table=qmckl_det_inv_matrix_alpha_args,rettyp=get_value("CRetType"),fname="qmckl_compute_det_inv_matrix_alpha"))
@ -1848,15 +1863,15 @@ end function qmckl_compute_det_inv_matrix_alpha_f
#+RESULTS:
#+begin_src f90 :tangle (eval f) :comments org :exports none
integer(c_int32_t) function qmckl_compute_det_inv_matrix_alpha &
(context, &
det_num_alpha, &
walk_num, &
alpha_num, &
det_vgl_alpha, &
det_value_alpha, &
det_adj_matrix_alpha, &
det_inv_matrix_alpha) &
bind(C) result(info)
(context, &
det_num_alpha, &
walk_num, &
alpha_num, &
det_vgl_alpha, &
det_value_alpha, &
det_adj_matrix_alpha, &
det_inv_matrix_alpha) &
bind(C) result(info)
use, intrinsic :: iso_c_binding
implicit none
@ -1872,14 +1887,14 @@ end function qmckl_compute_det_inv_matrix_alpha_f
integer(c_int32_t), external :: qmckl_compute_det_inv_matrix_alpha_f
info = qmckl_compute_det_inv_matrix_alpha_f &
(context, &
det_num_alpha, &
walk_num, &
alpha_num, &
det_vgl_alpha, &
det_value_alpha, &
det_adj_matrix_alpha, &
det_inv_matrix_alpha)
(context, &
det_num_alpha, &
walk_num, &
alpha_num, &
det_vgl_alpha, &
det_value_alpha, &
det_adj_matrix_alpha, &
det_inv_matrix_alpha)
end function qmckl_compute_det_inv_matrix_alpha
#+end_src
@ -1892,14 +1907,16 @@ end function qmckl_compute_det_inv_matrix_alpha_f
:END:
#+NAME: qmckl_det_inv_matrix_beta_args
| ~qmckl_context~ | ~context~ | in | Global state |
| ~int64_t~ | ~det_num_beta~ | in | Number of determinants |
| ~int64_t~ | ~walk_num~ | in | Number of walkers |
| ~int64_t~ | ~beta_num~ | in | Number of electrons |
| ~double~ | ~det_vgl_beta[det_num_beta][walk_num][5][beta_num][beta_num]~ | in | determinant matrix Value, gradients and Laplacian of the MOs |
| ~double~ | ~det_value_beta[det_num_beta][walk_num]~ | out | value of determinant matrix |
| ~double~ | ~det_adj_matrix_beta[det_num_beta][walk_num][beta_num][beta_num]~ | out | adjoint of determinant matrix |
| ~double~ | ~det_inv_matrix_beta[det_num_beta][walk_num][beta_num][beta_num]~ | out | inverse of determinant matrix |
| Variable | Type | In/Out | Description |
|-----------------------+---------------------------------------------------------+--------+--------------------------------------------------------------|
| ~context~ | ~qmckl_context~ | in | Global state |
| ~det_num_beta~ | ~int64_t~ | in | Number of determinants |
| ~walk_num~ | ~int64_t~ | in | Number of walkers |
| ~beta_num~ | ~int64_t~ | in | Number of electrons |
| ~det_vgl_beta~ | ~double[det_num_beta][walk_num][5][beta_num][beta_num]~ | in | determinant matrix Value, gradients and Laplacian of the MOs |
| ~det_value_beta~ | ~double[det_num_beta][walk_num]~ | out | value of determinant matrix |
| ~det_adj_matrix_beta~ | ~double[det_num_beta][walk_num][beta_num][beta_num]~ | out | adjoint of determinant matrix |
| ~det_inv_matrix_beta~ | ~double[det_num_beta][walk_num][beta_num][beta_num]~ | out | inverse of determinant matrix |
#+begin_src f90 :comments org :tangle (eval f) :noweb yes
integer function qmckl_compute_det_inv_matrix_beta_f(context, &
@ -1945,33 +1962,43 @@ integer function qmckl_compute_det_inv_matrix_beta_f(context, &
LDA = beta_num
do idet = 1, det_num_beta
do iwalk = 1, walk_num
! Value
matA(1:beta_num,1:beta_num) = det_vgl_beta(1:beta_num, 1:beta_num, 1, iwalk, idet)
res = qmckl_adjugate(context, beta_num, LDA, matA, det_l)
det_adj_matrix_beta(1:beta_num, 1:beta_num, iwalk, idet) = matA
det_inv_matrix_beta(1:beta_num, 1:beta_num, iwalk, idet) = matA/det_l
det_value_beta(iwalk, idet) = det_l
end do
do iwalk = 1, walk_num
! Value
matA(1:beta_num,1:beta_num) = &
det_vgl_beta(1:beta_num, 1:beta_num, 1, iwalk, idet)
res = qmckl_adjugate(context, &
beta_num, matA, LDA, &
det_adj_matrix_beta(1, 1, iwalk, idet), &
int(size(det_adj_matrix_beta,1),8), &
det_l)
det_inv_matrix_beta(1:beta_num, 1:beta_num, iwalk, idet) = &
(1.d0/det_l) * &
det_adj_matrix_beta(1:beta_num, 1:beta_num, iwalk, idet)
det_value_beta(iwalk, idet) = det_l
end do
end do
deallocate(matA)
end function qmckl_compute_det_inv_matrix_beta_f
#+end_src
#+CALL: generate_c_header(table=qmckl_det_inv_matrix_beta_args,rettyp=get_value("CRetType"),fname="qmckl_compute_det_inv_matrix_beta"))
#+CALL: generate_c_header(table=qmckl_det_inv_matrix_beta_args,rettyp=get_value("CRetType"),fname="qmckl_compute_det_inv_matrix_beta"))
#+RESULTS:
#+begin_src c :tangle (eval h_func) :comments org
qmckl_exit_code qmckl_compute_det_inv_matrix_beta (
const qmckl_context context,
const int64_t det_num_beta,
const int64_t walk_num,
const int64_t beta_num,
const double* det_vgl_beta,
double* const det_value_beta,
double* const det_adj_matrix_beta,
double* const det_inv_matrix_beta );
const qmckl_context context,
const int64_t det_num_beta,
const int64_t walk_num,
const int64_t beta_num,
const double* det_vgl_beta,
double* const det_value_beta,
double* const det_adj_matrix_beta,
double* const det_inv_matrix_beta );
#+end_src
#+CALL: generate_c_interface(table=qmckl_det_inv_matrix_beta_args,rettyp=get_value("CRetType"),fname="qmckl_compute_det_inv_matrix_beta"))
@ -1979,15 +2006,15 @@ end function qmckl_compute_det_inv_matrix_beta_f
#+RESULTS:
#+begin_src f90 :tangle (eval f) :comments org :exports none
integer(c_int32_t) function qmckl_compute_det_inv_matrix_beta &
(context, &
det_num_beta, &
walk_num, &
beta_num, &
det_vgl_beta, &
det_value_beta, &
det_adj_matrix_beta, &
det_inv_matrix_beta) &
bind(C) result(info)
(context, &
det_num_beta, &
walk_num, &
beta_num, &
det_vgl_beta, &
det_value_beta, &
det_adj_matrix_beta, &
det_inv_matrix_beta) &
bind(C) result(info)
use, intrinsic :: iso_c_binding
implicit none
@ -2003,20 +2030,19 @@ end function qmckl_compute_det_inv_matrix_beta_f
integer(c_int32_t), external :: qmckl_compute_det_inv_matrix_beta_f
info = qmckl_compute_det_inv_matrix_beta_f &
(context, &
det_num_beta, &
walk_num, &
beta_num, &
det_vgl_beta, &
det_value_beta, &
det_adj_matrix_beta, &
det_inv_matrix_beta)
(context, &
det_num_beta, &
walk_num, &
beta_num, &
det_vgl_beta, &
det_value_beta, &
det_adj_matrix_beta, &
det_inv_matrix_beta)
end function qmckl_compute_det_inv_matrix_beta
#+end_src
*** Test
*** Test :noexport:
#+begin_src c :tangle (eval c_test) :exports none
// Get adjoint of the slater-determinant