1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-06-30 00:44:52 +02:00

Merge branch 'master' into jastrow_c

This commit is contained in:
Gianfranco Abrusci 2022-02-09 17:45:37 +01:00
commit c3889340eb
2 changed files with 110 additions and 62 deletions

View File

@ -872,7 +872,7 @@ end function test_qmckl_dist
pairs of points in two sets, one point within each set: pairs of points in two sets, one point within each set:
\[ \[
C_{ij} = \left( 1 - \exp{-\kappa C_{ij}}\right)/\kappa C_{ij} = \left( 1 - \exp \left(-\kappa C_{ij} \right) \right)/\kappa
\] \]
If the input array is normal (~'N'~), the xyz coordinates are in If the input array is normal (~'N'~), the xyz coordinates are in

View File

@ -3,10 +3,61 @@
#+SETUPFILE: ../tools/theme.setup #+SETUPFILE: ../tools/theme.setup
#+INCLUDE: ../tools/lib.org #+INCLUDE: ../tools/lib.org
Functions for the calculation of the Jastrow factor \(f_{ee}, f_{en}, f_{een}\). * Introduction
These are stored in the ~factor_ee~, ~factor_en~, and ~factor_een~ variables.
The ~jastrow~ structure contains all the information required to build The Jastrow factor depends on the electronic ($\mathbf{r}$) and
these factors along with their derivatives. nuclear ($\mathbf{R}$) coordinates. Its defined as $\exp(J(\mathbf{r},\mathbf{R}))$, where
\[
J(\mathbf{r},\mathbf{R}) = J_{\text{eN}}(\mathbf{r},\mathbf{R}) + J_{\text{ee}}(\mathbf{r}) + J_{\text{eeN}}(\mathbf{r},\mathbf{R})
\]
In the following, we us the notations $r_{ij} = |\mathbf{r}_i - \mathbf{r}_j|$ and
$R_{i\alpha} = |\mathbf{r}_i - \mathbf{R}_\alpha|$.
$J_{\text{eN}}$ contains electron-nucleus terms:
\[
J_{\text{eN}}(\mathbf{r},\mathbf{R}) = \sum_{i=1}^{N_\text{elec}} \sum_{\alpha=1}^{N_\text{nucl}}
\frac{a_1\, f(R_{i\alpha})}{1+a_2\, f(R_{i\alpha})} +
\sum_{p=2}^{N_\text{ord}^a} a_{p+1}\, [f(R_{i\alpha})]^p - J_{eN}^\infty
\]
$J_{\text{ee}}$ contains electron-electron terms:
\[
J_{\text{ee}}(\mathbf{r}) =
\sum_{i=1}^{N_\text{elec}} \sum_{j=1}^{i-1}
\frac{b_1\, f(r_{ij})}{1+b_2\, f(r_{ij})} +
\sum_{p=2}^{N_\text{ord}^b} a_{p+1}\, [f(r_{ij})]^p - J_{ee}^\infty
\]
and $J_{\text{eeN}}$ contains electron-electron-Nucleus terms:
\[
J_{\text{eeN}}(\mathbf{r},\mathbf{R}) =
\sum_{\alpha=1}^{N_{\text{nucl}}}
\sum_{i=1}^{N_{\text{elec}}}
\sum_{j=1}^{i-1}
\sum_{p=2}^{N_{\text{ord}}}
\sum_{k=0}^{p-1}
\sum_{l=0}^{p-k-2\delta_{k,0}}
c_{lkp\alpha} \left[ g({r}_{ij}) \right]^k
\left[ \left[ g({R}_{i\alpha}) \right]^l + \left[ g({R}_{j\alpha}) \right]^l \right]
\left[ g({R}_{i\,\alpha}) \, g({R}_{j\alpha}) \right]^{(p-k-l)/2}
\]
$c_{lkp\alpha}$ are non-zero only when $p-k-l$ is even.
$f$ and $g$ are scaling function defined as
\[
f(r) = \frac{1-e^{-\kappa\, r}}{\kappa} \text{ and }
g(r) = e^{-\kappa\, r}.
\]
The terms $J_{\text{ee}}^\infty$ and $J_{\text{eN}}^\infty$ are shifts to ensure that
$J_{\text{ee}}$ and $J_{\text{eN}}$ have an asymptotic value of zero.
* Headers :noexport: * Headers :noexport:
#+begin_src elisp :noexport :results none #+begin_src elisp :noexport :results none
@ -79,7 +130,7 @@ int main() {
#+NAME: qmckl_jastrow_args #+NAME: qmckl_jastrow_args
| Variable | Type | In/Out | Description | | Variable | Type | In/Out | Description |
|---------------------------+---------------------------------------+--------+-------------------------------------------------------------------| |---------------------------+---------------------------------------+--------+-------------------------------------------------------------------|
| ~uninitialized~ | ~int32_t~ | in | Keeps bit set for uninitialized data | | ~uninitialized~ | ~int32_t~ | in | Keeps bits set for uninitialized data |
| ~aord_num~ | ~int64_t~ | in | The number of a coeffecients | | ~aord_num~ | ~int64_t~ | in | The number of a coeffecients |
| ~bord_num~ | ~int64_t~ | in | The number of b coeffecients | | ~bord_num~ | ~int64_t~ | in | The number of b coeffecients |
| ~cord_num~ | ~int64_t~ | in | The number of c coeffecients | | ~cord_num~ | ~int64_t~ | in | The number of c coeffecients |
@ -123,12 +174,11 @@ int main() {
| ~een_rescaled_n_deriv_e~ | ~double[walk_num][elec_num][4][nucl_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons | | | ~een_rescaled_n_deriv_e~ | ~double[walk_num][elec_num][4][nucl_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons | |
| ~een_rescaled_n_deriv_e_date~ | ~uint64_t~ | Keep track of the date of creation | | | ~een_rescaled_n_deriv_e_date~ | ~uint64_t~ | Keep track of the date of creation | |
For H2O we have the following data:
#+NAME: jastrow_data #+NAME: jastrow_data
#+BEGIN_SRC python :results output #+BEGIN_SRC python :results none :exports none
import numpy as np import numpy as np
# For H2O we have the following data:
elec_num = 10 elec_num = 10
nucl_num = 2 nucl_num = 2
up_num = 5 up_num = 5
@ -149,46 +199,46 @@ elec_coord = [[[-0.250655104764153 , 0.503070975550133 , -0.16655
[ 0.397978144318712 , -0.254277292595981 , 2.54553335476344]]]; [ 0.397978144318712 , -0.254277292595981 , 2.54553335476344]]];
ee_distance_rescaled = [ ee_distance_rescaled = [
[ 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, [ 0.000000000000000, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.000000000000000, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.000000000000000, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000], 0.000000000000000 ],
[ 0.550227800352402 ,0.000000000000000E+000 ,0.000000000000000E+000, [ 0.550227800352402, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.000000000000000, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.000000000000000, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000], 0.000000000000000 ],
[ 0.919155060185168 ,0.937695909123175 ,0.000000000000000E+000, [ 0.919155060185168, 0.937695909123175, 0.000000000000000,
0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.000000000000000, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.000000000000000, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000], 0.000000000000000 ],
[ 0.893325429242815 ,0.851181978173561 ,0.978501685226877 , [ 0.893325429242815, 0.851181978173561, 0.978501685226877,
0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.000000000000000, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.000000000000000, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000], 0.000000000000000 ],
[ 0.982457268305353 ,0.976125002619471 ,0.994349933143149 , [ 0.982457268305353, 0.976125002619471, 0.994349933143149,
0.844077311588328 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.844077311588328, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.000000000000000, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000], 0.000000000000000 ],
[ 0.482407528408731 ,0.414816073699124 ,0.894716035479343 , [ 0.482407528408731, 0.414816073699124, 0.894716035479343,
0.876540187084407 ,0.978921170036895 ,0.000000000000000E+000, 0.876540187084407, 0.978921170036895, 0.000000000000000,
0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.000000000000000, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000], 0.000000000000000 ],
[ 0.459541909660400 ,0.545007215761510 ,0.883752955884551 , [ 0.459541909660400, 0.545007215761510, 0.883752955884551,
0.918958134888791 ,0.986386936267237 ,0.362209822236419 , 0.918958134888791, 0.986386936267237, 0.362209822236419,
0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.000000000000000, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000], 0.000000000000000 ],
[ 0.763732576854455 ,0.817282762358449 ,0.801802919535959 , [ 0.763732576854455, 0.817282762358449, 0.801802919535959,
0.900089095449775 ,0.975704636491453 ,0.707836537586060 , 0.900089095449775, 0.975704636491453, 0.707836537586060,
0.755705808346586 ,0.000000000000000E+000 ,0.000000000000000E+000, 0.755705808346586, 0.000000000000000, 0.000000000000000,
0.000000000000000E+000], 0.000000000000000 ],
[ 0.904249454052971 ,0.871097965261373 ,0.982717262706270 , [ 0.904249454052971, 0.871097965261373, 0.982717262706270,
0.239901207363622 ,0.836519456769083 ,0.896135326270534 , 0.239901207363622, 0.836519456769083, 0.896135326270534,
0.930694340243023 ,0.917708540815567 ,0.000000000000000E+000, 0.930694340243023, 0.917708540815567, 0.000000000000000,
0.000000000000000E+000], 0.000000000000000 ],
[ 0.944400908070716 ,0.922589018494961 ,0.984615718580670 , [ 0.944400908070716, 0.922589018494961, 0.984615718580670,
0.514328661540623 ,0.692362267147064 ,0.931894098453677 , 0.514328661540623, 0.692362267147064, 0.931894098453677,
0.956034127544344 ,0.931221472309472 ,0.540903688625053 , 0.956034127544344, 0.931221472309472, 0.540903688625053,
0.000000000000000E+000]] 0.000000000000000 ]]
en_distance_rescaled = np.transpose(np.array([ en_distance_rescaled = np.transpose(np.array([
[ 0.443570948411811 , 0.467602196999105 , 0.893870160799932 , [ 0.443570948411811 , 0.467602196999105 , 0.893870160799932 ,
@ -275,8 +325,6 @@ kappa = 1.0
kappa_inv = 1.0/kappa kappa_inv = 1.0/kappa
#+END_SRC #+END_SRC
#+RESULTS: jastrow_data
** Data structure ** Data structure
#+begin_src c :comments org :tangle (eval h_private_type) #+begin_src c :comments org :tangle (eval h_private_type)
@ -921,7 +969,7 @@ qmckl_exit_code qmckl_set_jastrow_cord_vector(qmckl_context context, double cons
When the required information is completely entered, other data structures are When the required information is completely entered, other data structures are
computed to accelerate the calculations. The intermediates factors computed to accelerate the calculations. The intermediates factors
are precontracted using BLAS LEVEL 3 operations for an optimal FLOP count. are precontracted using BLAS LEVEL 3 operations for an optimal flop count.
#+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none
qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context); qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context);
@ -1150,14 +1198,14 @@ assert(qmckl_nucleus_provided(context));
compute. If it is the case, then the data is recomputed and the compute. If it is the case, then the data is recomputed and the
current date is stored. current date is stored.
** Asymptotic component for \(f_{ee}\) ** Asymptotic component for \(J_{ee}\)
Calculate the asymptotic component ~asymp_jasb~ to be substracted from the final Calculate the asymptotic component ~asymp_jasb~ to be substracted from the final
electron-electron jastrow factor \(f_{ee}\). The asymptotic componenet is calculated electron-electron jastrow factor \(J_{\text{ee}}\). The asymptotic component is calculated
via the ~bord_vector~ and the electron-electron rescale factor ~rescale_factor_kappa~. via the ~bord_vector~ and the electron-electron rescale factor ~rescale_factor_kappa~.
\[ \[
J_{asymp} = \frac{b_1 \kappa^-1}{1 + b_2 \kappa^-1} J_{\text{ee}}^{\infty} = \frac{b_1 \kappa^{-1}}{1 + b_2 \kappa^{-1}}
\] \]
*** Get *** Get
@ -1255,12 +1303,12 @@ qmckl_exit_code qmckl_provide_asymp_jasb(qmckl_context context)
#+NAME: qmckl_asymp_jasb_args #+NAME: qmckl_asymp_jasb_args
| Variable | Type | In/Out | Description | | Variable | Type | In/Out | Description |
|---------------------------+----------------------+--------+-----------------------------| |---------------------------+----------------------+--------+-------------------------|
| ~context~ | ~qmckl_context~ | in | Global state | | ~context~ | ~qmckl_context~ | in | Global state |
| ~bord_num~ | ~int64_t~ | in | Number of electrons | | ~bord_num~ | ~int64_t~ | in | Order of the polynomial |
| ~bord_vector~ | ~double[bord_num+1]~ | in | Number of walkers | | ~bord_vector~ | ~double[bord_num+1]~ | in | Values of b |
| ~rescale_factor_kappa_ee~ | ~double~ | in | Electron coordinates | | ~rescale_factor_kappa_ee~ | ~double~ | in | Electron coordinates |
| ~asymp_jasb~ | ~double[2]~ | out | Electron-electron distances | | ~asymp_jasb~ | ~double[2]~ | out | Asymptotic value |
#+begin_src f90 :comments org :tangle (eval f) :noweb yes #+begin_src f90 :comments org :tangle (eval f) :noweb yes
integer function qmckl_compute_asymp_jasb_f(context, bord_num, bord_vector, rescale_factor_kappa_ee, asymp_jasb) & integer function qmckl_compute_asymp_jasb_f(context, bord_num, bord_vector, rescale_factor_kappa_ee, asymp_jasb) &