From 1f31183be48fe86d3dbb3015f20d5418903ff759 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Thu, 3 Feb 2022 12:11:33 +0100 Subject: [PATCH 01/16] init compute_factor_ee --- org/qmckl_jastrow.org | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index c70ef9f..a713a5e 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1642,6 +1642,22 @@ integer function qmckl_compute_factor_ee_f(context, walk_num, elec_num, up_num, end function qmckl_compute_factor_ee_f #+end_src +#+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_factor_ee ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t up_num, + const int64_t bord_num, + const double* bord_vector, + const double* ee_distance_rescaled, + const double* asymp_jasb, + double* const factor_ee ) { + + + } +#+end_src + #+CALL: generate_c_header(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+RESULTS: From b0bfb3157c7ae9a34943fd9a8ce8b0d302c3a426 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Thu, 3 Feb 2022 17:10:31 +0100 Subject: [PATCH 02/16] translation completed; error at accessing ee_distance_rescaled --- org/qmckl_jastrow.org | 91 +++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 42 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index a713a5e..0f63118 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1642,7 +1642,7 @@ integer function qmckl_compute_factor_ee_f(context, walk_num, elec_num, up_num, end function qmckl_compute_factor_ee_f #+end_src -#+begin_src c :tangle (eval h_func) :comments org +#+begin_src c :comments org :tangle (eval c) :noweb yes qmckl_exit_code qmckl_compute_factor_ee ( const qmckl_context context, const int64_t walk_num, @@ -1654,8 +1654,56 @@ end function qmckl_compute_factor_ee_f const double* asymp_jasb, double* const factor_ee ) { + int64_t ipar; // can we use a smaller integer? + double pow_ser, x, spin_fact, power_ser; + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (walk_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + if (elec_num <= 0) { + return QMCKL_INVALID_ARG_3; + } + + if (bord_num <= 0) { + return QMCKL_INVALID_ARG_4; + } + + for (int nw = 0; nw < walk_num; ++nw) { + factor_ee[nw] = 0.0; // put init array here. + for (int j = 0; j < elec_num; ++j ) { + for (int i = 0; i < j; ++i) { + x = ee_distance_rescaled[nw][i][j]; + power_ser = 0.0; + spin_fact = 1.0; + ipar = 0; // index of asymp_jasb + + for (int p = 1; p < bord_num; ++p) { + x = x * ee_distance_rescaled[nw][i][j]; + power_ser = power_ser + bord_vector[p + 1] * x; + } + + if(j <= up_num || i > up_num) { + spin_fact = 0.5; + ipar = 1; + } + + factor_ee[nw] = factor_ee[nw] + spin_fact * bord_vector[0] * \ + ee_distance_rescaled[nw][i][j] / \ + (1.0 + bord_vector[1] * \ + ee_distance_rescaled[nw][i][j]) \ + -asymp_jasb[ipar] + power_ser; + + } } + } + + return QMCKL_SUCCESS; +} #+end_src #+CALL: generate_c_header(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name")) @@ -1677,47 +1725,6 @@ end function qmckl_compute_factor_ee_f #+CALL: generate_c_interface(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name")) - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_compute_factor_ee & - (context, & - walk_num, & - elec_num, & - up_num, & - bord_num, & - bord_vector, & - ee_distance_rescaled, & - asymp_jasb, & - factor_ee) & - 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 :: 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) :: bord_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) - real (c_double ) , intent(out) :: factor_ee(walk_num) - - integer(c_int32_t), external :: qmckl_compute_factor_ee_f - info = qmckl_compute_factor_ee_f & - (context, & - walk_num, & - elec_num, & - up_num, & - bord_num, & - bord_vector, & - ee_distance_rescaled, & - asymp_jasb, & - factor_ee) - - end function qmckl_compute_factor_ee - #+end_src *** Test #+begin_src python :results output :exports none :noweb yes From 81d55b4189daf7b5ca22444eb03b598e13cece14 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Thu, 3 Feb 2022 18:27:33 +0100 Subject: [PATCH 03/16] ee_distance_rescaled fixed;assert fails due to number mismatch --- org/qmckl_jastrow.org | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 0f63118..f47139f 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1654,7 +1654,7 @@ end function qmckl_compute_factor_ee_f const double* asymp_jasb, double* const factor_ee ) { - int64_t ipar; // can we use a smaller integer? + int ipar; // can we use a smaller integer? double pow_ser, x, spin_fact, power_ser; if (context == QMCKL_NULL_CONTEXT) { @@ -1677,13 +1677,13 @@ end function qmckl_compute_factor_ee_f factor_ee[nw] = 0.0; // put init array here. for (int j = 0; j < elec_num; ++j ) { for (int i = 0; i < j; ++i) { - x = ee_distance_rescaled[nw][i][j]; + x = ee_distance_rescaled[j + elec_num*(i + elec_num*nw)]; power_ser = 0.0; spin_fact = 1.0; ipar = 0; // index of asymp_jasb for (int p = 1; p < bord_num; ++p) { - x = x * ee_distance_rescaled[nw][i][j]; + x = x * ee_distance_rescaled[j + elec_num*(i + elec_num*nw)]; power_ser = power_ser + bord_vector[p + 1] * x; } @@ -1693,9 +1693,9 @@ end function qmckl_compute_factor_ee_f } factor_ee[nw] = factor_ee[nw] + spin_fact * bord_vector[0] * \ - ee_distance_rescaled[nw][i][j] / \ + ee_distance_rescaled[j + elec_num*(i + elec_num*nw)] / \ (1.0 + bord_vector[1] * \ - ee_distance_rescaled[nw][i][j]) \ + ee_distance_rescaled[j + elec_num*(i + elec_num*nw)]) \ -asymp_jasb[ipar] + power_ser; } From b8b2997382dd883aa80d330e6a2aefa2d5c323a1 Mon Sep 17 00:00:00 2001 From: v1j4y Date: Fri, 4 Feb 2022 17:13:15 +0100 Subject: [PATCH 04/16] Fixed indexing of ee_distance_rescaled. --- org/qmckl_jastrow.org | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index fd2c8a5..57628bf 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1624,7 +1624,7 @@ end function qmckl_compute_factor_ee_f double* const factor_ee ) { int ipar; // can we use a smaller integer? - double pow_ser, x, spin_fact, power_ser; + double pow_ser, x, x1, spin_fact, power_ser; if (context == QMCKL_NULL_CONTEXT) { return QMCKL_INVALID_CONTEXT; @@ -1646,13 +1646,14 @@ end function qmckl_compute_factor_ee_f factor_ee[nw] = 0.0; // put init array here. for (int j = 0; j < elec_num; ++j ) { for (int i = 0; i < j; ++i) { - x = ee_distance_rescaled[j + elec_num*(i + elec_num*nw)]; + x = ee_distance_rescaled[j * (walk_num * elec_num) + i * (walk_num) + nw]; + x1 = x; power_ser = 0.0; spin_fact = 1.0; ipar = 0; // index of asymp_jasb for (int p = 1; p < bord_num; ++p) { - x = x * ee_distance_rescaled[j + elec_num*(i + elec_num*nw)]; + x = x * x1; power_ser = power_ser + bord_vector[p + 1] * x; } @@ -1662,9 +1663,9 @@ end function qmckl_compute_factor_ee_f } factor_ee[nw] = factor_ee[nw] + spin_fact * bord_vector[0] * \ - ee_distance_rescaled[j + elec_num*(i + elec_num*nw)] / \ + x1 / \ (1.0 + bord_vector[1] * \ - ee_distance_rescaled[j + elec_num*(i + elec_num*nw)]) \ + x1) \ -asymp_jasb[ipar] + power_ser; } From 794ee5fe8c7a55c1c888c54c6f4df6f23a01cd7f Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Mon, 7 Feb 2022 12:17:44 +0100 Subject: [PATCH 05/16] remove generate interface --- org/qmckl_jastrow.org | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 57628bf..32e2fb4 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1652,7 +1652,7 @@ end function qmckl_compute_factor_ee_f spin_fact = 1.0; ipar = 0; // index of asymp_jasb - for (int p = 1; p < bord_num; ++p) { + for (int p = 1; p <= bord_num; ++p) { x = x * x1; power_ser = power_ser + bord_vector[p + 1] * x; } @@ -1693,7 +1693,6 @@ end function qmckl_compute_factor_ee_f #+end_src - #+CALL: generate_c_interface(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name")) *** Test From 2332007a7ce21a5ab7c978e0363a10dceb60e96e Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Mon, 7 Feb 2022 13:53:50 +0100 Subject: [PATCH 06/16] fixed qmckl_compute_factor_ee --- org/qmckl_jastrow.org | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 32e2fb4..a55d85a 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1644,20 +1644,20 @@ end function qmckl_compute_factor_ee_f for (int nw = 0; nw < walk_num; ++nw) { factor_ee[nw] = 0.0; // put init array here. - for (int j = 0; j < elec_num; ++j ) { - for (int i = 0; i < j; ++i) { + for (int i = 0; i < elec_num; ++i ) { + for (int j = 0; j < i; ++j) { x = ee_distance_rescaled[j * (walk_num * elec_num) + i * (walk_num) + nw]; x1 = x; power_ser = 0.0; spin_fact = 1.0; ipar = 0; // index of asymp_jasb - for (int p = 1; p <= bord_num; ++p) { + for (int p = 1; p < bord_num; ++p) { x = x * x1; power_ser = power_ser + bord_vector[p + 1] * x; } - if(j <= up_num || i > up_num) { + if(i < up_num || j >= up_num) { spin_fact = 0.5; ipar = 1; } From 05cfd10cc48fe728905de11127bce640ccdfe7de Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Wed, 16 Feb 2022 14:14:05 +0100 Subject: [PATCH 07/16] completed qmckl_compute_factor_en --- org/qmckl_jastrow.org | 115 +++++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 47 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index c46fe63..a177d91 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2442,6 +2442,74 @@ integer function qmckl_compute_factor_en_f(context, walk_num, elec_num, nucl_num end function qmckl_compute_factor_en_f #+end_src + + + #+begin_src c :comments org :tangle (eval c) :noweb yes +qmckl_exit_code qmckl_compute_factor_en ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t type_nucl_num, + const int64_t* type_nucl_vector, + const int64_t aord_num, + const double* aord_vector, + const double* en_distance_rescaled, + double* const factor_en ) { + + + int ipar; + double x, x1, spin_fact, power_ser; + + + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (walk_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + if (elec_num <= 0) { + return QMCKL_INVALID_ARG_3; + } + + if (nucl_num <= 0) { + return QMCKL_INVALID_ARG_4; + } + + if (aord_num <= 0) { + return QMCKL_INVALID_ARG_7; + } + + + for (int nw = 0; nw < walk_num; ++nw ) { + // init array + factor_en[nw] = 0.0; + for (int a = 0; a < nucl_num; ++a ) { + for (int i = 0; i < elec_num; ++i ) { + // x = ee_distance_rescaled[j * (walk_num * elec_num) + i * (walk_num) + nw]; + x = en_distance_rescaled[i * (walk_num * nucl_num) + a * (walk_num) + nw]; + x1 = x; + power_ser = 0.0; + + for (int p = 2; p < aord_num+1; ++p) { + x = x * x1; + power_ser = power_ser + aord_vector[(p+1)-1 + (type_nucl_vector[a]-1) * aord_num] * x; + } + + factor_en[nw] = factor_en[nw] + aord_vector[0 + (type_nucl_vector[a]-1)*aord_num] * x1 / \ + (1.0 + aord_vector[1 + (type_nucl_vector[a]-1) * aord_num] * x1) + \ + power_ser; + + } + } + } + + return QMCKL_SUCCESS; +} + #+end_src + #+CALL: generate_c_header(table=qmckl_factor_en_args,rettyp=get_value("CRetType"),fname=get_value("Name")) @@ -2461,53 +2529,6 @@ end function qmckl_compute_factor_en_f #+end_src - #+CALL: generate_c_interface(table=qmckl_factor_en_args,rettyp=get_value("CRetType"),fname=get_value("Name")) - - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_compute_factor_en & - (context, & - walk_num, & - elec_num, & - nucl_num, & - type_nucl_num, & - type_nucl_vector, & - aord_num, & - aord_vector, & - en_distance_rescaled, & - factor_en) & - 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 :: 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) :: aord_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(out) :: factor_en(walk_num) - - integer(c_int32_t), external :: qmckl_compute_factor_en_f - info = qmckl_compute_factor_en_f & - (context, & - walk_num, & - elec_num, & - nucl_num, & - type_nucl_num, & - type_nucl_vector, & - aord_num, & - aord_vector, & - en_distance_rescaled, & - factor_en) - - end function qmckl_compute_factor_en - #+end_src - *** Test #+begin_src python :results output :exports none :noweb yes import numpy as np From bf8cec7f3cf39c3bb8b100675401304b60da4d8b Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Wed, 16 Feb 2022 18:09:02 +0100 Subject: [PATCH 08/16] reordered index in ee_distance_rescaled that makes sense --- org/qmckl_jastrow.org | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index a177d91..eabde1e 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1735,7 +1735,8 @@ end function qmckl_compute_factor_ee_f factor_ee[nw] = 0.0; // put init array here. for (int i = 0; i < elec_num; ++i ) { for (int j = 0; j < i; ++j) { - x = ee_distance_rescaled[j * (walk_num * elec_num) + i * (walk_num) + nw]; + //x = ee_distance_rescaled[j * (walk_num * elec_num) + i * (walk_num) + nw]; + x = ee_distance_rescaled[j + i * elec_num + nw*(elec_num * elec_num)]; x1 = x; power_ser = 0.0; spin_fact = 1.0; From bb2e8384e8b8cde1bab3edef6bbc44c8949b0ba2 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Wed, 16 Feb 2022 18:13:57 +0100 Subject: [PATCH 09/16] fix reorder of nex function --- org/qmckl_jastrow.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index eabde1e..7b1f0b8 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2490,7 +2490,7 @@ qmckl_exit_code qmckl_compute_factor_en ( for (int a = 0; a < nucl_num; ++a ) { for (int i = 0; i < elec_num; ++i ) { // x = ee_distance_rescaled[j * (walk_num * elec_num) + i * (walk_num) + nw]; - x = en_distance_rescaled[i * (walk_num * nucl_num) + a * (walk_num) + nw]; + x = en_distance_rescaled[i + a * elec_num + nw * (elec_num * nucl_num)]; x1 = x; power_ser = 0.0; From 2427d1b56ebc836c603a8466ac6098fd2d8820f9 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Tue, 22 Feb 2022 14:52:21 +0100 Subject: [PATCH 10/16] working qmckl_compute_een_rescaled_n --- org/qmckl_jastrow.org | 106 +++++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 42 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 7b1f0b8..9867010 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -3855,6 +3855,70 @@ integer function qmckl_compute_een_rescaled_n_f(context, walk_num, elec_num, nuc end function qmckl_compute_een_rescaled_n_f #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes +qmckl_exit_code qmckl_compute_een_rescaled_n ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t cord_num, + const double rescale_factor_kappa_en, + const double* en_distance, + double* const een_rescaled_n ) { + + + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (walk_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + if (elec_num <= 0) { + return QMCKL_INVALID_ARG_3; + } + + if (nucl_num <= 0) { + return QMCKL_INVALID_ARG_4; + } + + if (cord_num <= 0) { + return QMCKL_INVALID_ARG_5; + } + + // Prepare table of exponentiated distances raised to appropriate power + for (int i = 0; i < (walk_num*(cord_num+1)*nucl_num*elec_num); ++i) { + een_rescaled_n[i] = 17.0; + } + + for (int nw = 0; nw < walk_num; ++nw) { + for (int a = 0; a < nucl_num; ++a) { + for (int i = 0; i < elec_num; ++i) { + // prepare the actual een table + //een_rescaled_n(:, :, 0, nw) = 1.0d0 + een_rescaled_n[i + a * elec_num + 0 + nw * elec_num*nucl_num*(cord_num+1)] = 1.0; + //een_rescaled_n(i, a, 1, nw) = dexp(-rescale_factor_kappa_en * en_distance(i, a, nw)) + een_rescaled_n[i + a*elec_num + elec_num*nucl_num + nw*elec_num*nucl_num*(cord_num+1)] = exp(-rescale_factor_kappa_en * \ + en_distance[i + a*elec_num + nw*elec_num*nucl_num]); + } + } + + for (int l = 2; l < (cord_num+1); ++l){ + for (int a = 0; a < nucl_num; ++a) { + for (int i = 0; i < elec_num; ++i) { + een_rescaled_n[i + a*elec_num + l*elec_num*nucl_num + nw*elec_num*nucl_num*(cord_num+1)] = een_rescaled_n[i + a*elec_num + (l-1)*elec_num*nucl_num + nw*elec_num*nucl_num*(cord_num+1)] *\ + een_rescaled_n[i + a*elec_num + elec_num*nucl_num + nw*elec_num*nucl_num*(cord_num+1)]; + } + } + } + + } + + return QMCKL_SUCCESS; +} + #+end_src + #+CALL: generate_c_header(table=qmckl_factor_een_rescaled_n_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+RESULTS: @@ -3870,47 +3934,6 @@ end function qmckl_compute_een_rescaled_n_f double* const een_rescaled_n ); #+end_src - #+CALL: generate_c_interface(table=qmckl_factor_een_rescaled_n_args,rettyp=get_value("CRetType"),fname=get_value("Name")) - - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_compute_een_rescaled_n & - (context, & - walk_num, & - elec_num, & - nucl_num, & - cord_num, & - rescale_factor_kappa_en, & - en_distance, & - een_rescaled_n) & - 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 :: 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 - real (c_double ) , intent(in) , value :: rescale_factor_kappa_en - real (c_double ) , intent(in) :: en_distance(nucl_num,elec_num,walk_num) - real (c_double ) , intent(out) :: een_rescaled_n(nucl_num,elec_num,0:cord_num,walk_num) - - integer(c_int32_t), external :: qmckl_compute_een_rescaled_n_f - info = qmckl_compute_een_rescaled_n_f & - (context, & - walk_num, & - elec_num, & - nucl_num, & - cord_num, & - rescale_factor_kappa_en, & - en_distance, & - een_rescaled_n) - - end function qmckl_compute_een_rescaled_n - #+end_src - *** Test #+begin_src python :results output :exports none :noweb yes @@ -3969,7 +3992,6 @@ assert(fabs(een_rescaled_n[0][1][0][4]-0.023391817607642338) < 1.e-12); assert(fabs(een_rescaled_n[0][2][1][3]-0.880957224822116) < 1.e-12); assert(fabs(een_rescaled_n[0][2][1][4]-0.027185942659395074) < 1.e-12); assert(fabs(een_rescaled_n[0][2][1][5]-0.01343938025140174) < 1.e-12); - #+end_src ** Electron-nucleus rescaled distances for each order and derivatives From 4fac9f06c9f86e6072fac909c1132f403f6f6267 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Mon, 28 Feb 2022 17:47:24 +0100 Subject: [PATCH 11/16] to be checked --- org/qmckl_jastrow.org | 61 +++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index aac48b8..9674f47 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -4962,6 +4962,45 @@ integer function qmckl_compute_dim_cord_vect_f(context, cord_num, dim_cord_vect) end function qmckl_compute_dim_cord_vect_f #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes +qmckl_exit_code qmckl_compute_dim_cord_vect ( + const qmckl_context context, + const int64_t cord_num, + int64_t* const dim_cord_vect){ + + int lmax; + + + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (cord_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + dim_cord_vect = 0; + + for (int p=2; p < cord_num; ++p){ + for (int k=p-1; k <= 0; --k) { + if (k != 0) { + lmax = p - k; + } else { + lmax = p - k - 2; + } + for (l = lmax; l <= 0; --l) { +// if ( iand(p - k - l, 1_8) == 1) continue; +// Does it make sense? it should + if ( ((p - k - l) & 1)==1) continue; + dim_cord_vect = dim_cord_vect + 1; + } + } + } + + return QMCKL_SUCCESS; +} + #+end_src + #+CALL: generate_c_header(table=qmckl_factor_dim_cord_vect_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+RESULTS: @@ -4973,28 +5012,6 @@ end function qmckl_compute_dim_cord_vect_f #+end_src - #+CALL: generate_c_interface(table=qmckl_factor_dim_cord_vect_args,rettyp=get_value("CRetType"),fname=get_value("Name")) - - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_compute_dim_cord_vect & - (context, cord_num, dim_cord_vect) & - 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 :: cord_num - integer (c_int64_t) , intent(out) :: dim_cord_vect - - integer(c_int32_t), external :: qmckl_compute_dim_cord_vect_f - info = qmckl_compute_dim_cord_vect_f & - (context, cord_num, dim_cord_vect) - - end function qmckl_compute_dim_cord_vect - #+end_src - *** Compute cord_vect_full :PROPERTIES: :Name: qmckl_compute_cord_vect_full From d13693a822c22acff50d9b7b640fc94d4a71751c Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Wed, 2 Mar 2022 10:18:45 +0100 Subject: [PATCH 12/16] to be cleaned from print --- org/qmckl_jastrow.org | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 9674f47..518ddfb 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -4979,23 +4979,28 @@ qmckl_exit_code qmckl_compute_dim_cord_vect ( return QMCKL_INVALID_ARG_2; } - dim_cord_vect = 0; + printf("hello %d\n", *dim_cord_vect); + *dim_cord_vect = 0; for (int p=2; p < cord_num; ++p){ + printf("in da loop\n"); for (int k=p-1; k <= 0; --k) { if (k != 0) { lmax = p - k; } else { lmax = p - k - 2; } - for (l = lmax; l <= 0; --l) { + printf("lmax %d\n", lmax); + for (int l = lmax; l <= 0; --l) { // if ( iand(p - k - l, 1_8) == 1) continue; // Does it make sense? it should if ( ((p - k - l) & 1)==1) continue; - dim_cord_vect = dim_cord_vect + 1; + printf("in da loop\n"); + *dim_cord_vect = *dim_cord_vect + 1; } } } + printf("hello 2 %d\n", *dim_cord_vect); return QMCKL_SUCCESS; } From a4ba5deac4a74fe48c8d928408d8d611f285826b Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Wed, 9 Mar 2022 11:15:15 +0100 Subject: [PATCH 13/16] compute_dim_cord_vect done --- org/qmckl_jastrow.org | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 518ddfb..74fe58e 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -4979,29 +4979,22 @@ qmckl_exit_code qmckl_compute_dim_cord_vect ( return QMCKL_INVALID_ARG_2; } - printf("hello %d\n", *dim_cord_vect); *dim_cord_vect = 0; - - for (int p=2; p < cord_num; ++p){ - printf("in da loop\n"); - for (int k=p-1; k <= 0; --k) { + + for (int p=2; p <= cord_num; ++p){ + for (int k=p-1; k >= 0; --k) { if (k != 0) { lmax = p - k; } else { lmax = p - k - 2; } - printf("lmax %d\n", lmax); - for (int l = lmax; l <= 0; --l) { -// if ( iand(p - k - l, 1_8) == 1) continue; -// Does it make sense? it should + for (int l = lmax; l >= 0; --l) { if ( ((p - k - l) & 1)==1) continue; - printf("in da loop\n"); - *dim_cord_vect = *dim_cord_vect + 1; + *dim_cord_vect=*dim_cord_vect+1; } } } - printf("hello 2 %d\n", *dim_cord_vect); - + return QMCKL_SUCCESS; } #+end_src From b222ee3156a273a8580964c1de03096bd3b1b5fc Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Mon, 14 Mar 2022 11:21:31 +0100 Subject: [PATCH 14/16] lkpm works --- org/qmckl_jastrow.org | 73 +++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 74fe58e..423f152 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -5128,7 +5128,7 @@ end function qmckl_compute_cord_vect_full_f | ~context~ | ~qmckl_context~ | in | Global state | | ~cord_num~ | ~int64_t~ | in | Order of polynomials | | ~dim_cord_vect~ | ~int64_t~ | in | dimension of cord full table | - | ~lpkm_combined_index~ | ~int64_t[4][dim_cord_vect]~ | out | Full list of combined indices | + | ~lkpm_combined_index~ | ~int64_t[4][dim_cord_vect]~ | out | Full list of combined indices | #+begin_src f90 :comments org :tangle (eval f) :noweb yes integer function qmckl_compute_lkpm_combined_index_f(context, cord_num, dim_cord_vect, & @@ -5184,6 +5184,53 @@ integer function qmckl_compute_lkpm_combined_index_f(context, cord_num, dim_cord end function qmckl_compute_lkpm_combined_index_f #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes +qmckl_exit_code qmckl_compute_lkpm_combined_index ( + const qmckl_context context, + const int64_t cord_num, + const int64_t dim_cord_vect, + int64_t* const lkpm_combined_index ) { + + int kk, lmax, m; + + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (cord_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + if (dim_cord_vect <= 0) { + return QMCKL_INVALID_ARG_3; + } + +/* +*/ + kk = 0; + for (int p = 2; p <= cord_num; ++p) { + for (int k=(p-1); k >= 0; --k) { + if (k != 0) { + lmax = p - k; + } else { + lmax = p - k - 2; + } + for (int l=lmax; l >= 0; --l) { + if (((p - k - l) & 1) == 1) continue; + m = (p - k - l)/2; + lkpm_combined_index[kk ] = l; + lkpm_combined_index[kk + dim_cord_vect] = k; + lkpm_combined_index[kk + 2*dim_cord_vect] = p; + lkpm_combined_index[kk + 3*dim_cord_vect] = m; + kk = kk + 1; + } + } + } + + return QMCKL_SUCCESS; +} + #+end_src + #+CALL: generate_c_header(table=qmckl_factor_lkpm_combined_index_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+RESULTS: @@ -5192,32 +5239,10 @@ end function qmckl_compute_lkpm_combined_index_f const qmckl_context context, const int64_t cord_num, const int64_t dim_cord_vect, - int64_t* const lpkm_combined_index ); + int64_t* const lkpm_combined_index ); #+end_src - #+CALL: generate_c_interface(table=qmckl_factor_lkpm_combined_index_args,rettyp=get_value("CRetType"),fname=get_value("Name")) - - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_compute_lkpm_combined_index & - (context, cord_num, dim_cord_vect, lpkm_combined_index) & - 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 :: cord_num - integer (c_int64_t) , intent(in) , value :: dim_cord_vect - integer (c_int64_t) , intent(out) :: lpkm_combined_index(dim_cord_vect,4) - - integer(c_int32_t), external :: qmckl_compute_lkpm_combined_index_f - info = qmckl_compute_lkpm_combined_index_f & - (context, cord_num, dim_cord_vect, lpkm_combined_index) - - end function qmckl_compute_lkpm_combined_index - #+end_src *** Compute tmp_c :PROPERTIES: From 6b45157212c211f398dca3c2c99eeef859852029 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Thu, 17 Mar 2022 17:46:21 +0100 Subject: [PATCH 15/16] tmp_c done --- org/qmckl_jastrow.org | 94 ++++++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 27 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 423f152..4f777da 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -5330,6 +5330,73 @@ integer function qmckl_compute_tmp_c_f(context, cord_num, elec_num, nucl_num, & end function qmckl_compute_tmp_c_f #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes +qmckl_exit_code qmckl_compute_tmp_c ( + const qmckl_context context, + const int64_t cord_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t walk_num, + const double* een_rescaled_e, + const double* een_rescaled_n, + double* const tmp_c ) { + + qmckl_exit_code info; + int i, j, a, l, kk, p, lmax, nw; + char TransA, TransB; + double alpha, beta; + int M, N, K, LDA, LDB, LDC; + + TransA = 'N'; + TransB = 'N'; + alpha = 1.0; + beta = 0.0; + + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (cord_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + if (elec_num <= 0) { + return QMCKL_INVALID_ARG_3; + } + + if (nucl_num <= 0) { + return QMCKL_INVALID_ARG_4; + } + + M = elec_num; + N = nucl_num*(cord_num + 1); + K = elec_num; + + LDA = sizeof(een_rescaled_e)/sizeof(double); + LDB = sizeof(een_rescaled_n)/sizeof(double); + LDC = sizeof(tmp_c)/sizeof(double); + +// DOING + for (int nw=0; nw < walk_num; ++nw) { + for (int i=0; i Date: Thu, 17 Mar 2022 22:27:10 +0100 Subject: [PATCH 16/16] dtmp_c done --- org/qmckl_jastrow.org | 95 ++++++++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 29 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 4f777da..9b0370c 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -5376,7 +5376,6 @@ qmckl_exit_code qmckl_compute_tmp_c ( LDB = sizeof(een_rescaled_n)/sizeof(double); LDC = sizeof(tmp_c)/sizeof(double); -// DOING for (int nw=0; nw < walk_num; ++nw) { for (int i=0; i