diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 91ec082..86345b9 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -29,7 +29,7 @@ J_{\text{ee}}(\mathbf{r}) = \sum_{i=1}^{N_\text{elec}} \sum_{j=1}^{i-1} \frac{\frac{1}{2}(1+\delta^{\uparrow\downarrow}_{ij}) b_1\, f_{\text{ee}}(r_{ij})}{1+b_2\, f_{\text{ee}}(r_{ij})} + - \sum_{p=2}^{N_\text{ord}^b} a_{p+1}\, [f_{\text{ee}}(r_{ij})]^p - J_{ee}^\infty + \sum_{p=2}^{N_\text{ord}^b} b_{p+1}\, [f_{\text{ee}}(r_{ij})]^p - J_{ee}^\infty \] and $J_{\text{eeN}}$ contains electron-electron-Nucleus terms: @@ -1651,14 +1651,16 @@ assert(qmckl_nucleus_provided(context)); compute. If it is the case, then the data is recomputed and the current date is stored. -** Asymptotic component for \(J_{ee}\) +** Asymptotic component for \(J_\text{ee}\) - Calculate the asymptotic component ~asymp_jasb~ to be substracted from the final - electron-electron jastrow factor \(J_{\text{ee}}\). The asymptotic component is calculated - via the ~b_vector~ and the electron-electron rescale factor ~rescale_factor_ee~. + Calculate the asymptotic component ~asymp_jasb~ to be substracted from the + electron-electron jastrow factor \(J_{\text{ee}}\). Two values are + computed. The first one is for antiparallel spin pairs, and the + second one for parallel spin pairs. \[ - J_{\text{ee}}^{\infty} = \frac{b_1 \kappa^{-1}}{1 + b_2 \kappa^{-1}} + J_{\text{ee}}^{\infty} = \frac{\frac{1}{2}(1+\delta^{\uparrow \downarrow})\,b_1 \kappa_\text{ee}^{-1}}{1 + b_2\, + \kappa_\text{ee}^{-1}} + \sum_{p=2}^{N_\text{ord}^b} b_{p+1}\, \kappa_\text{ee}^{-p} \] *** Get @@ -1801,8 +1803,31 @@ qmckl_exit_code qmckl_provide_jastrow_asymp_jasb(qmckl_context context) | ~rescale_factor_ee~ | ~double~ | in | Electron coordinates | | ~asymp_jasb~ | ~double[2]~ | out | Asymptotic value | +# #+CALL: generate_c_interface(table=qmckl_asymp_jasb_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_jastrow_asymp_jasb_doc & + (context, bord_num, b_vector, rescale_factor_ee, asymp_jasb) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , 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 + real (c_double ) , intent(out) :: asymp_jasb(2) + + integer(c_int32_t), external :: qmckl_compute_jastrow_asymp_jasb_doc_f + info = qmckl_compute_jastrow_asymp_jasb_doc_f & + (context, bord_num, b_vector, rescale_factor_ee, asymp_jasb) + + end function qmckl_compute_jastrow_asymp_jasb_doc + #+end_src + #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_jastrow_asymp_jasb_f(context, bord_num, b_vector, rescale_factor_ee, asymp_jasb) & +integer function qmckl_compute_jastrow_asymp_jasb_doc_f(context, bord_num, b_vector, rescale_factor_ee, asymp_jasb) & result(info) use qmckl implicit none @@ -1839,53 +1864,86 @@ integer function qmckl_compute_jastrow_asymp_jasb_f(context, bord_num, b_vector, end do end do -end function qmckl_compute_jastrow_asymp_jasb_f +end function qmckl_compute_jastrow_asymp_jasb_doc_f #+end_src +#+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_compute_jastrow_asymp_jasb_doc (const qmckl_context context, + const int64_t bord_num, + const double* b_vector, + const double rescale_factor_ee, + double* const asymp_jasb ); +#+end_src + + +#+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_compute_jastrow_asymp_jasb_hpc (const qmckl_context context, + const int64_t bord_num, + const double* b_vector, + const double rescale_factor_ee, + double* const asymp_jasb ); +#+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes +qmckl_exit_code +qmckl_compute_jastrow_asymp_jasb_hpc (const qmckl_context context, + const int64_t bord_num, + const double* b_vector, + const double rescale_factor_ee, + double* const asymp_jasb ) +{ + + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (bord_num < 0) { + return QMCKL_INVALID_ARG_2; + } + + const double kappa_inv = 1.0 / rescale_factor_ee; + const double asym_one = b_vector[0] * kappa_inv / (1.0 + b_vector[1] * kappa_inv); + asymp_jasb[0] = asym_one; + asymp_jasb[1] = 0.5 * asym_one; + + for (int i = 0 ; i<2 ; ++i) { + double x = kappa_inv; + for (int p = 1; p < bord_num; ++p) { + x *= kappa_inv; + asymp_jasb[i] += b_vector[p+1]*x; + } + } + + return QMCKL_SUCCESS; +} + #+end_src + + +#+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_compute_jastrow_asymp_jasb (const qmckl_context context, + const int64_t bord_num, + const double* b_vector, + const double rescale_factor_ee, + double* const asymp_jasb ); +#+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes qmckl_exit_code qmckl_compute_jastrow_asymp_jasb ( const qmckl_context context, const int64_t bord_num, const double* b_vector, const double rescale_factor_ee, - double* const asymp_jasb ) { - - if (context == QMCKL_NULL_CONTEXT){ - return QMCKL_INVALID_CONTEXT; - } - - if (bord_num < 0) { - return QMCKL_INVALID_ARG_2; - } - - const double kappa_inv = 1.0 / rescale_factor_ee; - const double asym_one = b_vector[0] * kappa_inv / (1.0 + b_vector[1] * kappa_inv); - asymp_jasb[0] = asym_one; - asymp_jasb[1] = 0.5 * asym_one; - - for (int i = 0 ; i <= 1; ++i) { - double x = kappa_inv; - for (int p = 1; p < bord_num; ++p){ - x *= kappa_inv; - asymp_jasb[i] = asymp_jasb[i] + b_vector[p + 1] * x; - } - } - - return QMCKL_SUCCESS; + double* const asymp_jasb ) +{ +#ifdef HAVE_HPC + return qmckl_compute_jastrow_asymp_jasb_hpc (context, + bord_num, b_vector, rescale_factor_ee, asymp_jasb); +#else + return qmckl_compute_jastrow_asymp_jasb_doc (context, + bord_num, b_vector, rescale_factor_ee, asymp_jasb); +#endif } #+end_src - -# #+CALL: generate_c_header(table=qmckl_asymp_jasb_args,rettyp=get_value("CRetType"),fname=get_value("Name")) - - #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none - qmckl_exit_code qmckl_compute_jastrow_asymp_jasb ( - const qmckl_context context, - const int64_t bord_num, - const double* b_vector, - const double rescale_factor_ee, - double* const asymp_jasb ); - #+end_src - *** Test #+name: asymp_jasb #+begin_src python :results output :exports none :noweb yes @@ -2007,7 +2065,7 @@ assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); component and the electron-electron rescaled distances ~ee_distance_rescaled~. \[ -f_\text{ee} = \sum_{i,j