mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-01-03 18:16:28 +01:00
Fixed cppcheck in AOs
This commit is contained in:
parent
713008097a
commit
ecfe58a966
163
org/qmckl_ao.org
163
org/qmckl_ao.org
@ -117,7 +117,7 @@ int main() {
|
||||
| ~ao_shell~ | ~[ao_num]~ | For each AO, specify to which shell it belongs |
|
||||
|
||||
Computed data:
|
||||
|
||||
|
||||
|--------------------------+----------------------------+-----------------------------------------------------------------------------------------------|
|
||||
| ~coefficient_normalized~ | ~[prim_num]~ | Normalized primitive coefficients |
|
||||
| ~nucleus_prim_index~ | ~[nucl_num]~ | Index of the first primitive for each nucleus |
|
||||
@ -193,7 +193,7 @@ prim_factor = [ 1.0006253235944540e+01, 2.4169531573445120e+00, 7.96109248497664
|
||||
typedef struct qmckl_ao_basis_struct {
|
||||
int64_t shell_num;
|
||||
int64_t prim_num;
|
||||
int64_t ao_num;
|
||||
int64_t ao_num;
|
||||
int64_t * nucleus_index;
|
||||
int64_t * nucleus_shell_num;
|
||||
int32_t * shell_ang_mom;
|
||||
@ -230,10 +230,10 @@ typedef struct qmckl_ao_basis_struct {
|
||||
Some values are initialized by default, and are not concerned by
|
||||
this mechanism.
|
||||
|
||||
#+begin_src c :comments org :tangle (eval h_private_func)
|
||||
#+begin_src c :comments org :tangle (eval h_private_func)
|
||||
qmckl_exit_code qmckl_init_ao_basis(qmckl_context context);
|
||||
#+end_src
|
||||
|
||||
|
||||
#+begin_src c :comments org :tangle (eval c)
|
||||
qmckl_exit_code qmckl_init_ao_basis(qmckl_context context) {
|
||||
|
||||
@ -252,7 +252,7 @@ qmckl_exit_code qmckl_init_ao_basis(qmckl_context context) {
|
||||
return QMCKL_SUCCESS;
|
||||
}
|
||||
#+end_src
|
||||
|
||||
|
||||
** Access functions
|
||||
|
||||
In the following functions, when an array is passed as an argument
|
||||
@ -380,7 +380,7 @@ qmckl_get_ao_basis_prim_num (const qmckl_context context,
|
||||
}
|
||||
|
||||
#+end_src
|
||||
|
||||
|
||||
#+begin_src c :comments org :tangle (eval h_func) :exports none
|
||||
qmckl_exit_code
|
||||
qmckl_get_ao_basis_nucleus_shell_num (const qmckl_context context,
|
||||
@ -1098,7 +1098,6 @@ qmckl_exit_code qmckl_set_ao_basis_prim_num(qmckl_context context, const int64_
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_set_ao_basis_nucleus_shell_num(qmckl_context context, const int64_t* nucleus_shell_num) {
|
||||
<<pre2>>
|
||||
qmckl_exit_code rc = QMCKL_FAILURE;
|
||||
|
||||
int32_t mask = 1 << 3;
|
||||
|
||||
@ -1112,7 +1111,7 @@ qmckl_exit_code qmckl_set_ao_basis_nucleus_shell_num(qmckl_context context, con
|
||||
}
|
||||
|
||||
if (ctx->ao_basis.nucleus_shell_num != NULL) {
|
||||
rc = qmckl_free(context, ctx->ao_basis.nucleus_shell_num);
|
||||
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.nucleus_shell_num);
|
||||
if (rc != QMCKL_SUCCESS) {
|
||||
return qmckl_failwith( context, rc,
|
||||
"qmckl_set_ao_basis_nucleus_shell_num",
|
||||
@ -1142,7 +1141,6 @@ qmckl_exit_code qmckl_set_ao_basis_nucleus_shell_num(qmckl_context context, con
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_set_ao_basis_nucleus_index(qmckl_context context, const int64_t* nucleus_index) {
|
||||
<<pre2>>
|
||||
qmckl_exit_code rc = QMCKL_FAILURE;
|
||||
|
||||
int32_t mask = 1 << 4;
|
||||
|
||||
@ -1156,7 +1154,7 @@ qmckl_exit_code qmckl_set_ao_basis_nucleus_index(qmckl_context context, const i
|
||||
}
|
||||
|
||||
if (ctx->ao_basis.nucleus_index != NULL) {
|
||||
rc = qmckl_free(context, ctx->ao_basis.nucleus_index);
|
||||
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.nucleus_index);
|
||||
if (rc != QMCKL_SUCCESS) {
|
||||
return qmckl_failwith( context, rc,
|
||||
"qmckl_set_ao_basis_nucleus_index",
|
||||
@ -1186,7 +1184,6 @@ qmckl_exit_code qmckl_set_ao_basis_nucleus_index(qmckl_context context, const i
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const int32_t* shell_ang_mom) {
|
||||
<<pre2>>
|
||||
qmckl_exit_code rc = QMCKL_FAILURE;
|
||||
|
||||
int32_t mask = 1 << 5;
|
||||
|
||||
@ -1200,7 +1197,7 @@ qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const i
|
||||
}
|
||||
|
||||
if (ctx->ao_basis.shell_ang_mom != NULL) {
|
||||
rc = qmckl_free(context, ctx->ao_basis.shell_ang_mom);
|
||||
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_ang_mom);
|
||||
if (rc != QMCKL_SUCCESS) {
|
||||
return qmckl_failwith( context, rc,
|
||||
"qmckl_set_ao_basis_shell_ang_mom",
|
||||
@ -1231,7 +1228,6 @@ qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const i
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_set_ao_basis_shell_prim_num(qmckl_context context, const int64_t* shell_prim_num) {
|
||||
<<pre2>>
|
||||
qmckl_exit_code rc = QMCKL_FAILURE;
|
||||
|
||||
int32_t mask = 1 << 6;
|
||||
|
||||
@ -1245,7 +1241,7 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_num(qmckl_context context, const
|
||||
}
|
||||
|
||||
if (ctx->ao_basis.shell_prim_num != NULL) {
|
||||
rc = qmckl_free(context, ctx->ao_basis.shell_prim_num);
|
||||
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_prim_num);
|
||||
if (rc != QMCKL_SUCCESS) {
|
||||
return qmckl_failwith( context, rc,
|
||||
"qmckl_set_ao_basis_shell_prim_num",
|
||||
@ -1276,7 +1272,6 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_num(qmckl_context context, const
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_set_ao_basis_shell_prim_index(qmckl_context context, const int64_t* shell_prim_index) {
|
||||
<<pre2>>
|
||||
qmckl_exit_code rc = QMCKL_FAILURE;
|
||||
|
||||
int32_t mask = 1 << 7;
|
||||
|
||||
@ -1290,7 +1285,7 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_index(qmckl_context context, cons
|
||||
}
|
||||
|
||||
if (ctx->ao_basis.shell_prim_index != NULL) {
|
||||
rc = qmckl_free(context, ctx->ao_basis.shell_prim_index);
|
||||
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_prim_index);
|
||||
if (rc != QMCKL_SUCCESS) {
|
||||
return qmckl_failwith( context, rc,
|
||||
"qmckl_set_ao_basis_shell_prim_index",
|
||||
@ -1320,7 +1315,6 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_index(qmckl_context context, cons
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_set_ao_basis_shell_factor(qmckl_context context, const double* shell_factor) {
|
||||
<<pre2>>
|
||||
qmckl_exit_code rc = QMCKL_FAILURE;
|
||||
|
||||
int32_t mask = 1 << 8;
|
||||
|
||||
@ -1335,7 +1329,7 @@ qmckl_exit_code qmckl_set_ao_basis_shell_factor(qmckl_context context, const do
|
||||
|
||||
|
||||
if (ctx->ao_basis.shell_factor != NULL) {
|
||||
rc = qmckl_free(context, ctx->ao_basis.shell_factor);
|
||||
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_factor);
|
||||
if (rc != QMCKL_SUCCESS) {
|
||||
return qmckl_failwith( context, rc,
|
||||
"qmckl_set_ao_basis_shell_factor",
|
||||
@ -1365,7 +1359,6 @@ qmckl_exit_code qmckl_set_ao_basis_shell_factor(qmckl_context context, const do
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_set_ao_basis_exponent(qmckl_context context, const double* exponent) {
|
||||
<<pre2>>
|
||||
qmckl_exit_code rc = QMCKL_FAILURE;
|
||||
|
||||
int32_t mask = 1 << 9;
|
||||
|
||||
@ -1379,7 +1372,7 @@ qmckl_exit_code qmckl_set_ao_basis_exponent(qmckl_context context, const double
|
||||
}
|
||||
|
||||
if (ctx->ao_basis.exponent != NULL) {
|
||||
rc = qmckl_free(context, ctx->ao_basis.exponent);
|
||||
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.exponent);
|
||||
if (rc != QMCKL_SUCCESS) {
|
||||
return qmckl_failwith( context, rc,
|
||||
"qmckl_set_ao_basis_exponent",
|
||||
@ -1409,7 +1402,6 @@ qmckl_exit_code qmckl_set_ao_basis_exponent(qmckl_context context, const double
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_set_ao_basis_coefficient(qmckl_context context, const double* coefficient) {
|
||||
<<pre2>>
|
||||
qmckl_exit_code rc = QMCKL_FAILURE;
|
||||
|
||||
int32_t mask = 1 << 10;
|
||||
|
||||
@ -1423,7 +1415,7 @@ qmckl_exit_code qmckl_set_ao_basis_coefficient(qmckl_context context, const dou
|
||||
}
|
||||
|
||||
if (ctx->ao_basis.coefficient != NULL) {
|
||||
rc = qmckl_free(context, ctx->ao_basis.coefficient);
|
||||
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.coefficient);
|
||||
if (rc != QMCKL_SUCCESS) {
|
||||
return qmckl_failwith( context, rc,
|
||||
"qmckl_set_ao_basis_coefficient",
|
||||
@ -1453,7 +1445,6 @@ qmckl_exit_code qmckl_set_ao_basis_coefficient(qmckl_context context, const dou
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_set_ao_basis_prim_factor(qmckl_context context, const double* prim_factor) {
|
||||
<<pre2>>
|
||||
qmckl_exit_code rc = QMCKL_FAILURE;
|
||||
|
||||
int32_t mask = 1 << 11;
|
||||
|
||||
@ -1468,7 +1459,7 @@ qmckl_exit_code qmckl_set_ao_basis_prim_factor(qmckl_context context, const dou
|
||||
|
||||
|
||||
if (ctx->ao_basis.prim_factor != NULL) {
|
||||
rc = qmckl_free(context, ctx->ao_basis.prim_factor);
|
||||
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.prim_factor);
|
||||
if (rc != QMCKL_SUCCESS) {
|
||||
return qmckl_failwith( context, rc,
|
||||
"qmckl_set_ao_basis_prim_factor",
|
||||
@ -1531,7 +1522,6 @@ qmckl_exit_code qmckl_set_ao_basis_ao_num(qmckl_context context, const int64_t
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_set_ao_basis_ao_factor(qmckl_context context, const double* ao_factor) {
|
||||
<<pre2>>
|
||||
qmckl_exit_code rc = QMCKL_FAILURE;
|
||||
|
||||
int32_t mask = 1 << 13;
|
||||
|
||||
@ -1546,7 +1536,7 @@ qmckl_exit_code qmckl_set_ao_basis_ao_factor(qmckl_context context, const doubl
|
||||
|
||||
|
||||
if (ctx->ao_basis.ao_factor != NULL) {
|
||||
rc = qmckl_free(context, ctx->ao_basis.ao_factor);
|
||||
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.ao_factor);
|
||||
if (rc != QMCKL_SUCCESS) {
|
||||
return qmckl_failwith( context, rc,
|
||||
"qmckl_set_ao_basis_ao_factor",
|
||||
@ -1607,9 +1597,8 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) {
|
||||
assert (ctx != NULL);
|
||||
|
||||
int64_t nucl_num = 0;
|
||||
qmckl_exit_code rc = QMCKL_FAILURE;
|
||||
|
||||
rc = qmckl_get_nucleus_num(context, &nucl_num);
|
||||
qmckl_exit_code rc = qmckl_get_nucleus_num(context, &nucl_num);
|
||||
if (rc != QMCKL_SUCCESS) return rc;
|
||||
|
||||
/* nucleus_prim_index */
|
||||
@ -1632,7 +1621,7 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) {
|
||||
}
|
||||
ctx->ao_basis.nucleus_prim_index[nucl_num] = ctx->ao_basis.prim_num;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Normalize coefficients */
|
||||
{
|
||||
@ -1652,34 +1641,34 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) {
|
||||
for (int64_t iprim=ctx->ao_basis.shell_prim_index[ishell] ;
|
||||
iprim < ctx->ao_basis.shell_prim_index[ishell]+ctx->ao_basis.shell_prim_num[ishell] ;
|
||||
++iprim) {
|
||||
ctx->ao_basis.coefficient_normalized[iprim] =
|
||||
ctx->ao_basis.coefficient_normalized[iprim] =
|
||||
ctx->ao_basis.coefficient[iprim] * ctx->ao_basis.prim_factor[iprim] *
|
||||
ctx->ao_basis.shell_factor[ishell];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Find max angular momentum on each nucleus */
|
||||
{
|
||||
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
|
||||
mem_info.size = ctx->nucleus.num * sizeof(int32_t);
|
||||
|
||||
|
||||
ctx->ao_basis.nucleus_max_ang_mom = (int32_t *) qmckl_malloc(context, mem_info);
|
||||
|
||||
|
||||
if (ctx->ao_basis.nucleus_max_ang_mom == NULL) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_ALLOCATION_FAILED,
|
||||
"ao_basis.nucleus_max_ang_mom",
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
for (int64_t inucl=0 ; inucl < nucl_num ; ++inucl) {
|
||||
ctx->ao_basis.nucleus_max_ang_mom[inucl] = 0;
|
||||
for (int64_t ishell=ctx->ao_basis.nucleus_index[inucl] ;
|
||||
ishell < ctx->ao_basis.nucleus_index[inucl] + ctx->ao_basis.nucleus_shell_num[inucl] ;
|
||||
++ishell) {
|
||||
ctx->ao_basis.nucleus_max_ang_mom[inucl] =
|
||||
ctx->ao_basis.nucleus_max_ang_mom[inucl] =
|
||||
ctx->ao_basis.nucleus_max_ang_mom[inucl] > ctx->ao_basis.shell_ang_mom[ishell] ?
|
||||
ctx->ao_basis.nucleus_max_ang_mom[inucl] : ctx->ao_basis.shell_ang_mom[ishell] ;
|
||||
}
|
||||
@ -1711,7 +1700,7 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) {
|
||||
iprim < ctx->ao_basis.shell_prim_index[ishell] + ctx->ao_basis.shell_prim_num[ishell] ;
|
||||
++iprim) {
|
||||
double range = 1./ctx->ao_basis.exponent[iprim];
|
||||
ctx->ao_basis.nucleus_range[inucl] =
|
||||
ctx->ao_basis.nucleus_range[inucl] =
|
||||
ctx->ao_basis.nucleus_range[inucl] > range ?
|
||||
ctx->ao_basis.nucleus_range[inucl] : range;
|
||||
}
|
||||
@ -1723,10 +1712,10 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) {
|
||||
return QMCKL_SUCCESS;
|
||||
}
|
||||
#+end_src
|
||||
|
||||
|
||||
** Fortran interfaces
|
||||
|
||||
#+begin_src f90 :tangle (eval fh_func) :comments org :exports none
|
||||
#+begin_src f90 :tangle (eval fh_func) :comments org :exports none
|
||||
interface
|
||||
integer(c_int32_t) function qmckl_set_ao_basis_type (context, t) &
|
||||
bind(C)
|
||||
@ -2076,7 +2065,7 @@ rc = qmckl_get_ao_basis_ao_num(context, &ao_num_test);
|
||||
assert(ao_num == ao_num_test);
|
||||
|
||||
ao_factor_test = (double*) malloc ( ao_num * sizeof(double));
|
||||
rc = qmckl_get_ao_basis_ao_factor (context, ao_factor_test, ao_num);
|
||||
rc = qmckl_get_ao_basis_ao_factor (context, ao_factor_test, ao_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
for (int64_t i=0 ; i < ao_num ; ++i) {
|
||||
@ -2084,9 +2073,9 @@ for (int64_t i=0 ; i < ao_num ; ++i) {
|
||||
}
|
||||
|
||||
#+end_src
|
||||
|
||||
|
||||
* Radial part
|
||||
|
||||
|
||||
** TODO Helper functions to accelerate calculations
|
||||
** General functions for Gaussian basis functions
|
||||
|
||||
@ -2311,7 +2300,7 @@ qmckl_exit_code qmckl_get_ao_basis_primitive_vgl(qmckl_context context, double*
|
||||
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_get_ao_basis_primitive_vgl(qmckl_context context, double* const primitive_vgl) {
|
||||
|
||||
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return QMCKL_NULL_CONTEXT;
|
||||
}
|
||||
@ -2354,7 +2343,7 @@ qmckl_exit_code qmckl_provide_ao_basis_primitive_vgl(qmckl_context context)
|
||||
"qmckl_ao_basis_primitive_vgl",
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/* Compute if necessary */
|
||||
if (ctx->electron.coord_new_date > ctx->ao_basis.primitive_vgl_date) {
|
||||
|
||||
@ -2375,7 +2364,7 @@ qmckl_exit_code qmckl_provide_ao_basis_primitive_vgl(qmckl_context context)
|
||||
ctx->ao_basis.primitive_vgl = primitive_vgl;
|
||||
}
|
||||
|
||||
qmckl_exit_code rc;
|
||||
qmckl_exit_code rc;
|
||||
if (ctx->ao_basis.type == 'G') {
|
||||
rc = qmckl_compute_ao_basis_primitive_gaussian_vgl(context,
|
||||
ctx->ao_basis.prim_num,
|
||||
@ -2391,7 +2380,7 @@ qmckl_exit_code qmckl_provide_ao_basis_primitive_vgl(qmckl_context context)
|
||||
QMCKL_FAILURE,
|
||||
"compute_ao_basis_primitive_vgl",
|
||||
"Not yet implemented");
|
||||
}
|
||||
}
|
||||
if (rc != QMCKL_SUCCESS) {
|
||||
return rc;
|
||||
}
|
||||
@ -2420,7 +2409,7 @@ qmckl_exit_code qmckl_provide_ao_basis_primitive_vgl(qmckl_context context)
|
||||
| double | nucl_coord[3][elec_num] | in | Nuclear coordinates |
|
||||
| double | expo[prim_num] | in | Exponents of the primitives |
|
||||
| double | primitive_vgl[5][elec_num][prim_num] | out | Value, gradients and Laplacian of the primitives |
|
||||
|
||||
|
||||
#+begin_src f90 :comments org :tangle (eval f) :noweb yes
|
||||
integer function qmckl_compute_ao_basis_primitive_gaussian_vgl_f(context, &
|
||||
prim_num, elec_num, nucl_num, &
|
||||
@ -2450,9 +2439,9 @@ integer function qmckl_compute_ao_basis_primitive_gaussian_vgl_f(context, &
|
||||
! C is zero-based, so shift bounds by one
|
||||
do iprim = nucleus_prim_index(inucl)+1, nucleus_prim_index(inucl+1)
|
||||
do ielec = 1, elec_num
|
||||
x = elec_coord(ielec,1) - nucl_coord(inucl,1)
|
||||
y = elec_coord(ielec,2) - nucl_coord(inucl,2)
|
||||
z = elec_coord(ielec,3) - nucl_coord(inucl,3)
|
||||
x = elec_coord(ielec,1) - nucl_coord(inucl,1)
|
||||
y = elec_coord(ielec,2) - nucl_coord(inucl,2)
|
||||
z = elec_coord(ielec,3) - nucl_coord(inucl,3)
|
||||
|
||||
r2 = x*x + y*y + z*z
|
||||
ar2 = expo(iprim)*r2
|
||||
@ -2462,7 +2451,7 @@ integer function qmckl_compute_ao_basis_primitive_gaussian_vgl_f(context, &
|
||||
two_a = -2.d0 * expo(iprim) * v
|
||||
|
||||
primitive_vgl(iprim, ielec, 1) = v
|
||||
primitive_vgl(iprim, ielec, 2) = two_a * x
|
||||
primitive_vgl(iprim, ielec, 2) = two_a * x
|
||||
primitive_vgl(iprim, ielec, 3) = two_a * y
|
||||
primitive_vgl(iprim, ielec, 4) = two_a * z
|
||||
primitive_vgl(iprim, ielec, 5) = two_a * (3.d0 - 2.d0*ar2)
|
||||
@ -2535,7 +2524,7 @@ qmckl_exit_code qmckl_compute_ao_basis_primitive_gaussian_vgl(
|
||||
import numpy as np
|
||||
|
||||
def f(a,x,y):
|
||||
return np.exp( -a*(np.linalg.norm(x-y))**2 )
|
||||
return np.exp( -a*(np.linalg.norm(x-y))**2 )
|
||||
|
||||
def df(a,x,y,n):
|
||||
h0 = 1.e-6
|
||||
@ -2587,7 +2576,7 @@ int64_t elec_up_num = chbrclf_elec_up_num;
|
||||
int64_t elec_dn_num = chbrclf_elec_dn_num;
|
||||
double* elec_coord = &(chbrclf_elec_coord[0][0][0]);
|
||||
|
||||
rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num);
|
||||
rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_electron_walk_num (context, walk_num);
|
||||
@ -2595,7 +2584,7 @@ assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
assert(qmckl_electron_provided(context));
|
||||
|
||||
rc = qmckl_set_electron_coord (context, 'N', elec_coord);
|
||||
rc = qmckl_set_electron_coord (context, 'N', elec_coord);
|
||||
assert(rc == QMCKL_SUCCESS);
|
||||
|
||||
|
||||
@ -2610,7 +2599,7 @@ assert( fabs(prim_vgl[1][26][7] - (-7.5014974095310560E-004)) < 1.e-14 );
|
||||
assert( fabs(prim_vgl[2][26][7] - (-3.8250692897610380E-003)) < 1.e-14 );
|
||||
assert( fabs(prim_vgl[3][26][7] - ( 3.4950559194080275E-003)) < 1.e-14 );
|
||||
assert( fabs(prim_vgl[4][26][7] - ( 2.0392163767356572E-002)) < 1.e-14 );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -2625,11 +2614,11 @@ assert( fabs(prim_vgl[4][26][7] - ( 2.0392163767356572E-002)) < 1.e-14 );
|
||||
k=0;
|
||||
for (j=0 ; j<elec_num ; ++j) {
|
||||
for (i=0 ; i<nucl_num ; ++i) {
|
||||
|
||||
|
||||
r2 = nucl_elec_dist[i][j];
|
||||
|
||||
|
||||
if (r2 < nucl_radius2[i]) {
|
||||
|
||||
|
||||
for (l=0 ; l<prim_num ; ++l) {
|
||||
tmp[k].i = i;
|
||||
tmp[k].j = j;
|
||||
@ -2656,7 +2645,7 @@ qmckl_exit_code qmckl_get_ao_basis_shell_vgl(qmckl_context context, double* cons
|
||||
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_get_ao_basis_shell_vgl(qmckl_context context, double* const shell_vgl) {
|
||||
|
||||
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return QMCKL_NULL_CONTEXT;
|
||||
}
|
||||
@ -2720,7 +2709,7 @@ qmckl_exit_code qmckl_provide_ao_basis_shell_vgl(qmckl_context context)
|
||||
"qmckl_electron",
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/* Compute if necessary */
|
||||
if (ctx->electron.coord_new_date > ctx->ao_basis.shell_vgl_date) {
|
||||
|
||||
@ -2740,7 +2729,7 @@ qmckl_exit_code qmckl_provide_ao_basis_shell_vgl(qmckl_context context)
|
||||
ctx->ao_basis.shell_vgl = shell_vgl;
|
||||
}
|
||||
|
||||
qmckl_exit_code rc;
|
||||
qmckl_exit_code rc;
|
||||
if (ctx->ao_basis.type == 'G') {
|
||||
rc = qmckl_compute_ao_basis_shell_gaussian_vgl(context,
|
||||
ctx->ao_basis.prim_num,
|
||||
@ -2761,7 +2750,7 @@ qmckl_exit_code qmckl_provide_ao_basis_shell_vgl(qmckl_context context)
|
||||
QMCKL_FAILURE,
|
||||
"compute_ao_basis_shell_vgl",
|
||||
"Not yet implemented");
|
||||
}
|
||||
}
|
||||
if (rc != QMCKL_SUCCESS) {
|
||||
return rc;
|
||||
}
|
||||
@ -2795,7 +2784,7 @@ qmckl_exit_code qmckl_provide_ao_basis_shell_vgl(qmckl_context context)
|
||||
| ~double~ | ~expo[prim_num]~ | in | Exponents of the primitives |
|
||||
| ~double~ | ~coef_normalized[prim_num]~ | in | Coefficients of the primitives |
|
||||
| ~double~ | ~shell_vgl[5][elec_num][shell_num]~ | out | Value, gradients and Laplacian of the shells |
|
||||
|
||||
|
||||
#+begin_src f90 :comments org :tangle (eval f) :noweb yes
|
||||
integer function qmckl_compute_ao_basis_shell_gaussian_vgl_f(context, &
|
||||
prim_num, shell_num, elec_num, nucl_num, &
|
||||
@ -2832,9 +2821,9 @@ integer function qmckl_compute_ao_basis_shell_gaussian_vgl_f(context, &
|
||||
|
||||
do ielec = 1, elec_num
|
||||
|
||||
x = elec_coord(ielec,1) - nucl_coord(inucl,1)
|
||||
y = elec_coord(ielec,2) - nucl_coord(inucl,2)
|
||||
z = elec_coord(ielec,3) - nucl_coord(inucl,3)
|
||||
x = elec_coord(ielec,1) - nucl_coord(inucl,1)
|
||||
y = elec_coord(ielec,2) - nucl_coord(inucl,2)
|
||||
z = elec_coord(ielec,3) - nucl_coord(inucl,3)
|
||||
|
||||
r2 = x*x + y*y + z*z
|
||||
|
||||
@ -2861,13 +2850,13 @@ integer function qmckl_compute_ao_basis_shell_gaussian_vgl_f(context, &
|
||||
shell_vgl(ishell, ielec, 1) + v
|
||||
|
||||
shell_vgl(ishell, ielec, 2) = &
|
||||
shell_vgl(ishell, ielec, 2) + two_a * x
|
||||
shell_vgl(ishell, ielec, 2) + two_a * x
|
||||
|
||||
shell_vgl(ishell, ielec, 3) = &
|
||||
shell_vgl(ishell, ielec, 3) + two_a * y
|
||||
shell_vgl(ishell, ielec, 3) + two_a * y
|
||||
|
||||
shell_vgl(ishell, ielec, 4) = &
|
||||
shell_vgl(ishell, ielec, 4) + two_a * z
|
||||
shell_vgl(ishell, ielec, 4) + two_a * z
|
||||
|
||||
shell_vgl(ishell, ielec, 5) = &
|
||||
shell_vgl(ishell, ielec, 5) + two_a * (3.d0 - 2.d0*ar2)
|
||||
@ -2900,7 +2889,7 @@ end function qmckl_compute_ao_basis_shell_gaussian_vgl_f
|
||||
const double* nucl_coord,
|
||||
const double* expo,
|
||||
const double* coef_normalized,
|
||||
double* const shell_vgl );
|
||||
double* const shell_vgl );
|
||||
#+end_src
|
||||
|
||||
#+CALL: generate_c_interface(table=qmckl_ao_basis_shell_gaussian_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_ao_basis_shell_gaussian_vgl"))
|
||||
@ -2966,7 +2955,7 @@ end function qmckl_compute_ao_basis_shell_gaussian_vgl_f
|
||||
import numpy as np
|
||||
|
||||
def f(a,x,y):
|
||||
return np.sum( [c * np.exp( -b*(np.linalg.norm(x-y))**2) for b,c in a] )
|
||||
return np.sum( [c * np.exp( -b*(np.linalg.norm(x-y))**2) for b,c in a] )
|
||||
|
||||
def df(a,x,y,n):
|
||||
h0 = 1.e-6
|
||||
@ -3030,7 +3019,7 @@ int64_t elec_up_num = chbrclf_elec_up_num;
|
||||
int64_t elec_dn_num = chbrclf_elec_dn_num;
|
||||
double* elec_coord = &(chbrclf_elec_coord[0][0][0]);
|
||||
|
||||
rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num);
|
||||
rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_electron_walk_num (context, walk_num);
|
||||
@ -3038,7 +3027,7 @@ assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
assert(qmckl_electron_provided(context));
|
||||
|
||||
rc = qmckl_set_electron_coord (context, 'N', elec_coord);
|
||||
rc = qmckl_set_electron_coord (context, 'N', elec_coord);
|
||||
assert(rc == QMCKL_SUCCESS);
|
||||
|
||||
|
||||
@ -3052,15 +3041,15 @@ printf(" shell_vgl[1][1][26] %25.15e\n", shell_vgl[1][26][1]);
|
||||
printf(" shell_vgl[1][2][26] %25.15e\n", shell_vgl[2][26][1]);
|
||||
printf(" shell_vgl[1][3][26] %25.15e\n", shell_vgl[3][26][1]);
|
||||
printf(" shell_vgl[1][4][26] %25.15e\n", shell_vgl[4][26][1]);
|
||||
|
||||
|
||||
assert( fabs(shell_vgl[0][26][1] - ( 3.564393437193868e-02)) < 1.e-14 );
|
||||
assert( fabs(shell_vgl[1][26][1] - (-6.030177987072189e-03)) < 1.e-14 );
|
||||
assert( fabs(shell_vgl[2][26][1] - (-3.074832579537582e-02)) < 1.e-14 );
|
||||
assert( fabs(shell_vgl[3][26][1] - ( 2.809546963519935e-02)) < 1.e-14 );
|
||||
assert( fabs(shell_vgl[4][26][1] - ( 1.896046117183968e-02)) < 1.e-14 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#+end_src
|
||||
|
||||
* Polynomial part
|
||||
@ -3122,7 +3111,7 @@ assert( fabs(shell_vgl[4][26][1] - ( 1.896046117183968e-02)) < 1.e-14 );
|
||||
const double* X,
|
||||
const int32_t* LMAX,
|
||||
double* const P,
|
||||
const int64_t ldp );
|
||||
const int64_t ldp );
|
||||
#+end_src
|
||||
|
||||
*** Source
|
||||
@ -3661,7 +3650,7 @@ qmckl_exit_code qmckl_get_ao_vgl(qmckl_context context, double* const ao_vgl);
|
||||
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_get_ao_vgl(qmckl_context context, double* const ao_vgl) {
|
||||
|
||||
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return QMCKL_NULL_CONTEXT;
|
||||
}
|
||||
@ -3725,7 +3714,7 @@ qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context)
|
||||
"qmckl_electron",
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/* Compute if necessary */
|
||||
if (ctx->electron.coord_new_date > ctx->ao_basis.ao_vgl_date) {
|
||||
|
||||
@ -3802,7 +3791,7 @@ qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context)
|
||||
| ~double~ | ~ao_factor[ao_num]~ | in | Normalization factor of the AOs |
|
||||
| ~double~ | ~shell_vgl[5][elec_num][shell_num]~ | in | Value, gradients and Laplacian of the shells |
|
||||
| ~double~ | ~ao_vgl[5][elec_num][ao_num]~ | out | Value, gradients and Laplacian of the AOs |
|
||||
|
||||
|
||||
#+begin_src f90 :comments org :tangle (eval f) :noweb yes
|
||||
integer function qmckl_compute_ao_vgl_f(context, &
|
||||
ao_num, shell_num, elec_num, nucl_num, &
|
||||
@ -3944,7 +3933,7 @@ end function qmckl_compute_ao_vgl_f
|
||||
const int32_t* shell_ang_mom,
|
||||
const double* ao_factor,
|
||||
const double* shell_vgl,
|
||||
double* const ao_vgl );
|
||||
double* const ao_vgl );
|
||||
#+end_src
|
||||
|
||||
#+CALL: generate_c_interface(table=qmckl_ao_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_ao_vgl"))
|
||||
@ -4014,7 +4003,7 @@ import numpy as np
|
||||
from math import sqrt
|
||||
|
||||
def f(a,x,y):
|
||||
return np.sum( [c * np.exp( -b*(np.linalg.norm(x-y))**2) for b,c in a] )
|
||||
return np.sum( [c * np.exp( -b*(np.linalg.norm(x-y))**2) for b,c in a] )
|
||||
|
||||
def df(a,x,y,n):
|
||||
h0 = 1.e-6
|
||||
@ -4052,7 +4041,7 @@ norm = sqrt(3.)
|
||||
print ( "[0][26][219] : %25.15e"%(f(a,x,y) * (x[0] - y[0])**2) )
|
||||
print ( "[1][26][219] : %25.15e"%(df(a,x,y,1)* (x[0] - y[0]) * (x[1] - y[1]) + 2.*f(a,x,y) * (x[0] - y[0])) )
|
||||
|
||||
print ( "[0][26][220] : %25.15e"%(norm*f(a,x,y) * (x[0] - y[0]) * (x[1] - y[1]) ))
|
||||
print ( "[0][26][220] : %25.15e"%(norm*f(a,x,y) * (x[0] - y[0]) * (x[1] - y[1]) ))
|
||||
print ( "[1][26][220] : %25.15e"%(norm*df(a,x,y,1)* (x[0] - y[0]) * (x[1] - y[1]) + norm*f(a,x,y) * (x[1] - y[1])) )
|
||||
|
||||
print ( "[0][26][221] : %25.15e"%(norm*f(a,x,y) * (x[0] - y[0]) * (x[2] - y[2])) )
|
||||
@ -4098,7 +4087,7 @@ int64_t elec_up_num = chbrclf_elec_up_num;
|
||||
int64_t elec_dn_num = chbrclf_elec_dn_num;
|
||||
double* elec_coord = &(chbrclf_elec_coord[0][0][0]);
|
||||
|
||||
rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num);
|
||||
rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_electron_walk_num (context, walk_num);
|
||||
@ -4106,7 +4095,7 @@ assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
assert(qmckl_electron_provided(context));
|
||||
|
||||
rc = qmckl_set_electron_coord (context, 'N', elec_coord);
|
||||
rc = qmckl_set_electron_coord (context, 'N', elec_coord);
|
||||
assert(rc == QMCKL_SUCCESS);
|
||||
|
||||
|
||||
@ -4142,8 +4131,8 @@ assert( fabs(ao_vgl[0][26][223] - (-4.021908374204471e-09)) < 1.e-14 );
|
||||
assert( fabs(ao_vgl[1][26][223] - ( 2.154644255710413e-08)) < 1.e-14 );
|
||||
assert( fabs(ao_vgl[0][26][224] - ( 7.175045873560788e-10)) < 1.e-14 );
|
||||
assert( fabs(ao_vgl[1][26][224] - (-3.843864637762753e-09)) < 1.e-14 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#+end_src
|
||||
|
||||
* End of files :noexport:
|
||||
|
Loading…
Reference in New Issue
Block a user