1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-08-16 18:38:28 +02:00

completed qmckl_compute_factor_en

This commit is contained in:
Gianfranco Abrusci 2022-02-16 14:14:05 +01:00
parent 85e0a6e8e0
commit 05cfd10cc4

View File

@ -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