From 531c1d4a2de42045142ef13e2f23818d840312ca Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 5 Jan 2022 12:26:11 +0100 Subject: [PATCH] Added size argument to AO functions --- org/qmckl_ao.org | 2009 ++++++++++++++++++++++++++-------------------- 1 file changed, 1139 insertions(+), 870 deletions(-) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index 0807e83..7b51528 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -2,10 +2,12 @@ #+SETUPFILE: ../tools/theme.setup #+INCLUDE: ../tools/lib.org +* Introduction + The atomic basis set is defined as a list of shells. Each shell $s$ is centered on a nucleus $A$, possesses a given angular momentum $l$ and a radial function $R_s$. The radial function is a linear combination of -\emph{primitive} functions that can be of type Slater ($p=1$) or +/primitive/ functions that can be of type Slater ($p=1$) or Gaussian ($p=2$): \[ @@ -14,7 +16,7 @@ Gaussian ($p=2$): \exp \left( - \gamma_{ks} | \mathbf{r}-\mathbf{R}_A | ^p \right). \] -In the case of Gaussian functions, $n_s$ is always zero. The +In the case of Gaussian functions, $n_s$ is always zero. The normalization factor $\mathcal{N}_s$ ensures that all the functions of the shell are normalized (integrate) to unity. Usually, basis sets are given a combination of normalized primitives, so the normalization @@ -37,9 +39,6 @@ In this section we describe first how the basis set is stored in the context, and then we present the kernels used to compute the values, gradients and Laplacian of the atomic basis functions. -* TODO [0/1] Missing features :noexport: - - [ ] Error messages to tell what is missing when initializing - * Headers :noexport: #+begin_src elisp :noexport :results none (org-babel-lob-ingest "../tools/lib.org") @@ -104,6 +103,8 @@ int main() { The following arrays are stored in the context: + |---------------------+---------------+----------------------------------------------------------------------| + | Variable | Dimensions | Description | |---------------------+---------------+----------------------------------------------------------------------| | ~type~ | | Gaussian (~'G'~) or Slater (~'S'~) | | ~shell_num~ | | Number of shells | @@ -120,10 +121,11 @@ int main() { | ~ao_num~ | | Number of AOs | | ~ao_cartesian~ | | If true, use polynomials. Otherwise, use spherical harmonics | | ~ao_factor~ | ~[ao_num]~ | Normalization factor of the AO | - | ~ao_shell~ | ~[ao_num]~ | For each AO, specify to which shell it belongs | Computed data: + |--------------------------+----------------------------+-----------------------------------------------------------------------------------------------| + | Variable | Dimensions | Description | |--------------------------+----------------------------+-----------------------------------------------------------------------------------------------| | ~coefficient_normalized~ | ~[prim_num]~ | Normalized primitive coefficients | | ~nucleus_prim_index~ | ~[nucl_num]~ | Index of the first primitive for each nucleus | @@ -148,21 +150,21 @@ int main() { #+BEGIN_EXAMPLE HYDROGEN S 5 -1 3.387000E+01 6.068000E-03 -2 5.095000E+00 4.530800E-02 -3 1.159000E+00 2.028220E-01 -4 3.258000E-01 5.039030E-01 -5 1.027000E-01 3.834210E-01 + 1 3.387000E+01 6.068000E-03 + 2 5.095000E+00 4.530800E-02 + 3 1.159000E+00 2.028220E-01 + 4 3.258000E-01 5.039030E-01 + 5 1.027000E-01 3.834210E-01 S 1 -1 3.258000E-01 1.000000E+00 + 1 3.258000E-01 1.000000E+00 S 1 -1 1.027000E-01 1.000000E+00 + 1 1.027000E-01 1.000000E+00 P 1 -1 1.407000E+00 1.000000E+00 + 1 1.407000E+00 1.000000E+00 P 1 -1 3.880000E-01 1.000000E+00 + 1 3.880000E-01 1.000000E+00 D 1 -1 1.057000E+00 1.0000000 + 1 1.057000E+00 1.0000000 #+END_EXAMPLE we have: @@ -173,17 +175,22 @@ type = 'G' shell_num = 12 prim_num = 20 ao_num = 38 + nucleus_index = [0 , 6] + shell_ang_mom = [0, 0, 0, 1, 1, 2, 0, 0, 0, 1, 1, 2] shell_factor = [ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.] shell_prim_num = [5, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1] shell_prim_index = [0 , 5 , 6 , 7 , 8 , 9 , 10, 15, 16, 17, 18, 19] + exponent = [ 33.87, 5.095, 1.159, 0.3258, 0.1027, 0.3258, 0.1027, 1.407, 0.388, 1.057, 33.87, 5.095, 1.159, 0.3258, 0.1027, 0.3258, 0.1027, 1.407, 0.388, 1.057] + coefficient = [ 0.006068, 0.045308, 0.202822, 0.503903, 0.383421, 1.0, 1.0, 1.0, 1.0, 1.0, 0.006068, 0.045308, 0.202822, 0.503903, 0.383421, 1.0, 1.0, 1.0, 1.0, 1.0] + prim_factor = [ 1.0006253235944540e+01, 2.4169531573445120e+00, 7.9610924849766440e-01 3.0734305383061117e-01, 1.2929684417481876e-01, 3.0734305383061117e-01, 1.2929684417481876e-01, 2.1842769845268308e+00, 4.3649547399719840e-01, @@ -193,7 +200,7 @@ prim_factor = [ 1.0006253235944540e+01, 2.4169531573445120e+00, 7.96109248497664 4.3649547399719840e-01, 1.8135965626177861e+00 ] #+END_EXAMPLE -** Data structure +** Data structure :noexport: #+begin_src c :comments org :tangle (eval h_private_type) typedef struct qmckl_ao_basis_struct { @@ -262,748 +269,8 @@ qmckl_exit_code qmckl_init_ao_basis(qmckl_context context) { } #+end_src -** Access functions - - In the following functions, when an array is passed as an argument - the size of the array should be also passed to check that the array - is large enough to accept the data. - - #+NAME:post - #+begin_src c :exports none -if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return NULL; -} - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code -qmckl_get_ao_basis_type (const qmckl_context context, - char* const type); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_type (const qmckl_context context, - char* const basis_type) -{ - - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_type", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_type", - NULL); - - } - - assert (ctx->ao_basis.type != (char) 0); - - ,*basis_type = ctx->ao_basis.type; - return QMCKL_SUCCESS; -} - - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code -qmckl_get_ao_basis_shell_num (const qmckl_context context, - int64_t* const shell_num); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_shell_num (const qmckl_context context, - int64_t* const shell_num) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_shell_factor", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 1; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_shell_num", - NULL); - } - - assert (ctx->ao_basis.shell_num > (int64_t) 0); - ,*shell_num = ctx->ao_basis.shell_num; - return QMCKL_SUCCESS; -} - - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code -qmckl_get_ao_basis_prim_num (const qmckl_context context, - int64_t* const prim_num); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_prim_num (const qmckl_context context, - int64_t* const prim_num) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_prim_num", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 2; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_prim_num", - NULL); - } - - assert (ctx->ao_basis.prim_num > (int64_t) 0); - - ,*prim_num = ctx->ao_basis.prim_num; - return QMCKL_SUCCESS; -} - - #+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, - int64_t* const nucleus_shell_num, - const int64_t size_max); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_nucleus_shell_num (const qmckl_context context, - int64_t* const nucleus_shell_num, - const int64_t size_max) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_nucleus_shell_num", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 3; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_nucleus_shell_num", - NULL); - } - - if (nucleus_shell_num == NULL) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_get_ao_basis_nucleus_shell_num", - "NULL pointer"); - } - - if (size_max < ctx->nucleus.num) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_3, - "qmckl_get_ao_basis_nucleus_shell_num", - "Array too small. Expected nucl_num"); - } - - assert (ctx->ao_basis.nucleus_shell_num != NULL); - memcpy(nucleus_shell_num, ctx->ao_basis.nucleus_shell_num, ctx->nucleus.num * sizeof(int64_t)); - return QMCKL_SUCCESS; -} - - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code -qmckl_get_ao_basis_nucleus_index (const qmckl_context context, - int64_t* const nucleus_index, - const int64_t size_max); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_nucleus_index (const qmckl_context context, - int64_t* const nucleus_index, - const int64_t size_max) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_nucleus_index", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 4; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_nucleus_index", - NULL); - } - - if (nucleus_index == NULL) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_get_ao_basis_nucleus_index", - "NULL pointer"); - } - - if (size_max < ctx->nucleus.num) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_3, - "qmckl_get_ao_basis_nucleus_index", - "Array too small. Expected shell_num"); - } - - assert (ctx->ao_basis.nucleus_index != NULL); - memcpy(nucleus_index, ctx->ao_basis.nucleus_index, ctx->nucleus.num * sizeof(int64_t)); - return QMCKL_SUCCESS; -} - - - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code -qmckl_get_ao_basis_shell_ang_mom (const qmckl_context context, - int32_t* const shell_ang_mom, - const int64_t size_max); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_shell_ang_mom (const qmckl_context context, - int32_t* const shell_ang_mom, - const int64_t size_max) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_shell_ang_mom", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 5; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_shell_ang_mom", - NULL); - } - - if (shell_ang_mom == NULL) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_get_ao_basis_shell_ang_mom", - "NULL pointer"); - } - - if (size_max < ctx->ao_basis.shell_num) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_3, - "qmckl_get_ao_basis_shell_ang_mom", - "Array too small. Expected shell_num"); - } - - assert (ctx->ao_basis.shell_ang_mom != NULL); - memcpy(shell_ang_mom, ctx->ao_basis.shell_ang_mom, ctx->ao_basis.shell_num * sizeof(int32_t)); - return QMCKL_SUCCESS; -} - - - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code -qmckl_get_ao_basis_shell_prim_num (const qmckl_context context, - int64_t* const shell_prim_num, - const int64_t size_max); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_shell_prim_num (const qmckl_context context, - int64_t* const shell_prim_num, - const int64_t size_max) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_shell_prim_num", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 6; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_shell_prim_num", - NULL); - } - - if (shell_prim_num == NULL) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_get_ao_basis_shell_prim_num", - "NULL pointer"); - } - - if (size_max < ctx->ao_basis.shell_num) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_3, - "qmckl_get_ao_basis_shell_prim_num", - "Array too small. Expected shell_num"); - } - - assert (ctx->ao_basis.shell_prim_num != NULL); - memcpy(shell_prim_num, ctx->ao_basis.shell_prim_num, ctx->ao_basis.shell_num * sizeof(int64_t)); - return QMCKL_SUCCESS; -} - - - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code -qmckl_get_ao_basis_shell_prim_index (const qmckl_context context, - int64_t* const shell_prim_index, - const int64_t size_max); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_shell_prim_index (const qmckl_context context, - int64_t* const shell_prim_index, - const int64_t size_max) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_shell_prim_index", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 7; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_shell_prim_index", - NULL); - } - - if (shell_prim_index == NULL) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_get_ao_basis_shell_prim_index", - "NULL pointer"); - } - - if (size_max < ctx->ao_basis.shell_num) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_3, - "qmckl_get_ao_basis_shell_prim_index", - "Array too small. Expected shell_num"); - } - - assert (ctx->ao_basis.shell_prim_index != NULL); - memcpy(shell_prim_index, ctx->ao_basis.shell_prim_index, ctx->ao_basis.shell_num * sizeof(int64_t)); - return QMCKL_SUCCESS; -} - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code -qmckl_get_ao_basis_shell_factor (const qmckl_context context, - double* const shell_factor, - const int64_t size_max); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_shell_factor (const qmckl_context context, - double* const shell_factor, - const int64_t size_max) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_shell_factor", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 8; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_shell_factor", - NULL); - } - - if (shell_factor == NULL) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_get_ao_basis_shell_factor", - "NULL pointer"); - } - - if (size_max < ctx->ao_basis.shell_num) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_3, - "qmckl_get_ao_basis_shell_factor", - "Array too small. Expected shell_num"); - } - - assert (ctx->ao_basis.shell_factor != NULL); - memcpy(shell_factor, ctx->ao_basis.shell_factor, ctx->ao_basis.shell_num * sizeof(double)); - return QMCKL_SUCCESS; -} - - - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code -qmckl_get_ao_basis_exponent (const qmckl_context context, - double* const exponent, - const int64_t size_max); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_exponent (const qmckl_context context, - double* const exponent, - const int64_t size_max) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_exponent", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 9; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_exponent", - NULL); - } - - if (exponent == NULL) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_get_ao_basis_exponent", - "NULL pointer"); - } - - if (size_max < ctx->ao_basis.prim_num) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_3, - "qmckl_get_ao_basis_exponent", - "Array too small. Expected prim_num"); - } - - assert (ctx->ao_basis.exponent != NULL); - memcpy(exponent, ctx->ao_basis.exponent, ctx->ao_basis.prim_num * sizeof(double)); - return QMCKL_SUCCESS; -} - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code -qmckl_get_ao_basis_coefficient (const qmckl_context context, - double* const coefficient, - const int64_t size_max); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_coefficient (const qmckl_context context, - double* const coefficient, - const int64_t size_max) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_coefficient", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 10; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_coefficient", - NULL); - } - - if (coefficient == NULL) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_get_ao_basis_coefficient", - "NULL pointer"); - } - - if (size_max < ctx->ao_basis.prim_num) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_3, - "qmckl_get_ao_basis_coefficient", - "Array too small. Expected prim_num"); - } - assert (ctx->ao_basis.coefficient != NULL); - memcpy(coefficient, ctx->ao_basis.coefficient, ctx->ao_basis.prim_num * sizeof(double)); - return QMCKL_SUCCESS; -} - - - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code -qmckl_get_ao_basis_prim_factor (const qmckl_context context, - double* const prim_factor, - const int64_t size_max); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_prim_factor (const qmckl_context context, - double* const prim_factor, - const int64_t size_max) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_prim_factor", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 11; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_prim_factor", - NULL); - } - - if (prim_factor == NULL) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_get_ao_basis_prim_factor", - "NULL pointer"); - } - - if (size_max < ctx->ao_basis.prim_num) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_3, - "qmckl_get_ao_basis_prim_factor", - "Array too small. Expected prim_num"); - } - - assert (ctx->ao_basis.prim_factor != NULL); - memcpy(prim_factor, ctx->ao_basis.prim_factor, ctx->ao_basis.prim_num * sizeof(double)); - return QMCKL_SUCCESS; -} - - - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code -qmckl_get_ao_basis_ao_num (const qmckl_context context, - int64_t* const ao_num); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_ao_num (const qmckl_context context, - int64_t* const ao_num) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_ao_num", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 12; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_ao_num", - NULL); - } - - assert (ctx->ao_basis.ao_num > (int64_t) 0); - - *ao_num = ctx->ao_basis.ao_num; - return QMCKL_SUCCESS; -} - - - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code -qmckl_get_ao_basis_ao_factor (const qmckl_context context, - double* const ao_factor, - const int64_t size_max) -{ - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return qmckl_failwith( context, - QMCKL_INVALID_CONTEXT, - "qmckl_get_ao_basis_ao_factor", - NULL); - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - int32_t mask = 1 << 13; - - if ( (ctx->ao_basis.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_ao_basis_ao_factor", - NULL); - } - - if (ao_factor == NULL) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_get_ao_basis_ao_factor", - "NULL pointer"); - } - - if (size_max < ctx->ao_basis.ao_num) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_3, - "qmckl_get_ao_basis_ao_factor", - "Array too small. Expected ao_num"); - } - - assert (ctx->ao_basis.ao_factor != NULL); - memcpy(ao_factor, ctx->ao_basis.ao_factor, ctx->ao_basis.ao_num * sizeof(double)); - return QMCKL_SUCCESS; -} - #+end_src - - #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code qmckl_get_ao_basis_ao_factor (const qmckl_context context, - double* const ao_factor, - const int64_t size_max); - #+end_src - - When all the data for the AOs have been provided, the following - function returns ~true~. - - #+begin_src c :comments org :tangle (eval h_func) -bool qmckl_ao_basis_provided (const qmckl_context context); - #+end_src - - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -bool qmckl_ao_basis_provided(const qmckl_context context) { - - if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { - return false; - } - - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; - assert (ctx != NULL); - - return ctx->ao_basis.provided; -} - #+end_src - ** Initialization functions - To set the basis set, all the following functions need to be - called. - - #+begin_src c :comments org :tangle (eval h_func) -qmckl_exit_code qmckl_set_ao_basis_type (qmckl_context context, const char t); -qmckl_exit_code qmckl_set_ao_basis_shell_num (qmckl_context context, const int64_t shell_num); -qmckl_exit_code qmckl_set_ao_basis_prim_num (qmckl_context context, const int64_t prim_num); -qmckl_exit_code qmckl_set_ao_basis_ao_num (qmckl_context context, const int64_t ao_num); -qmckl_exit_code qmckl_set_ao_basis_nucleus_index (qmckl_context context, const int64_t * nucleus_index); -qmckl_exit_code qmckl_set_ao_basis_nucleus_shell_num(qmckl_context context, const int64_t * nucleus_shell_num); -qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom (qmckl_context context, const int32_t * shell_ang_mom); -qmckl_exit_code qmckl_set_ao_basis_shell_prim_num (qmckl_context context, const int64_t * shell_prim_num); -qmckl_exit_code qmckl_set_ao_basis_shell_prim_index (qmckl_context context, const int64_t * shell_prim_index); -qmckl_exit_code qmckl_set_ao_basis_shell_factor (qmckl_context context, const double * shell_factor); -qmckl_exit_code qmckl_set_ao_basis_exponent (qmckl_context context, const double * exponent); -qmckl_exit_code qmckl_set_ao_basis_coefficient (qmckl_context context, const double * coefficient); -qmckl_exit_code qmckl_set_ao_basis_prim_factor (qmckl_context context, const double * prim_factor); -qmckl_exit_code qmckl_set_ao_basis_ao_factor (qmckl_context context, const double * ao_factor); -qmckl_exit_code qmckl_set_ao_basis_cartesian (qmckl_context context, const bool cartesian); - #+end_src - #+NAME:pre2 #+begin_src c :exports none if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { @@ -1028,8 +295,20 @@ if (ctx->ao_basis.provided) { return QMCKL_SUCCESS; #+end_src + To set the basis set, all the following functions need to be + called. + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_type (qmckl_context context, + const char basis_type); + #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code qmckl_set_ao_basis_type(qmckl_context context, const char t) { +qmckl_exit_code +qmckl_set_ao_basis_type(qmckl_context context, + const char basis_type) +{ <> if (t != 'G' && t != 'S') { @@ -1040,14 +319,24 @@ qmckl_exit_code qmckl_set_ao_basis_type(qmckl_context context, const char t) { } int32_t mask = 1; - ctx->ao_basis.type = t; + ctx->ao_basis.type = basis_type; <> } #+end_src + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_shell_num (qmckl_context context, + const int64_t shell_num); + #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code qmckl_set_ao_basis_shell_num(qmckl_context context, const int64_t shell_num) { +qmckl_exit_code +qmckl_set_ao_basis_shell_num (qmckl_context context, + const int64_t shell_num); +{ <> if (shell_num <= 0) { @@ -1073,8 +362,18 @@ qmckl_exit_code qmckl_set_ao_basis_shell_num(qmckl_context context, const int64_ } #+end_src + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_prim_num (qmckl_context context, + const int64_t prim_num); + #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code qmckl_set_ao_basis_prim_num(qmckl_context context, const int64_t prim_num) { +qmckl_exit_code +qmckl_set_ao_basis_prim_num (qmckl_context context, + const int64_t prim_num) +{ <> if (prim_num <= 0) { @@ -1107,62 +406,81 @@ qmckl_exit_code qmckl_set_ao_basis_prim_num(qmckl_context context, const int64_ } #+end_src + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_ao_num (qmckl_context context, + const int64_t ao_num); + #+end_src + #+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) { +qmckl_exit_code +qmckl_set_ao_basis_ao_num (qmckl_context context, + const int64_t ao_num) +{ <> - int32_t mask = 1 << 3; + if (ao_num <= 0) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_set_ao_basis_shell_num", + "ao_num must be positive"); + } const int64_t shell_num = ctx->ao_basis.shell_num; - if (shell_num <= 0L) { return qmckl_failwith( context, - QMCKL_FAILURE, - "qmckl_set_ao_basis_nucleus_shell_num", + QMCKL_INVALID_ARG_2, + "qmckl_set_ao_basis_shell_num", "shell_num is not set"); } - if (ctx->ao_basis.nucleus_shell_num != NULL) { - 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", - NULL); - } - } - - qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; - mem_info.size = shell_num * sizeof(int64_t); - int64_t* new_array = (int64_t*) qmckl_malloc(context, mem_info); - - if (new_array == NULL) { + if (ao_num < shell_num) { return qmckl_failwith( context, - QMCKL_ALLOCATION_FAILED, - "qmckl_set_ao_basis_nucleus_shell_num", - NULL); + QMCKL_INVALID_ARG_2, + "qmckl_set_ao_basis_shell_num", + "ao_num < shell_num"); } - memcpy(new_array, nucleus_shell_num, mem_info.size); - - ctx->ao_basis.nucleus_shell_num = new_array; + int32_t mask = 1 << 12; + ctx->ao_basis.ao_num = ao_num; <> } #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_nucleus_index (qmckl_context context, + const int64_t* nucleus_index, + const int64_t size_max); + #+end_src #+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) { +qmckl_exit_code +qmckl_set_ao_basis_nucleus_index (qmckl_context context, + const int64_t* nucleus_index, + const int64_t size_max) +{ <> int32_t mask = 1 << 4; - const int64_t shell_num = ctx->ao_basis.shell_num; + const int64_t nucl_num = ctx->nucleus.num; - if (shell_num <= 0L) { + if (nucl_num <= 0L) { return qmckl_failwith( context, QMCKL_FAILURE, "qmckl_set_ao_basis_nucleus_index", - "shell_num is not set"); + "nucl_num is not set"); + } + + if (size_max < nucl_num) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_nucleus_index", + "input array too small"); } if (ctx->ao_basis.nucleus_index != NULL) { @@ -1175,7 +493,7 @@ qmckl_exit_code qmckl_set_ao_basis_nucleus_index(qmckl_context context, const i } qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; - mem_info.size = shell_num * sizeof(int64_t); + mem_info.size = nucl_num * sizeof(int64_t); int64_t* new_array = (int64_t*) qmckl_malloc(context, mem_info); if (new_array == NULL) { @@ -1193,8 +511,82 @@ qmckl_exit_code qmckl_set_ao_basis_nucleus_index(qmckl_context context, const i } #+end_src + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_nucleus_shell_num (qmckl_context context, + const int64_t* nucleus_shell_num, + const int64_t size_max); + #+end_src + #+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) { +qmckl_exit_code +qmckl_set_ao_basis_nucleus_shell_num (qmckl_context context, + const int64_t* nucleus_shell_num, + const int64_t size_max); +{ + <> + + int32_t mask = 1 << 3; + + const int64_t nucl_num = ctx->nucleus.num; + + if (nucl_num <= 0L) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_nucleus_shell_num", + "shell_num is not set"); + } + + if (size_max < nucl_num) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_nucleus_shell_num", + "input array too small"); + } + + if (ctx->ao_basis.nucleus_shell_num != NULL) { + 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", + NULL); + } + } + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = nucl_num * sizeof(int64_t); + int64_t* new_array = (int64_t*) qmckl_malloc(context, mem_info); + + if (new_array == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_set_ao_basis_nucleus_shell_num", + NULL); + } + + memcpy(new_array, nucleus_shell_num, mem_info.size); + + ctx->ao_basis.nucleus_shell_num = new_array; + + <> +} + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_shell_ang_mom (qmckl_context context, + const int32_t* shell_ang_mom, + const int64_t size_max); + #+end_src + + #+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, + const int64_t size_max); +{ <> int32_t mask = 1 << 5; @@ -1208,6 +600,13 @@ qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const i "shell_num is not set"); } + if (size_max < shell_num) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_shell_ang_mom", + "input array too small"); + } + if (ctx->ao_basis.shell_ang_mom != NULL) { qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_ang_mom); if (rc != QMCKL_SUCCESS) { @@ -1237,8 +636,20 @@ qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const i } #+end_src + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_shell_prim_num (qmckl_context context, + const int64_t* shell_prim_num, + const int64_t size_max); + #+end_src + #+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) { +qmckl_exit_code +qmckl_set_ao_basis_shell_prim_num (qmckl_context context, + const int64_t* shell_prim_num, + const int64_t size_max) +{ <> int32_t mask = 1 << 6; @@ -1252,6 +663,13 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_num(qmckl_context context, const "shell_num is not set"); } + if (size_max < shell_num) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_shell_prim_num", + "input array too small"); + } + if (ctx->ao_basis.shell_prim_num != NULL) { qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_prim_num); if (rc != QMCKL_SUCCESS) { @@ -1281,8 +699,20 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_num(qmckl_context context, const } #+end_src + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_shell_prim_index (qmckl_context context, + const int64_t* shell_prim_index, + const int64_t size_max); + #+end_src + #+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) { +qmckl_exit_code +qmckl_set_ao_basis_shell_prim_index (qmckl_context context, + const int64_t* shell_prim_index, + const int64_t size_max) +{ <> int32_t mask = 1 << 7; @@ -1296,6 +726,13 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_index(qmckl_context context, cons "shell_num is not set"); } + if (size_max < shell_num) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_shell_prim_index", + "input array too small"); + } + if (ctx->ao_basis.shell_prim_index != NULL) { qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_prim_index); if (rc != QMCKL_SUCCESS) { @@ -1324,8 +761,20 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_index(qmckl_context context, cons } #+end_src + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_shell_factor (qmckl_context context, + const double* shell_factor, + const int64_t size_max); + #+end_src + #+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) { +qmckl_exit_code +qmckl_set_ao_basis_shell_factor (qmckl_context context, + const double* shell_factor, + const int64_t size_max) +{ <> int32_t mask = 1 << 8; @@ -1339,6 +788,12 @@ qmckl_exit_code qmckl_set_ao_basis_shell_factor(qmckl_context context, const do "shell_num is not set"); } + if (size_max < shell_num) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_shell_factor", + "input array too small"); + } if (ctx->ao_basis.shell_factor != NULL) { qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_factor); @@ -1368,8 +823,20 @@ qmckl_exit_code qmckl_set_ao_basis_shell_factor(qmckl_context context, const do } #+end_src + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_exponent (qmckl_context context, + const double* exponent, + const int64_t size_max); + #+end_src + #+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) { +qmckl_exit_code +qmckl_set_ao_basis_exponent (qmckl_context context, + const double* exponent, + const int64_t size_max) +{ <> int32_t mask = 1 << 9; @@ -1383,6 +850,13 @@ qmckl_exit_code qmckl_set_ao_basis_exponent(qmckl_context context, const double "prim_num is not set"); } + if (size_max < prim_num) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_exponent", + "input array too small"); + } + if (ctx->ao_basis.exponent != NULL) { qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.exponent); if (rc != QMCKL_SUCCESS) { @@ -1411,8 +885,20 @@ qmckl_exit_code qmckl_set_ao_basis_exponent(qmckl_context context, const double } #+end_src + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_coefficient (qmckl_context context, + const double* coefficient, + const int64_t size_max); + #+end_src + #+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) { +qmckl_exit_code +qmckl_set_ao_basis_coefficient (qmckl_context context, + const double* coefficient, + const int64_t size_max) +{ <> int32_t mask = 1 << 10; @@ -1426,6 +912,13 @@ qmckl_exit_code qmckl_set_ao_basis_coefficient(qmckl_context context, const dou "prim_num is not set"); } + if (size_max < prim_num) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_coefficient", + "input array too small"); + } + if (ctx->ao_basis.coefficient != NULL) { qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.coefficient); if (rc != QMCKL_SUCCESS) { @@ -1454,8 +947,20 @@ qmckl_exit_code qmckl_set_ao_basis_coefficient(qmckl_context context, const dou } #+end_src + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_prim_factor (qmckl_context context, + const double* prim_factor, + const int64_t size_max); + #+end_src + #+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) { +qmckl_exit_code +qmckl_set_ao_basis_prim_factor (qmckl_context context, + const double* prim_factor, + const int64_t size_max) +{ <> int32_t mask = 1 << 11; @@ -1469,6 +974,12 @@ qmckl_exit_code qmckl_set_ao_basis_prim_factor(qmckl_context context, const dou "prim_num is not set"); } + if (size_max < prim_num) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_prim_factor", + "input array too small"); + } if (ctx->ao_basis.prim_factor != NULL) { qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.prim_factor); @@ -1498,41 +1009,19 @@ qmckl_exit_code qmckl_set_ao_basis_prim_factor(qmckl_context context, const dou } #+end_src - #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code qmckl_set_ao_basis_ao_num(qmckl_context context, const int64_t ao_num) { - <> - if (ao_num <= 0) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_set_ao_basis_shell_num", - "ao_num must be positive"); - } - - const int64_t shell_num = ctx->ao_basis.shell_num; - if (shell_num <= 0L) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_set_ao_basis_shell_num", - "shell_num is not set"); - } - - if (ao_num < shell_num) { - return qmckl_failwith( context, - QMCKL_INVALID_ARG_2, - "qmckl_set_ao_basis_shell_num", - "ao_num < shell_num"); - } - - int32_t mask = 1 << 12; - ctx->ao_basis.ao_num = ao_num; - - <> -} + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_ao_factor (qmckl_context context, + const double* ao_factor, + const int64_t size_max); #+end_src #+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) { +qmckl_exit_code +qmckl_set_ao_basis_ao_factor (qmckl_context context, + const double* ao_factor, + const int64_t size_max) <> int32_t mask = 1 << 13; @@ -1546,6 +1035,12 @@ qmckl_exit_code qmckl_set_ao_basis_ao_factor(qmckl_context context, const doubl "ao_num is not set"); } + if (size_max < ao_num) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_ao_factor", + "input array too small"); + } if (ctx->ao_basis.ao_factor != NULL) { qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.ao_factor); @@ -1575,8 +1070,18 @@ qmckl_exit_code qmckl_set_ao_basis_ao_factor(qmckl_context context, const doubl } #+end_src + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_set_ao_basis_cartesian (qmckl_context context, + const bool cartesian); + #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code qmckl_set_ao_basis_cartesian(qmckl_context context, const bool t) { +qmckl_exit_code +qmckl_set_ao_basis_cartesian (qmckl_context context, + const bool cartesian) +{ <> int32_t mask = 1; @@ -1586,7 +1091,7 @@ qmckl_exit_code qmckl_set_ao_basis_cartesian(qmckl_context context, const bool t } #+end_src - When the basis set is completely entered, other data structures are + When the basis set is completely entered, extra data structures may be computed to accelerate the calculations. The primitives within each contraction are sorted in ascending order of their exponents, such that as soon as a primitive is zero all the following functions @@ -1728,6 +1233,741 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) { } #+end_src +** Access functions + + ~size_max~ is the dimension of the input array, which should be + equal of larger than the value given in the table of the [[Context]] + section. + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_type (const qmckl_context context, + char* const basis_type) + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_type (const qmckl_context context, + char* const basis_type) +{ + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_type", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_type", + NULL); + + } + + assert (ctx->ao_basis.type != (char) 0); + + basis_type[0] = ctx->ao_basis.type; + return QMCKL_SUCCESS; +} + + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_shell_num (const qmckl_context context, + int64_t* const shell_num); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_shell_num (const qmckl_context context, + int64_t* const shell_num) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_shell_factor", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 1; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_shell_num", + NULL); + } + + assert (ctx->ao_basis.shell_num > (int64_t) 0); + ,*shell_num = ctx->ao_basis.shell_num; + return QMCKL_SUCCESS; +} + + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_prim_num (const qmckl_context context, + int64_t* const prim_num); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_prim_num (const qmckl_context context, + int64_t* const prim_num) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_prim_num", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 2; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_prim_num", + NULL); + } + + assert (ctx->ao_basis.prim_num > (int64_t) 0); + + ,*prim_num = ctx->ao_basis.prim_num; + return QMCKL_SUCCESS; +} + + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_nucleus_shell_num (const qmckl_context context, + int64_t* const nucleus_shell_num, + const int64_t size_max); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_nucleus_shell_num (const qmckl_context context, + int64_t* const nucleus_shell_num, + const int64_t size_max) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_nucleus_shell_num", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 3; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_nucleus_shell_num", + NULL); + } + + if (nucleus_shell_num == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_ao_basis_nucleus_shell_num", + "NULL pointer"); + } + + if (size_max < ctx->nucleus.num) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_3, + "qmckl_get_ao_basis_nucleus_shell_num", + "Array too small. Expected nucl_num"); + } + + assert (ctx->ao_basis.nucleus_shell_num != NULL); + memcpy(nucleus_shell_num, ctx->ao_basis.nucleus_shell_num, + (size_t) ctx->nucleus.num * sizeof(int64_t)); + return QMCKL_SUCCESS; +} + + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_nucleus_index (const qmckl_context context, + int64_t* const nucleus_index, + const int64_t size_max); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_nucleus_index (const qmckl_context context, + int64_t* const nucleus_index, + const int64_t size_max) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_nucleus_index", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 4; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_nucleus_index", + NULL); + } + + if (nucleus_index == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_ao_basis_nucleus_index", + "NULL pointer"); + } + + if (size_max < ctx->nucleus.num) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_3, + "qmckl_get_ao_basis_nucleus_index", + "Array too small. Expected shell_num"); + } + + assert (ctx->ao_basis.nucleus_index != NULL); + memcpy(nucleus_index, ctx->ao_basis.nucleus_index, + (size_t) ctx->nucleus.num * sizeof(int64_t)); + return QMCKL_SUCCESS; +} + + + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_shell_ang_mom (const qmckl_context context, + int32_t* const shell_ang_mom, + const int64_t size_max); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_shell_ang_mom (const qmckl_context context, + int32_t* const shell_ang_mom, + const int64_t size_max) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_shell_ang_mom", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 5; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_shell_ang_mom", + NULL); + } + + if (shell_ang_mom == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_ao_basis_shell_ang_mom", + "NULL pointer"); + } + + if (size_max < ctx->ao_basis.shell_num) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_3, + "qmckl_get_ao_basis_shell_ang_mom", + "Array too small. Expected shell_num"); + } + + assert (ctx->ao_basis.shell_ang_mom != NULL); + memcpy(shell_ang_mom, ctx->ao_basis.shell_ang_mom, + (size_t) ctx->ao_basis.shell_num * sizeof(int32_t)); + return QMCKL_SUCCESS; +} + + + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_shell_prim_num (const qmckl_context context, + int64_t* const shell_prim_num, + const int64_t size_max); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_shell_prim_num (const qmckl_context context, + int64_t* const shell_prim_num, + const int64_t size_max) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_shell_prim_num", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 6; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_shell_prim_num", + NULL); + } + + if (shell_prim_num == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_ao_basis_shell_prim_num", + "NULL pointer"); + } + + if (size_max < ctx->ao_basis.shell_num) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_3, + "qmckl_get_ao_basis_shell_prim_num", + "Array too small. Expected shell_num"); + } + + assert (ctx->ao_basis.shell_prim_num != NULL); + memcpy(shell_prim_num, ctx->ao_basis.shell_prim_num, + (size_t) ctx->ao_basis.shell_num * sizeof(int64_t)); + return QMCKL_SUCCESS; +} + + + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_shell_prim_index (const qmckl_context context, + int64_t* const shell_prim_index, + const int64_t size_max); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_shell_prim_index (const qmckl_context context, + int64_t* const shell_prim_index, + const int64_t size_max) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_shell_prim_index", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 7; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_shell_prim_index", + NULL); + } + + if (shell_prim_index == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_ao_basis_shell_prim_index", + "NULL pointer"); + } + + if (size_max < ctx->ao_basis.shell_num) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_3, + "qmckl_get_ao_basis_shell_prim_index", + "Array too small. Expected shell_num"); + } + + assert (ctx->ao_basis.shell_prim_index != NULL); + memcpy(shell_prim_index, ctx->ao_basis.shell_prim_index, + (size_t) ctx->ao_basis.shell_num * sizeof(int64_t)); + return QMCKL_SUCCESS; +} + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_shell_factor (const qmckl_context context, + double* const shell_factor, + const int64_t size_max); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_shell_factor (const qmckl_context context, + double* const shell_factor, + const int64_t size_max) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_shell_factor", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 8; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_shell_factor", + NULL); + } + + if (shell_factor == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_ao_basis_shell_factor", + "NULL pointer"); + } + + if (size_max < ctx->ao_basis.shell_num) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_3, + "qmckl_get_ao_basis_shell_factor", + "Array too small. Expected shell_num"); + } + + assert (ctx->ao_basis.shell_factor != NULL); + memcpy(shell_factor, ctx->ao_basis.shell_factor, + (size_t) ctx->ao_basis.shell_num * sizeof(double)); + return QMCKL_SUCCESS; +} + + + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_exponent (const qmckl_context context, + double* const exponent, + const int64_t size_max); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_exponent (const qmckl_context context, + double* const exponent, + const int64_t size_max) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_exponent", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 9; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_exponent", + NULL); + } + + if (exponent == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_ao_basis_exponent", + "NULL pointer"); + } + + if (size_max < ctx->ao_basis.prim_num) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_3, + "qmckl_get_ao_basis_exponent", + "Array too small. Expected prim_num"); + } + + assert (ctx->ao_basis.exponent != NULL); + memcpy(exponent, ctx->ao_basis.exponent, + (size_t) ctx->ao_basis.prim_num * sizeof(double)); + return QMCKL_SUCCESS; +} + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_coefficient (const qmckl_context context, + double* const coefficient, + const int64_t size_max); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_coefficient (const qmckl_context context, + double* const coefficient, + const int64_t size_max) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_coefficient", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 10; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_coefficient", + NULL); + } + + if (coefficient == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_ao_basis_coefficient", + "NULL pointer"); + } + + if (size_max < ctx->ao_basis.prim_num) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_3, + "qmckl_get_ao_basis_coefficient", + "Array too small. Expected prim_num"); + } + assert (ctx->ao_basis.coefficient != NULL); + memcpy(coefficient, ctx->ao_basis.coefficient, + (size_t) ctx->ao_basis.prim_num * sizeof(double)); + return QMCKL_SUCCESS; +} + + + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_prim_factor (const qmckl_context context, + double* const prim_factor, + const int64_t size_max); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_prim_factor (const qmckl_context context, + double* const prim_factor, + const int64_t size_max) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_prim_factor", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 11; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_prim_factor", + NULL); + } + + if (prim_factor == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_ao_basis_prim_factor", + "NULL pointer"); + } + + if (size_max < ctx->ao_basis.prim_num) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_3, + "qmckl_get_ao_basis_prim_factor", + "Array too small. Expected prim_num"); + } + + assert (ctx->ao_basis.prim_factor != NULL); + memcpy(prim_factor, ctx->ao_basis.prim_factor, + (size_t) ctx->ao_basis.prim_num * sizeof(double)); + return QMCKL_SUCCESS; +} + + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_ao_num (const qmckl_context context, + int64_t* const ao_num); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_ao_num (const qmckl_context context, + int64_t* const ao_num) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_ao_num", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 12; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_ao_num", + NULL); + } + + assert (ctx->ao_basis.ao_num > (int64_t) 0); + + *ao_num = ctx->ao_basis.ao_num; + return QMCKL_SUCCESS; +} + + + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code +qmckl_get_ao_basis_ao_factor (const qmckl_context context, + double* const ao_factor, + const int64_t size_max); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_ao_basis_ao_factor (const qmckl_context context, + double* const ao_factor, + const int64_t size_max) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_ao_basis_ao_factor", + NULL); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 13; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_get_ao_basis_ao_factor", + NULL); + } + + if (ao_factor == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_ao_basis_ao_factor", + "NULL pointer"); + } + + if (size_max < ctx->ao_basis.ao_num) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_3, + "qmckl_get_ao_basis_ao_factor", + "Array too small. Expected ao_num"); + } + + assert (ctx->ao_basis.ao_factor != NULL); + memcpy(ao_factor, ctx->ao_basis.ao_factor, ctx->ao_basis.ao_num * sizeof(double)); + return QMCKL_SUCCESS; +} + #+end_src + + + When all the data for the AOs have been provided, the following + function returns ~true~. + + #+begin_src c :comments org :tangle (eval h_func) +bool qmckl_ao_basis_provided (const qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +bool qmckl_ao_basis_provided(const qmckl_context context) { + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return false; + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + return ctx->ao_basis.provided; +} + #+end_src + ** Fortran interfaces #+begin_src f90 :tangle (eval fh_func) :comments org :exports none @@ -1741,6 +1981,7 @@ interface character(c_char) , intent(in) , value :: t end function end interface + interface integer(c_int32_t) function qmckl_set_ao_basis_shell_num(context, num) & bind(C) @@ -1751,6 +1992,7 @@ interface integer (c_int64_t) , intent(in) , value :: num end function end interface + interface integer(c_int32_t) function qmckl_set_ao_basis_prim_num(context, num) & bind(C) @@ -1761,96 +2003,115 @@ interface integer (c_int64_t) , intent(in) , value :: num end function end interface + interface - integer(c_int32_t) function qmckl_set_ao_basis_nucleus_index(context, idx) & + integer(c_int32_t) function qmckl_set_ao_basis_nucleus_index(context, idx, size_max) & bind(C) use, intrinsic :: iso_c_binding import implicit none integer (c_int64_t) , intent(in) , value :: context integer (c_int64_t) , intent(in) :: idx(*) + integer (c_int64_t) , intent(in) , value :: size_max end function end interface + interface - integer(c_int32_t) function qmckl_set_ao_basis_nucleus_shell_num(context,shell_num) & + integer(c_int32_t) function qmckl_set_ao_basis_nucleus_shell_num(context,shell_num, size_max) & bind(C) use, intrinsic :: iso_c_binding import implicit none integer (c_int64_t) , intent(in) , value :: context integer (c_int64_t) , intent(in) :: shell_num(*) + integer (c_int64_t) , intent(in) , value :: size_max end function end interface + interface - integer(c_int32_t) function qmckl_set_ao_basis_shell_ang_mom(context,shell_ang_mom) & + integer(c_int32_t) function qmckl_set_ao_basis_shell_ang_mom(context,shell_ang_mom, size_max) & bind(C) use, intrinsic :: iso_c_binding import implicit none integer (c_int64_t) , intent(in) , value :: context integer (c_int32_t) , intent(in) :: shell_ang_mom(*) + integer (c_int64_t) , intent(in) , value :: size_max end function end interface + interface - integer(c_int32_t) function qmckl_set_ao_basis_shell_prim_num(context,shell_prim_num) & + integer(c_int32_t) function qmckl_set_ao_basis_shell_prim_num(context,shell_prim_num, size_max) & bind(C) use, intrinsic :: iso_c_binding import implicit none integer (c_int64_t) , intent(in) , value :: context integer (c_int64_t) , intent(in) :: shell_prim_num(*) + integer (c_int64_t) , intent(in) , value :: size_max end function end interface + interface - integer(c_int32_t) function qmckl_set_ao_basis_shell_prim_index(context,shell_prim_index) & + integer(c_int32_t) function qmckl_set_ao_basis_shell_prim_index(context,shell_prim_index, size_max) & bind(C) use, intrinsic :: iso_c_binding import implicit none integer (c_int64_t) , intent(in) , value :: context integer (c_int64_t) , intent(in) :: shell_prim_index(*) + integer (c_int64_t) , intent(in) , value :: size_max end function end interface + interface - integer(c_int32_t) function qmckl_set_ao_basis_shell_factor(context,shell_factor) & + integer(c_int32_t) function qmckl_set_ao_basis_shell_factor(context,shell_factor, size_max) & bind(C) use, intrinsic :: iso_c_binding import implicit none integer (c_int64_t) , intent(in) , value :: context real (c_double) , intent(in) :: shell_factor(*) + integer (c_int64_t) , intent(in) , value :: size_max end function end interface + interface - integer(c_int32_t) function qmckl_set_ao_basis_exponent(context,exponent) & + integer(c_int32_t) function qmckl_set_ao_basis_exponent(context,exponent, size_max) & bind(C) use, intrinsic :: iso_c_binding import implicit none integer (c_int64_t) , intent(in) , value :: context real (c_double) , intent(in) :: exponent(*) + integer (c_int64_t) , intent(in) , value :: size_max end function end interface + interface - integer(c_int32_t) function qmckl_set_ao_basis_coefficient(context,coefficient) & + integer(c_int32_t) function qmckl_set_ao_basis_coefficient(context,coefficient, size_max) & bind(C) use, intrinsic :: iso_c_binding import implicit none integer (c_int64_t) , intent(in) , value :: context real (c_double) , intent(in) :: coefficient(*) + integer (c_int64_t) , intent(in) , value :: size_max end function end interface + interface - integer(c_int32_t) function qmckl_set_ao_basis_prim_factor(context,prim_factor) & + integer(c_int32_t) function qmckl_set_ao_basis_prim_factor(context,prim_factor, size_max) & bind(C) use, intrinsic :: iso_c_binding import implicit none integer (c_int64_t) , intent(in) , value :: context real (c_double) , intent(in) :: prim_factor(*) + integer (c_int64_t) , intent(in) , value :: size_max end function end interface + interface integer(c_int32_t) function qmckl_set_ao_basis_ao_num(context, num) & bind(C) @@ -1861,16 +2122,7 @@ interface integer (c_int64_t) , intent(in) , value :: num end function end interface -interface - integer(c_int32_t) function qmckl_set_ao_basis_ao_factor(context,ao_factor) & - bind(C) - use, intrinsic :: iso_c_binding - import - implicit none - integer (c_int64_t) , intent(in) , value :: context - real (c_double) , intent(in) :: ao_factor(*) - end function -end interface + interface integer(c_int32_t) function qmckl_set_ao_basis_cartesian(context,cartesian) & bind(C) @@ -1881,6 +2133,18 @@ interface logical (c_bool) , intent(in) , value :: cartesian end function end interface + +interface + integer(c_int32_t) function qmckl_set_ao_basis_ao_factor(context,ao_factor, size_max) & + bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + integer (c_int64_t) , intent(in) , value :: context + real (c_double) , intent(in) :: ao_factor(*) + integer (c_int64_t) , intent(in) , value :: size_max + end function +end interface #+end_src ** Test :noexport: @@ -1933,45 +2197,45 @@ rc = qmckl_set_ao_basis_prim_num (context, prim_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_nucleus_index (context, nucleus_index); +rc = qmckl_set_ao_basis_nucleus_index (context, nucleus_index, nucl_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_nucleus_shell_num (context, nucleus_shell_num); +rc = qmckl_set_ao_basis_nucleus_shell_num (context, nucleus_shell_num, nucl_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_shell_ang_mom (context, shell_ang_mom); +rc = qmckl_set_ao_basis_shell_ang_mom (context, shell_ang_mom, shell_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_shell_factor (context, shell_factor); +rc = qmckl_set_ao_basis_shell_factor (context, shell_factor, shell_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_shell_prim_num (context, shell_prim_num); +rc = qmckl_set_ao_basis_shell_prim_num (context, shell_prim_num, shell_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_shell_prim_index (context, shell_prim_index); +rc = qmckl_set_ao_basis_shell_prim_index (context, shell_prim_index, shell_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_exponent (context, exponent); +rc = qmckl_set_ao_basis_exponent (context, exponent, prim_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_coefficient (context, coefficient); +rc = qmckl_set_ao_basis_coefficient (context, coefficient, prim_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_prim_factor (context, prim_factor); +rc = qmckl_set_ao_basis_prim_factor (context, prim_factor, prim_num); assert(rc == QMCKL_SUCCESS); rc = qmckl_set_ao_basis_ao_num(context, ao_num); assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_ao_basis_ao_factor (context, ao_factor); +rc = qmckl_set_ao_basis_ao_factor (context, ao_factor, ao_num); assert(rc == QMCKL_SUCCESS); assert(qmckl_ao_basis_provided(context)); @@ -2104,15 +2368,17 @@ for (int64_t i=0 ; i < ao_num ; ++i) { \[ \nabla_z v_i = -2 a_i (X_z - R_z) v_i \] \[ \Delta v_i = a_i (4 |X-R|^2 a_i - 6) v_i \] - |--------------+--------+------------------------------------------------------| - | ~context~ | input | Global state | - | ~X(3)~ | input | Array containing the coordinates of the points | - | ~R(3)~ | input | Array containing the x,y,z coordinates of the center | - | ~n~ | input | Number of computed Gaussians | - | ~A(n)~ | input | Exponents of the Gaussians | - | ~VGL(ldv,5)~ | output | Value, gradients and Laplacian of the Gaussians | - | ~ldv~ | input | Leading dimension of array ~VGL~ | - |--------------+--------+------------------------------------------------------| + |--------------+------------+------------------------------------------------------| + | Variable | Dimensions | Description | + |--------------+------------+------------------------------------------------------| + | ~context~ | | Global state | + | ~X(3)~ | ~[3]~ | Array containing the coordinates of the points | + | ~R(3)~ | ~[3]~ | Array containing the x,y,z coordinates of the center | + | ~n~ | | Number of computed Gaussians | + | ~A(n)~ | ~[n]~ | Exponents of the Gaussians | + | ~VGL(ldv,5)~ | ~[5][ldv]~ | Value, gradients and Laplacian of the Gaussians | + | ~ldv~ | | Leading dimension of array ~VGL~ | + |--------------+------------+------------------------------------------------------| Requirements @@ -2337,7 +2603,7 @@ qmckl_exit_code qmckl_get_ao_basis_primitive_vgl(qmckl_context context, double* return QMCKL_SUCCESS; } #+end_src - + *** Provide #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none @@ -4218,3 +4484,6 @@ assert( fabs(ao_vgl[1][26][224] - (-3.843864637762753e-09)) < 1.e-14 ); # vim: syntax=c + +* TODO [0/1] Missing features :noexport: + - [ ] Error messages to tell what is missing when initializing