diff --git a/.gitignore b/.gitignore index 96b7a1b..61f6fbb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,10 @@ +*.la +*.lo .deps/ -compile -depcomp -generated.mk -stamp-h1 -libtool -ltmain.sh -missing -m4/libtool.m4 -m4/ltoptions.m4 -m4/ltsugar.m4 -m4/ltversion.m4 -m4/lt~obsolete.m4 +.dirstamp +.libs Makefile +Makefile.in aclocal.m4 autom4te.cache/ config.guess @@ -19,13 +12,20 @@ config.log config.status config.sub configure -install-sh -qmckl.pc -Makefile.in -test-driver -.libs -.dirstamp -*.la -*.lo +generated.mk +m4/libtool.m4 +m4/ltoptions.m4 +m4/ltsugar.m4 +m4/ltversion.m4 +m4/lt~obsolete.m4 qmckl-*.tar.gz qmckl.mod +qmckl.pc +stamp-h1 +tools/compile +tools/depcomp +tools/install-sh +tools/libtool +tools/ltmain.sh +tools/missing +tools/test-driver diff --git a/Makefile.am b/Makefile.am index b911ad8..57ad20b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -159,14 +159,16 @@ tests/chbrclf.h: $(qmckl_h) generated.mk: $(ORG_FILES) - python $(srcdir)/tools/build_makefile.py + $(PYTHON) $(srcdir)/tools/build_makefile.py cppcheck: cppcheck.out cppcheck.out: $(qmckl_h) cd src/ && \ cppcheck --addon=cert -q --error-exitcode=0 \ - --enable=all \ + --enable=all --suppress="unusedStructMember"\ + --suppress="unusedFunction" \ + --suppress="missingIncludeSystem" \ --language=c --std=c99 -rp --platform=unix64 \ -I../include *.c *.h 2>../$@ diff --git a/README.md b/README.md index 1fa2d3c..97606c1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # QMCkl: Quantum Monte Carlo Kernel Library -![Build Status](https://github.com/TREX-CoE/qmckl/workflows/test-build/badge.svg?branch=main) +![Build Status](https://github.com/TREX-CoE/qmckl/workflows/test-build/badge.svg?branch=master) The domain of quantum chemistry needs a library in which the main kernels of Quantum Monte Carlo (QMC) methods are implemented. In the @@ -9,7 +9,7 @@ simple language and provide a standard API and tests to enable the development of high-performance QMCkl implementations taking advantage of modern hardware. -See the [source code](https://github.com/TREX-CoE/qmckl/tree/main/src) +See the [source code](https://github.com/TREX-CoE/qmckl/blob/master/org/qmckl.org) to read the documentation. diff --git a/configure.ac b/configure.ac index 7a6c365..c313f56 100644 --- a/configure.ac +++ b/configure.ac @@ -38,13 +38,13 @@ AC_PREREQ([2.69]) AC_INIT([qmckl],[0.1.1], [https://github.com/TREX-CoE/qmckl/issues], [], [https://trex-coe.github.io/qmckl/index.html]) +AC_CONFIG_AUX_DIR(tools) AM_INIT_AUTOMAKE([subdir-objects color-tests parallel-tests silent-rules 1.11]) AM_MAINTAINER_MODE() LT_INIT AC_CONFIG_SRCDIR([Makefile.in]) AC_CONFIG_HEADERS([include/config.h]) AC_CONFIG_MACRO_DIR([m4]) -#AM_MAINTAINER_MODE VERSION_MAJOR=`echo ${PACKAGE_VERSION} | cut -d. -f1` VERSION_MINOR=`echo ${PACKAGE_VERSION} | cut -d. -f2` @@ -64,6 +64,9 @@ AC_LANG(C) # Checks for programs. AC_PROG_CC +# Make sure the c compiler supports C99 +m4_version_prereq([2.70],[], [AC_PROG_CC_C99]) +AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([The compiler does not support C99])]) AC_PROG_CC_C_O AC_PROG_FC AC_PROG_FC_C_O @@ -72,13 +75,10 @@ AC_FC_FREEFORM AC_PROG_LIBTOOL AC_PROG_INSTALL AC_PROG_LN_S -AC_PROG_CC_C99 PKG_PROG_PKG_CONFIG([]) PKG_LIBS="" PKG_CFLAGS="" -AC_SUBST([HAS_CPPCHECK]) - # Checks for libraries. AC_FC_LIBRARY_LDFLAGS @@ -178,15 +178,8 @@ if test "x${QMCKL_DEVEL}" != "x"; then QMCKL_DEVEL=" -- Developer mode" AC_PROG_AWK - AC_CHECK_PROGS([PYTHON],[python python3 python2],[no]) - if test x${PYTHON} == xno ; then - AC_MSG_ERROR([ - -------------------------------------------- - Error: Python is required to build makefiles - -------------------------------------------- - ]) - fi - python ${srcdir}/tools/build_makefile.py + AM_PATH_PYTHON + ${PYTHON} ${srcdir}/tools/build_makefile.py AC_CHECK_PROGS([EMACS],[emacs26 emacs],[no]) if test x${EMACS} == xno ; then @@ -211,6 +204,8 @@ LIBS="${LAPACK_LIBS} ${BLAS_LIBS} ${LIBS}" PKG_LIBS="${PKG_LIBS} ${LIBS}" AC_SUBST([PKG_LIBS]) AC_SUBST([PKG_CFLAGS]) +AC_SUBST([HAS_CPPCHECK]) + AC_CONFIG_FILES([Makefile pkgconfig/qmckl.pc diff --git a/org/.gitignore b/org/.gitignore index e0963f0..931ace3 100644 --- a/org/.gitignore +++ b/org/.gitignore @@ -1,2 +1,3 @@ +ltximg/ *.tangled *.exported diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index 906bf17..abdb227 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -10,27 +10,30 @@ Gaussian ($p=2$): \[ R_s(\mathbf{r}) = \mathcal{N}_s |\mathbf{r}-\mathbf{R}_A|^{n_s} - \sum_{k=1}^{N_{\text{prim}}} a_{ks} + \sum_{k=1}^{N_{\text{prim}}} a_{ks}\, f_{ks} \exp \left( - \gamma_{ks} | \mathbf{r}-\mathbf{R}_A | ^p \right). \] 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 to unity. As this normalization requires -the ability to compute overlap integrals, it should be written in the -file to ensure that the file is self-contained and does not require -the client program to have the ability to compute such integrals. +of the shell are normalized to unity. Usually, basis sets are given +a combination of normalized primitives, so the normalization +coefficients of the primitives, $f_{ks}$, need also to be provided. Atomic orbitals (AOs) are defined as \[ -\chi_i (\mathbf{r}) = P_{\eta(i)}(\mathbf{r})\, R_{\theta(i)} (\mathbf{r}) +\chi_i (\mathbf{r}) = \mathcal{M}_i\, P_{\eta(i)}(\mathbf{r})\, R_{\theta(i)} (\mathbf{r}) \] where $\theta(i)$ returns the shell on which the AO is expanded, and $\eta(i)$ denotes which angular function is chosen. +Here, the parameter $\mathcal{M}_i$ is an extra parameter which allows +the normalization of the different functions of the same shell to be +different, as in GAMESS for example. -In this section we describe the kernels used to compute the values, +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. * Headers :noexport: @@ -53,6 +56,9 @@ gradients and Laplacian of the atomic basis functions. #include "config.h" #endif +#include +#include "chbrclf.h" + int main() { qmckl_context context; context = qmckl_context_create(); @@ -78,22 +84,38 @@ int main() { #include "qmckl_context_private_type.h" #include "qmckl_memory_private_type.h" #include "qmckl_memory_private_func.h" +#include "qmckl_ao_private_type.h" +#include "qmckl_ao_private_func.h" #+end_src * Context The following arrays are stored in the context: - | ~type~ | | Gaussian (~'G'~) or Slater (~'S'~) | - | ~shell_num~ | | Number of shells | - | ~prim_num~ | | Total number of primitives | - | ~shell_center~ | ~[shell_num]~ | Id of the nucleus on which each shell is centered | - | ~shell_ang_mom~ | ~[shell_num]~ | Angular momentum of each shell | - | ~shell_prim_num~ | ~[shell_num]~ | Number of primitives in each shell | - | ~shell_prim_index~ | ~[shell_num]~ | Address of the first primitive of each shell in the ~EXPONENT~ array | - | ~shell_factor~ | ~[shell_num]~ | Normalization factor for each shell | - | ~exponent~ | ~[prim_num]~ | Array of exponents | - | ~coefficient~ | ~[prim_num]~ | Array of coefficients | + |--------------------+---------------+----------------------------------------------------------------------| + | ~type~ | | Gaussian (~'G'~) or Slater (~'S'~) | + | ~shell_num~ | | Number of shells | + | ~prim_num~ | | Total number of primitives | + | ~nucleus_index~ | ~[nucl_num]~ | Index of the first shell of each nucleus | + | ~shell_ang_mom~ | ~[shell_num]~ | Angular momentum of each shell | + | ~shell_prim_num~ | ~[shell_num]~ | Number of primitives in each shell | + | ~shell_prim_index~ | ~[shell_num]~ | Address of the first primitive of each shell in the ~EXPONENT~ array | + | ~shell_factor~ | ~[shell_num]~ | Normalization factor for each shell | + | ~exponent~ | ~[prim_num]~ | Array of exponents | + | ~coefficient~ | ~[prim_num]~ | Array of coefficients | + | ~prim_factor~ | ~[prim_num]~ | Normalization factors of the primtives | + + Computed data + |----------------------+-------------------------------------+-----------------------------------------------------------------------------------------------| + | ~nucleus_prim_index~ | ~[nucl_num]~ | Index of the first primitive for each nucleus | + | ~primitive_vgl~ | ~[prim_num][5][walk_num][elec_num]~ | Value, gradients, Laplacian of the primitives at electron positions | + | ~primitive_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the primitives at electron positions | + |----------------------+-------------------------------------+-----------------------------------------------------------------------------------------------| + | ~nucl_shell_index~ | ~[nucl_num]~ | Index of the first shell for each nucleus | + | ~exponent_sorted~ | ~[prim_num]~ | Array of exponents for sorted primitives | + | ~coeff_norm_sorted~ | ~[prim_num]~ | Array of normalized coefficients for sorted primitives | + | ~prim_factor_sorted~ | ~[prim_num]~ | Normalization factors of the sorted primtives | + | ~nuclear_radius~ | ~[nucl_num]~ | Distance beyond which all the AOs are zero | For H_2 with the following basis set, @@ -123,17 +145,24 @@ D 1 type = 'G' shell_num = 12 prim_num = 20 -shell_center = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2] -shell_ang_mom = ['S', 'S', 'S', 'P', 'P', 'D', 'S', 'S', 'S', 'P', 'P', 'D'] +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 = [1, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19, 20] -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] +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, + 1.8135965626177861e+00, 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, 1.8135965626177861e+00 ] #+END_EXAMPLE ** Data structure @@ -143,36 +172,69 @@ typedef struct qmckl_ao_basis_struct { int32_t uninitialized; int64_t shell_num; int64_t prim_num; - int64_t * shell_center; - char * shell_ang_mom; + int64_t * nucleus_index; + int64_t * nucleus_shell_num; + int32_t * shell_ang_mom; int64_t * shell_prim_num; + int64_t * nucleus_prim_index; int64_t * shell_prim_index; double * shell_factor; double * exponent ; double * coefficient ; + double * prim_factor ; + double * primitive_vgl; + int64_t primitive_vgl_date; bool provided; char type; } qmckl_ao_basis_struct; #+end_src The ~uninitialized~ integer contains one bit set to one for each - initialization function which has not bee called. It becomes equal + initialization function which has not been called. It becomes equal to zero after all initialization functions have been called. The struct is then initialized and ~provided == true~. + Some values are initialized by default, and are not concerned by + this mechanism. + #+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) { + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return false; + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + ctx->ao_basis.uninitialized = (1 << 12) - 1; + + /* Default values */ + /* ctx->ao_basis. + ,*/ + + return QMCKL_SUCCESS; +} + #+end_src + + ** Access functions #+begin_src c :comments org :tangle (eval h_private_func) :exports none char qmckl_get_ao_basis_type (const qmckl_context context); int64_t qmckl_get_ao_basis_shell_num (const qmckl_context context); int64_t qmckl_get_ao_basis_prim_num (const qmckl_context context); -int64_t* qmckl_get_ao_basis_shell_center (const qmckl_context context); -char* qmckl_get_ao_basis_shell_ang_mom (const qmckl_context context); +int64_t* qmckl_get_ao_basis_nucleus_index (const qmckl_context context); +int32_t* qmckl_get_ao_basis_shell_ang_mom (const qmckl_context context); int64_t* qmckl_get_ao_basis_shell_prim_num (const qmckl_context context); int64_t* qmckl_get_ao_basis_shell_prim_index (const qmckl_context context); double* qmckl_get_ao_basis_shell_factor (const qmckl_context context); double* qmckl_get_ao_basis_exponent (const qmckl_context context); double* qmckl_get_ao_basis_coefficient (const qmckl_context context); +double* qmckl_get_ao_basis_prim_factor (const qmckl_context context); #+end_src When all the data for the AOs have been provided, the following @@ -248,7 +310,7 @@ int64_t qmckl_get_ao_basis_prim_num (const qmckl_context context) { } -int64_t* qmckl_get_ao_basis_shell_center (const qmckl_context context) { +int64_t* qmckl_get_ao_basis_nucleus_shell_num (const qmckl_context context) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return NULL; } @@ -262,12 +324,11 @@ int64_t* qmckl_get_ao_basis_shell_center (const qmckl_context context) { return NULL; } - assert (ctx->ao_basis.shell_center != NULL); - return ctx->ao_basis.shell_center; + assert (ctx->ao_basis.nucleus_shell_num != NULL); + return ctx->ao_basis.nucleus_shell_num ; } - -char* qmckl_get_ao_basis_shell_ang_mom (const qmckl_context context) { +int64_t* qmckl_get_ao_basis_nucleus_index (const qmckl_context context) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return NULL; } @@ -281,6 +342,25 @@ char* qmckl_get_ao_basis_shell_ang_mom (const qmckl_context context) { return NULL; } + assert (ctx->ao_basis.nucleus_index != NULL); + return ctx->ao_basis.nucleus_index ; +} + + +int32_t* qmckl_get_ao_basis_shell_ang_mom (const qmckl_context context) { + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return 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 NULL; + } + assert (ctx->ao_basis.shell_ang_mom != NULL); return ctx->ao_basis.shell_ang_mom; } @@ -294,7 +374,7 @@ int64_t* qmckl_get_ao_basis_shell_prim_num (const qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 5; + int32_t mask = 1 << 6; if ( (ctx->ao_basis.uninitialized & mask) != 0) { return NULL; @@ -313,7 +393,7 @@ int64_t* qmckl_get_ao_basis_shell_prim_index (const qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 6; + int32_t mask = 1 << 7; if ( (ctx->ao_basis.uninitialized & mask) != 0) { return NULL; @@ -332,7 +412,7 @@ double* qmckl_get_ao_basis_shell_factor (const qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 7; + int32_t mask = 1 << 8; if ( (ctx->ao_basis.uninitialized & mask) != 0) { return NULL; @@ -352,7 +432,7 @@ double* qmckl_get_ao_basis_exponent (const qmckl_context context) { assert (ctx != NULL); - int32_t mask = 1 << 8; + int32_t mask = 1 << 9; if ( (ctx->ao_basis.uninitialized & mask) != 0) { return NULL; @@ -371,7 +451,7 @@ double* qmckl_get_ao_basis_coefficient (const qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 9; + int32_t mask = 1 << 10; if ( (ctx->ao_basis.uninitialized & mask) != 0) { return NULL; @@ -382,6 +462,25 @@ double* qmckl_get_ao_basis_coefficient (const qmckl_context context) { } +double* qmckl_get_ao_basis_prim_factor (const qmckl_context context) { + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return 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 NULL; + } + + assert (ctx->ao_basis.prim_factor != NULL); + return ctx->ao_basis.prim_factor; +} + + bool qmckl_ao_basis_provided(const qmckl_context context) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { @@ -398,19 +497,21 @@ bool qmckl_ao_basis_provided(const qmckl_context context) { ** Initialization functions To set the basis set, all the following functions need to be - called. When + 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_shell_prim_index (qmckl_context context, const int64_t * shell_prim_index); -qmckl_exit_code qmckl_set_ao_basis_shell_center (qmckl_context context, const int64_t * shell_center); -qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom (qmckl_context context, const char * shell_ang_mom); +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); #+end_src #+NAME:pre2 @@ -426,11 +527,14 @@ qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; #+begin_src c :exports none ctx->ao_basis.uninitialized &= ~mask; ctx->ao_basis.provided = (ctx->ao_basis.uninitialized == 0); +if (ctx->ao_basis.provided) { + qmckl_exit_code rc_ = qmckl_finalize_basis(context); + if (rc_ != QMCKL_SUCCESS) return rc_; + } return QMCKL_SUCCESS; #+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) { <> @@ -501,7 +605,7 @@ qmckl_exit_code qmckl_set_ao_basis_prim_num(qmckl_context context, const int64_ } -qmckl_exit_code qmckl_set_ao_basis_shell_center(qmckl_context context, const int64_t* shell_center) { +qmckl_exit_code qmckl_set_ao_basis_nucleus_shell_num(qmckl_context context, const int64_t* nucleus_shell_num) { <> int32_t mask = 1 << 3; @@ -510,15 +614,15 @@ qmckl_exit_code qmckl_set_ao_basis_shell_center(qmckl_context context, const in if (shell_num == 0L) { return qmckl_failwith( context, QMCKL_FAILURE, - "qmckl_set_ao_basis_shell_center", + "qmckl_set_ao_basis_nucleus_shell_num", "shell_num is not set"); } - if (ctx->ao_basis.shell_center != NULL) { - qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_center); + 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_shell_center", + "qmckl_set_ao_basis_nucleus_shell_num", NULL); } } @@ -530,22 +634,62 @@ qmckl_exit_code qmckl_set_ao_basis_shell_center(qmckl_context context, const in if (new_array == NULL) { return qmckl_failwith( context, QMCKL_ALLOCATION_FAILED, - "qmckl_set_ao_basis_shell_center", + "qmckl_set_ao_basis_nucleus_shell_num", NULL); } - memcpy(new_array, shell_center, mem_info.size); + memcpy(new_array, nucleus_shell_num, mem_info.size); - ctx->ao_basis.shell_center = new_array; + ctx->ao_basis.nucleus_shell_num = new_array; + + <> +} + +qmckl_exit_code qmckl_set_ao_basis_nucleus_index(qmckl_context context, const int64_t* nucleus_index) { + <> + + int32_t mask = 1 << 4; + + const int64_t shell_num = qmckl_get_ao_basis_shell_num(context); + if (shell_num == 0L) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_nucleus_index", + "shell_num is not set"); + } + + if (ctx->ao_basis.nucleus_index != NULL) { + 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", + 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) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_set_ao_basis_nucleus_index", + NULL); + } + + memcpy(new_array, nucleus_index, mem_info.size); + + ctx->ao_basis.nucleus_index = new_array; <> } -qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const char* shell_ang_mom) { +qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const int32_t* shell_ang_mom) { <> - int32_t mask = 1 << 4; + int32_t mask = 1 << 5; const int64_t shell_num = qmckl_get_ao_basis_shell_num(context); if (shell_num == 0L) { @@ -567,7 +711,7 @@ qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const c qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; mem_info.size = shell_num * sizeof(char); - char* new_array = (char*) qmckl_malloc(context, mem_info); + int32_t * new_array = (int32_t*) qmckl_malloc(context, mem_info); if (new_array == NULL) { return qmckl_failwith( context, @@ -587,7 +731,7 @@ qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const c qmckl_exit_code qmckl_set_ao_basis_shell_prim_num(qmckl_context context, const int64_t* shell_prim_num) { <> - int32_t mask = 1 << 5; + int32_t mask = 1 << 6; const int64_t shell_num = qmckl_get_ao_basis_shell_num(context); if (shell_num == 0L) { @@ -629,7 +773,7 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_num(qmckl_context context, const qmckl_exit_code qmckl_set_ao_basis_shell_prim_index(qmckl_context context, const int64_t* shell_prim_index) { <> - int32_t mask = 1 << 6; + int32_t mask = 1 << 7; const int64_t shell_num = qmckl_get_ao_basis_shell_num(context); if (shell_num == 0L) { @@ -670,7 +814,7 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_index(qmckl_context context, cons qmckl_exit_code qmckl_set_ao_basis_shell_factor(qmckl_context context, const double* shell_factor) { <> - int32_t mask = 1 << 7; + int32_t mask = 1 << 8; const int64_t shell_num = qmckl_get_ao_basis_shell_num(context); if (shell_num == 0L) { @@ -711,7 +855,7 @@ qmckl_exit_code qmckl_set_ao_basis_shell_factor(qmckl_context context, const do qmckl_exit_code qmckl_set_ao_basis_exponent(qmckl_context context, const double* exponent) { <> - int32_t mask = 1 << 8; + int32_t mask = 1 << 9; const int64_t prim_num = qmckl_get_ao_basis_prim_num(context); if (prim_num == 0L) { @@ -751,7 +895,7 @@ qmckl_exit_code qmckl_set_ao_basis_exponent(qmckl_context context, const double qmckl_exit_code qmckl_set_ao_basis_coefficient(qmckl_context context, const double* coefficient) { <> - int32_t mask = 1 << 9; + int32_t mask = 1 << 10; const int64_t prim_num = qmckl_get_ao_basis_prim_num(context); if (prim_num == 0L) { @@ -788,97 +932,751 @@ qmckl_exit_code qmckl_set_ao_basis_coefficient(qmckl_context context, const dou <> } +qmckl_exit_code qmckl_set_ao_basis_prim_factor(qmckl_context context, const double* prim_factor) { + <> + + int32_t mask = 1 << 11; + + const int64_t prim_num = qmckl_get_ao_basis_prim_num(context); + if (prim_num == 0L) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_prim_factor", + "prim_num is not set"); + } + + + if (ctx->ao_basis.prim_factor != NULL) { + 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", + NULL); + } + } + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = prim_num * sizeof(double); + double* new_array = (double*) qmckl_malloc(context, mem_info); + + if (new_array == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_set_ao_basis_prim_factor", + NULL); + } + + memcpy(new_array, prim_factor, mem_info.size); + + ctx->ao_basis.prim_factor = new_array; + + <> +} + #+end_src + When the basis set is completely entered, other data structures are + 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 + vanish. Also, it is possible to compute a nuclear radius beyond which + all the primitives are zero up to the numerical accuracy defined in + the context. + + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_finalize_basis(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_finalize_basis(qmckl_context context) { + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int64_t nucl_num = 0; + qmckl_exit_code rc = QMCKL_FAILURE; + + rc = qmckl_get_nucleus_num(context, &nucl_num); + if (rc != QMCKL_SUCCESS) return rc; + + /* nucleus_prim_index */ + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = (ctx->nucleus.num + (int64_t) 1) * sizeof(int64_t); + + ctx->ao_basis.nucleus_prim_index = (int64_t*) qmckl_malloc(context, mem_info); + + if (ctx->ao_basis.nucleus_prim_index == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_nucleus_prim_index", + NULL); + } + + for (int64_t i=0 ; iao_basis.nucleus_index[i]; + ctx->ao_basis.nucleus_prim_index[i] = ctx->ao_basis.shell_prim_index[shell_idx]; + } + ctx->ao_basis.nucleus_prim_index[nucl_num] = ctx->ao_basis.prim_num; + + + /* TODO : sort the basis set here */ + return QMCKL_SUCCESS; +} + #+end_src + ** TODO Fortran interfaces ** Test :noexport: - #+begin_src c :tangle (eval c_test) :exports none :exports none - /* Reference input data */ + #+begin_src c :tangle (eval c_test) :exports none :exports none +const int64_t nucl_num = chbrclf_nucl_num; +const double* nucl_charge = chbrclf_charge; +const double* nucl_coord = &(chbrclf_nucl_coord[0][0]); - char typ = 'G'; - #define shell_num ((int64_t) 12) - #define prim_num ((int64_t) 20) +qmckl_exit_code rc; +rc = qmckl_set_nucleus_num (context, nucl_num); +assert(rc == QMCKL_SUCCESS); - int64_t shell_center [shell_num] = - { 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2 }; +rc = qmckl_set_nucleus_coord (context, 'T', &(nucl_coord[0])); +assert(rc == QMCKL_SUCCESS); - char shell_ang_mom [shell_num] = - { 'S', 'S', 'S', 'P', 'P', 'D', 'S', 'S', 'S', 'P', 'P', 'D' }; +rc = qmckl_set_nucleus_charge(context, nucl_charge); +assert(rc == QMCKL_SUCCESS); - double shell_factor [shell_num] = - { 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1. }; +assert(qmckl_nucleus_provided(context)); - int64_t shell_prim_num [shell_num] = - {5, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1}; - int64_t shell_prim_index [shell_num] = - {1, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19, 20}; +const int64_t shell_num = chbrclf_shell_num; +const int64_t prim_num = chbrclf_prim_num; +const int64_t * nucleus_index = &(chbrclf_basis_nucleus_index[0]); +const int64_t * nucleus_shell_num = &(chbrclf_basis_nucleus_shell_num[0]); +const int32_t * shell_ang_mom = &(chbrclf_basis_shell_ang_mom[0]); +const int64_t * shell_prim_num = &(chbrclf_basis_shell_prim_num[0]); +const int64_t * shell_prim_index = &(chbrclf_basis_shell_prim_index[0]); +const double * shell_factor = &(chbrclf_basis_shell_factor[0]); +const double * exponent = &(chbrclf_basis_exponent[0]); +const double * coefficient = &(chbrclf_basis_coefficient[0]); +const double * prim_factor = &(chbrclf_basis_prim_factor[0]); - double exponent [prim_num] = - { 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 }; +char typ = 'G'; - double coefficient [prim_num] = - { 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 }; - /* --- */ +assert(!qmckl_ao_basis_provided(context)); - qmckl_exit_code rc; +rc = qmckl_set_ao_basis_type (context, typ); +assert(rc == QMCKL_SUCCESS); +assert(!qmckl_ao_basis_provided(context)); - assert(!qmckl_ao_basis_provided(context)); +rc = qmckl_set_ao_basis_shell_num (context, shell_num); +assert(rc == QMCKL_SUCCESS); +assert(!qmckl_ao_basis_provided(context)); - rc = qmckl_set_ao_basis_type (context, typ); - assert(rc == QMCKL_SUCCESS); - assert(!qmckl_ao_basis_provided(context)); +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_shell_num (context, shell_num); - assert(rc == QMCKL_SUCCESS); - assert(!qmckl_ao_basis_provided(context)); +rc = qmckl_set_ao_basis_nucleus_index (context, nucleus_index); +assert(rc == QMCKL_SUCCESS); +assert(!qmckl_ao_basis_provided(context)); - 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_shell_num (context, nucleus_shell_num); +assert(rc == QMCKL_SUCCESS); +assert(!qmckl_ao_basis_provided(context)); - rc = qmckl_set_ao_basis_shell_center (context, shell_center); - assert(rc == QMCKL_SUCCESS); - assert(!qmckl_ao_basis_provided(context)); +rc = qmckl_set_ao_basis_shell_ang_mom (context, shell_ang_mom); +assert(rc == QMCKL_SUCCESS); +assert(!qmckl_ao_basis_provided(context)); - rc = qmckl_set_ao_basis_shell_ang_mom (context, shell_ang_mom); - assert(rc == QMCKL_SUCCESS); - assert(!qmckl_ao_basis_provided(context)); +rc = qmckl_set_ao_basis_shell_factor (context, shell_factor); +assert(rc == QMCKL_SUCCESS); +assert(!qmckl_ao_basis_provided(context)); - rc = qmckl_set_ao_basis_shell_factor (context, shell_factor); - assert(rc == QMCKL_SUCCESS); - assert(!qmckl_ao_basis_provided(context)); +rc = qmckl_set_ao_basis_shell_prim_num (context, shell_prim_num); +assert(rc == QMCKL_SUCCESS); +assert(!qmckl_ao_basis_provided(context)); - rc = qmckl_set_ao_basis_shell_center (context, shell_prim_num); - assert(rc == QMCKL_SUCCESS); - assert(!qmckl_ao_basis_provided(context)); +rc = qmckl_set_ao_basis_shell_prim_index (context, shell_prim_index); +assert(rc == QMCKL_SUCCESS); +assert(!qmckl_ao_basis_provided(context)); - rc = qmckl_set_ao_basis_shell_prim_num (context, shell_prim_num); - assert(rc == QMCKL_SUCCESS); - assert(!qmckl_ao_basis_provided(context)); +rc = qmckl_set_ao_basis_exponent (context, exponent); +assert(rc == QMCKL_SUCCESS); +assert(!qmckl_ao_basis_provided(context)); - rc = qmckl_set_ao_basis_shell_prim_index (context, shell_prim_index); - assert(rc == QMCKL_SUCCESS); - assert(!qmckl_ao_basis_provided(context)); +rc = qmckl_set_ao_basis_coefficient (context, coefficient); +assert(rc == QMCKL_SUCCESS); +assert(!qmckl_ao_basis_provided(context)); - rc = qmckl_set_ao_basis_exponent (context, exponent); - assert(rc == QMCKL_SUCCESS); - assert(!qmckl_ao_basis_provided(context)); +rc = qmckl_set_ao_basis_prim_factor (context, prim_factor); +assert(rc == QMCKL_SUCCESS); +assert(qmckl_ao_basis_provided(context)); - rc = qmckl_set_ao_basis_coefficient (context, coefficient); - assert(rc == QMCKL_SUCCESS); - assert(qmckl_ao_basis_provided(context)); + #+end_src + +* Radial part +** General functions for Gaussian basis functions + + ~qmckl_ao_gaussian_vgl~ computes the values, gradients and + Laplacians at a given point of ~n~ Gaussian functions centered at + the same point: + + \[ v_i = \exp(-a_i |X-R|^2) \] + \[ \nabla_x v_i = -2 a_i (X_x - R_x) v_i \] + \[ \nabla_y v_i = -2 a_i (X_y - R_y) v_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~ | + |--------------+--------+------------------------------------------------------| + + Requirements + + - ~context~ is not 0 + - ~n~ > 0 + - ~ldv~ >= 5 + - ~A(i)~ > 0 for all ~i~ + - ~X~ is allocated with at least $3 \times 8$ bytes + - ~R~ is allocated with at least $3 \times 8$ bytes + - ~A~ is allocated with at least $n \times 8$ bytes + - ~VGL~ is allocated with at least $n \times 5 \times 8$ bytes + + #+begin_src c :tangle (eval h_func) +qmckl_exit_code +qmckl_ao_gaussian_vgl(const qmckl_context context, + const double *X, + const double *R, + const int64_t *n, + const int64_t *A, + const double *VGL, + const int64_t ldv); + #+end_src + + #+begin_src f90 :tangle (eval f) +integer function qmckl_ao_gaussian_vgl_f(context, X, R, n, A, VGL, ldv) result(info) + use qmckl + implicit none + integer*8 , intent(in) :: context + real*8 , intent(in) :: X(3), R(3) + integer*8 , intent(in) :: n + real*8 , intent(in) :: A(n) + real*8 , intent(out) :: VGL(ldv,5) + integer*8 , intent(in) :: ldv + + integer*8 :: i,j + real*8 :: Y(3), r2, t, u, v + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (n <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + if (ldv < n) then + info = QMCKL_INVALID_ARG_7 + return + endif + + + do i=1,3 + Y(i) = X(i) - R(i) + end do + r2 = Y(1)*Y(1) + Y(2)*Y(2) + Y(3)*Y(3) + + do i=1,n + VGL(i,1) = dexp(-A(i) * r2) + end do + + do i=1,n + VGL(i,5) = A(i) * VGL(i,1) + end do + + t = -2.d0 * ( X(1) - R(1) ) + u = -2.d0 * ( X(2) - R(2) ) + v = -2.d0 * ( X(3) - R(3) ) + + do i=1,n + VGL(i,2) = t * VGL(i,5) + VGL(i,3) = u * VGL(i,5) + VGL(i,4) = v * VGL(i,5) + end do + + t = 4.d0 * r2 + do i=1,n + VGL(i,5) = (t * A(i) - 6.d0) * VGL(i,5) + end do + +end function qmckl_ao_gaussian_vgl_f + #+end_src + + #+begin_src f90 :tangle (eval f) :exports none +integer(c_int32_t) function qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv) & + bind(C) result(info) + use, intrinsic :: iso_c_binding + implicit none + integer (c_int64_t) , intent(in) , value :: context + real (c_double) , intent(in) :: X(3), R(3) + integer (c_int64_t) , intent(in) , value :: n + real (c_double) , intent(in) :: A(n) + real (c_double) , intent(out) :: VGL(ldv,5) + integer (c_int64_t) , intent(in) , value :: ldv + + integer, external :: qmckl_ao_gaussian_vgl_f + info = qmckl_ao_gaussian_vgl_f(context, X, R, n, A, VGL, ldv) +end function qmckl_ao_gaussian_vgl + #+end_src + + #+begin_src f90 :tangle (eval fh_func) :exports none + interface + integer(c_int32_t) function qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv) & + bind(C) + use, intrinsic :: iso_c_binding + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: ldv + integer (c_int64_t) , intent(in) , value :: n + real (c_double) , intent(in) :: X(3), R(3), A(n) + real (c_double) , intent(out) :: VGL(ldv,5) + end function qmckl_ao_gaussian_vgl + end interface + #+end_src + + # Test + #+begin_src f90 :tangle (eval f_test) +integer(c_int32_t) function test_qmckl_ao_gaussian_vgl(context) bind(C) + use qmckl + implicit none + + integer(c_int64_t), intent(in), value :: context + + integer*8 :: n, ldv, j, i + double precision :: X(3), R(3), Y(3), r2 + double precision, allocatable :: VGL(:,:), A(:) + double precision :: epsilon + + epsilon = qmckl_get_numprec_epsilon(context) + + X = (/ 1.1 , 2.2 , 3.3 /) + R = (/ 0.1 , 1.2 , -2.3 /) + Y(:) = X(:) - R(:) + r2 = Y(1)**2 + Y(2)**2 + Y(3)**2 + + n = 10; + ldv = 100; + + allocate (A(n), VGL(ldv,5)) + do i=1,n + A(i) = 0.0013 * dble(ishft(1,i)) + end do + + + test_qmckl_ao_gaussian_vgl = & + qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv) + if (test_qmckl_ao_gaussian_vgl /= 0) return + + test_qmckl_ao_gaussian_vgl = -1 + + do i=1,n + test_qmckl_ao_gaussian_vgl = -11 + if (dabs(1.d0 - VGL(i,1) / (& + dexp(-A(i) * r2) & + )) > epsilon ) return + + test_qmckl_ao_gaussian_vgl = -12 + if (dabs(1.d0 - VGL(i,2) / (& + -2.d0 * A(i) * Y(1) * dexp(-A(i) * r2) & + )) > epsilon ) return + + test_qmckl_ao_gaussian_vgl = -13 + if (dabs(1.d0 - VGL(i,3) / (& + -2.d0 * A(i) * Y(2) * dexp(-A(i) * r2) & + )) > epsilon ) return + + test_qmckl_ao_gaussian_vgl = -14 + if (dabs(1.d0 - VGL(i,4) / (& + -2.d0 * A(i) * Y(3) * dexp(-A(i) * r2) & + )) > epsilon ) return + + test_qmckl_ao_gaussian_vgl = -15 + if (dabs(1.d0 - VGL(i,5) / (& + A(i) * (4.d0*r2*A(i) - 6.d0) * dexp(-A(i) * r2) & + )) > epsilon ) return + end do + + test_qmckl_ao_gaussian_vgl = 0 + + deallocate(VGL) +end function test_qmckl_ao_gaussian_vgl + #+end_src + + #+begin_src c :tangle (eval c_test) :exports none + int test_qmckl_ao_gaussian_vgl(qmckl_context context); + assert(0 == test_qmckl_ao_gaussian_vgl(context)); + #+end_src + +** TODO General functions for Slater basis functions +** TODO General functions for Radial functions on a grid +** Computation of primitives +*** Get + + #+begin_src c :comments org :tangle (eval h_func) :noweb yes +qmckl_exit_code qmckl_get_ao_basis_primitive_vgl(qmckl_context context, double* const primitive_vgl); + #+end_src + + #+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; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_ao_basis_primitive_vgl(context); + if (rc != QMCKL_SUCCESS) return rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + size_t sze = ctx->ao_basis.prim_num * 5 * ctx->electron.num * ctx->electron.walk_num; + memcpy(primitive_vgl, ctx->ao_basis.primitive_vgl, sze * sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide + + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_ao_basis_primitive_vgl(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_ao_basis_primitive_vgl(qmckl_context context) +{ + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + if (!ctx->ao_basis.provided) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_ao_basis_primitive_vgl", + NULL); + } + + /* Compute if necessary */ + if (ctx->electron.coord_new_date > ctx->ao_basis.primitive_vgl_date) { + + /* Allocate array */ + if (ctx->ao_basis.primitive_vgl == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->ao_basis.prim_num * 5 * ctx->electron.num * + ctx->electron.walk_num * sizeof(double); + double* primitive_vgl = (double*) qmckl_malloc(context, mem_info); + + if (primitive_vgl == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_ao_basis_primitive_vgl", + NULL); + } + ctx->ao_basis.primitive_vgl = primitive_vgl; + } + + qmckl_exit_code rc; + if (ctx->ao_basis.type == 'G') { + rc = qmckl_compute_ao_basis_primitive_gaussian_vgl(context, + ctx->ao_basis.prim_num, + ctx->electron.num, + ctx->nucleus.num, + ctx->electron.walk_num, + ctx->ao_basis.nucleus_prim_index, + ctx->electron.coord_new, + ctx->nucleus.coord, + ctx->ao_basis.exponent, + ctx->ao_basis.primitive_vgl); + } else { + return qmckl_failwith( context, + QMCKL_FAILURE, + "compute_ao_basis_primitive_vgl", + "Not yet implemented"); + } + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->ao_basis.primitive_vgl_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute + :PROPERTIES: + :Name: qmckl_compute_ao_basis_primitive_gaussian_vgl + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_ao_basis_primitive_gaussian_vgl_args + | qmckl_context | context | in | Global state | + | int64_t | prim_num | in | Number of primitives | + | int64_t | elec_num | in | Number of electrons | + | int64_t | nucl_num | in | Number of nuclei | + | int64_t | walk_num | in | Number of walkers | + | int64_t | nucleus_prim_index[nucl_num] | in | Index of the 1st primitive of each nucleus | + | double | elec_coord[walk_num][3][elec_num] | in | Electron coordinates | + | double | nucl_coord[3][elec_num] | in | Nuclear coordinates | + | double | expo[prim_num] | in | Exponents of the primitives | + | double | primitive_vgl[prim_num][5][walk_num][elec_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, walk_num, & + nucleus_prim_index, elec_coord, nucl_coord, expo, primitive_vgl) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: prim_num + integer*8 , intent(in) :: nucl_num + integer*8 , intent(in) :: elec_num + integer*8 , intent(in) :: walk_num + integer*8 , intent(in) :: nucleus_prim_index(nucl_num+1) + double precision , intent(in) :: elec_coord(elec_num,3,walk_num) + double precision , intent(in) :: nucl_coord(nucl_num,3) + double precision , intent(in) :: expo(prim_num) + double precision , intent(out) :: primitive_vgl(elec_num,walk_num,5,prim_num) + + integer*8 :: inucl, iprim, iwalk, ielec + double precision :: x, y, z, two_a, ar2, r2, v + double precision :: r2_cut(elec_num,walk_num) + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (prim_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (elec_num <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + if (nucl_num <= 0) then + info = QMCKL_INVALID_ARG_5 + return + endif + + if (walk_num <= 0) then + info = QMCKL_INVALID_ARG_6 + return + endif + + do inucl=1,nucl_num + ! C is zero-based, so shift bounds by one + do iprim = nucleus_prim_index(inucl)+1, nucleus_prim_index(inucl+1) + do iwalk = 1, walk_num + do ielec = 1, elec_num + x = elec_coord(ielec,1,iwalk) - nucl_coord(inucl,1) + y = elec_coord(ielec,2,iwalk) - nucl_coord(inucl,2) + z = elec_coord(ielec,3,iwalk) - nucl_coord(inucl,3) + + r2 = x*x + y*y + z*z + ar2 = expo(iprim)*r2 + v = dexp(-ar2) + two_a = -2.d0 * expo(iprim) * v + + primitive_vgl(ielec, iwalk, 1, iprim) = v + primitive_vgl(ielec, iwalk, 2, iprim) = two_a * x + primitive_vgl(ielec, iwalk, 3, iprim) = two_a * y + primitive_vgl(ielec, iwalk, 4, iprim) = two_a * z + primitive_vgl(ielec, iwalk, 5, iprim) = two_a * (3.d0 - 2.d0*ar2) + + end do + end do + end do + end do + +end function qmckl_compute_ao_basis_primitive_gaussian_vgl_f + #+end_src + + #+begin_src c :tangle (eval h_private_func) :comments org :exports none +qmckl_exit_code qmckl_compute_ao_basis_primitive_gaussian_vgl( + const qmckl_context context, + const int64_t prim_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t walk_num, + const int64_t* nucleus_prim_index, + const double* elec_coord, + const double* nucl_coord, + const double* expo, + double* const primitive_vgl); + #+end_src + + #+CALL: generate_c_interface(table=qmckl_ao_basis_primitive_gaussian_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_ao_basis_primitive_gaussian_vgl")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_ao_basis_primitive_gaussian_vgl & + (context, prim_num, elec_num, nucl_num, walk_num, nucleus_prim_index, elec_coord, nucl_coord, expo, primitive_vgl) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: prim_num + integer (c_int64_t) , intent(in) , value :: elec_num + integer (c_int64_t) , intent(in) , value :: nucl_num + integer (c_int64_t) , intent(in) , value :: walk_num + integer (c_int64_t) , intent(in) :: nucleus_prim_index(nucl_num) + real (c_double ) , intent(in) :: elec_coord(elec_num,3,walk_num) + real (c_double ) , intent(in) :: nucl_coord(elec_num,3) + real (c_double ) , intent(in) :: expo(prim_num) + real (c_double ) , intent(out) :: primitive_vgl(elec_num,walk_num,5,prim_num) + + integer(c_int32_t), external :: qmckl_compute_ao_basis_primitive_gaussian_vgl_f + info = qmckl_compute_ao_basis_primitive_gaussian_vgl_f & + (context, prim_num, elec_num, nucl_num, walk_num, nucleus_prim_index, elec_coord, nucl_coord, expo, primitive_vgl) + + end function qmckl_compute_ao_basis_primitive_gaussian_vgl + #+end_src + + #+begin_src python :results output :exports none +import numpy as np + +def f(a,x,y): + return np.exp( -a*(np.linalg.norm(x-y))**2 ) + +def df(a,x,y,n): + h0 = 1.e-6 + if n == 1: h = np.array([h0,0.,0.]) + elif n == 2: h = np.array([0.,h0,0.]) + elif n == 3: h = np.array([0.,0.,h0]) + return ( f(a,x+h,y) - f(a,x-h,y) ) / (2.*h0) + +def d2f(a,x,y,n): + h0 = 1.e-6 + if n == 1: h = np.array([h0,0.,0.]) + elif n == 2: h = np.array([0.,h0,0.]) + elif n == 3: h = np.array([0.,0.,h0]) + return ( f(a,x+h,y) - 2.*f(a,x,y) + f(a,x-h,y) ) / h0**2 + +def lf(a,x,y): + return d2f(a,x,y,1) + d2f(a,x,y,2) + d2f(a,x,y,3) + +elec_26_w1 = np.array( [ 1.49050402641, 2.90106987953, -1.05920815468 ] ) +elec_15_w2 = np.array( [ -2.20180344582,-1.9113150239, 2.2193744778600002 ] ) +nucl_1 = np.array( [ 1.096243353458458e+00, 8.907054016973815e-01, 7.777092280258892e-01 ] ) +nucl_2 = np.array( [ 1.168459237342663e+00, 1.125660720053393e+00, 2.833370314829343e+00 ] ) + +#double prim_vgl[prim_num][5][walk_num][elec_num]; +a = 0.9059; x = elec_26_w1 ; y = nucl_1 +print ( "[7][0][0][26] : %e"% f(a,x,y)) +print ( "[7][1][0][26] : %e"% df(a,x,y,1)) +print ( "[7][2][0][26] : %e"% df(a,x,y,2)) +print ( "[7][3][0][26] : %e"% df(a,x,y,3)) +print ( "[7][4][0][26] : %e"% lf(a,x,y)) + +a = 0.32578; x = elec_15_w2 ; y = nucl_2 +print ( "[39][0][1][15] : %e"% f(a,x,y)) +print ( "[39][1][1][15] : %e"% df(a,x,y,1)) +print ( "[39][2][1][15] : %e"% df(a,x,y,2)) +print ( "[39][3][1][15] : %e"% df(a,x,y,3)) +print ( "[39][4][1][15] : %e"% lf(a,x,y)) #+end_src + #+RESULTS: + #+begin_example + [7][0][0][26] : 1.050157e-03 + [7][1][0][26] : -7.501497e-04 + [7][2][0][26] : -3.825069e-03 + [7][3][0][26] : 3.495056e-03 + [7][4][0][26] : 2.040013e-02 + [39][0][1][15] : 1.083038e-03 + [39][1][1][15] : 2.378275e-03 + [39][2][1][15] : 2.143086e-03 + [39][3][1][15] : 4.332750e-04 + [39][4][1][15] : 7.514605e-03 + #+end_example + +*** Test + + #+begin_src c :tangle (eval c_test) +#define walk_num chbrclf_walk_num +#define elec_num chbrclf_elec_num +#define prim_num chbrclf_prim_num + +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); +assert (rc == QMCKL_SUCCESS); + +rc = qmckl_set_electron_walk_num (context, walk_num); +assert (rc == QMCKL_SUCCESS); + +assert(qmckl_electron_provided(context)); + +rc = qmckl_set_electron_coord (context, 'N', elec_coord); +assert(rc == QMCKL_SUCCESS); + + + +double prim_vgl[prim_num][5][walk_num][elec_num]; + +rc = qmckl_get_ao_basis_primitive_vgl(context, &(prim_vgl[0][0][0][0])); +assert (rc == QMCKL_SUCCESS); + +assert( fabs(prim_vgl[7][0][0][26] - ( 1.0501570432064878E-003)) < 1.e-14 ); +assert( fabs(prim_vgl[7][1][0][26] - (-7.5014974095310560E-004)) < 1.e-14 ); +assert( fabs(prim_vgl[7][2][0][26] - (-3.8250692897610380E-003)) < 1.e-14 ); +assert( fabs(prim_vgl[7][3][0][26] - ( 3.4950559194080275E-003)) < 1.e-14 ); +assert( fabs(prim_vgl[7][4][0][26] - ( 2.0392163767356572E-002)) < 1.e-14 ); + +assert( fabs(prim_vgl[39][0][1][15] - ( 1.0825844173157661E-003)) < 1.e-14 ); +assert( fabs(prim_vgl[39][1][1][15] - ( 2.3774237611651531E-003)) < 1.e-14 ); +assert( fabs(prim_vgl[39][2][1][15] - ( 2.1423191526963063E-003)) < 1.e-14 ); +assert( fabs(prim_vgl[39][3][1][15] - ( 4.3312003523048492E-004)) < 1.e-14 ); +assert( fabs(prim_vgl[39][4][1][15] - ( 7.5174404780004771E-003)) < 1.e-14 ); + + + + + #+end_src * Polynomial part -** Powers of $x-X_i$ +** General functions for Powers of $x-X_i$ :PROPERTIES: :Name: qmckl_ao_power :CRetType: qmckl_exit_code @@ -1074,7 +1872,7 @@ end function test_qmckl_ao_power assert(0 == test_qmckl_ao_power(context)); #+end_src -** Value, Gradient and Laplacian of a polynomial +** General functions for Value, Gradient and Laplacian of a polynomial :PROPERTIES: :Name: qmckl_ao_polynomial_vgl :CRetType: qmckl_exit_code @@ -1450,219 +2248,6 @@ end function test_qmckl_ao_polynomial_vgl assert(0 == test_qmckl_ao_polynomial_vgl(context)); #+end_src -* Radial part -** Gaussian basis functions - - ~qmckl_ao_gaussian_vgl~ computes the values, gradients and - Laplacians at a given point of ~n~ Gaussian functions centered at - the same point: - - \[ v_i = \exp(-a_i |X-R|^2) \] - \[ \nabla_x v_i = -2 a_i (X_x - R_x) v_i \] - \[ \nabla_y v_i = -2 a_i (X_y - R_y) v_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~ | - - Requirements - - - ~context~ is not 0 - - ~n~ > 0 - - ~ldv~ >= 5 - - ~A(i)~ > 0 for all ~i~ - - ~X~ is allocated with at least $3 \times 8$ bytes - - ~R~ is allocated with at least $3 \times 8$ bytes - - ~A~ is allocated with at least $n \times 8$ bytes - - ~VGL~ is allocated with at least $n \times 5 \times 8$ bytes - - #+begin_src c :tangle (eval h_func) -qmckl_exit_code -qmckl_ao_gaussian_vgl(const qmckl_context context, - const double *X, - const double *R, - const int64_t *n, - const int64_t *A, - const double *VGL, - const int64_t ldv); - #+end_src - - #+begin_src f90 :tangle (eval f) -integer function qmckl_ao_gaussian_vgl_f(context, X, R, n, A, VGL, ldv) result(info) - use qmckl - implicit none - integer*8 , intent(in) :: context - real*8 , intent(in) :: X(3), R(3) - integer*8 , intent(in) :: n - real*8 , intent(in) :: A(n) - real*8 , intent(out) :: VGL(ldv,5) - integer*8 , intent(in) :: ldv - - integer*8 :: i,j - real*8 :: Y(3), r2, t, u, v - - info = QMCKL_SUCCESS - - if (context == QMCKL_NULL_CONTEXT) then - info = QMCKL_INVALID_CONTEXT - return - endif - - if (n <= 0) then - info = QMCKL_INVALID_ARG_4 - return - endif - - if (ldv < n) then - info = QMCKL_INVALID_ARG_7 - return - endif - - - do i=1,3 - Y(i) = X(i) - R(i) - end do - r2 = Y(1)*Y(1) + Y(2)*Y(2) + Y(3)*Y(3) - - do i=1,n - VGL(i,1) = dexp(-A(i) * r2) - end do - - do i=1,n - VGL(i,5) = A(i) * VGL(i,1) - end do - - t = -2.d0 * ( X(1) - R(1) ) - u = -2.d0 * ( X(2) - R(2) ) - v = -2.d0 * ( X(3) - R(3) ) - - do i=1,n - VGL(i,2) = t * VGL(i,5) - VGL(i,3) = u * VGL(i,5) - VGL(i,4) = v * VGL(i,5) - end do - - t = 4.d0 * r2 - do i=1,n - VGL(i,5) = (t * A(i) - 6.d0) * VGL(i,5) - end do - -end function qmckl_ao_gaussian_vgl_f - #+end_src - - #+begin_src f90 :tangle (eval f) :exports none -integer(c_int32_t) function qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv) & - bind(C) result(info) - use, intrinsic :: iso_c_binding - implicit none - integer (c_int64_t) , intent(in) , value :: context - real (c_double) , intent(in) :: X(3), R(3) - integer (c_int64_t) , intent(in) , value :: n - real (c_double) , intent(in) :: A(n) - real (c_double) , intent(out) :: VGL(ldv,5) - integer (c_int64_t) , intent(in) , value :: ldv - - integer, external :: qmckl_ao_gaussian_vgl_f - info = qmckl_ao_gaussian_vgl_f(context, X, R, n, A, VGL, ldv) -end function qmckl_ao_gaussian_vgl - #+end_src - - #+begin_src f90 :tangle (eval fh_func) :exports none - interface - integer(c_int32_t) function qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv) & - bind(C) - use, intrinsic :: iso_c_binding - integer (c_int64_t) , intent(in) , value :: context - integer (c_int64_t) , intent(in) , value :: ldv - integer (c_int64_t) , intent(in) , value :: n - real (c_double) , intent(in) :: X(3), R(3), A(n) - real (c_double) , intent(out) :: VGL(ldv,5) - end function qmckl_ao_gaussian_vgl - end interface - #+end_src - - # Test - #+begin_src f90 :tangle (eval f_test) -integer(c_int32_t) function test_qmckl_ao_gaussian_vgl(context) bind(C) - use qmckl - implicit none - - integer(c_int64_t), intent(in), value :: context - - integer*8 :: n, ldv, j, i - double precision :: X(3), R(3), Y(3), r2 - double precision, allocatable :: VGL(:,:), A(:) - double precision :: epsilon - - epsilon = qmckl_get_numprec_epsilon(context) - - X = (/ 1.1 , 2.2 , 3.3 /) - R = (/ 0.1 , 1.2 , -2.3 /) - Y(:) = X(:) - R(:) - r2 = Y(1)**2 + Y(2)**2 + Y(3)**2 - - n = 10; - ldv = 100; - - allocate (A(n), VGL(ldv,5)) - do i=1,n - A(i) = 0.0013 * dble(ishft(1,i)) - end do - - - test_qmckl_ao_gaussian_vgl = & - qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv) - if (test_qmckl_ao_gaussian_vgl /= 0) return - - test_qmckl_ao_gaussian_vgl = -1 - - do i=1,n - test_qmckl_ao_gaussian_vgl = -11 - if (dabs(1.d0 - VGL(i,1) / (& - dexp(-A(i) * r2) & - )) > epsilon ) return - - test_qmckl_ao_gaussian_vgl = -12 - if (dabs(1.d0 - VGL(i,2) / (& - -2.d0 * A(i) * Y(1) * dexp(-A(i) * r2) & - )) > epsilon ) return - - test_qmckl_ao_gaussian_vgl = -13 - if (dabs(1.d0 - VGL(i,3) / (& - -2.d0 * A(i) * Y(2) * dexp(-A(i) * r2) & - )) > epsilon ) return - - test_qmckl_ao_gaussian_vgl = -14 - if (dabs(1.d0 - VGL(i,4) / (& - -2.d0 * A(i) * Y(3) * dexp(-A(i) * r2) & - )) > epsilon ) return - - test_qmckl_ao_gaussian_vgl = -15 - if (dabs(1.d0 - VGL(i,5) / (& - A(i) * (4.d0*r2*A(i) - 6.d0) * dexp(-A(i) * r2) & - )) > epsilon ) return - end do - - test_qmckl_ao_gaussian_vgl = 0 - - deallocate(VGL) -end function test_qmckl_ao_gaussian_vgl - #+end_src - - #+begin_src c :tangle (eval c_test) :exports none - int test_qmckl_ao_gaussian_vgl(qmckl_context context); - assert(0 == test_qmckl_ao_gaussian_vgl(context)); - #+end_src - -** TODO Slater basis functions - -** TODO Radial functions on a grid * Combining radial and polynomial parts * End of files :noexport: diff --git a/org/qmckl_context.org b/org/qmckl_context.org index 6472365..11eb235 100644 --- a/org/qmckl_context.org +++ b/org/qmckl_context.org @@ -31,6 +31,9 @@ int main() { #include "qmckl_nucleus_private_type.h" #include "qmckl_electron_private_type.h" #include "qmckl_ao_private_type.h" +#include "qmckl_nucleus_private_func.h" +#include "qmckl_electron_private_func.h" +#include "qmckl_ao_private_func.h" #+end_src #+begin_src c :tangle (eval c) @@ -213,17 +216,26 @@ qmckl_context qmckl_context_create() { } /* Initialize data */ - ctx->tag = VALID_TAG; + { + ctx->tag = VALID_TAG; + + const qmckl_context context = (const qmckl_context) ctx; + assert ( qmckl_context_check(context) != QMCKL_NULL_CONTEXT ); + + qmckl_exit_code rc; + + ctx->numprec.precision = QMCKL_DEFAULT_PRECISION; + ctx->numprec.range = QMCKL_DEFAULT_RANGE; - const qmckl_context context = (const qmckl_context) ctx; - assert ( qmckl_context_check(context) != QMCKL_NULL_CONTEXT ); - - ctx->numprec.precision = QMCKL_DEFAULT_PRECISION; - ctx->numprec.range = QMCKL_DEFAULT_RANGE; - - ctx->ao_basis.uninitialized = (1 << 10) - 1; - ctx->nucleus.uninitialized = (1 << 4) - 1; - ctx->electron.uninitialized = (1 << 3) - 1; + rc = qmckl_init_electron(context); + assert (rc == QMCKL_SUCCESS); + + rc = qmckl_init_nucleus(context); + assert (rc == QMCKL_SUCCESS); + + rc = qmckl_init_ao_basis(context); + assert (rc == QMCKL_SUCCESS); + } /* Allocate qmckl_memory_struct */ { diff --git a/org/qmckl_electron.org b/org/qmckl_electron.org index 691f16b..064a66b 100644 --- a/org/qmckl_electron.org +++ b/org/qmckl_electron.org @@ -87,6 +87,7 @@ int main() { | ~en_distance_rescaled_deriv_e~ | ~double[walk_num][4][num][num]~ | Electron-electron rescaled distances derivatives | | ~en_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | + ** Data structure #+begin_src c :comments org :tangle (eval h_private_type) @@ -115,16 +116,41 @@ typedef struct qmckl_electron_struct { int32_t uninitialized; bool provided; } qmckl_electron_struct; + #+end_src The ~uninitialized~ integer contains one bit set to one for each - initialization function which has not bee called. It becomes equal + initialization function which has not been called. It becomes equal to zero after all initialization functions have been called. The struct is then initialized and ~provided == true~. + Some values are initialized by default, and are not concerned by + this mechanism. - When all the data relative to electrons have been set, the - following function returns ~true~. + #+begin_src c :comments org :tangle (eval h_private_func) +qmckl_exit_code qmckl_init_electron(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) +qmckl_exit_code qmckl_init_electron(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); + + ctx->electron.uninitialized = (1 << 2) - 1; + + /* Default values */ + ctx->electron.rescale_factor_kappa_ee = 1.0; + ctx->electron.rescale_factor_kappa_en = 1.0; + + return QMCKL_SUCCESS; +} + #+end_src + + #+begin_src c :comments org :tangle (eval h_func) bool qmckl_electron_provided (const qmckl_context context); #+end_src @@ -295,13 +321,13 @@ qmckl_get_electron_walk_num (const qmckl_context context, int64_t* const walk_nu *** Scaling factors Kappa #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code qmckl_get_kappa_ee (const qmckl_context context, double* const rescale_factor_kappa_ee); -qmckl_exit_code qmckl_get_kappa_en (const qmckl_context context, double* const rescale_factor_kappa_en); +qmckl_exit_code qmckl_get_electron_rescale_factor_ee (const qmckl_context context, double* const rescale_factor_kappa_ee); +qmckl_exit_code qmckl_get_electron_rescale_factor_en (const qmckl_context context, double* const rescale_factor_kappa_en); #+end_src #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none qmckl_exit_code -qmckl_get_kappa_ee (const qmckl_context context, double* const rescale_factor_kappa_ee) { +qmckl_get_electron_rescale_factor_ee (const qmckl_context context, double* const rescale_factor_kappa_ee) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return QMCKL_INVALID_CONTEXT; @@ -310,27 +336,22 @@ qmckl_get_kappa_ee (const qmckl_context context, double* const rescale_factor_ka if (rescale_factor_kappa_ee == NULL) { return qmckl_failwith( context, QMCKL_INVALID_ARG_2, - "qmckl_get_kappa_ee", + "qmckl_get_electron_rescale_factor_ee", "rescale_factor_kappa_ee is a null pointer"); } qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 2; + assert (ctx->electron.rescale_factor_kappa_ee > 0.0); - if ( (ctx->electron.uninitialized & mask) != 0) { - return QMCKL_NOT_PROVIDED; - } - - // TODO: assert (ctx->electron.rescale_factor_kappa_ee > (double) 0); - ,*rescale_factor_kappa_ee = ctx->electron.rescale_factor_kappa_ee; + *rescale_factor_kappa_ee = ctx->electron.rescale_factor_kappa_ee; return QMCKL_SUCCESS; } qmckl_exit_code -qmckl_get_kappa_en (const qmckl_context context, double* const rescale_factor_kappa_en) { +qmckl_get_electron_rescale_factor_en (const qmckl_context context, double* const rescale_factor_kappa_en) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return QMCKL_INVALID_CONTEXT; } @@ -338,21 +359,15 @@ qmckl_get_kappa_en (const qmckl_context context, double* const rescale_factor_ka if (rescale_factor_kappa_en == NULL) { return qmckl_failwith( context, QMCKL_INVALID_ARG_2, - "qmckl_get_kappa_en", + "qmckl_get_electron_rescale_factor_en", "rescale_factor_kappa_en is a null pointer"); } qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 2; - - if ( (ctx->electron.uninitialized & mask) != 0) { - return QMCKL_NOT_PROVIDED; - } - - // TODO: assert (ctx->electron.rescale_factor_kappa_en > (double) 0); - ,*rescale_factor_kappa_en = ctx->electron.rescale_factor_kappa_en; + assert (ctx->electron.rescale_factor_kappa_en > 0.0); + *rescale_factor_kappa_en = ctx->electron.rescale_factor_kappa_en; return QMCKL_SUCCESS; } #+end_src @@ -443,10 +458,12 @@ qmckl_get_electron_coord (const qmckl_context context, const char transp, double both allocated. #+begin_src c :comments org :tangle (eval h_func) -qmckl_exit_code qmckl_set_electron_num (qmckl_context context, const int64_t up_num, const int64_t down_num); -qmckl_exit_code qmckl_set_kappa (qmckl_context context, const double rescale_factor_kappa_ee, const double rescale_factor_kappa_en); -qmckl_exit_code qmckl_set_electron_walk_num (qmckl_context context, const int64_t walk_num); -qmckl_exit_code qmckl_set_electron_coord (qmckl_context context, const char transp, const double* coord); +qmckl_exit_code qmckl_set_electron_num (qmckl_context context, const int64_t up_num, const int64_t down_num); +qmckl_exit_code qmckl_set_electron_walk_num (qmckl_context context, const int64_t walk_num); +qmckl_exit_code qmckl_set_electron_coord (qmckl_context context, const char transp, const double* coord); + +qmckl_exit_code qmckl_set_electron_rescale_factor_ee (qmckl_context context, const double kappa_ee); +qmckl_exit_code qmckl_set_electron_rescale_factor_en (qmckl_context context, const double kappa_en); #+end_src #+NAME:pre2 @@ -559,32 +576,37 @@ qmckl_set_electron_walk_num(qmckl_context context, const int64_t walk_num) { #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none qmckl_exit_code -qmckl_set_kappa(qmckl_context context, - const double rescale_factor_kappa_ee, +qmckl_set_electron_rescale_factor_ee(qmckl_context context, + const double rescale_factor_kappa_ee) { + <> + + if (rescale_factor_kappa_ee <= 0.0) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_set_electron_rescale_factor_ee", + "rescale_factor_kappa_ee <= 0.0"); + } + + ctx->electron.rescale_factor_kappa_ee = rescale_factor_kappa_ee; + + return QMCKL_SUCCESS; +} + +qmckl_exit_code +qmckl_set_electron_rescale_factor_en(qmckl_context context, const double rescale_factor_kappa_en) { <> - // TODO: Check for 0 values - //if (rescale_factor_kappa_ee != 0) { - // return qmckl_failwith( context, - // QMCKL_INVALID_ARG_2, - // "qmckl_set_kappa", - // "rescale_factor_kappa_ee == 0"); - //} + if (rescale_factor_kappa_en <= 0.0) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_set_electron_rescale_factor_en", + "rescale_factor_kappa_en <= 0.0"); + } - //if (rescale_factor_kappa_en <= 0) { - // return qmckl_failwith( context, - // QMCKL_INVALID_ARG_3, - // "qmckl_set_kappa", - // "rescale_factor_kappa_en == 0"); - //} - - int32_t mask = 1 << 2; - - ctx->electron.rescale_factor_kappa_ee = rescale_factor_kappa_ee; ctx->electron.rescale_factor_kappa_en = rescale_factor_kappa_en; - <> + return QMCKL_SUCCESS; } #+end_src @@ -688,14 +710,13 @@ int64_t walk_num = chbrclf_walk_num; int64_t elec_num = chbrclf_elec_num; int64_t elec_up_num = chbrclf_elec_up_num; int64_t elec_dn_num = chbrclf_elec_dn_num; -double rescale_factor_kappa_ee = 1.0; // TODO Get rescale_factor_kappa_ee from chbrclf -double rescale_factor_kappa_en = 1.0; // TODO Get rescale_factor_kappa_en from chbrclf +double rescale_factor_kappa_ee = 2.0; +double rescale_factor_kappa_en = 3.0; double* elec_coord = &(chbrclf_elec_coord[0][0][0]); int64_t nucl_num = chbrclf_nucl_num; double* charge = chbrclf_charge; double* nucl_coord = &(chbrclf_nucl_coord[0][0]); -double nucl_rescale_factor_kappa = 1.0; // TODO Change get rescale_factor_kappa from chbrclf example /* --- */ @@ -730,23 +751,27 @@ rc = qmckl_get_electron_num (context, &n); assert(rc == QMCKL_SUCCESS); assert(n == elec_num); -double k_ee; -double k_en; -rc = qmckl_get_kappa_ee (context, &k_ee); -assert(rc == QMCKL_NOT_PROVIDED); - -rc = qmckl_get_kappa_en (context, &k_en); -assert(rc == QMCKL_NOT_PROVIDED); - -rc = qmckl_set_kappa (context, rescale_factor_kappa_ee, rescale_factor_kappa_en); +double k_ee = 0.; +double k_en = 0.; +rc = qmckl_get_electron_rescale_factor_ee (context, &k_ee); assert(rc == QMCKL_SUCCESS); -assert(!qmckl_electron_provided(context)); +assert(k_ee == 1.0); -rc = qmckl_get_kappa_ee (context, &k_ee); +rc = qmckl_get_electron_rescale_factor_en (context, &k_en); +assert(rc == QMCKL_SUCCESS); +assert(k_en == 1.0); + +rc = qmckl_set_electron_rescale_factor_en(context, rescale_factor_kappa_en); +assert(rc == QMCKL_SUCCESS); + +rc = qmckl_set_electron_rescale_factor_ee(context, rescale_factor_kappa_ee); +assert(rc == QMCKL_SUCCESS); + +rc = qmckl_get_electron_rescale_factor_ee (context, &k_ee); assert(rc == QMCKL_SUCCESS); assert(k_ee == rescale_factor_kappa_ee); -rc = qmckl_get_kappa_en (context, &k_en); +rc = qmckl_get_electron_rescale_factor_en (context, &k_en); assert(rc == QMCKL_SUCCESS); assert(k_en == rescale_factor_kappa_en); @@ -1538,7 +1563,10 @@ qmckl_exit_code qmckl_provide_en_distance(qmckl_context context) assert (ctx != NULL); if (!(ctx->nucleus.provided)) { - return QMCKL_NOT_PROVIDED; + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_provide_en_distance", + NULL); } /* Compute if necessary */ @@ -1719,9 +1747,6 @@ assert(qmckl_electron_provided(context)); rc = qmckl_set_nucleus_num (context, nucl_num); assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_nucleus_kappa (context, nucl_rescale_factor_kappa); -assert(rc == QMCKL_SUCCESS); - rc = qmckl_set_nucleus_charge (context, charge); assert (rc == QMCKL_SUCCESS); @@ -2009,9 +2034,6 @@ assert(qmckl_electron_provided(context)); rc = qmckl_set_nucleus_num (context, nucl_num); assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_nucleus_kappa (context, nucl_rescale_factor_kappa); -assert(rc == QMCKL_SUCCESS); - rc = qmckl_set_nucleus_charge (context, charge); assert (rc == QMCKL_SUCCESS); @@ -2023,6 +2045,7 @@ assert(qmckl_nucleus_provided(context)); double en_distance_rescaled[walk_num][nucl_num][elec_num]; rc = qmckl_get_electron_en_distance_rescaled(context, &(en_distance_rescaled[0][0][0])); + assert (rc == QMCKL_SUCCESS); // (e,n,w) in Fortran notation @@ -2290,27 +2313,28 @@ assert(qmckl_nucleus_provided(context)); double en_distance_rescaled_deriv_e[walk_num][4][nucl_num][elec_num]; rc = qmckl_get_electron_en_distance_rescaled_deriv_e(context, &(en_distance_rescaled_deriv_e[0][0][0][0])); + assert (rc == QMCKL_SUCCESS); // TODO: check exact values //// (e,n,w) in Fortran notation //// (1,1,1) -//assert(fabs(en_distance[0][0][0] - 7.546738741619978) < 1.e-12); +//assert(fabs(en_distance_rescaled[0][0][0] - 7.546738741619978) < 1.e-12); // //// (1,2,1) -//assert(fabs(en_distance[0][1][0] - 8.77102435246984) < 1.e-12); +//assert(fabs(en_distance_rescaled[0][1][0] - 8.77102435246984) < 1.e-12); // //// (2,1,1) -//assert(fabs(en_distance[0][0][1] - 3.698922010513608) < 1.e-12); +//assert(fabs(en_distance_rescaled[0][0][1] - 3.698922010513608) < 1.e-12); // //// (1,1,2) -//assert(fabs(en_distance[1][0][0] - 5.824059436060509) < 1.e-12); +//assert(fabs(en_distance_rescaled[1][0][0] - 5.824059436060509) < 1.e-12); // //// (1,2,2) -//assert(fabs(en_distance[1][1][0] - 7.080482110317645) < 1.e-12); +//assert(fabs(en_distance_rescaled[1][1][0] - 7.080482110317645) < 1.e-12); // //// (2,1,2) -//assert(fabs(en_distance[1][0][1] - 3.1804527583077356) < 1.e-12); +//assert(fabs(en_distance_rescaled[1][0][1] - 3.1804527583077356) < 1.e-12); #+end_src diff --git a/org/qmckl_error.org b/org/qmckl_error.org index 0d50308..0849de2 100644 --- a/org/qmckl_error.org +++ b/org/qmckl_error.org @@ -104,7 +104,8 @@ typedef int32_t qmckl_exit_code; | ~QMCKL_ALLOCATION_FAILED~ | 104 | 'Allocation failed' | | ~QMCKL_DEALLOCATION_FAILED~ | 105 | 'De-allocation failed' | | ~QMCKL_NOT_PROVIDED~ | 106 | 'Not provided' | - | ~QMCKL_INVALID_EXIT_CODE~ | 107 | 'Invalid exit code' | + | ~QMCKL_OUT_OF_BOUNDS~ | 107 | 'Index out of bounds' | + | ~QMCKL_INVALID_EXIT_CODE~ | 108 | 'Invalid exit code' | # We need to force Emacs not to indent the Python code: # -*- org-src-preserve-indentation: t @@ -162,7 +163,8 @@ return '\n'.join(result) #define QMCKL_ALLOCATION_FAILED ((qmckl_exit_code) 104) #define QMCKL_DEALLOCATION_FAILED ((qmckl_exit_code) 105) #define QMCKL_NOT_PROVIDED ((qmckl_exit_code) 106) - #define QMCKL_INVALID_EXIT_CODE ((qmckl_exit_code) 107) + #define QMCKL_OUT_OF_BOUNDS ((qmckl_exit_code) 107) + #define QMCKL_INVALID_EXIT_CODE ((qmckl_exit_code) 108) #+end_src #+begin_src f90 :comments org :tangle (eval fh_type) :exports none @@ -193,7 +195,8 @@ return '\n'.join(result) integer(qmckl_exit_code), parameter :: QMCKL_ALLOCATION_FAILED = 104 integer(qmckl_exit_code), parameter :: QMCKL_DEALLOCATION_FAILED = 105 integer(qmckl_exit_code), parameter :: QMCKL_NOT_PROVIDED = 106 - integer(qmckl_exit_code), parameter :: QMCKL_INVALID_EXIT_CODE = 107 + integer(qmckl_exit_code), parameter :: QMCKL_OUT_OF_BOUNDS = 107 + integer(qmckl_exit_code), parameter :: QMCKL_INVALID_EXIT_CODE = 108 #+end_src :end: diff --git a/org/qmckl_nucleus.org b/org/qmckl_nucleus.org index 8bd2893..99237af 100644 --- a/org/qmckl_nucleus.org +++ b/org/qmckl_nucleus.org @@ -92,20 +92,49 @@ typedef struct qmckl_nucleus_struct { int32_t uninitialized; bool provided; } qmckl_nucleus_struct; + #+end_src The ~uninitialized~ integer contains one bit set to one for each initialization function which has not been called. It becomes equal to zero after all initialization functions have been called. The struct is then initialized and ~provided == true~. + Some values are initialized by default, and are not concerned by + this mechanism. + #+begin_src c :comments org :tangle (eval h_private_func) +qmckl_exit_code qmckl_init_nucleus(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) +qmckl_exit_code qmckl_init_nucleus(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); + + ctx->nucleus.uninitialized = (1 << 3) - 1; + + /* Default values */ + ctx->nucleus.rescale_factor_kappa = 1.0; + + return QMCKL_SUCCESS; +} + #+end_src + + + ** Access functions #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code qmckl_get_nucleus_num (const qmckl_context context, int64_t* const num); -qmckl_exit_code qmckl_get_nucleus_charge (const qmckl_context context, double* const charge); -qmckl_exit_code qmckl_get_nucleus_kappa (const qmckl_context context, double* const rescale_factor_kappa); -qmckl_exit_code qmckl_get_nucleus_coord (const qmckl_context context, const char transp, double* const coord); +qmckl_exit_code qmckl_get_nucleus_num (const qmckl_context context, int64_t* const num); +qmckl_exit_code qmckl_get_nucleus_charge (const qmckl_context context, double* const charge); +qmckl_exit_code qmckl_get_nucleus_coord (const qmckl_context context, const char transp, double* const coord); + +qmckl_exit_code qmckl_get_nucleus_rescale_factor (const qmckl_context context, double* const rescale_factor_kappa); #+end_src #+NAME:post @@ -136,7 +165,7 @@ qmckl_get_nucleus_num (const qmckl_context context, int64_t* const num) { int32_t mask = 1 << 0; if ( (ctx->nucleus.uninitialized & mask) != 0) { - *num = (int64_t) 0; + ,*num = (int64_t) 0; return qmckl_failwith( context, QMCKL_NOT_PROVIDED, "qmckl_get_nucleus_num", @@ -187,23 +216,25 @@ qmckl_get_nucleus_charge (const qmckl_context context, double* const charge) { qmckl_exit_code -qmckl_get_nucleus_kappa (const qmckl_context context, double* const rescale_factor_kappa) { +qmckl_get_nucleus_rescale_factor (const qmckl_context context, + double* const rescale_factor_kappa) +{ if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return QMCKL_INVALID_CONTEXT; } + if (rescale_factor_kappa == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_nucleus_rescale_factor", + "rescale_factor_kappa is a null pointer"); + } + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 2; - - if ( (ctx->nucleus.uninitialized & mask) != 0) { - return qmckl_failwith( context, - QMCKL_NOT_PROVIDED, - "qmckl_get_nucleus_kappa", - "nucleus data is not provided"); - } + assert (ctx->nucleus.rescale_factor_kappa > 0.0); (*rescale_factor_kappa) = ctx->nucleus.rescale_factor_kappa; @@ -235,7 +266,7 @@ qmckl_get_nucleus_coord (const qmckl_context context, const char transp, double* qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 3; + int32_t mask = 1 << 2; if ( (ctx->nucleus.uninitialized & mask) != 0) { return qmckl_failwith( context, @@ -295,8 +326,9 @@ bool qmckl_nucleus_provided(const qmckl_context context) { #+begin_src c :comments org :tangle (eval h_func) qmckl_exit_code qmckl_set_nucleus_num (qmckl_context context, const int64_t num); qmckl_exit_code qmckl_set_nucleus_charge (qmckl_context context, const double* charge); -qmckl_exit_code qmckl_set_nucleus_kappa (qmckl_context context, const double rescale_factor_kappa); qmckl_exit_code qmckl_set_nucleus_coord (qmckl_context context, const char transp, const double* coord); + +qmckl_exit_code qmckl_set_nucleus_rescale_factor (qmckl_context context, const double rescale_factor_kappa); #+end_src #+NAME:pre2 @@ -331,7 +363,7 @@ qmckl_set_nucleus_num(qmckl_context context, const int64_t num) { "num <= 0"); } - int32_t mask = 1; + int32_t mask = 1 << 0; ctx->nucleus.num = num; @@ -388,25 +420,19 @@ qmckl_set_nucleus_charge(qmckl_context context, const double* charge) { #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none qmckl_exit_code -qmckl_set_nucleus_kappa(qmckl_context context, const double rescale_factor_kappa) { +qmckl_set_nucleus_rescale_factor(qmckl_context context, const double rescale_factor_kappa) { <> - //TODO: Check for small values of kappa - //if (rescale_factor_kappa == 0) { - // return qmckl_failwith( context, - // QMCKL_INVALID_ARG_2, - // "qmckl_set_nucleus_kappa", - // "rescale_factor_kappa cannot be 0"); - //} - - int32_t mask = 1 << 2; - - int64_t num; - qmckl_exit_code rc; + if (rescale_factor_kappa <= 0.0) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_set_nucleus_kappa", + "rescale_factor_kappa cannot be <= 0."); + } ctx->nucleus.rescale_factor_kappa = rescale_factor_kappa; - <> + return QMCKL_SUCCESS; } #+end_src @@ -421,7 +447,7 @@ qmckl_set_nucleus_coord(qmckl_context context, const char transp, const double* int64_t nucl_num = (int64_t) 0; qmckl_exit_code rc; - int32_t mask = 1 << 3; + int32_t mask = 1 << 2; rc = qmckl_get_nucleus_num(context, &nucl_num); if (rc != QMCKL_SUCCESS) return rc; @@ -462,7 +488,7 @@ qmckl_set_nucleus_coord(qmckl_context context, const char transp, const double* const int64_t nucl_num = chbrclf_nucl_num; const double* nucl_charge = chbrclf_charge; const double* nucl_coord = &(chbrclf_nucl_coord[0][0]); -const double nucl_rescale_factor_kappa = 1.0; // TODO Change get rescale_factor_kappa from chbrclf example +const double nucl_rescale_factor_kappa = 2.0; /* --- */ @@ -484,15 +510,15 @@ assert(rc == QMCKL_SUCCESS); assert(n == nucl_num); double k; -rc = qmckl_get_nucleus_kappa (context, &k); -assert(rc == QMCKL_NOT_PROVIDED); - - -rc = qmckl_set_nucleus_kappa (context, nucl_rescale_factor_kappa); +rc = qmckl_get_nucleus_rescale_factor (context, &k); assert(rc == QMCKL_SUCCESS); -assert(!qmckl_nucleus_provided(context)); +assert(k == 1.0); -rc = qmckl_get_nucleus_kappa (context, &k); + +rc = qmckl_set_nucleus_rescale_factor (context, nucl_rescale_factor_kappa); +assert(rc == QMCKL_SUCCESS); + +rc = qmckl_get_nucleus_rescale_factor (context, &k); assert(rc == QMCKL_SUCCESS); assert(k == nucl_rescale_factor_kappa); @@ -535,7 +561,7 @@ for (size_t i=0 ; i $exported + extract_doc ${i} > $exported # Make log file older than the exported files touch -t ${NOW} $exported diff --git a/tools/build_makefile.py b/tools/build_makefile.py index 5290b3f..6f1f30f 100755 --- a/tools/build_makefile.py +++ b/tools/build_makefile.py @@ -33,8 +33,8 @@ def main(): for org in glob("org/*.org"): i = org.split('/')[-1].rsplit(".",1)[0] - tangled = "org/"+i+".tangled" - exported = "org/"+i+".exported" + tangled = "org/."+i+".tangled" + exported = "org/."+i+".exported" c_test_x = "tests/test_"+i c_test_o = "tests/test_"+i+".$(OBJEXT)" f_test_o = "tests/test_"+i+"_f.$(OBJEXT)" diff --git a/tools/install_htmlize.sh b/tools/install_htmlize.sh index 29f8208..b069777 100755 --- a/tools/install_htmlize.sh +++ b/tools/install_htmlize.sh @@ -2,7 +2,7 @@ # # Installs the htmlize Emacs plugin -./missing git clone "https://github.com/hniksic/emacs-htmlize" +./tools/missing git clone "https://github.com/hniksic/emacs-htmlize" mv emacs-htmlize/htmlize.el $1 rm -rf emacs-htmlize diff --git a/tools/tangle.sh b/tools/tangle.sh index a94189d..0f28038 100755 --- a/tools/tangle.sh +++ b/tools/tangle.sh @@ -24,7 +24,7 @@ function tangle() elif [[ ${org_file} -ot ${f_file} ]] ; then return fi - ./missing \ + ./tools/missing \ emacs --batch ${org_file} \ --load=${PWD}/tools/config_tangle.el \ -f org-babel-tangle @@ -33,8 +33,9 @@ function tangle() for i in $@ do tangled=${i%.org}.tangled + tangled=$(dirname $tangled)/.$(basename $tangled) NOW=$(date +"%m%d%H%M.%S") - tangle ${i} &> $tangled + tangle ${i} > $tangled # Make log file older than the tangled files touch -t ${NOW} $tangled diff --git a/tools/theme.setup b/tools/theme.setup index 3c46c18..156662b 100644 --- a/tools/theme.setup +++ b/tools/theme.setup @@ -6,7 +6,7 @@ #+INFOJS_OPT: toc:t mouse:underline path:org-info.js #+HTML_HEAD: -#+STARTUP: align fold nodlcheck hidestars oddeven lognotestate +#+STARTUP: align fold nodlcheck hidestars oddeven lognotestate latexpreview #+AUTHOR: TREX CoE #+LANGUAGE: en