From 4430414dc9d397e87e752060ef70333a5b46dcc3 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 22 Jun 2021 19:52:11 +0530 Subject: [PATCH 01/92] Begin inclusion of chameleon in qmckl. #20 --- configure.ac | 51 +++++++++++++++++++++++++++++++++++++++++++++ include/config.h.in | 6 ++++++ 2 files changed, 57 insertions(+) diff --git a/configure.ac b/configure.ac index 7a6c365..8174fdf 100644 --- a/configure.ac +++ b/configure.ac @@ -99,6 +99,57 @@ AC_CHECK_LIB([pthread], [pthread_create]) #fi +# CHAMELEON +AC_ARG_WITH(chameleon, + AS_HELP_STRING([--without-chameleon], + [Do not use Chameleon. Default: auto-detect]), [ +case "$with_chameleon" in + yes|no) + : # Nothing special to do here + ;; + *) + if test ! -d "$withval" ; then + AC_MSG_ERROR([--with-chameleon path does not point to a directory]) + fi + LIBCHAMELEON_PATH="-L$with_chameleon/lib" + CXXFLAGS="-I$with_chameleon/include $CXXFLAGS" + esac +]) +AH_TEMPLATE(USE_CHAMELEON,[Chameleon support is available]) + +if test "x$with_chameleon" != "xno"; then + LIBS="$LIBS $LIBCHAMELEON_PATH" + + if test "x$with_chameleon" = "xyes" -a "x$LIBCHAMELEON_LIBS" = "x"; then + AC_MSG_ERROR([Required Chameleon library not found]) + fi + if test "x$LIBCHAMELEON_LIBS" != "x" ; then + CXXFLAGS="$LIBCHAMELEON_CFLAGS $CXXFLAGS" + CFLAGS="$LIBCHAMELEON_CFLAGS $CFLAGS" + CPPFLAGS="$LIBCHAMELEON_CFLAGS $CPPFLAGS" + CHAMELEONLIB="$LIBCHAMELEON_PATH $LIBCHAMELEON_LIBS" + AC_DEFINE(USE_CHAMELEON,1,[CHAMELEON support is available]) + with_CHAMELEON=yes + else + with_CHAMELEON=no + fi +fi +AC_MSG_NOTICE([CHAMELEON library support: ${with_CHAMELEON:=auto} ${LIBCHAMELEON_PATH} ${LIBCHAMELEON_LIBS}]) +AC_SUBST(CHAMELEONLIB) + # auto-detect using pkg-config + PKG_CHECK_MODULES([LIBCHAMELEON],[chameleon >= 1.0.0],,[ + + ## something went wrong. + ## try to find the package without pkg-config + + ## check that the library is actually new enough. + ## by testing for a 1.0.0+ function which we use + AC_CHECK_LIB(chameleon,CHAMELEON_finalize,[LIBCHAMELEON_LIBS="-lchameleon"]) + ]) + if test "x$LIBCHAMELEON_LIBS" != "x" ; then + AC_CHECK_HEADERS(chameleon.h) + fi + ## BLAS #AX_BLAS([], [AC_MSG_ERROR([BLAS was not found.])]) diff --git a/include/config.h.in b/include/config.h.in index 6d33cba..ca089de 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -12,6 +12,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ASSERT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_CHAMELEON_H + /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H @@ -124,6 +127,9 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* CHAMELEON support is available */ +#undef USE_CHAMELEON + /* Version number of package */ #undef VERSION From 2a0469eb0101b2e2967384afb5960dda5b3fe70a Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 22 Jun 2021 19:54:55 +0530 Subject: [PATCH 02/92] Update README.md to reflect installation with chameleon. #20 --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 1fa2d3c..2334bf6 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,16 @@ make make check ``` +### Building with Chameleon Library + +``` +./autogen.sh +LIBCHAMELEON_LIBS="-L/home/vijay/.local/lib -lchameleon -lchameleon_starpu -lhqr -lcoreblas" LIBCHAMELEON_CFLAGS="-I/home/vijay/.local/include -I/opt/starpu-1.3.7/build/include/starpu/1.3" QMCKL_DEVEL=1 ./configure --prefix=/home/vijay/.local --enable-silent-rules --enable-maintainer-mode --with-chameleon=yes + +make +make check +``` + ## For users Obtain a source distribution and run From 5b68b96b73ad77c44391bb16aac4154d329bc2dd Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 22 Jun 2021 19:59:05 +0530 Subject: [PATCH 03/92] Modify readme. #20 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2334bf6..c2e5268 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ make check ``` ./autogen.sh -LIBCHAMELEON_LIBS="-L/home/vijay/.local/lib -lchameleon -lchameleon_starpu -lhqr -lcoreblas" LIBCHAMELEON_CFLAGS="-I/home/vijay/.local/include -I/opt/starpu-1.3.7/build/include/starpu/1.3" QMCKL_DEVEL=1 ./configure --prefix=/home/vijay/.local --enable-silent-rules --enable-maintainer-mode --with-chameleon=yes +LIBCHAMELEON_LIBS="$(shell pkg-config --libs chameleon)" LIBCHAMELEON_CFLAGS="$(shell pkg-config --cflags chameleon)" QMCKL_DEVEL=1 ./configure --prefix=$PWD/_install --enable-silent-rules --enable-maintainer-mode --with-chameleon=yes make make check From 20a73f27c74b20abc8cd8347eb29888a3ec1abe2 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 22 Jun 2021 20:27:30 +0530 Subject: [PATCH 04/92] Modify readme 2. #20 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2e5268..fbb6032 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ make check ``` ./autogen.sh -LIBCHAMELEON_LIBS="$(shell pkg-config --libs chameleon)" LIBCHAMELEON_CFLAGS="$(shell pkg-config --cflags chameleon)" QMCKL_DEVEL=1 ./configure --prefix=$PWD/_install --enable-silent-rules --enable-maintainer-mode --with-chameleon=yes +LIBCHAMELEON_LIBS="$(pkg-config --libs chameleon)" LIBCHAMELEON_CFLAGS="$(pkg-config --cflags chameleon)" QMCKL_DEVEL=1 ./configure --prefix=$PWD/_install --enable-silent-rules --enable-maintainer-mode --with-chameleon=yes make make check From 79077f3a06061e6656753c1d4402dbb2b48174b5 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 22 Jun 2021 20:31:37 +0530 Subject: [PATCH 05/92] Fixed indent in configure.ac. #20 --- configure.ac | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 8174fdf..bbca950 100644 --- a/configure.ac +++ b/configure.ac @@ -124,8 +124,8 @@ if test "x$with_chameleon" != "xno"; then AC_MSG_ERROR([Required Chameleon library not found]) fi if test "x$LIBCHAMELEON_LIBS" != "x" ; then - CXXFLAGS="$LIBCHAMELEON_CFLAGS $CXXFLAGS" CFLAGS="$LIBCHAMELEON_CFLAGS $CFLAGS" + CXXFLAGS="$LIBCHAMELEON_CFLAGS $CXXFLAGS" CPPFLAGS="$LIBCHAMELEON_CFLAGS $CPPFLAGS" CHAMELEONLIB="$LIBCHAMELEON_PATH $LIBCHAMELEON_LIBS" AC_DEFINE(USE_CHAMELEON,1,[CHAMELEON support is available]) @@ -136,19 +136,19 @@ if test "x$with_chameleon" != "xno"; then fi AC_MSG_NOTICE([CHAMELEON library support: ${with_CHAMELEON:=auto} ${LIBCHAMELEON_PATH} ${LIBCHAMELEON_LIBS}]) AC_SUBST(CHAMELEONLIB) - # auto-detect using pkg-config - PKG_CHECK_MODULES([LIBCHAMELEON],[chameleon >= 1.0.0],,[ +# auto-detect using pkg-config +PKG_CHECK_MODULES([LIBCHAMELEON],[chameleon >= 1.0.0],,[ - ## something went wrong. - ## try to find the package without pkg-config + ## something went wrong. + ## try to find the package without pkg-config - ## check that the library is actually new enough. - ## by testing for a 1.0.0+ function which we use - AC_CHECK_LIB(chameleon,CHAMELEON_finalize,[LIBCHAMELEON_LIBS="-lchameleon"]) - ]) - if test "x$LIBCHAMELEON_LIBS" != "x" ; then - AC_CHECK_HEADERS(chameleon.h) - fi + ## check that the library is actually new enough. + ## by testing for a 1.0.0+ function which we use + AC_CHECK_LIB(chameleon,CHAMELEON_finalize,[LIBCHAMELEON_LIBS="-lchameleon"]) +]) +if test "x$LIBCHAMELEON_LIBS" != "x" ; then + AC_CHECK_HEADERS(chameleon.h) +fi ## BLAS #AX_BLAS([], [AC_MSG_ERROR([BLAS was not found.])]) From 856adafb16cc1884fa74596a44fa8706209f47b3 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 22 Jun 2021 20:38:29 +0530 Subject: [PATCH 06/92] Added chameleon usage indication in configure output. #20 --- configure.ac | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index bbca950..912cc30 100644 --- a/configure.ac +++ b/configure.ac @@ -277,13 +277,14 @@ ${PACKAGE_NAME} Version ${PACKAGE_VERSION} ${QMCKL_DEVEL} Prefix: '${prefix}'. -CC..........: ${CC} -CPPFLAGS....: ${CPPFLAGS} -CFLAGS......: ${CFLAGS} -FC..........: ${FC} -FCLAGS......: ${FCFLAGS} -LDFLAGS:....: ${LDFLAGS} -LIBS........: ${LIBS} +CC..............: ${CC} +CPPFLAGS........: ${CPPFLAGS} +CFLAGS..........: ${CFLAGS} +FC..............: ${FC} +FCLAGS..........: ${FCFLAGS} +LDFLAGS:........: ${LDFLAGS} +LIBS............: ${LIBS} +USE CHAMELEON...: ${with_chameleon} Package features: ${ARGS} From 440ac2b7523124a8d2e8104ad1468227911d28df Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 22 Jun 2021 20:44:51 +0530 Subject: [PATCH 07/92] Added CFLAGS and CPPFLAGS for Chameleon. #20 --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 912cc30..74c6f78 100644 --- a/configure.ac +++ b/configure.ac @@ -112,7 +112,9 @@ case "$with_chameleon" in AC_MSG_ERROR([--with-chameleon path does not point to a directory]) fi LIBCHAMELEON_PATH="-L$with_chameleon/lib" + CFLAGS="$LIBCHAMELEON_CFLAGS $CFLAGS" CXXFLAGS="-I$with_chameleon/include $CXXFLAGS" + CPPFLAGS="$LIBCHAMELEON_CFLAGS $CPPFLAGS" esac ]) AH_TEMPLATE(USE_CHAMELEON,[Chameleon support is available]) From 4d7e334da76d53fd0a25266418d33990f541eb1e Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 22 Jun 2021 21:03:39 +0530 Subject: [PATCH 08/92] Fixed format in context definition for electrons. #20 --- org/qmckl_electron.org | 48 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/org/qmckl_electron.org b/org/qmckl_electron.org index b41ac14..80071de 100644 --- a/org/qmckl_electron.org +++ b/org/qmckl_electron.org @@ -63,29 +63,29 @@ int main() { The following data stored in the context: - | ~uninitialized~ | int32_t | Keeps bit set for uninitialized data | - | ~num~ | int64_t | Total number of electrons | - | ~up_num~ | int64_t | Number of up-spin electrons | - | ~down_num~ | int64_t | Number of down-spin electrons | - | ~walk_num~ | int64_t | Number of walkers | - | ~rescale_factor_kappa_ee~ | double | The distance scaling factor | - | ~rescale_factor_kappa_en~ | double | The distance scaling factor | - | ~provided~ | bool | If true, ~electron~ is valid | - | ~coord_new~ | double[walk_num][3][num] | New set of electron coordinates | - | ~coord_old~ | double[walk_num][3][num] | Old set of electron coordinates | - | ~coord_new_date~ | uint64_t | Last modification date of the coordinates | - | ~ee_distance~ | double[walk_num][num][num] | Electron-electron distances | - | ~ee_distance_date~ | uint64_t | Last modification date of the electron-electron distances | - | ~en_distance~ | double[walk_num][nucl_num][num] | Electron-nucleus distances | - | ~en_distance_date~ | uint64_t | Last modification date of the electron-electron distances | - | ~ee_distance_rescaled~ | double[walk_num][num][num] | Electron-electron rescaled distances | - | ~ee_distance_rescaled_date~ | uint64_t | Last modification date of the electron-electron distances | - | ~ee_distance_rescaled_deriv_e~ | double[walk_num][4][num][num] | Electron-electron rescaled distances derivatives | - | ~ee_distance_rescaled_deriv_e_date~ | uint64_t | Last modification date of the electron-electron distance derivatives | - | ~en_distance_rescaled~ | double[walk_num][nucl_num][num] | Electron-nucleus distances | - | ~en_distance_rescaled_date~ | uint64_t | Last modification date of the electron-electron distances | - | ~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 | + | ~uninitialized~ | ~int32_t~ | Keeps bit set for uninitialized data | + | ~num~ | ~int64_t~ | Total number of electrons | + | ~up_num~ | ~int64_t~ | Number of up-spin electrons | + | ~down_num~ | ~int64_t~ | Number of down-spin electrons | + | ~walk_num~ | ~int64_t~ | Number of walkers | + | ~rescale_factor_kappa_ee~ | ~double~ | The distance scaling factor | + | ~rescale_factor_kappa_en~ | ~double~ | The distance scaling factor | + | ~provided~ | ~bool~ | If true, ~electron~ is valid | + | ~coord_new~ | ~double[walk_num][3][num]~ | New set of electron coordinates | + | ~coord_old~ | ~double[walk_num][3][num]~ | Old set of electron coordinates | + | ~coord_new_date~ | ~uint64_t~ | Last modification date of the coordinates | + | ~ee_distance~ | ~double[walk_num][num][num]~ | Electron-electron distances | + | ~ee_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~en_distance~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | + | ~en_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~ee_distance_rescaled~ | ~double[walk_num][num][num]~ | Electron-electron rescaled distances | + | ~ee_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~ee_distance_rescaled_deriv_e~ | ~double[walk_num][4][num][num]~ | Electron-electron rescaled distances derivatives | + | ~ee_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | + | ~en_distance_rescaled~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | + | ~en_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~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 @@ -2056,7 +2056,7 @@ assert(fabs(en_distance_rescaled[1][0][1] - 0.9584331688679852) < 1.e-12); gives the Laplacian $\partial x^2 + \partial y^2 + \partial z^2$. *** Get - + #+begin_src c :comments org :tangle (eval h_func) :noweb yes qmckl_exit_code qmckl_get_electron_en_distance_rescaled_deriv_e(qmckl_context context, double* distance_rescaled_deriv_e); #+end_src From fe0d51b968508aa5ae2a96357113619651a0fefa Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 23 Jun 2021 12:18:43 +0530 Subject: [PATCH 09/92] Started working on Jastrow. #20 --- org/qmckl_jastrow.org | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 org/qmckl_jastrow.org diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org new file mode 100644 index 0000000..116004e --- /dev/null +++ b/org/qmckl_jastrow.org @@ -0,0 +1,9 @@ +#+TITLE: Jastrow Factor +#+SETUPFILE: ../tools/theme.setup +#+INCLUDE: ../tools/lib.org + +Functions for the calculation of the Jastrow factor \(f_{ee}, f_{en}, f_{een}\). + + + + From b63f28ee72cfaee4334f55279efc6aeada6a487b Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 23 Jun 2021 14:25:59 +0530 Subject: [PATCH 10/92] Working on context. --- org/qmckl_jastrow.org | 147 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 146 insertions(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 116004e..4852544 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -3,7 +3,152 @@ #+INCLUDE: ../tools/lib.org Functions for the calculation of the Jastrow factor \(f_{ee}, f_{en}, f_{een}\). - +These are stored in the ~factor_ee~, ~factor_en~, and ~factor_een~ variables. +The ~jastrow~ structure contains all the information required to build +these factors along with their derivatives. + +* Headers :noexport: + #+begin_src elisp :noexport :results none +(org-babel-lob-ingest "../tools/lib.org") +#+end_src + + + #+begin_src c :tangle (eval h_private_type) +#ifndef QMCKL_JASTROW_HPT +#define QMCKL_JASTROW_HPT +#include + #+end_src + + #+begin_src c :tangle (eval c_test) :noweb yes +#include "qmckl.h" +#include +#include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "chbrclf.h" + +int main() { + qmckl_context context; + context = qmckl_context_create(); + #+end_src + + #+begin_src c :tangle (eval c) +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_STDINT_H +#include +#elif HAVE_INTTYPES_H +#include +#endif + +#include +#include +#include +#include +#include + +#include + +#include "qmckl.h" +#include "qmckl_context_private_type.h" +#include "qmckl_memory_private_type.h" +#include "qmckl_memory_private_func.h" +#include "qmckl_jastrow_private_func.h" + #+end_src + + +* Context + :PROPERTIES: + :Name: qmckl_jastrow + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + The following data stored in the context: + + #+NAME: qmckl_jastrow_args + | ~uninitialized~ | ~int32_t~ | in | Keeps bit set for uninitialized data | + | ~aord_num~ | ~int64_t~ | in | The number of a coeffecients | + | ~bord_num~ | ~int64_t~ | in | The number of b coeffecients | + | ~cord_num~ | ~int64_t~ | in | The number of c coeffecients | + | ~type_nuc_num~ | ~uint64_t~ | in | Number of Nucleii types | + | ~dim_cord_vec~ | ~uint64_t~ | in | Number of unique C coefficients | + | ~aord_vector~ | ~double[aord_num + 1][type_nuc_num]~ | in | Order of a polynomial coefficients | + | ~bord_vector~ | ~double[bord_num + 1]~ | in | Order of b polynomial coefficients | + | ~cord_vector~ | ~double[cord_num][type_nuc_num]~ | in | Order of c polynomial coefficients | + +** Data structure + + #+CALL: generate_c_header(table=qmckl_jastrow_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_jastrow ( + const uninitialized int32_t, + const aord_num int64_t, + const bord_num int64_t, + const cord_num int64_t, + const type_nuc_num uint64_t, + const dim_cord_vec uint64_t, + const aord_vector* double, + const bord_vector* double, + const cord_vector* double ); + #+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_jastrow(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) +qmckl_exit_code qmckl_init_jastrow(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->jastrow.uninitialized = (1 << 2) - 1; + + /* Default values */ + ctx->jastrow.rescale_factor_kappa_ee = 1.0; + ctx->jastrow.rescale_factor_kappa_en = 1.0; + + return QMCKL_SUCCESS; +} + #+end_src + + + #+begin_src c :comments org :tangle (eval h_func) +bool qmckl_jastrow_provided (const qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +bool qmckl_jastrow_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->jastrow.provided; +} + #+end_src From 25b30382dc2c7d77a91e4dd71718541c37fa61f1 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 23 Jun 2021 15:08:38 +0530 Subject: [PATCH 11/92] Modified library function. #20 --- org/qmckl_jastrow.org | 2 +- tools/lib.org | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 4852544..4f22db2 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -88,7 +88,7 @@ int main() { #+RESULTS: #+begin_src c :tangle (eval h_func) :comments org qmckl_exit_code qmckl_jastrow ( - const uninitialized int32_t, + const uninitialized int32_t, const aord_num int64_t, const bord_num int64_t, const cord_num int64_t, diff --git a/tools/lib.org b/tools/lib.org index 3536c32..ec9a2c5 100644 --- a/tools/lib.org +++ b/tools/lib.org @@ -124,8 +124,7 @@ for d in parse_table(table): results += [ f" {const}{c_type} {name}" ] results=',\n'.join(results) -template = f"""{rettyp} {fname} ( -{results} ); """ +template = f"""{rettyp} {fname} (\n{results} ); """ return template #+END_SRC From 5461d75161d4a20fe2e795727782d54a278ef8f7 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 23 Jun 2021 17:27:01 +0530 Subject: [PATCH 12/92] Added jastrow context. #22 --- org/qmckl_jastrow.org | 57 +++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 4f22db2..1b34cfa 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -71,15 +71,30 @@ int main() { The following data stored in the context: #+NAME: qmckl_jastrow_args - | ~uninitialized~ | ~int32_t~ | in | Keeps bit set for uninitialized data | - | ~aord_num~ | ~int64_t~ | in | The number of a coeffecients | - | ~bord_num~ | ~int64_t~ | in | The number of b coeffecients | - | ~cord_num~ | ~int64_t~ | in | The number of c coeffecients | - | ~type_nuc_num~ | ~uint64_t~ | in | Number of Nucleii types | - | ~dim_cord_vec~ | ~uint64_t~ | in | Number of unique C coefficients | - | ~aord_vector~ | ~double[aord_num + 1][type_nuc_num]~ | in | Order of a polynomial coefficients | - | ~bord_vector~ | ~double[bord_num + 1]~ | in | Order of b polynomial coefficients | - | ~cord_vector~ | ~double[cord_num][type_nuc_num]~ | in | Order of c polynomial coefficients | + |------------+-------------------------------------------+-----+-------------------------------------------------------------------| + | ~int32_t~ | ~uninitialized~ | in | Keeps bit set for uninitialized data | + | ~int64_t~ | ~aord_num~ | in | The number of a coeffecients | + | ~int64_t~ | ~bord_num~ | in | The number of b coeffecients | + | ~int64_t~ | ~cord_num~ | in | The number of c coeffecients | + | ~uint64_t~ | ~type_nuc_num~ | in | Number of Nucleii types | + | ~uint64_t~ | ~dim_cord_vec~ | in | Number of unique C coefficients | + | ~double~ | ~aord_vector[aord_num + 1][type_nuc_num]~ | in | Order of a polynomial coefficients | + | ~double~ | ~bord_vector[bord_num + 1]~ | in | Order of b polynomial coefficients | + | ~double~ | ~cord_vector[cord_num][type_nuc_num]~ | in | Order of c polynomial coefficients | + | ~double~ | ~factor_ee~ | out | Jastrow factor: electron-electron part | + | ~double~ | ~factor_en~ | out | Jastrow factor: electron-nucleus part | + | ~double~ | ~factor_een~ | out | Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_ee_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_en_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_een_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + + computed data: + + |-------------------+--------------------------------------------+---------------------------------| + | ~coord_vect_full~ | ~[dim_cord_vec]~ | vector of non-zero coefficients | + | ~tmp_c~ | ~[elec_num][nuc_num][ncord + 1][ncord]~ | vector of non-zero coefficients | + | ~dtmp_c~ | ~[elec_num][4][nuc_num][ncord + 1][ncord]~ | vector of non-zero coefficients | + ** Data structure @@ -88,15 +103,21 @@ int main() { #+RESULTS: #+begin_src c :tangle (eval h_func) :comments org qmckl_exit_code qmckl_jastrow ( - const uninitialized int32_t, - const aord_num int64_t, - const bord_num int64_t, - const cord_num int64_t, - const type_nuc_num uint64_t, - const dim_cord_vec uint64_t, - const aord_vector* double, - const bord_vector* double, - const cord_vector* double ); + const int32_t uninitialized, + const int64_t aord_num, + const int64_t bord_num, + const int64_t cord_num, + const uint64_t type_nuc_num, + const uint64_t dim_cord_vec, + const double* aord_vector, + const double* bord_vector, + const double* cord_vector, + double* const factor_ee, + double* const factor_en, + double* const factor_een, + double* const factor_ee_deriv_e, + double* const factor_en_deriv_e, + double* const factor_een_deriv_e ); #+end_src From 062a1b8b5507c45f45049959770ed3b5aa66f1c6 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 23 Jun 2021 17:29:39 +0530 Subject: [PATCH 13/92] Removed advanced chameleon configure options in this user friendly build. #22 --- README.md | 10 ---------- configure.ac | 54 ---------------------------------------------------- 2 files changed, 64 deletions(-) diff --git a/README.md b/README.md index 0b95b4b..97606c1 100644 --- a/README.md +++ b/README.md @@ -34,16 +34,6 @@ make make check ``` -### Building with Chameleon Library - -``` -./autogen.sh -LIBCHAMELEON_LIBS="$(pkg-config --libs chameleon)" LIBCHAMELEON_CFLAGS="$(pkg-config --cflags chameleon)" QMCKL_DEVEL=1 ./configure --prefix=$PWD/_install --enable-silent-rules --enable-maintainer-mode --with-chameleon=yes - -make -make check -``` - ## For users Obtain a source distribution and run diff --git a/configure.ac b/configure.ac index 0e44e39..7d2e6a2 100644 --- a/configure.ac +++ b/configure.ac @@ -98,60 +98,6 @@ AC_CHECK_LIB([pthread], [pthread_create]) # CFLAGS="${CFLAGS} ${OPENMP_CFLAGS}" #fi - -# CHAMELEON -AC_ARG_WITH(chameleon, - AS_HELP_STRING([--without-chameleon], - [Do not use Chameleon. Default: auto-detect]), [ -case "$with_chameleon" in - yes|no) - : # Nothing special to do here - ;; - *) - if test ! -d "$withval" ; then - AC_MSG_ERROR([--with-chameleon path does not point to a directory]) - fi - LIBCHAMELEON_PATH="-L$with_chameleon/lib" - CFLAGS="$LIBCHAMELEON_CFLAGS $CFLAGS" - CXXFLAGS="-I$with_chameleon/include $CXXFLAGS" - CPPFLAGS="$LIBCHAMELEON_CFLAGS $CPPFLAGS" - esac -]) -AH_TEMPLATE(USE_CHAMELEON,[Chameleon support is available]) - -if test "x$with_chameleon" != "xno"; then - LIBS="$LIBS $LIBCHAMELEON_PATH" - - if test "x$with_chameleon" = "xyes" -a "x$LIBCHAMELEON_LIBS" = "x"; then - AC_MSG_ERROR([Required Chameleon library not found]) - fi - if test "x$LIBCHAMELEON_LIBS" != "x" ; then - CFLAGS="$LIBCHAMELEON_CFLAGS $CFLAGS" - CXXFLAGS="$LIBCHAMELEON_CFLAGS $CXXFLAGS" - CPPFLAGS="$LIBCHAMELEON_CFLAGS $CPPFLAGS" - CHAMELEONLIB="$LIBCHAMELEON_PATH $LIBCHAMELEON_LIBS" - AC_DEFINE(USE_CHAMELEON,1,[CHAMELEON support is available]) - with_CHAMELEON=yes - else - with_CHAMELEON=no - fi -fi -AC_MSG_NOTICE([CHAMELEON library support: ${with_CHAMELEON:=auto} ${LIBCHAMELEON_PATH} ${LIBCHAMELEON_LIBS}]) -AC_SUBST(CHAMELEONLIB) -# auto-detect using pkg-config -PKG_CHECK_MODULES([LIBCHAMELEON],[chameleon >= 1.0.0],,[ - - ## something went wrong. - ## try to find the package without pkg-config - - ## check that the library is actually new enough. - ## by testing for a 1.0.0+ function which we use - AC_CHECK_LIB(chameleon,CHAMELEON_finalize,[LIBCHAMELEON_LIBS="-lchameleon"]) -]) -if test "x$LIBCHAMELEON_LIBS" != "x" ; then - AC_CHECK_HEADERS(chameleon.h) -fi - ## BLAS #AX_BLAS([], [AC_MSG_ERROR([BLAS was not found.])]) From 8d9c02c05cde3d5215052e0f9d9eb23f09165083 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 23 Jun 2021 17:34:37 +0530 Subject: [PATCH 14/92] Removed chameleon from header. #22 --- configure.ac | 1 - include/config.h.in | 6 ------ 2 files changed, 7 deletions(-) diff --git a/configure.ac b/configure.ac index 7d2e6a2..a2a2438 100644 --- a/configure.ac +++ b/configure.ac @@ -227,7 +227,6 @@ FC..............: ${FC} FCLAGS..........: ${FCFLAGS} LDFLAGS:........: ${LDFLAGS} LIBS............: ${LIBS} -USE CHAMELEON...: ${with_chameleon} Package features: ${ARGS} diff --git a/include/config.h.in b/include/config.h.in index ca089de..6d33cba 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -12,9 +12,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ASSERT_H -/* Define to 1 if you have the header file. */ -#undef HAVE_CHAMELEON_H - /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H @@ -127,9 +124,6 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS -/* CHAMELEON support is available */ -#undef USE_CHAMELEON - /* Version number of package */ #undef VERSION From 7593bf7436b8348310b3f5fd2510087fc96fc4a5 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 23 Jun 2021 17:56:01 +0530 Subject: [PATCH 15/92] Added jastrow header to context. #22 --- org/qmckl_context.org | 2 ++ org/qmckl_jastrow.org | 66 ++++++++++++++++++++++++++++--------------- 2 files changed, 46 insertions(+), 22 deletions(-) diff --git a/org/qmckl_context.org b/org/qmckl_context.org index 11eb235..d2ca467 100644 --- a/org/qmckl_context.org +++ b/org/qmckl_context.org @@ -31,6 +31,7 @@ int main() { #include "qmckl_nucleus_private_type.h" #include "qmckl_electron_private_type.h" #include "qmckl_ao_private_type.h" +#include "qmckl_jastrow_private_type.h" #include "qmckl_nucleus_private_func.h" #include "qmckl_electron_private_func.h" #include "qmckl_ao_private_func.h" @@ -118,6 +119,7 @@ typedef struct qmckl_context_struct { qmckl_nucleus_struct nucleus; qmckl_electron_struct electron; qmckl_ao_basis_struct ao_basis; + qmckl_jastrow_struct jastrow; /* To be implemented: qmckl_mo_struct mo; diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 1b34cfa..c034f1d 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -58,6 +58,7 @@ int main() { #include "qmckl_memory_private_type.h" #include "qmckl_memory_private_func.h" #include "qmckl_jastrow_private_func.h" +#include "qmckl_jastrow_private_type.h" #+end_src @@ -98,26 +99,26 @@ int main() { ** Data structure - #+CALL: generate_c_header(table=qmckl_jastrow_args,rettyp=get_value("CRetType"),fname=get_value("Name")) - - #+RESULTS: - #+begin_src c :tangle (eval h_func) :comments org - qmckl_exit_code qmckl_jastrow ( - const int32_t uninitialized, - const int64_t aord_num, - const int64_t bord_num, - const int64_t cord_num, - const uint64_t type_nuc_num, - const uint64_t dim_cord_vec, - const double* aord_vector, - const double* bord_vector, - const double* cord_vector, - double* const factor_ee, - double* const factor_en, - double* const factor_een, - double* const factor_ee_deriv_e, - double* const factor_en_deriv_e, - double* const factor_een_deriv_e ); + #+begin_src c :comments org :tangle (eval h_private_type) +typedef struct qmckl_jastrow_struct{ + int32_t uninitialized; + int64_t aord_num; + int64_t bord_num; + int64_t cord_num; + uint64_t type_nuc_num; + uint64_t dim_cord_vec; + double * aord_vector; + double * bord_vector; + double * cord_vector; + double * factor_ee; + double * factor_en; + double * factor_een; + double * factor_ee_deriv_e; + double * factor_en_deriv_e; + double * factor_een_deriv_e; + bool provided; + char type; +} qmckl_jastrow_struct; #+end_src @@ -145,8 +146,8 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { ctx->jastrow.uninitialized = (1 << 2) - 1; /* Default values */ - ctx->jastrow.rescale_factor_kappa_ee = 1.0; - ctx->jastrow.rescale_factor_kappa_en = 1.0; + //ctx->jastrow.rescale_factor_kappa_ee = 1.0; + //ctx->jastrow.rescale_factor_kappa_en = 1.0; return QMCKL_SUCCESS; } @@ -173,3 +174,24 @@ bool qmckl_jastrow_provided(const qmckl_context context) { +* End of files :noexport: + + #+begin_src c :tangle (eval h_private_type) +#endif + #+end_src + +*** Test + #+begin_src c :tangle (eval c_test) + qmckl_exit_code rc = qmckl_context_destroy(context); + assert (rc == QMCKL_SUCCESS); + + return 0; +} + #+end_src + + +# -*- mode: org -*- +# vim: syntax=c + + + From 616815b9b4bdfee17799dd791c5567032d3e2129 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 24 Jun 2021 00:18:19 +0200 Subject: [PATCH 16/92] comment --- org/qmckl_ao.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index 4ec678c..0c820b9 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -1857,6 +1857,7 @@ integer function qmckl_compute_ao_basis_shell_gaussian_vgl_f(context, & info = QMCKL_SUCCESS ! Don't compute exponentials when the result will be almost zero. + ! TODO : Use numerical precision here cutoff = -dlog(1.d-15) do inucl=1,nucl_num @@ -2123,7 +2124,6 @@ assert( fabs(shell_vgl[14][4][1][15] - ( 1.572966698871693e-02)) < 1.e-14 ); } #+end_src - * Polynomial part ** General functions for Powers of $x-X_i$ :PROPERTIES: From c945514e561a62acdb19359b10a283afb9d0b5fb Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 24 Jun 2021 14:42:33 +0530 Subject: [PATCH 17/92] Added all the required tables and data for Jastrow. #22 --- org/qmckl_jastrow.org | 75 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 9 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index c034f1d..e7fb20d 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -78,7 +78,6 @@ int main() { | ~int64_t~ | ~bord_num~ | in | The number of b coeffecients | | ~int64_t~ | ~cord_num~ | in | The number of c coeffecients | | ~uint64_t~ | ~type_nuc_num~ | in | Number of Nucleii types | - | ~uint64_t~ | ~dim_cord_vec~ | in | Number of unique C coefficients | | ~double~ | ~aord_vector[aord_num + 1][type_nuc_num]~ | in | Order of a polynomial coefficients | | ~double~ | ~bord_vector[bord_num + 1]~ | in | Order of b polynomial coefficients | | ~double~ | ~cord_vector[cord_num][type_nuc_num]~ | in | Order of c polynomial coefficients | @@ -91,10 +90,67 @@ int main() { computed data: - |-------------------+--------------------------------------------+---------------------------------| - | ~coord_vect_full~ | ~[dim_cord_vec]~ | vector of non-zero coefficients | - | ~tmp_c~ | ~[elec_num][nuc_num][ncord + 1][ncord]~ | vector of non-zero coefficients | - | ~dtmp_c~ | ~[elec_num][4][nuc_num][ncord + 1][ncord]~ | vector of non-zero coefficients | + |-------------------+--------------------------------------------+-------------------------------------------------| + | ~uint64_t~ | ~dim_cord_vec~ | Number of unique C coefficients | + | ~coord_vect_full~ | ~[dim_cord_vec][nuc_num]~ | vector of non-zero coefficients | + | ~lkpm_of_cindex~ | ~[4][dim_cord_vec]~ | Transform l,k,p, and m into consecutive indices | + | ~tmp_c~ | ~[elec_num][nuc_num][ncord + 1][ncord]~ | vector of non-zero coefficients | + | ~dtmp_c~ | ~[elec_num][4][nuc_num][ncord + 1][ncord]~ | vector of non-zero coefficients | + + For H2O we have the following data: + + #+BEGIN_EXAMPLE +type_nuc_num = 1 +aord_num = 5 +bord_num = 5 +cord_num = 23 +dim_cord_vec = 23 + +aord_vector = [ 0.000000000000000E+000, 0.000000000000000E+000, -0.380512000000000E+000, + -0.157996000000000E+000, -3.155800000000000E-002, 2.151200000000000E-002] + +bord_vector = [ 0.500000000000000E-000, 0.153660000000000E-000, 6.722620000000000E-002, + 2.157000000000000E-002, 7.309600000000000E-003, 2.866000000000000E-003] + +cord_vector = [ 0.571702000000000E-000, -0.514253000000000E-000, -0.513043000000000E-000, + 9.486000000000000E-003, -4.205000000000000E-003, 0.426325800000000E-000, + 8.288150000000000E-002, 5.118600000000000E-003, -2.997800000000000E-003, + -5.270400000000000E-003, -7.499999999999999E-005, -8.301649999999999E-002, + 1.454340000000000E-002, 5.143510000000000E-002, 9.250000000000000E-004, + -4.099100000000000E-003, 4.327600000000000E-003, -1.654470000000000E-003, + 2.614000000000000E-003, -1.477000000000000E-003, -1.137000000000000E-003, + -4.010475000000000E-002, 6.106710000000000E-003 ] + +cord_vector_full = [ +[ 0.571702000000000E-000, -0.514253000000000E-000, -0.513043000000000E-000, + 9.486000000000000E-003, -4.205000000000000E-003, 0.426325800000000E-000, + 8.288150000000000E-002, 5.118600000000000E-003, -2.997800000000000E-003, + -5.270400000000000E-003, -7.499999999999999E-005, -8.301649999999999E-002, + 1.454340000000000E-002, 5.143510000000000E-002, 9.250000000000000E-004, + -4.099100000000000E-003, 4.327600000000000E-003, -1.654470000000000E-003, + 2.614000000000000E-003, -1.477000000000000E-003, -1.137000000000000E-003, + -4.010475000000000E-002, 6.106710000000000E-003 ], +[ 0.571702000000000E-000, -0.514253000000000E-000, -0.513043000000000E-000, + 9.486000000000000E-003, -4.205000000000000E-003, 0.426325800000000E-000, + 8.288150000000000E-002, 5.118600000000000E-003, -2.997800000000000E-003, + -5.270400000000000E-003, -7.499999999999999E-005, -8.301649999999999E-002, + 1.454340000000000E-002, 5.143510000000000E-002, 9.250000000000000E-004, + -4.099100000000000E-003, 4.327600000000000E-003, -1.654470000000000E-003, + 2.614000000000000E-003, -1.477000000000000E-003, -1.137000000000000E-003, + -4.010475000000000E-002, 6.106710000000000E-003 ], +] + +lkpm_of_cindex = + [ 1, 1, 2, 0, 0, 0, 2, 1, 1, 2, 3, 0, 2, 1, 3, 0, 0, 1, + 3, 1, 1, 0, 3, 1, 1, 3, 4, 0, 2, 2, 4, 0, 0, 2, 4, 1, + 3, 1, 4, 0, 1, 1, 4, 1, 2, 0, 4, 1, 0, 0, 4, 2, 1, 4, + 5, 0, 2, 3, 5, 0, 0, 3, 5, 1, 3, 2, 5, 0, 1, 2, 5, 1, + 4, 1, 5, 0, 2, 1, 5, 1, 0, 1, 5, 2, 3, 0, 5, 1, 1, 0, + 5, 2 ] + + + #+END_EXAMPLE + ** Data structure @@ -106,7 +162,6 @@ typedef struct qmckl_jastrow_struct{ int64_t bord_num; int64_t cord_num; uint64_t type_nuc_num; - uint64_t dim_cord_vec; double * aord_vector; double * bord_vector; double * cord_vector; @@ -116,6 +171,10 @@ typedef struct qmckl_jastrow_struct{ double * factor_ee_deriv_e; double * factor_en_deriv_e; double * factor_een_deriv_e; + uint64_t dim_cord_vec; + double * coord_vect_full, + double * tmp_c, + double * dtmp_c, bool provided; char type; } qmckl_jastrow_struct; @@ -143,11 +202,9 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - ctx->jastrow.uninitialized = (1 << 2) - 1; + ctx->jastrow.uninitialized = (1 << ) - 1; /* Default values */ - //ctx->jastrow.rescale_factor_kappa_ee = 1.0; - //ctx->jastrow.rescale_factor_kappa_en = 1.0; return QMCKL_SUCCESS; } From 04de6a5b5294a031ff793c14f464cc537ce6deda Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 24 Jun 2021 14:44:43 +0530 Subject: [PATCH 18/92] Fixed typos and bugs. #22 --- org/qmckl_jastrow.org | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index e7fb20d..5cdfa86 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -172,9 +172,9 @@ typedef struct qmckl_jastrow_struct{ double * factor_en_deriv_e; double * factor_een_deriv_e; uint64_t dim_cord_vec; - double * coord_vect_full, - double * tmp_c, - double * dtmp_c, + double * coord_vect_full; + double * tmp_c; + double * dtmp_c; bool provided; char type; } qmckl_jastrow_struct; @@ -202,7 +202,7 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - ctx->jastrow.uninitialized = (1 << ) - 1; + ctx->jastrow.uninitialized = (1 << 4) - 1; /* Default values */ From d487b5365f7cc283038873b87dfd94dac414461c Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 24 Jun 2021 17:05:16 +0530 Subject: [PATCH 19/92] Implemented setters and getters. #22 --- org/qmckl_jastrow.org | 413 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 396 insertions(+), 17 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 5cdfa86..3db05c3 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -61,7 +61,6 @@ int main() { #include "qmckl_jastrow_private_type.h" #+end_src - * Context :PROPERTIES: :Name: qmckl_jastrow @@ -105,13 +104,10 @@ aord_num = 5 bord_num = 5 cord_num = 23 dim_cord_vec = 23 - aord_vector = [ 0.000000000000000E+000, 0.000000000000000E+000, -0.380512000000000E+000, -0.157996000000000E+000, -3.155800000000000E-002, 2.151200000000000E-002] - bord_vector = [ 0.500000000000000E-000, 0.153660000000000E-000, 6.722620000000000E-002, 2.157000000000000E-002, 7.309600000000000E-003, 2.866000000000000E-003] - cord_vector = [ 0.571702000000000E-000, -0.514253000000000E-000, -0.513043000000000E-000, 9.486000000000000E-003, -4.205000000000000E-003, 0.426325800000000E-000, 8.288150000000000E-002, 5.118600000000000E-003, -2.997800000000000E-003, @@ -120,7 +116,6 @@ cord_vector = [ 0.571702000000000E-000, -0.514253000000000E-000, -0.513043000000 -4.099100000000000E-003, 4.327600000000000E-003, -1.654470000000000E-003, 2.614000000000000E-003, -1.477000000000000E-003, -1.137000000000000E-003, -4.010475000000000E-002, 6.106710000000000E-003 ] - cord_vector_full = [ [ 0.571702000000000E-000, -0.514253000000000E-000, -0.513043000000000E-000, 9.486000000000000E-003, -4.205000000000000E-003, 0.426325800000000E-000, @@ -139,7 +134,6 @@ cord_vector_full = [ 2.614000000000000E-003, -1.477000000000000E-003, -1.137000000000000E-003, -4.010475000000000E-002, 6.106710000000000E-003 ], ] - lkpm_of_cindex = [ 1, 1, 2, 0, 0, 0, 2, 1, 1, 2, 3, 0, 2, 1, 3, 0, 0, 1, 3, 1, 1, 0, 3, 1, 1, 3, 4, 0, 2, 2, 4, 0, 0, 2, 4, 1, @@ -147,8 +141,6 @@ lkpm_of_cindex = 5, 0, 2, 3, 5, 0, 0, 3, 5, 1, 3, 2, 5, 0, 1, 2, 5, 1, 4, 1, 5, 0, 2, 1, 5, 1, 0, 1, 5, 2, 3, 0, 5, 1, 1, 0, 5, 2 ] - - #+END_EXAMPLE @@ -157,11 +149,11 @@ lkpm_of_cindex = #+begin_src c :comments org :tangle (eval h_private_type) typedef struct qmckl_jastrow_struct{ - int32_t uninitialized; - int64_t aord_num; - int64_t bord_num; - int64_t cord_num; - uint64_t type_nuc_num; + int32_t uninitialized; + int64_t aord_num; + int64_t bord_num; + int64_t cord_num; + int64_t type_nuc_num; double * aord_vector; double * bord_vector; double * cord_vector; @@ -171,12 +163,12 @@ typedef struct qmckl_jastrow_struct{ double * factor_ee_deriv_e; double * factor_en_deriv_e; double * factor_een_deriv_e; - uint64_t dim_cord_vec; + int64_t dim_cord_vec; double * coord_vect_full; double * tmp_c; double * dtmp_c; - bool provided; - char type; + bool provided; + char type; } qmckl_jastrow_struct; #+end_src @@ -202,7 +194,7 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - ctx->jastrow.uninitialized = (1 << 4) - 1; + ctx->jastrow.uninitialized = (1 << 5) - 1; /* Default values */ @@ -230,6 +222,393 @@ bool qmckl_jastrow_provided(const qmckl_context context) { #+end_src +** Access functions + + #+begin_src c :comments org :tangle (eval h_private_func) :exports none +int64_t qmckl_get_jastrow_aord_num (qmckl_context context); +int64_t qmckl_get_jastrow_bord_num (qmckl_context context); +int64_t qmckl_get_jastrow_cord_num (qmckl_context context); +int64_t qmckl_get_jastrow_type_nuc_num (qmckl_context context); +double* qmckl_get_jastrow_aord_vector (qmckl_context context); +double* qmckl_get_jastrow_bord_vector (qmckl_context context); +double* qmckl_get_jastrow_cord_vector (qmckl_context context); + #+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_jastrow_provided (const qmckl_context context); + #+end_src + + #+NAME:post + #+begin_src c :exports none +if ( (ctx->jastrow.uninitialized & mask) != 0) { + return NULL; +} + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +int64_t qmckl_get_jastrow_aord_num (const qmckl_context context) { + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return (char) 0; + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 0; + + if ( (ctx->jastrow.uninitialized & mask) != 0) { + return (char) 0; + } + + assert (ctx->jastrow.aord_num > 0); + return ctx->jastrow.aord_num; +} + +int64_t qmckl_get_jastrow_bord_num (const qmckl_context context) { + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return (char) 0; + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 1; + + if ( (ctx->jastrow.uninitialized & mask) != 0) { + return (char) 0; + } + + assert (ctx->jastrow.bord_num > 0); + return ctx->jastrow.bord_num; +} + +int64_t qmckl_get_jastrow_cord_num (const qmckl_context context) { + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return (char) 0; + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 0; + + if ( (ctx->jastrow.uninitialized & mask) != 0) { + return (char) 0; + } + + assert (ctx->jastrow.cord_num > 0); + return ctx->jastrow.cord_num; +} + +int64_t qmckl_get_type_nuc_num (const qmckl_context context) { + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return (char) 0; + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 2; + + if ( (ctx->jastrow.uninitialized & mask) != 0) { + return (char) 0; + } + + assert (ctx->jastrow.type_nuc_num > 0); + return ctx->jastrow.type_nuc_num; +} + +double* qmckl_get_aord_vector (const qmckl_context context) { + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return (char) 0; + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 3; + + if ( (ctx->jastrow.uninitialized & mask) != 0) { + return (char) 0; + } + + assert (ctx->jastrow.aord_vector != NULL); + return ctx->jastrow.aord_vector; +} + +double* qmckl_get_bord_vector (const qmckl_context context) { + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return (char) 0; + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 3; + + if ( (ctx->jastrow.uninitialized & mask) != 0) { + return (char) 0; + } + + assert (ctx->jastrow.bord_vector != NULL); + return ctx->jastrow.bord_vector; +} + +double* qmckl_get_cord_vector (const qmckl_context context) { + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return (char) 0; + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 3; + + if ( (ctx->jastrow.uninitialized & mask) != 0) { + return (char) 0; + } + + assert (ctx->jastrow.cord_vector != NULL); + return ctx->jastrow.cord_vector; +} + #+end_src + +** Initialization functions + + To prepare for the Jastrow and its derivative, all the following functions need to be + called. + + #+begin_src c :comments org :tangle (eval h_func) +qmckl_exit_code qmckl_set_jastrow_ord_num (qmckl_context context, const int64_t aord_num, const int64_t bord_num, const int64_t cord_num); +qmckl_exit_code qmckl_set_jastrow_type_nuc_num (qmckl_context context, const int64_t type_nuc_num); +qmckl_exit_code qmckl_set_jastrow_aord_vector (qmckl_context context, const double * aord_vector); +qmckl_exit_code qmckl_set_jastrow_bord_vector (qmckl_context context, const double * bord_vector); +qmckl_exit_code qmckl_set_jastrow_cord_vector (qmckl_context context, const double * cord_vector); + #+end_src + + #+NAME:pre2 + #+begin_src c :exports none +if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + +qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + #+end_src + + #+NAME:post2 + #+begin_src c :exports none +ctx->jastrow.uninitialized &= ~mask; +ctx->jastrow.provided = (ctx->jastrow.uninitialized == 0); +if (ctx->jastrow.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_jastrow_ord_num(qmckl_context context, const int64_t aord_num, const int64_t bord_num, const int64_t cord_num) { +<> + + if (aord_num <= 0) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_set_jastrow_ord_num", + "aord_num <= 0"); + } + + if (bord_num <= 0) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_set_jastrow_ord_num", + "bord_num <= 0"); + } + + if (cord_num <= 0) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_set_jastrow_ord_num", + "cord_num <= 0"); + } + + int32_t mask = 1 << 1; + ctx->jastrow.aord_num = aord_num; + ctx->jastrow.bord_num = bord_num; + ctx->jastrow.cord_num = cord_num; + + <> +} + +qmckl_exit_code qmckl_set_jastrow_type_nuc_num(qmckl_context context, const int64_t type_nuc_num) { +<> + + if (type_nuc_num <= 0) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_set_jastrow_type_nuc_num", + "type_nuc_num < 0"); + } + + int32_t mask = 1 << 2; + ctx->jastrow.type_nuc_num = type_nuc_num; + + <> +} + +qmckl_exit_code qmckl_set_jastrow_aord_vector(qmckl_context context, double const * aord_vector) { +<> + + int32_t mask = 1 << 3; + + const int64_t aord_num = qmckl_get_jastrow_aord_num(context); + if (aord_num == 0) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_jastrow_coefficient", + "aord_num is not set"); + } + + if (aord_vector == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_set_jastrow_aord_vector", + "aord_vector = NULL"); + } + + if (ctx->jastrow.aord_vector != NULL) { + qmckl_exit_code rc = qmckl_free(context, ctx->jastrow.aord_vector); + if (rc != QMCKL_SUCCESS) { + return qmckl_failwith( context, rc, + "qmckl_set_ord_vector", + NULL); + } + } + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = aord_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_jastrow_coefficient", + NULL); + } + + memcpy(new_array, aord_vector, mem_info.size); + + ctx->jastrow.aord_vector = new_array; + + <> +} + +qmckl_exit_code qmckl_set_jastrow_bord_vector(qmckl_context context, double const * bord_vector) { +<> + + int32_t mask = 1 << 4; + + const int64_t bord_num = qmckl_get_jastrow_bord_num(context); + if (bord_num == 0) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_jastrow_coefficient", + "bord_num is not set"); + } + + if (bord_vector == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_set_jastrow_bord_vector", + "bord_vector = NULL"); + } + + if (ctx->jastrow.bord_vector != NULL) { + qmckl_exit_code rc = qmckl_free(context, ctx->jastrow.bord_vector); + if (rc != QMCKL_SUCCESS) { + return qmckl_failwith( context, rc, + "qmckl_set_ord_vector", + NULL); + } + } + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = bord_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_jastrow_coefficient", + NULL); + } + + memcpy(new_array, bord_vector, mem_info.size); + + ctx->jastrow.aord_vector = new_array; + + <> +} + +qmckl_exit_code qmckl_set_jastrow_cord_vector(qmckl_context context, double const * cord_vector) { +<> + + int32_t mask = 1 << 5; + + const int64_t cord_num = qmckl_get_jastrow_cord_num(context); + if (cord_num == 0) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_jastrow_coefficient", + "cord_num is not set"); + } + + if (cord_vector == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_set_jastrow_cord_vector", + "cord_vector = NULL"); + } + + if (ctx->jastrow.cord_vector != NULL) { + qmckl_exit_code rc = qmckl_free(context, ctx->jastrow.cord_vector); + if (rc != QMCKL_SUCCESS) { + return qmckl_failwith( context, rc, + "qmckl_set_ord_vector", + NULL); + } + } + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = cord_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_jastrow_coefficient", + NULL); + } + + memcpy(new_array, cord_vector, mem_info.size); + + ctx->jastrow.cord_vector = new_array; + + <> +} + #+end_src + * End of files :noexport: From 06ad700b2925151ee060de4cc5c219a154b30d75 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 24 Jun 2021 17:09:39 +0530 Subject: [PATCH 20/92] Started work on finalizing Jastrow. #22 --- org/qmckl_jastrow.org | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 3db05c3..d82fec9 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -609,6 +609,28 @@ qmckl_exit_code qmckl_set_jastrow_cord_vector(qmckl_context context, double cons } #+end_src + When the required information is completely entered, other data structures are + computed to accelerate the calculations. The intermediates factors + are precontracted using BLAS LEVEL 3 operations for an optimal FLOP count. + + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_finalize_jastrow(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; +} + #+end_src * End of files :noexport: From de65455eeebe403480312a3e92fc911572291fe2 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 24 Jun 2021 17:26:24 +0530 Subject: [PATCH 21/92] moved the provided function. #22 --- org/qmckl_jastrow.org | 47 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index d82fec9..f33714d 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -203,9 +203,29 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { #+end_src - #+begin_src c :comments org :tangle (eval h_func) -bool qmckl_jastrow_provided (const qmckl_context context); - #+end_src + +** Access functions + + #+begin_src c :comments org :tangle (eval h_private_func) :exports none +int64_t qmckl_get_jastrow_aord_num (qmckl_context context); +int64_t qmckl_get_jastrow_bord_num (qmckl_context context); +int64_t qmckl_get_jastrow_cord_num (qmckl_context context); +int64_t qmckl_get_jastrow_type_nuc_num (qmckl_context context); +double* qmckl_get_jastrow_aord_vector (qmckl_context context); +double* qmckl_get_jastrow_bord_vector (qmckl_context context); +double* qmckl_get_jastrow_cord_vector (qmckl_context context); + #+end_src + + Along with these core functions, calculation of the jastrow factor + requires the following additional information to be set: + + + 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_jastrow_provided (const qmckl_context context); + #+end_src #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none bool qmckl_jastrow_provided(const qmckl_context context) { @@ -221,26 +241,6 @@ bool qmckl_jastrow_provided(const qmckl_context context) { } #+end_src - -** Access functions - - #+begin_src c :comments org :tangle (eval h_private_func) :exports none -int64_t qmckl_get_jastrow_aord_num (qmckl_context context); -int64_t qmckl_get_jastrow_bord_num (qmckl_context context); -int64_t qmckl_get_jastrow_cord_num (qmckl_context context); -int64_t qmckl_get_jastrow_type_nuc_num (qmckl_context context); -double* qmckl_get_jastrow_aord_vector (qmckl_context context); -double* qmckl_get_jastrow_bord_vector (qmckl_context context); -double* qmckl_get_jastrow_cord_vector (qmckl_context context); - #+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_jastrow_provided (const qmckl_context context); - #+end_src - #+NAME:post #+begin_src c :exports none if ( (ctx->jastrow.uninitialized & mask) != 0) { @@ -629,6 +629,7 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { int64_t nucl_num = 0; qmckl_exit_code rc = QMCKL_FAILURE; + } #+end_src From 01516c84c59b1bfdab8dd6587f0743d86124cd67 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 24 Jun 2021 17:32:42 +0530 Subject: [PATCH 22/92] Added checking providers for electron and nucleus distance. #22 --- org/qmckl_jastrow.org | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index f33714d..261e988 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -194,7 +194,7 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - ctx->jastrow.uninitialized = (1 << 5) - 1; + ctx->jastrow.uninitialized = (1 << 6) - 1; /* Default values */ @@ -394,6 +394,7 @@ qmckl_exit_code qmckl_set_jastrow_type_nuc_num (qmckl_context context, const i qmckl_exit_code qmckl_set_jastrow_aord_vector (qmckl_context context, const double * aord_vector); qmckl_exit_code qmckl_set_jastrow_bord_vector (qmckl_context context, const double * bord_vector); qmckl_exit_code qmckl_set_jastrow_cord_vector (qmckl_context context, const double * cord_vector); +qmckl_exit_code qmckl_set_jastrow_dependencies (qmckl_context context); #+end_src #+NAME:pre2 @@ -607,6 +608,31 @@ qmckl_exit_code qmckl_set_jastrow_cord_vector(qmckl_context context, double cons <> } + +qmckl_exit_code qmckl_set_jastrow_dependencies(qmckl_context context) { +<> + + /* Check for electron data */ + if (!(ctx->electron.provided)) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_provide_ee_distance", + NULL); + } + + /* Check for nucleus data */ + if (!(ctx->nucleus.provided)) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_provide_en_distance", + NULL); + } + + int32_t mask = 1 << 6; + + <> +} + #+end_src When the required information is completely entered, other data structures are From 97ad53fd762b692a27f71525e24e75d3f0931609 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Fri, 25 Jun 2021 07:48:08 +0530 Subject: [PATCH 23/92] Added public get and set functions. #22 --- org/qmckl_jastrow.org | 125 ++++++++++++++++++++++++++++++++---------- 1 file changed, 95 insertions(+), 30 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 261e988..7818247 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -168,7 +168,7 @@ typedef struct qmckl_jastrow_struct{ double * tmp_c; double * dtmp_c; bool provided; - char type; + char * type; } qmckl_jastrow_struct; #+end_src @@ -180,7 +180,7 @@ typedef struct qmckl_jastrow_struct{ Some values are initialized by default, and are not concerned by this mechanism. - #+begin_src c :comments org :tangle (eval h_private_func) + #+begin_src c :comments org :tangle (eval h_func) qmckl_exit_code qmckl_init_jastrow(qmckl_context context); #+end_src @@ -203,17 +203,16 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { #+end_src - ** Access functions - #+begin_src c :comments org :tangle (eval h_private_func) :exports none -int64_t qmckl_get_jastrow_aord_num (qmckl_context context); -int64_t qmckl_get_jastrow_bord_num (qmckl_context context); -int64_t qmckl_get_jastrow_cord_num (qmckl_context context); -int64_t qmckl_get_jastrow_type_nuc_num (qmckl_context context); -double* qmckl_get_jastrow_aord_vector (qmckl_context context); -double* qmckl_get_jastrow_bord_vector (qmckl_context context); -double* qmckl_get_jastrow_cord_vector (qmckl_context context); + #+begin_src c :comments org :tangle (eval h_func) :exports none +qmckl_exit_code qmckl_get_jastrow_aord_num (qmckl_context context, int64_t* const aord_num); +qmckl_exit_code qmckl_get_jastrow_bord_num (qmckl_context context, int64_t* const bord_num); +qmckl_exit_code qmckl_get_jastrow_cord_num (qmckl_context context, int64_t* const bord_num); +qmckl_exit_code qmckl_get_jastrow_type_nuc_num (qmckl_context context, int64_t* const type_nuc_num); +qmckl_exit_code qmckl_get_jastrow_aord_vector (qmckl_context context, double * const aord_vector); +qmckl_exit_code qmckl_get_jastrow_bord_vector (qmckl_context context, double * const bord_vector); +qmckl_exit_code qmckl_get_jastrow_cord_vector (qmckl_context context, double * const cord_vector); #+end_src Along with these core functions, calculation of the jastrow factor @@ -249,12 +248,19 @@ if ( (ctx->jastrow.uninitialized & mask) != 0) { #+end_src #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -int64_t qmckl_get_jastrow_aord_num (const qmckl_context context) { +qmckl_exit_code qmckl_get_jastrow_aord_num (const qmckl_context context, int64_t* const aord_num) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return (char) 0; } + if (aord_num == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_jastrow_aord_num", + "aord_num is a null pointer"); + } + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); @@ -265,34 +271,50 @@ int64_t qmckl_get_jastrow_aord_num (const qmckl_context context) { } assert (ctx->jastrow.aord_num > 0); - return ctx->jastrow.aord_num; + *aord_num = ctx->jastrow.aord_num; + return QMCKL_SUCCESS; } -int64_t qmckl_get_jastrow_bord_num (const qmckl_context context) { +qmckl_exit_code qmckl_get_jastrow_bord_num (const qmckl_context context, int64_t* const bord_num) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return (char) 0; } + if (bord_num == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_jastrow_bord_num", + "aord_num is a null pointer"); + } + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 1; + int32_t mask = 1 << 0; if ( (ctx->jastrow.uninitialized & mask) != 0) { return (char) 0; } assert (ctx->jastrow.bord_num > 0); - return ctx->jastrow.bord_num; + *bord_num = ctx->jastrow.bord_num; + return QMCKL_SUCCESS; } -int64_t qmckl_get_jastrow_cord_num (const qmckl_context context) { +qmckl_exit_code qmckl_get_jastrow_cord_num (const qmckl_context context, int64_t* const cord_num) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return (char) 0; } + if (cord_num == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_jastrow_cord_num", + "aord_num is a null pointer"); + } + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); @@ -303,15 +325,23 @@ int64_t qmckl_get_jastrow_cord_num (const qmckl_context context) { } assert (ctx->jastrow.cord_num > 0); - return ctx->jastrow.cord_num; + *cord_num = ctx->jastrow.cord_num; + return QMCKL_SUCCESS; } -int64_t qmckl_get_type_nuc_num (const qmckl_context context) { +qmckl_exit_code qmckl_get_type_nuc_num (const qmckl_context context, int64_t* const type_nuc_num) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return (char) 0; } + if (type_nuc_num == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_jastrow_type_nuc_num", + "type_nuc_num is a null pointer"); + } + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); @@ -322,14 +352,22 @@ int64_t qmckl_get_type_nuc_num (const qmckl_context context) { } assert (ctx->jastrow.type_nuc_num > 0); - return ctx->jastrow.type_nuc_num; + *type_nuc_num = ctx->jastrow.type_nuc_num; + return QMCKL_SUCCESS; } -double* qmckl_get_aord_vector (const qmckl_context context) { +qmckl_exit_code qmckl_get_aord_vector (const qmckl_context context, double * const aord_vector) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return (char) 0; } + + if (aord_vector == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_jastrow_aord_vector", + "aord_vector is a null pointer"); + } qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); @@ -341,14 +379,22 @@ double* qmckl_get_aord_vector (const qmckl_context context) { } assert (ctx->jastrow.aord_vector != NULL); - return ctx->jastrow.aord_vector; + memcpy(aord_vector, ctx->jastrow.aord_vector, ctx->jastrow.aord_num*sizeof(double)); + return QMCKL_SUCCESS; } -double* qmckl_get_bord_vector (const qmckl_context context) { +qmckl_exit_code qmckl_get_bord_vector (const qmckl_context context, double * const bord_vector) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return (char) 0; } + + if (bord_vector == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_jastrow_bord_vector", + "bord_vector is a null pointer"); + } qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); @@ -360,14 +406,22 @@ double* qmckl_get_bord_vector (const qmckl_context context) { } assert (ctx->jastrow.bord_vector != NULL); - return ctx->jastrow.bord_vector; + memcpy(bord_vector, ctx->jastrow.bord_vector, ctx->jastrow.bord_num*sizeof(double)); + return QMCKL_SUCCESS; } -double* qmckl_get_cord_vector (const qmckl_context context) { +qmckl_exit_code qmckl_get_cord_vector (const qmckl_context context, double * const cord_vector) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return (char) 0; } + + if (cord_vector == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_jastrow_cord_vector", + "cord_vector is a null pointer"); + } qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); @@ -379,8 +433,10 @@ double* qmckl_get_cord_vector (const qmckl_context context) { } assert (ctx->jastrow.cord_vector != NULL); - return ctx->jastrow.cord_vector; + memcpy(cord_vector, ctx->jastrow.cord_vector, ctx->jastrow.cord_num*sizeof(double)); + return QMCKL_SUCCESS; } + #+end_src ** Initialization functions @@ -473,7 +529,10 @@ qmckl_exit_code qmckl_set_jastrow_aord_vector(qmckl_context context, double cons int32_t mask = 1 << 3; - const int64_t aord_num = qmckl_get_jastrow_aord_num(context); + int64_t aord_num; + int rc = qmckl_get_jastrow_aord_num(context, &aord_num); + if (rc != QMCKL_SUCCESS) return rc; + if (aord_num == 0) { return qmckl_failwith( context, QMCKL_FAILURE, @@ -520,7 +579,10 @@ qmckl_exit_code qmckl_set_jastrow_bord_vector(qmckl_context context, double cons int32_t mask = 1 << 4; - const int64_t bord_num = qmckl_get_jastrow_bord_num(context); + int64_t bord_num; + int rc = qmckl_get_jastrow_bord_num(context, &bord_num); + if (rc != QMCKL_SUCCESS) return rc; + if (bord_num == 0) { return qmckl_failwith( context, QMCKL_FAILURE, @@ -557,7 +619,7 @@ qmckl_exit_code qmckl_set_jastrow_bord_vector(qmckl_context context, double cons memcpy(new_array, bord_vector, mem_info.size); - ctx->jastrow.aord_vector = new_array; + ctx->jastrow.bord_vector = new_array; <> } @@ -567,7 +629,10 @@ qmckl_exit_code qmckl_set_jastrow_cord_vector(qmckl_context context, double cons int32_t mask = 1 << 5; - const int64_t cord_num = qmckl_get_jastrow_cord_num(context); + int64_t cord_num; + int rc = qmckl_get_jastrow_cord_num(context, &cord_num); + if (rc != QMCKL_SUCCESS) return rc; + if (cord_num == 0) { return qmckl_failwith( context, QMCKL_FAILURE, From 7bac20bfae7c7014996a3be3d5b1d167f8f9aacd Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Fri, 25 Jun 2021 07:48:54 +0530 Subject: [PATCH 24/92] Check if electron is provided in provide shell vgl. --- org/qmckl_ao.org | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index b193f3a..b307c65 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -1871,6 +1871,13 @@ qmckl_exit_code qmckl_provide_ao_basis_shell_vgl(qmckl_context context) "qmckl_ao_basis_shell_vgl", NULL); } + + if(!(ctx->electron.provided)) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_electron", + NULL); + } /* Compute if necessary */ if (ctx->electron.coord_new_date > ctx->ao_basis.shell_vgl_date) { From 32c0e7c72316452d56fe90d04e481c16006b2955 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Fri, 25 Jun 2021 08:54:50 +0530 Subject: [PATCH 25/92] Added function to compute asymmetric factor. #22 --- org/qmckl_jastrow.org | 260 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 250 insertions(+), 10 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 7818247..6045001 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -81,20 +81,25 @@ int main() { | ~double~ | ~bord_vector[bord_num + 1]~ | in | Order of b polynomial coefficients | | ~double~ | ~cord_vector[cord_num][type_nuc_num]~ | in | Order of c polynomial coefficients | | ~double~ | ~factor_ee~ | out | Jastrow factor: electron-electron part | + | ~double~ | ~factor_ee_date~ | out | Jastrow factor: electron-electron part | | ~double~ | ~factor_en~ | out | Jastrow factor: electron-nucleus part | + | ~double~ | ~factor_en_date~ | out | Jastrow factor: electron-nucleus part | | ~double~ | ~factor_een~ | out | Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_een_date~ | out | Jastrow factor: electron-electron-nucleus part | | ~double~ | ~factor_ee_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | | ~double~ | ~factor_en_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | | ~double~ | ~factor_een_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | computed data: - |-------------------+--------------------------------------------+-------------------------------------------------| - | ~uint64_t~ | ~dim_cord_vec~ | Number of unique C coefficients | - | ~coord_vect_full~ | ~[dim_cord_vec][nuc_num]~ | vector of non-zero coefficients | - | ~lkpm_of_cindex~ | ~[4][dim_cord_vec]~ | Transform l,k,p, and m into consecutive indices | - | ~tmp_c~ | ~[elec_num][nuc_num][ncord + 1][ncord]~ | vector of non-zero coefficients | - | ~dtmp_c~ | ~[elec_num][4][nuc_num][ncord + 1][ncord]~ | vector of non-zero coefficients | + |-----------+--------------------------------------------------+-------------------------------------------------| + | ~int64_t~ | ~dim_cord_vec~ | Number of unique C coefficients | + | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | + | ~int64_t~ | ~asymp_jasb_date~ | Asymptotic component | + | ~double~ | ~coord_vect_full[dim_cord_vec][nuc_num]~ | vector of non-zero coefficients | + | ~int64_t~ | ~lkpm_of_cindex[4][dim_cord_vec]~ | Transform l,k,p, and m into consecutive indices | + | ~double~ | ~tmp_c[elec_num][nuc_num][ncord + 1][ncord]~ | vector of non-zero coefficients | + | ~double~ | ~dtmp_c[elec_num][4][nuc_num][ncord + 1][ncord]~ | vector of non-zero coefficients | For H2O we have the following data: @@ -143,8 +148,6 @@ lkpm_of_cindex = 5, 2 ] #+END_EXAMPLE - - ** Data structure #+begin_src c :comments org :tangle (eval h_private_type) @@ -154,9 +157,16 @@ typedef struct qmckl_jastrow_struct{ int64_t bord_num; int64_t cord_num; int64_t type_nuc_num; + int64_t asymp_jasb_date; + int64_t tmp_c_date; + int64_t dtmp_c_date; + int64_t factor_ee_date; + int64_t factor_en_date; + int64_t factor_een_date; double * aord_vector; double * bord_vector; double * cord_vector; + double * asymp_jasb; double * factor_ee; double * factor_en; double * factor_een; @@ -202,7 +212,6 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { } #+end_src - ** Access functions #+begin_src c :comments org :tangle (eval h_func) :exports none @@ -718,12 +727,243 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int64_t nucl_num = 0; + /* ----------------------------------- */ + /* Check for the necessary information */ + /* ----------------------------------- */ + + /* Check for the electron data + 1. elec_num + 2. ee_distances_rescaled + */ + if (!(ctx->electron.provided)) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_electron", + NULL); + } + + /* Check for the nucleus data + 1. nuc_num + 2. en_distances_rescaled + */ + if (!(ctx->nucleus.provided)) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_nucleus", + NULL); + } + qmckl_exit_code rc = QMCKL_FAILURE; + + /* ----------------------------------- */ + /* Start calculation of data */ + /* ----------------------------------- */ + + } #+end_src +* Computation + + The computed data is stored in the context so that it can be reused + by different kernels. To ensure that the data is valid, for each + computed data the date of the context is stored when it is computed. + To know if some data needs to be recomputed, we check if the date of + the dependencies are more recent than the date of the data to + compute. If it is the case, then the data is recomputed and the + current date is stored. + +** Asymptotic component for \(J_{ee}\) + + Calculate the asymptotic component ~asymp_jasb~ to be substracted from the final + electron-electron jastrow factor \(f_{ee}\). The asymptotic componenet is calculated + via the ~bord_vector~ and the electron-electron rescale factor ~rescale_factor_kappa~. + + \[ + J_{asymp} = \frac{b_1 \kappa^-1}{1 + b_2 \kappa^-1} + \] + +*** Get + #+begin_src c :comments org :tangle (eval h_func) :noweb yes +qmckl_exit_code qmckl_get_jastrow_asymp_jasb(qmckl_context context, double* const asymp_jasb); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_get_jastrow_asymp_jasb(qmckl_context context, double* const asymp_jasb) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_asymp_jasb(context); + if (rc != QMCKL_SUCCESS) return rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + size_t sze = 2; + memcpy(asymp_jasb, ctx->jastrow.asymp_jasb, sze * sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide :noexport: + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_asymp_jasb(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_asymp_jasb(qmckl_context context) +{ + + qmckl_exit_code rc; + + 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); + + /* Check if ee kappa is provided */ + double rescale_factor_kappa_ee; + rc = qmckl_get_electron_rescale_factor_ee(context, &rescale_factor_kappa_ee); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.asymp_jasb_date) { + + /* Allocate array */ + if (ctx->jastrow.asymp_jasb == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = 2 * sizeof(double); + double* asymp_jasb = (double*) qmckl_malloc(context, mem_info); + + if (asymp_jasb == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_asymp_jasb", + NULL); + } + ctx->jastrow.asymp_jasb = asymp_jasb; + } + + qmckl_exit_code rc = + qmckl_compute_asymp_jasb(context, + ctx->jastrow.bord_num, + ctx->jastrow.bord_vector, + rescale_factor_kappa_ee, + ctx->jastrow.asymp_jasb); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.asymp_jasb_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute + :PROPERTIES: + :Name: qmckl_compute_asymp_jasb + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_asymp_jasb_args + | qmckl_context | context | in | Global state | + | int64_t | bord_num | in | Number of electrons | + | double | bord_vector[bord_num + 1] | in | Number of walkers | + | double | rescale_factor_kappa_ee | in | Electron coordinates | + | double | asymp_jasb[2] | out | Electron-electron distances | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_asymp_jasb_f(context, bord_num, bord_vector, rescale_factor_kappa_ee, asymp_jasb) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: bord_num + double precision , intent(in) :: bord_vector(bord_num) + double precision , intent(in) :: rescale_factor_kappa_ee + double precision , intent(out) :: asymp_jasb(2) + + integer*8 :: i, p + double precision :: kappa_inv, x, asym_one + kappa_inv = 1.0d0 / rescale_factor_kappa_ee + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (bord_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + asym_one = bord_vector(1) * kappa_inv / (1.0d0 + bord_vector(2) * kappa_inv) + asymp_jasb(:) = (/asym_one, 0.5d0 * asym_one/) + + do i = 1, 2 + x = kappa_inv + do p = 2, bord_num + x = x * kappa_inv + asymp_jasb(i) = asymp_jasb(i) + bord_vector(p + 1) * x + end do + end do + +end function qmckl_compute_asymp_jasb_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_asymp_jasb_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_private_func) :comments org + qmckl_exit_code qmckl_compute_asymp_jasb ( + const qmckl_context context, + const int64_t bord_num, + const double* bord_vector, + const double rescale_factor_kappa_ee, + double* const asymp_jasb ); + #+end_src + + + #+CALL: generate_c_interface(table=qmckl_asymp_jasb_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_asymp_jasb & + (context, bord_num, bord_vector, rescale_factor_kappa_ee, asymp_jasb) & + 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 :: bord_num + real (c_double ) , intent(in) :: bord_vector(bord_num + 1) + real (c_double ) , intent(in) , value :: rescale_factor_kappa_ee + real (c_double ) , intent(out) :: asymp_jasb(2) + + integer(c_int32_t), external :: qmckl_compute_asymp_jasb_f + info = qmckl_compute_asymp_jasb_f & + (context, bord_num, bord_vector, rescale_factor_kappa_ee, asymp_jasb) + + end function qmckl_compute_asymp_jasb + #+end_src + +*** Test + * End of files :noexport: #+begin_src c :tangle (eval h_private_type) From 931d364b1d2f71f5645a2f75c50abd6f7fa8b384 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Fri, 25 Jun 2021 11:54:53 +0530 Subject: [PATCH 26/92] Jastrow specific test b2.h header added. #22 --- org/qmckl_jastrow.org | 253 ++++++++++++++++++++++++++++++++++++------ tests/b2.h | 106 ++++++++++++++++++ 2 files changed, 323 insertions(+), 36 deletions(-) create mode 100644 tests/b2.h diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 6045001..90d4cf6 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -27,7 +27,7 @@ these factors along with their derivatives. #include "config.h" #endif -#include "chbrclf.h" +#include "b2.h" int main() { qmckl_context context; @@ -76,10 +76,10 @@ int main() { | ~int64_t~ | ~aord_num~ | in | The number of a coeffecients | | ~int64_t~ | ~bord_num~ | in | The number of b coeffecients | | ~int64_t~ | ~cord_num~ | in | The number of c coeffecients | - | ~uint64_t~ | ~type_nuc_num~ | in | Number of Nucleii types | - | ~double~ | ~aord_vector[aord_num + 1][type_nuc_num]~ | in | Order of a polynomial coefficients | + | ~uint64_t~ | ~type_nucl_num~ | in | Number of Nucleii types | + | ~double~ | ~aord_vector[aord_num + 1][type_nucl_num]~ | in | Order of a polynomial coefficients | | ~double~ | ~bord_vector[bord_num + 1]~ | in | Order of b polynomial coefficients | - | ~double~ | ~cord_vector[cord_num][type_nuc_num]~ | in | Order of c polynomial coefficients | + | ~double~ | ~cord_vector[cord_num][type_nucl_num]~ | in | Order of c polynomial coefficients | | ~double~ | ~factor_ee~ | out | Jastrow factor: electron-electron part | | ~double~ | ~factor_ee_date~ | out | Jastrow factor: electron-electron part | | ~double~ | ~factor_en~ | out | Jastrow factor: electron-nucleus part | @@ -96,15 +96,18 @@ int main() { | ~int64_t~ | ~dim_cord_vec~ | Number of unique C coefficients | | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | | ~int64_t~ | ~asymp_jasb_date~ | Asymptotic component | - | ~double~ | ~coord_vect_full[dim_cord_vec][nuc_num]~ | vector of non-zero coefficients | + | ~double~ | ~coord_vect_full[dim_cord_vec][nucl_num]~ | vector of non-zero coefficients | | ~int64_t~ | ~lkpm_of_cindex[4][dim_cord_vec]~ | Transform l,k,p, and m into consecutive indices | - | ~double~ | ~tmp_c[elec_num][nuc_num][ncord + 1][ncord]~ | vector of non-zero coefficients | - | ~double~ | ~dtmp_c[elec_num][4][nuc_num][ncord + 1][ncord]~ | vector of non-zero coefficients | + | ~double~ | ~tmp_c[elec_num][nucl_num][ncord + 1][ncord]~ | vector of non-zero coefficients | + | ~double~ | ~dtmp_c[elec_num][4][nucl_num][ncord + 1][ncord]~ | vector of non-zero coefficients | For H2O we have the following data: - #+BEGIN_EXAMPLE -type_nuc_num = 1 + #+NAME: jastrow_data + #+BEGIN_SRC python :results output +import numpy as np + +type_nucl_num = 1 aord_num = 5 bord_num = 5 cord_num = 23 @@ -139,14 +142,38 @@ cord_vector_full = [ 2.614000000000000E-003, -1.477000000000000E-003, -1.137000000000000E-003, -4.010475000000000E-002, 6.106710000000000E-003 ], ] -lkpm_of_cindex = - [ 1, 1, 2, 0, 0, 0, 2, 1, 1, 2, 3, 0, 2, 1, 3, 0, 0, 1, - 3, 1, 1, 0, 3, 1, 1, 3, 4, 0, 2, 2, 4, 0, 0, 2, 4, 1, - 3, 1, 4, 0, 1, 1, 4, 1, 2, 0, 4, 1, 0, 0, 4, 2, 1, 4, - 5, 0, 2, 3, 5, 0, 0, 3, 5, 1, 3, 2, 5, 0, 1, 2, 5, 1, - 4, 1, 5, 0, 2, 1, 5, 1, 0, 1, 5, 2, 3, 0, 5, 1, 1, 0, - 5, 2 ] - #+END_EXAMPLE +lkpm_of_cindex = [[1 , 1 , 2 , 0], + [0 , 0 , 2 , 1], + [1 , 2 , 3 , 0], + [2 , 1 , 3 , 0], + [0 , 1 , 3 , 1], + [1 , 0 , 3 , 1], + [1 , 3 , 4 , 0], + [2 , 2 , 4 , 0], + [0 , 2 , 4 , 1], + [3 , 1 , 4 , 0], + [1 , 1 , 4 , 1], + [2 , 0 , 4 , 1], + [0 , 0 , 4 , 2], + [1 , 4 , 5 , 0], + [2 , 3 , 5 , 0], + [0 , 3 , 5 , 1], + [3 , 2 , 5 , 0], + [1 , 2 , 5 , 1], + [4 , 1 , 5 , 0], + [2 , 1 , 5 , 1], + [0 , 1 , 5 , 2], + [3 , 0 , 5 , 1], + [1 , 0 , 5 , 2]] + +print(np.array(lkpm_of_cindex).reshape(4,dim_cord_vec)) + #+END_SRC + + #+RESULTS: jastrow_data + : [[1 1 2 0 0 0 2 1 1 2 3 0 2 1 3 0 0 1 3 1 1 0 3] + : [1 1 3 4 0 2 2 4 0 0 2 4 1 3 1 4 0 1 1 4 1 2 0] + : [4 1 0 0 4 2 1 4 5 0 2 3 5 0 0 3 5 1 3 2 5 0 1] + : [2 5 1 4 1 5 0 2 1 5 1 0 1 5 2 3 0 5 1 1 0 5 2]] ** Data structure @@ -156,7 +183,7 @@ typedef struct qmckl_jastrow_struct{ int64_t aord_num; int64_t bord_num; int64_t cord_num; - int64_t type_nuc_num; + int64_t type_nucl_num; int64_t asymp_jasb_date; int64_t tmp_c_date; int64_t dtmp_c_date; @@ -218,7 +245,7 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { qmckl_exit_code qmckl_get_jastrow_aord_num (qmckl_context context, int64_t* const aord_num); qmckl_exit_code qmckl_get_jastrow_bord_num (qmckl_context context, int64_t* const bord_num); qmckl_exit_code qmckl_get_jastrow_cord_num (qmckl_context context, int64_t* const bord_num); -qmckl_exit_code qmckl_get_jastrow_type_nuc_num (qmckl_context context, int64_t* const type_nuc_num); +qmckl_exit_code qmckl_get_jastrow_type_nucl_num (qmckl_context context, int64_t* const type_nucl_num); qmckl_exit_code qmckl_get_jastrow_aord_vector (qmckl_context context, double * const aord_vector); qmckl_exit_code qmckl_get_jastrow_bord_vector (qmckl_context context, double * const bord_vector); qmckl_exit_code qmckl_get_jastrow_cord_vector (qmckl_context context, double * const cord_vector); @@ -338,17 +365,17 @@ qmckl_exit_code qmckl_get_jastrow_cord_num (const qmckl_context context, int64_t return QMCKL_SUCCESS; } -qmckl_exit_code qmckl_get_type_nuc_num (const qmckl_context context, int64_t* const type_nuc_num) { +qmckl_exit_code qmckl_get_type_nucl_num (const qmckl_context context, int64_t* const type_nucl_num) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return (char) 0; } - if (type_nuc_num == NULL) { + if (type_nucl_num == NULL) { return qmckl_failwith( context, QMCKL_INVALID_ARG_2, - "qmckl_get_jastrow_type_nuc_num", - "type_nuc_num is a null pointer"); + "qmckl_get_jastrow_type_nucl_num", + "type_nucl_num is a null pointer"); } qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; @@ -360,8 +387,8 @@ qmckl_exit_code qmckl_get_type_nuc_num (const qmckl_context context, int64_t* co return (char) 0; } - assert (ctx->jastrow.type_nuc_num > 0); - *type_nuc_num = ctx->jastrow.type_nuc_num; + assert (ctx->jastrow.type_nucl_num > 0); + *type_nucl_num = ctx->jastrow.type_nucl_num; return QMCKL_SUCCESS; } @@ -455,7 +482,7 @@ qmckl_exit_code qmckl_get_cord_vector (const qmckl_context context, double * con #+begin_src c :comments org :tangle (eval h_func) qmckl_exit_code qmckl_set_jastrow_ord_num (qmckl_context context, const int64_t aord_num, const int64_t bord_num, const int64_t cord_num); -qmckl_exit_code qmckl_set_jastrow_type_nuc_num (qmckl_context context, const int64_t type_nuc_num); +qmckl_exit_code qmckl_set_jastrow_type_nucl_num (qmckl_context context, const int64_t type_nucl_num); qmckl_exit_code qmckl_set_jastrow_aord_vector (qmckl_context context, const double * aord_vector); qmckl_exit_code qmckl_set_jastrow_bord_vector (qmckl_context context, const double * bord_vector); qmckl_exit_code qmckl_set_jastrow_cord_vector (qmckl_context context, const double * cord_vector); @@ -517,18 +544,18 @@ qmckl_exit_code qmckl_set_jastrow_ord_num(qmckl_context context, const int64_t a <> } -qmckl_exit_code qmckl_set_jastrow_type_nuc_num(qmckl_context context, const int64_t type_nuc_num) { +qmckl_exit_code qmckl_set_jastrow_type_nucl_num(qmckl_context context, const int64_t type_nucl_num) { <> - if (type_nuc_num <= 0) { + if (type_nucl_num <= 0) { return qmckl_failwith( context, QMCKL_INVALID_ARG_2, - "qmckl_set_jastrow_type_nuc_num", - "type_nuc_num < 0"); + "qmckl_set_jastrow_type_nucl_num", + "type_nucl_num < 0"); } int32_t mask = 1 << 2; - ctx->jastrow.type_nuc_num = type_nuc_num; + ctx->jastrow.type_nucl_num = type_nucl_num; <> } @@ -539,7 +566,7 @@ qmckl_exit_code qmckl_set_jastrow_aord_vector(qmckl_context context, double cons int32_t mask = 1 << 3; int64_t aord_num; - int rc = qmckl_get_jastrow_aord_num(context, &aord_num); + qmckl_exit_code rc = qmckl_get_jastrow_aord_num(context, &aord_num); if (rc != QMCKL_SUCCESS) return rc; if (aord_num == 0) { @@ -589,7 +616,7 @@ qmckl_exit_code qmckl_set_jastrow_bord_vector(qmckl_context context, double cons int32_t mask = 1 << 4; int64_t bord_num; - int rc = qmckl_get_jastrow_bord_num(context, &bord_num); + qmckl_exit_code rc = qmckl_get_jastrow_bord_num(context, &bord_num); if (rc != QMCKL_SUCCESS) return rc; if (bord_num == 0) { @@ -639,7 +666,7 @@ qmckl_exit_code qmckl_set_jastrow_cord_vector(qmckl_context context, double cons int32_t mask = 1 << 5; int64_t cord_num; - int rc = qmckl_get_jastrow_cord_num(context, &cord_num); + qmckl_exit_code rc = qmckl_get_jastrow_cord_num(context, &cord_num); if (rc != QMCKL_SUCCESS) return rc; if (cord_num == 0) { @@ -743,7 +770,7 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { } /* Check for the nucleus data - 1. nuc_num + 1. nucl_num 2. en_distances_rescaled */ if (!(ctx->nucleus.provided)) { @@ -764,6 +791,107 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { } #+end_src +** Test + #+begin_src c :tangle (eval c_test) +/* Reference input data */ +int64_t walk_num = b2_walk_num; +int64_t elec_num = b2_elec_num; +int64_t elec_up_num = b2_elec_up_num; +int64_t elec_dn_num = b2_elec_dn_num; +double rescale_factor_kappa_ee = 1.0; +double rescale_factor_kappa_en = 1.0; +double nucl_rescale_factor_kappa = 1.0; +double* elec_coord = &(b2_elec_coord[0][0][0]); + +int64_t nucl_num = b2_nucl_num; +double* charge = b2_charge; +double* nucl_coord = &(b2_nucl_coord[0][0]); + +/* --- */ + +qmckl_exit_code rc; + +assert(!qmckl_electron_provided(context)); + +int64_t n; +rc = qmckl_get_electron_num (context, &n); +assert(rc == QMCKL_NOT_PROVIDED); + +rc = qmckl_get_electron_up_num (context, &n); +assert(rc == QMCKL_NOT_PROVIDED); + +rc = qmckl_get_electron_down_num (context, &n); +assert(rc == QMCKL_NOT_PROVIDED); + + +rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num); +assert(rc == QMCKL_SUCCESS); +assert(!qmckl_electron_provided(context)); + +rc = qmckl_get_electron_up_num (context, &n); +assert(rc == QMCKL_SUCCESS); +assert(n == elec_up_num); + +rc = qmckl_get_electron_down_num (context, &n); +assert(rc == QMCKL_SUCCESS); +assert(n == elec_dn_num); + +rc = qmckl_get_electron_num (context, &n); +assert(rc == QMCKL_SUCCESS); +assert(n == elec_num); + +double k_ee = 0.; +double k_en = 0.; +rc = qmckl_get_electron_rescale_factor_ee (context, &k_ee); +assert(rc == QMCKL_SUCCESS); +assert(k_ee == 1.0); + +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_electron_rescale_factor_en (context, &k_en); +assert(rc == QMCKL_SUCCESS); +assert(k_en == rescale_factor_kappa_en); + + +int64_t w; +rc = qmckl_get_electron_walk_num (context, &w); +assert(rc == QMCKL_NOT_PROVIDED); + + +rc = qmckl_set_electron_walk_num (context, walk_num); +assert(rc == QMCKL_SUCCESS); + +rc = qmckl_get_electron_walk_num (context, &w); +assert(rc == QMCKL_SUCCESS); +assert(w == walk_num); + +assert(qmckl_electron_provided(context)); + +rc = qmckl_set_electron_coord (context, 'N', elec_coord); +assert(rc == QMCKL_SUCCESS); + +double elec_coord2[walk_num*3*elec_num]; + +rc = qmckl_get_electron_coord (context, 'N', elec_coord2); +assert(rc == QMCKL_SUCCESS); +for (int64_t i=0 ; i<3*elec_num ; ++i) { + assert( elec_coord[i] == elec_coord2[i] ); + } + + #+end_src + * Computation The computed data is stored in the context so that it can be reused @@ -963,6 +1091,59 @@ end function qmckl_compute_asymp_jasb_f #+end_src *** Test + #+begin_src python :results output :exports none :noweb yes +import numpy as np + +<> + +kappa = 1.0 +kappa_inv = 1.0 + +asym_one = bord_vector[0] * kappa_inv / (1.0 + bord_vector[1]*kappa_inv) +asymp_jasb = np.array([asym_one, 0.5 * asym_one]) + +for i in range(2): + x = kappa_inv + for p in range(1,bord_num): + x = x * kappa_inv + asymp_jasb[i] += bord_vector[p + 1] * x + +print("asym_one : ", asym_one) +print("asymp_jasb : ", asymp_jasb) + #+end_src + + #+RESULTS: + : asym_one : 0.43340325572525706 + : asymp_jasb : [0.53237506 0.31567343] + + #+begin_src c :tangle (eval c_test) +assert(qmckl_electron_provided(context)); + + +double ee_distance[walk_num * elec_num * elec_num]; +rc = qmckl_get_electron_ee_distance(context, ee_distance); + +// (e1,e2,w) +// (0,0,0) == 0. +//assert(ee_distance[0] == 0.); +// +//// (1,0,0) == (0,1,0) +//assert(ee_distance[1] == ee_distance[elec_num]); +// +//// value of (1,0,0) +//assert(fabs(ee_distance[1]-7.152322512964209) < 1.e-12); +// +//// (0,0,1) == 0. +//assert(ee_distance[elec_num*elec_num] == 0.); +// +//// (1,0,1) == (0,1,1) +//assert(ee_distance[elec_num*elec_num+1] == ee_distance[elec_num*elec_num+elec_num]); +// +//// value of (1,0,1) +//assert(fabs(ee_distance[elec_num*elec_num+1]-6.5517646321055665) < 1.e-12); + + #+end_src + * End of files :noexport: @@ -972,7 +1153,7 @@ end function qmckl_compute_asymp_jasb_f *** Test #+begin_src c :tangle (eval c_test) - qmckl_exit_code rc = qmckl_context_destroy(context); + rc = qmckl_context_destroy(context); assert (rc == QMCKL_SUCCESS); return 0; diff --git a/tests/b2.h b/tests/b2.h new file mode 100644 index 0000000..bba2ebf --- /dev/null +++ b/tests/b2.h @@ -0,0 +1,106 @@ +#define b2_nucl_num ((int64_t) 2) + +double b2_charge[b2_nucl_num] = { 5., 5.}; + +double b2_nucl_coord[3][b2_nucl_num] = +{ {0.000000, 0.000000 }, + {0.000000, 0.000000 }, + {2.059801, 2.059801 } }; + +#define b2_elec_up_num ((int64_t) 5) +#define b2_elec_dn_num ((int64_t) 5) +#define b2_elec_num ((int64_t) 10) +#define b2_walk_num ((int64_t) 1) + +double b2_elec_coord[b2_walk_num][b2_elec_num][3] = { { + {-0.250655104764153 , 0.503070975550133 , -0.166554344502303}, + {-0.587812193472177 , -0.128751981129274 , 0.187773606533075}, + { 1.61335569047166 , -0.615556732874863 , -1.43165470979934 }, + {-4.901239896295210E-003 , -1.120440036458986E-002 , 1.99761909330422 }, + { 0.766647499681200 , -0.293515395797937 , 3.66454589201239 }, + {-0.127732483187947 , -0.138975497694196 , -8.669850480215846E-002}, + {-0.232271834949124 , -1.059321673434182E-002 , -0.504862241464867}, + { 1.09360863531826 , -2.036103063808752E-003 , -2.702796910818986E-002}, + {-0.108090166832043 , 0.189161729653261 , 2.15398313919894}, + { 0.397978144318712 , -0.254277292595981 , 2.54553335476344}}}; + +/* Jastrow related */ + +#define b2_type_nucl_num ((int64_t) 1) +#define b2_aord_num ((int64_t) 5) +#define b2_bord_num ((int64_t) 5) +#define b2_cord_num ((int64_t) 23) +#define b2_dim_cord_vec ((int64_t) 23) + +double b2_aord_vector[b2_aord_num + 1][b2_type_nucl_num] = { + { 0. }, + { 0. }, + {-0.380512}, + {-0.157996}, + {-0.031558}, + { 0.021512}}; + +double b2_bord_vector[b2_bord_num + 1] = { + 0.5 , + 0.15366 , + 0.0672262 , + 0.02157 , + 0.0073096 , + 0.002866 }; + +double b2_cord_vector[b2_cord_num][b2_type_nucl_num] = { + { 5.717020e-01}, + {-5.142530e-01}, + {-5.130430e-01}, + { 9.486000e-03}, + {-4.205000e-03}, + { 4.263258e-01}, + { 8.288150e-02}, + { 5.118600e-03}, + {-2.997800e-03}, + {-5.270400e-03}, + {-7.500000e-05}, + {-8.301650e-02}, + { 1.454340e-02}, + { 5.143510e-02}, + { 9.250000e-04}, + {-4.099100e-03}, + { 4.327600e-03}, + {-1.654470e-03}, + { 2.614000e-03}, + {-1.477000e-03}, + {-1.137000e-03}, + {-4.010475e-02}, + { 6.106710e-03}}; + +double b2_cord_vector_full[b2_dim_cord_vec][b2_nucl_num] = { + { 5.717020e-01, 5.717020e-01}, + {-5.142530e-01, -5.142530e-01}, + {-5.130430e-01, -5.130430e-01}, + { 9.486000e-03, 9.486000e-03}, + {-4.205000e-03, -4.205000e-03}, + { 4.263258e-01, 4.263258e-01}, + { 8.288150e-02, 8.288150e-02}, + { 5.118600e-03, 5.118600e-03}, + {-2.997800e-03, -2.997800e-03}, + {-5.270400e-03, -5.270400e-03}, + {-7.500000e-05, -7.500000e-05}, + {-8.301650e-02, -8.301650e-02}, + { 1.454340e-02, 1.454340e-02}, + { 5.143510e-02, 5.143510e-02}, + { 9.250000e-04, 9.250000e-04}, + {-4.099100e-03, -4.099100e-03}, + { 4.327600e-03, 4.327600e-03}, + {-1.654470e-03, -1.654470e-03}, + { 2.614000e-03, 2.614000e-03}, + {-1.477000e-03, -1.477000e-03}, + {-1.137000e-03, -1.137000e-03}, + {-4.010475e-02, -4.010475e-02}, + { 6.106710e-03, 6.106710e-03}}; + +double b2_lkpm_of_cindex[4][b2_dim_cord_vec] = { + {1, 1, 2, 0, 0, 0, 2, 1, 1, 2, 3, 0, 2, 1, 3, 0, 0, 1, 3, 1, 1, 0, 3}, + {1, 1, 3, 4, 0, 2, 2, 4, 0, 0, 2, 4, 1, 3, 1, 4, 0, 1, 1, 4, 1, 2, 0}, + {4, 1, 0, 0, 4, 2, 1, 4, 5, 0, 2, 3, 5, 0, 0, 3, 5, 1, 3, 2, 5, 0, 1}, + {2, 5, 1, 4, 1, 5, 0, 2, 1, 5, 1, 0, 1, 5, 2, 3, 0, 5, 1, 1, 0, 5, 2}}; + From f005f587e73be830b69429bc2d48f5d4bc84344a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 25 Jun 2021 17:37:45 +0200 Subject: [PATCH 27/92] Error in FOrtran interface fixed --- org/qmckl_ao.org | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index 4e7f97c..3fe9afd 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -1087,7 +1087,7 @@ interface end function end interface interface - integer(c_int32_t) function qmckl_set_ao_basis_nucleus_shell_ang_mom(context,shell_ang_mom) & + integer(c_int32_t) function qmckl_set_ao_basis_shell_ang_mom(context,shell_ang_mom) & bind(C) use, intrinsic :: iso_c_binding import @@ -1097,7 +1097,7 @@ interface end function end interface interface - integer(c_int32_t) function qmckl_set_ao_basis_nucleus_shell_prim_num(context,shell_prim_num) & + integer(c_int32_t) function qmckl_set_ao_basis_shell_prim_num(context,shell_prim_num) & bind(C) use, intrinsic :: iso_c_binding import @@ -1107,7 +1107,7 @@ interface end function end interface interface - integer(c_int32_t) function qmckl_set_ao_basis_nucleus_shell_prim_index(context,shell_prim_index) & + integer(c_int32_t) function qmckl_set_ao_basis_shell_prim_index(context,shell_prim_index) & bind(C) use, intrinsic :: iso_c_binding import @@ -1117,7 +1117,7 @@ interface end function end interface interface - integer(c_int32_t) function qmckl_set_ao_basis_nucleus_shell_factor(context,shell_factor) & + integer(c_int32_t) function qmckl_set_ao_basis_shell_factor(context,shell_factor) & bind(C) use, intrinsic :: iso_c_binding import @@ -1127,7 +1127,7 @@ interface end function end interface interface - integer(c_int32_t) function qmckl_set_ao_basis_nucleus_exponent(context,exponent) & + integer(c_int32_t) function qmckl_set_ao_basis_exponent(context,exponent) & bind(C) use, intrinsic :: iso_c_binding import @@ -1137,7 +1137,7 @@ interface end function end interface interface - integer(c_int32_t) function qmckl_set_ao_basis_nucleus_coefficient(context,coefficient) & + integer(c_int32_t) function qmckl_set_ao_basis_coefficient(context,coefficient) & bind(C) use, intrinsic :: iso_c_binding import @@ -1147,7 +1147,7 @@ interface end function end interface interface - integer(c_int32_t) function qmckl_set_ao_basis_nucleus_prim_factor(context,prim_factor) & + integer(c_int32_t) function qmckl_set_ao_basis_prim_factor(context,prim_factor) & bind(C) use, intrinsic :: iso_c_binding import From 04ed140e857c063cd992cf8c3716faedf654298b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sun, 27 Jun 2021 15:48:46 +0200 Subject: [PATCH 28/92] Added missing Fortran interfaces --- org/qmckl_ao.org | 14 ++++++++++++++ org/qmckl_electron.org | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index 3fe9afd..1bd3de0 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -1848,6 +1848,20 @@ qmckl_exit_code qmckl_get_ao_basis_shell_vgl(qmckl_context context, double* cons } #+end_src + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none + interface + integer(c_int32_t) function qmckl_get_ao_basis_shell_vgl (context, shell_vgl) & + bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + + integer (c_int64_t) , intent(in) , value :: context + double precision, intent(out) :: shell_vgl(*) + end function + end interface + #+end_src + *** Provide #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none diff --git a/org/qmckl_electron.org b/org/qmckl_electron.org index 742ba56..b4b6624 100644 --- a/org/qmckl_electron.org +++ b/org/qmckl_electron.org @@ -608,6 +608,30 @@ qmckl_set_electron_rescale_factor_en(qmckl_context context, return QMCKL_SUCCESS; } + #+end_src + + #+begin_src f90 :comments org :tangle (eval fh_func) :noweb yes +interface + integer(c_int32_t) function qmckl_set_electron_num(context, alpha, beta) bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: alpha + integer (c_int64_t) , intent(in) , value :: beta + end function +end interface +interface + integer(c_int32_t) function qmckl_set_electron_walk_num(context, walk_num) bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: walk_num + end function +end interface #+end_src The following function sets the electron coordinates of all the @@ -697,6 +721,20 @@ qmckl_set_electron_coord(qmckl_context context, const char transp, const double* } #+end_src + #+begin_src f90 :comments org :tangle (eval fh_func) :noweb yes +interface + integer(c_int32_t) function qmckl_set_electron_coord(context, transp, coord) bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + + integer (c_int64_t) , intent(in) , value :: context + character , intent(in) , value :: transp + double precision , intent(in) :: coord(*) + end function +end interface + #+end_src + ** Test #+begin_src python :results output :exports none From f9219ad204c022d7b4ba8a27bf511a8970b1ed85 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sun, 4 Jul 2021 15:19:57 +0200 Subject: [PATCH 29/92] Added fortran interfaces --- org/qmckl_electron.org | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/org/qmckl_electron.org b/org/qmckl_electron.org index b4b6624..6587f4a 100644 --- a/org/qmckl_electron.org +++ b/org/qmckl_electron.org @@ -860,6 +860,20 @@ for (int64_t i=0 ; i<3*elec_num ; ++i) { qmckl_exit_code qmckl_get_electron_ee_distance(qmckl_context context, double* const distance); #+end_src + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none +interface + integer(c_int32_t) function qmckl_get_electron_ee_distance(context, distance) & + bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + integer (c_int64_t) , intent(in) , value :: context + real (c_double ) , intent(out) :: distance(*) + end function +end interface + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none qmckl_exit_code qmckl_get_electron_ee_distance(qmckl_context context, double* const distance) { @@ -1561,6 +1575,19 @@ rc = qmckl_get_electron_ee_distance_rescaled_deriv_e(context, ee_distance_rescal qmckl_exit_code qmckl_get_electron_en_distance(qmckl_context context, double* distance); #+end_src + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none +interface + integer(c_int32_t) function qmckl_get_electron_en_distance(context, distance) & + bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + integer (c_int64_t) , intent(in) , value :: context + real (c_double ) , intent(out) :: distance(*) + end function +end interface + #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none qmckl_exit_code qmckl_get_electron_en_distance(qmckl_context context, double* distance) { From ad824d0f7174d3105c0ec797c376b494a8c05a9d Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Mon, 5 Jul 2021 14:37:09 +0530 Subject: [PATCH 30/92] Renamed test file to n2 and fixed a few bugs. #162 --- org/qmckl_jastrow.org | 257 +++++++++++++++++++++++++++-------------- org/table_of_contents | 1 + tests/{b2.h => n2.h} | 36 +++--- tools/build_qmckl_h.sh | 26 ++--- 4 files changed, 204 insertions(+), 116 deletions(-) rename tests/{b2.h => n2.h} (76%) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 90d4cf6..5830ebb 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -27,7 +27,8 @@ these factors along with their derivatives. #include "config.h" #endif -#include "b2.h" +#include +#include "n2.h" int main() { qmckl_context context; @@ -71,33 +72,33 @@ int main() { The following data stored in the context: #+NAME: qmckl_jastrow_args - |------------+-------------------------------------------+-----+-------------------------------------------------------------------| - | ~int32_t~ | ~uninitialized~ | in | Keeps bit set for uninitialized data | - | ~int64_t~ | ~aord_num~ | in | The number of a coeffecients | - | ~int64_t~ | ~bord_num~ | in | The number of b coeffecients | - | ~int64_t~ | ~cord_num~ | in | The number of c coeffecients | + |------------+--------------------------------------------+-----+-------------------------------------------------------------------| + | ~int32_t~ | ~uninitialized~ | in | Keeps bit set for uninitialized data | + | ~int64_t~ | ~aord_num~ | in | The number of a coeffecients | + | ~int64_t~ | ~bord_num~ | in | The number of b coeffecients | + | ~int64_t~ | ~cord_num~ | in | The number of c coeffecients | | ~uint64_t~ | ~type_nucl_num~ | in | Number of Nucleii types | | ~double~ | ~aord_vector[aord_num + 1][type_nucl_num]~ | in | Order of a polynomial coefficients | - | ~double~ | ~bord_vector[bord_num + 1]~ | in | Order of b polynomial coefficients | + | ~double~ | ~bord_vector[bord_num + 1]~ | in | Order of b polynomial coefficients | | ~double~ | ~cord_vector[cord_num][type_nucl_num]~ | in | Order of c polynomial coefficients | - | ~double~ | ~factor_ee~ | out | Jastrow factor: electron-electron part | - | ~double~ | ~factor_ee_date~ | out | Jastrow factor: electron-electron part | - | ~double~ | ~factor_en~ | out | Jastrow factor: electron-nucleus part | - | ~double~ | ~factor_en_date~ | out | Jastrow factor: electron-nucleus part | - | ~double~ | ~factor_een~ | out | Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_een_date~ | out | Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_ee_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_en_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_een_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_ee~ | out | Jastrow factor: electron-electron part | + | ~double~ | ~factor_ee_date~ | out | Jastrow factor: electron-electron part | + | ~double~ | ~factor_en~ | out | Jastrow factor: electron-nucleus part | + | ~double~ | ~factor_en_date~ | out | Jastrow factor: electron-nucleus part | + | ~double~ | ~factor_een~ | out | Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_een_date~ | out | Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_ee_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_en_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_een_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | computed data: - |-----------+--------------------------------------------------+-------------------------------------------------| - | ~int64_t~ | ~dim_cord_vec~ | Number of unique C coefficients | - | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | - | ~int64_t~ | ~asymp_jasb_date~ | Asymptotic component | + |-----------+---------------------------------------------------+-------------------------------------------------| + | ~int64_t~ | ~dim_cord_vec~ | Number of unique C coefficients | + | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | + | ~int64_t~ | ~asymp_jasb_date~ | Asymptotic component | | ~double~ | ~coord_vect_full[dim_cord_vec][nucl_num]~ | vector of non-zero coefficients | - | ~int64_t~ | ~lkpm_of_cindex[4][dim_cord_vec]~ | Transform l,k,p, and m into consecutive indices | + | ~int64_t~ | ~lkpm_of_cindex[4][dim_cord_vec]~ | Transform l,k,p, and m into consecutive indices | | ~double~ | ~tmp_c[elec_num][nucl_num][ncord + 1][ncord]~ | vector of non-zero coefficients | | ~double~ | ~dtmp_c[elec_num][4][nucl_num][ncord + 1][ncord]~ | vector of non-zero coefficients | @@ -166,14 +167,9 @@ lkpm_of_cindex = [[1 , 1 , 2 , 0], [3 , 0 , 5 , 1], [1 , 0 , 5 , 2]] -print(np.array(lkpm_of_cindex).reshape(4,dim_cord_vec)) #+END_SRC #+RESULTS: jastrow_data - : [[1 1 2 0 0 0 2 1 1 2 3 0 2 1 3 0 0 1 3 1 1 0 3] - : [1 1 3 4 0 2 2 4 0 0 2 4 1 3 1 4 0 1 1 4 1 2 0] - : [4 1 0 0 4 2 1 4 5 0 2 3 5 0 0 3 5 1 3 2 5 0 1] - : [2 5 1 4 1 5 0 2 1 5 1 0 1 5 2 3 0 5 1 1 0 5 2]] ** Data structure @@ -231,7 +227,7 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - ctx->jastrow.uninitialized = (1 << 6) - 1; + ctx->jastrow.uninitialized = (1 << 5) - 1; /* Default values */ @@ -245,7 +241,7 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { qmckl_exit_code qmckl_get_jastrow_aord_num (qmckl_context context, int64_t* const aord_num); qmckl_exit_code qmckl_get_jastrow_bord_num (qmckl_context context, int64_t* const bord_num); qmckl_exit_code qmckl_get_jastrow_cord_num (qmckl_context context, int64_t* const bord_num); -qmckl_exit_code qmckl_get_jastrow_type_nucl_num (qmckl_context context, int64_t* const type_nucl_num); +qmckl_exit_code qmckl_get_jastrow_type_nucl_num (qmckl_context context, int64_t* const type_nucl_num); qmckl_exit_code qmckl_get_jastrow_aord_vector (qmckl_context context, double * const aord_vector); qmckl_exit_code qmckl_get_jastrow_bord_vector (qmckl_context context, double * const bord_vector); qmckl_exit_code qmckl_get_jastrow_cord_vector (qmckl_context context, double * const cord_vector); @@ -303,7 +299,7 @@ qmckl_exit_code qmckl_get_jastrow_aord_num (const qmckl_context context, int64_t int32_t mask = 1 << 0; if ( (ctx->jastrow.uninitialized & mask) != 0) { - return (char) 0; + return QMCKL_NOT_PROVIDED; } assert (ctx->jastrow.aord_num > 0); @@ -330,7 +326,7 @@ qmckl_exit_code qmckl_get_jastrow_bord_num (const qmckl_context context, int64_t int32_t mask = 1 << 0; if ( (ctx->jastrow.uninitialized & mask) != 0) { - return (char) 0; + return QMCKL_NOT_PROVIDED; } assert (ctx->jastrow.bord_num > 0); @@ -357,7 +353,7 @@ qmckl_exit_code qmckl_get_jastrow_cord_num (const qmckl_context context, int64_t int32_t mask = 1 << 0; if ( (ctx->jastrow.uninitialized & mask) != 0) { - return (char) 0; + return QMCKL_NOT_PROVIDED; } assert (ctx->jastrow.cord_num > 0); @@ -365,7 +361,7 @@ qmckl_exit_code qmckl_get_jastrow_cord_num (const qmckl_context context, int64_t return QMCKL_SUCCESS; } -qmckl_exit_code qmckl_get_type_nucl_num (const qmckl_context context, int64_t* const type_nucl_num) { +qmckl_exit_code qmckl_get_jastrow_type_nucl_num (const qmckl_context context, int64_t* const type_nucl_num) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return (char) 0; @@ -381,10 +377,10 @@ qmckl_exit_code qmckl_get_type_nucl_num (const qmckl_context context, int64_t* c qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 2; + int32_t mask = 1 << 1; if ( (ctx->jastrow.uninitialized & mask) != 0) { - return (char) 0; + return QMCKL_NOT_PROVIDED; } assert (ctx->jastrow.type_nucl_num > 0); @@ -392,7 +388,7 @@ qmckl_exit_code qmckl_get_type_nucl_num (const qmckl_context context, int64_t* c return QMCKL_SUCCESS; } -qmckl_exit_code qmckl_get_aord_vector (const qmckl_context context, double * const aord_vector) { +qmckl_exit_code qmckl_get_jastrow_aord_vector (const qmckl_context context, double * const aord_vector) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return (char) 0; @@ -408,10 +404,10 @@ qmckl_exit_code qmckl_get_aord_vector (const qmckl_context context, double * con 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->jastrow.uninitialized & mask) != 0) { - return (char) 0; + return QMCKL_NOT_PROVIDED; } assert (ctx->jastrow.aord_vector != NULL); @@ -419,7 +415,7 @@ qmckl_exit_code qmckl_get_aord_vector (const qmckl_context context, double * con return QMCKL_SUCCESS; } -qmckl_exit_code qmckl_get_bord_vector (const qmckl_context context, double * const bord_vector) { +qmckl_exit_code qmckl_get_jastrow_bord_vector (const qmckl_context context, double * const bord_vector) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return (char) 0; @@ -438,7 +434,7 @@ qmckl_exit_code qmckl_get_bord_vector (const qmckl_context context, double * con int32_t mask = 1 << 3; if ( (ctx->jastrow.uninitialized & mask) != 0) { - return (char) 0; + return QMCKL_NOT_PROVIDED; } assert (ctx->jastrow.bord_vector != NULL); @@ -446,7 +442,7 @@ qmckl_exit_code qmckl_get_bord_vector (const qmckl_context context, double * con return QMCKL_SUCCESS; } -qmckl_exit_code qmckl_get_cord_vector (const qmckl_context context, double * const cord_vector) { +qmckl_exit_code qmckl_get_jastrow_cord_vector (const qmckl_context context, double * const cord_vector) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return (char) 0; @@ -462,10 +458,10 @@ qmckl_exit_code qmckl_get_cord_vector (const qmckl_context context, double * con qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 3; + int32_t mask = 1 << 4; if ( (ctx->jastrow.uninitialized & mask) != 0) { - return (char) 0; + return QMCKL_NOT_PROVIDED; } assert (ctx->jastrow.cord_vector != NULL); @@ -503,8 +499,8 @@ qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; ctx->jastrow.uninitialized &= ~mask; ctx->jastrow.provided = (ctx->jastrow.uninitialized == 0); if (ctx->jastrow.provided) { - qmckl_exit_code rc_ = qmckl_finalize_basis(context); - if (rc_ != QMCKL_SUCCESS) return rc_; + //qmckl_exit_code rc_ = qmckl_set_jastrow_dependencies(context); + //if (rc_ != QMCKL_SUCCESS) return rc_; } return QMCKL_SUCCESS; @@ -536,7 +532,7 @@ qmckl_exit_code qmckl_set_jastrow_ord_num(qmckl_context context, const int64_t a "cord_num <= 0"); } - int32_t mask = 1 << 1; + int32_t mask = 1 << 0; ctx->jastrow.aord_num = aord_num; ctx->jastrow.bord_num = bord_num; ctx->jastrow.cord_num = cord_num; @@ -554,7 +550,7 @@ qmckl_exit_code qmckl_set_jastrow_type_nucl_num(qmckl_context context, const int "type_nucl_num < 0"); } - int32_t mask = 1 << 2; + int32_t mask = 1 << 1; ctx->jastrow.type_nucl_num = type_nucl_num; <> @@ -563,12 +559,16 @@ qmckl_exit_code qmckl_set_jastrow_type_nucl_num(qmckl_context context, const int qmckl_exit_code qmckl_set_jastrow_aord_vector(qmckl_context context, double const * aord_vector) { <> - int32_t mask = 1 << 3; + int32_t mask = 1 << 2; int64_t aord_num; qmckl_exit_code rc = qmckl_get_jastrow_aord_num(context, &aord_num); if (rc != QMCKL_SUCCESS) return rc; + int64_t type_nucl_num; + rc = qmckl_get_jastrow_type_nucl_num(context, &type_nucl_num); + if (rc != QMCKL_SUCCESS) return rc; + if (aord_num == 0) { return qmckl_failwith( context, QMCKL_FAILURE, @@ -593,7 +593,7 @@ qmckl_exit_code qmckl_set_jastrow_aord_vector(qmckl_context context, double cons } qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; - mem_info.size = aord_num * sizeof(double); + mem_info.size = (aord_num + 1) * type_nucl_num * sizeof(double); double* new_array = (double*) qmckl_malloc(context, mem_info); if(new_array == NULL) { @@ -613,7 +613,7 @@ qmckl_exit_code qmckl_set_jastrow_aord_vector(qmckl_context context, double cons qmckl_exit_code qmckl_set_jastrow_bord_vector(qmckl_context context, double const * bord_vector) { <> - int32_t mask = 1 << 4; + int32_t mask = 1 << 3; int64_t bord_num; qmckl_exit_code rc = qmckl_get_jastrow_bord_num(context, &bord_num); @@ -643,7 +643,7 @@ qmckl_exit_code qmckl_set_jastrow_bord_vector(qmckl_context context, double cons } qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; - mem_info.size = bord_num * sizeof(double); + mem_info.size = (bord_num + 1) * sizeof(double); double* new_array = (double*) qmckl_malloc(context, mem_info); if(new_array == NULL) { @@ -663,11 +663,15 @@ qmckl_exit_code qmckl_set_jastrow_bord_vector(qmckl_context context, double cons qmckl_exit_code qmckl_set_jastrow_cord_vector(qmckl_context context, double const * cord_vector) { <> - int32_t mask = 1 << 5; + int32_t mask = 1 << 4; int64_t cord_num; qmckl_exit_code rc = qmckl_get_jastrow_cord_num(context, &cord_num); if (rc != QMCKL_SUCCESS) return rc; + + int64_t type_nucl_num; + rc = qmckl_get_jastrow_type_nucl_num(context, &type_nucl_num); + if (rc != QMCKL_SUCCESS) return rc; if (cord_num == 0) { return qmckl_failwith( context, @@ -693,7 +697,7 @@ qmckl_exit_code qmckl_set_jastrow_cord_vector(qmckl_context context, double cons } qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; - mem_info.size = cord_num * sizeof(double); + mem_info.size = cord_num * type_nucl_num * sizeof(double); double* new_array = (double*) qmckl_malloc(context, mem_info); if(new_array == NULL) { @@ -729,7 +733,7 @@ qmckl_exit_code qmckl_set_jastrow_dependencies(qmckl_context context) { NULL); } - int32_t mask = 1 << 6; + int32_t mask = 1 << 5; <> } @@ -794,20 +798,21 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { ** Test #+begin_src c :tangle (eval c_test) /* Reference input data */ -int64_t walk_num = b2_walk_num; -int64_t elec_num = b2_elec_num; -int64_t elec_up_num = b2_elec_up_num; -int64_t elec_dn_num = b2_elec_dn_num; +int64_t walk_num = n2_walk_num; +int64_t elec_num = n2_elec_num; +int64_t elec_up_num = n2_elec_up_num; +int64_t elec_dn_num = n2_elec_dn_num; double rescale_factor_kappa_ee = 1.0; double rescale_factor_kappa_en = 1.0; double nucl_rescale_factor_kappa = 1.0; -double* elec_coord = &(b2_elec_coord[0][0][0]); +double* elec_coord = &(n2_elec_coord[0][0][0]); -int64_t nucl_num = b2_nucl_num; -double* charge = b2_charge; -double* nucl_coord = &(b2_nucl_coord[0][0]); +const double* nucl_charge = n2_charge; +int64_t nucl_num = n2_nucl_num; +double* charge = n2_charge; +double* nucl_coord = &(n2_nucl_coord[0][0]); -/* --- */ +/* Provide Electron data */ qmckl_exit_code rc; @@ -890,6 +895,75 @@ for (int64_t i=0 ; i<3*elec_num ; ++i) { assert( elec_coord[i] == elec_coord2[i] ); } + +/* Provide Nucleus data */ + +assert(!qmckl_nucleus_provided(context)); + +rc = qmckl_get_nucleus_num (context, &n); +assert(rc == QMCKL_NOT_PROVIDED); + + +rc = qmckl_set_nucleus_num (context, nucl_num); +assert(rc == QMCKL_SUCCESS); +assert(!qmckl_nucleus_provided(context)); + +rc = qmckl_get_nucleus_num (context, &n); +assert(rc == QMCKL_SUCCESS); +assert(n == nucl_num); + +double k; +rc = qmckl_get_nucleus_rescale_factor (context, &k); +assert(rc == QMCKL_SUCCESS); +assert(k == 1.0); + + +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); + +double nucl_coord2[3*nucl_num]; + +rc = qmckl_get_nucleus_coord (context, 'T', nucl_coord2); +assert(rc == QMCKL_NOT_PROVIDED); + +rc = qmckl_set_nucleus_coord (context, 'T', &(nucl_coord[0])); +assert(rc == QMCKL_SUCCESS); + +assert(!qmckl_nucleus_provided(context)); + +rc = qmckl_get_nucleus_coord (context, 'N', nucl_coord2); +assert(rc == QMCKL_SUCCESS); +for (size_t k=0 ; k<3 ; ++k) { + for (size_t i=0 ; i ${OUTPUT} * ------------------------------------------ * QMCkl - Quantum Monte Carlo kernel library * ------------------------------------------ - * + * * Documentation : https://trex-coe.github.io/qmckl * Issues : https://github.com/trex-coe/qmckl/issues - * + * * BSD 3-Clause License - * + * * Copyright (c) 2020, TREX Center of Excellence * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -76,10 +76,10 @@ cat << EOF > ${OUTPUT} * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * - * + * + * + * + * */ #ifndef __QMCKL_H__ @@ -92,7 +92,7 @@ EOF for i in ${HEADERS} do - header=${srcdir}/src/$i + header=${srcdir}/src/$i if [[ -f $header ]] ; then echo "/* $header */" >> ${OUTPUT} cat $header >> ${OUTPUT} From 360587ef36cf7821851648c17fbb868c4cec289d Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Mon, 5 Jul 2021 18:32:05 +0530 Subject: [PATCH 31/92] Factor ee implemented. #22 --- org/qmckl_jastrow.org | 408 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 387 insertions(+), 21 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 5830ebb..df09b9c 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -81,26 +81,26 @@ int main() { | ~double~ | ~aord_vector[aord_num + 1][type_nucl_num]~ | in | Order of a polynomial coefficients | | ~double~ | ~bord_vector[bord_num + 1]~ | in | Order of b polynomial coefficients | | ~double~ | ~cord_vector[cord_num][type_nucl_num]~ | in | Order of c polynomial coefficients | - | ~double~ | ~factor_ee~ | out | Jastrow factor: electron-electron part | + | ~double~ | ~factor_ee[walk_num]~ | out | Jastrow factor: electron-electron part | | ~double~ | ~factor_ee_date~ | out | Jastrow factor: electron-electron part | - | ~double~ | ~factor_en~ | out | Jastrow factor: electron-nucleus part | + | ~double~ | ~factor_en[walk_num]~ | out | Jastrow factor: electron-nucleus part | | ~double~ | ~factor_en_date~ | out | Jastrow factor: electron-nucleus part | - | ~double~ | ~factor_een~ | out | Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_een[walk_num]~ | out | Jastrow factor: electron-electron-nucleus part | | ~double~ | ~factor_een_date~ | out | Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_ee_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_en_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_een_deriv_e[4][nelec]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_ee_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_en_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_een_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | computed data: - |-----------+---------------------------------------------------+-------------------------------------------------| - | ~int64_t~ | ~dim_cord_vec~ | Number of unique C coefficients | - | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | - | ~int64_t~ | ~asymp_jasb_date~ | Asymptotic component | - | ~double~ | ~coord_vect_full[dim_cord_vec][nucl_num]~ | vector of non-zero coefficients | - | ~int64_t~ | ~lkpm_of_cindex[4][dim_cord_vec]~ | Transform l,k,p, and m into consecutive indices | - | ~double~ | ~tmp_c[elec_num][nucl_num][ncord + 1][ncord]~ | vector of non-zero coefficients | - | ~double~ | ~dtmp_c[elec_num][4][nucl_num][ncord + 1][ncord]~ | vector of non-zero coefficients | + |-----------+-------------------------------------------------------------+-------------------------------------------------| + | ~int64_t~ | ~dim_cord_vec~ | Number of unique C coefficients | + | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | + | ~int64_t~ | ~asymp_jasb_date~ | Asymptotic component | + | ~double~ | ~coord_vect_full[dim_cord_vec][nucl_num]~ | vector of non-zero coefficients | + | ~int64_t~ | ~lkpm_of_cindex[4][dim_cord_vec]~ | Transform l,k,p, and m into consecutive indices | + | ~double~ | ~tmp_c[elec_num][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | + | ~double~ | ~dtmp_c[elec_num][4][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | For H2O we have the following data: @@ -108,6 +108,68 @@ int main() { #+BEGIN_SRC python :results output import numpy as np +elec_num = 10 +nucl_num = 2 +up_num = 5 +down_num = 5 +nucl_coord = [ [0.000000, 0.000000 ], + [0.000000, 0.000000 ], + [2.059801, 2.059801 ] ] + +elec_coord = [[[-0.250655104764153 , 0.503070975550133 , -0.166554344502303], + [-0.587812193472177 , -0.128751981129274 , 0.187773606533075], + [ 1.61335569047166 , -0.615556732874863 , -1.43165470979934 ], + [-4.901239896295210E-003 , -1.120440036458986E-002 , 1.99761909330422 ], + [ 0.766647499681200 , -0.293515395797937 , 3.66454589201239 ], + [-0.127732483187947 , -0.138975497694196 , -8.669850480215846E-002], + [-0.232271834949124 , -1.059321673434182E-002 , -0.504862241464867], + [ 1.09360863531826 , -2.036103063808752E-003 , -2.702796910818986E-002], + [-0.108090166832043 , 0.189161729653261 , 2.15398313919894], + [ 0.397978144318712 , -0.254277292595981 , 2.54553335476344]]]; + +ee_distance_rescaled = [ +[ 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000], +[ 0.550227800352402 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000], +[ 0.919155060185168 ,0.937695909123175 ,0.000000000000000E+000, + 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000], +[ 0.893325429242815 ,0.851181978173561 ,0.978501685226877 , + 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000], +[ 0.982457268305353 ,0.976125002619471 ,0.994349933143149 , + 0.844077311588328 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000], +[ 0.482407528408731 ,0.414816073699124 ,0.894716035479343 , + 0.876540187084407 ,0.978921170036895 ,0.000000000000000E+000, + 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000], +[ 0.459541909660400 ,0.545007215761510 ,0.883752955884551 , + 0.918958134888791 ,0.986386936267237 ,0.362209822236419 , + 0.000000000000000E+000 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000], +[ 0.763732576854455 ,0.817282762358449 ,0.801802919535959 , + 0.900089095449775 ,0.975704636491453 ,0.707836537586060 , + 0.755705808346586 ,0.000000000000000E+000 ,0.000000000000000E+000, + 0.000000000000000E+000], +[ 0.904249454052971 ,0.871097965261373 ,0.982717262706270 , + 0.239901207363622 ,0.836519456769083 ,0.896135326270534 , + 0.930694340243023 ,0.917708540815567 ,0.000000000000000E+000, + 0.000000000000000E+000], +[ 0.944400908070716 ,0.922589018494961 ,0.984615718580670 , + 0.514328661540623 ,0.692362267147064 ,0.931894098453677 , + 0.956034127544344 ,0.931221472309472 ,0.540903688625053 , + 0.000000000000000E+000]] + + type_nucl_num = 1 aord_num = 5 bord_num = 5 @@ -167,8 +229,10 @@ lkpm_of_cindex = [[1 , 1 , 2 , 0], [3 , 0 , 5 , 1], [1 , 0 , 5 , 2]] +kappa = 1.0 +kappa_inv = 1.0/kappa #+END_SRC - + #+RESULTS: jastrow_data ** Data structure @@ -976,7 +1040,7 @@ assert(qmckl_nucleus_provided(context)); compute. If it is the case, then the data is recomputed and the current date is stored. -** Asymptotic component for \(J_{ee}\) +** Asymptotic component for \(f_{ee}\) Calculate the asymptotic component ~asymp_jasb~ to be substracted from the final electron-electron jastrow factor \(f_{ee}\). The asymptotic componenet is calculated @@ -1107,13 +1171,11 @@ integer function qmckl_compute_asymp_jasb_f(context, bord_num, bord_vector, resc info = QMCKL_INVALID_CONTEXT return endif - print *,"In Compute 1", asym_one if (bord_num <= 0) then info = QMCKL_INVALID_ARG_2 return endif - print *,"In Compute 2", asym_one asym_one = bord_vector(1) * kappa_inv / (1.0d0 + bord_vector(2) * kappa_inv) asymp_jasb(:) = (/asym_one, 0.5d0 * asym_one/) @@ -1167,14 +1229,12 @@ end function qmckl_compute_asymp_jasb_f #+end_src *** Test + #+name: asymp_jasb #+begin_src python :results output :exports none :noweb yes import numpy as np <> -kappa = 1.0 -kappa_inv = 1.0 - asym_one = bord_vector[0] * kappa_inv / (1.0 + bord_vector[1]*kappa_inv) asymp_jasb = np.array([asym_one, 0.5 * asym_one]) @@ -1189,6 +1249,11 @@ print("asymp_jasb[0] : ", asymp_jasb[0]) print("asymp_jasb[1] : ", asymp_jasb[1]) #+end_src + #+RESULTS: asymp_jasb + : asym_one : 0.6634291325000664 + : asymp_jasb[0] : 1.043287918508297 + : asymp_jasb[1] : 0.7115733522582638 + #+RESULTS: : asym_one : 0.43340325572525706 : asymp_jasb[0] : 0.5323750557252571 @@ -1232,6 +1297,307 @@ assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); #+end_src + +** Electron-electron component \(f_{ee}\) + + Calculate the asymptotic component ~asymp_jasb~ to be substracted from the final + electron-electron jastrow factor \(f_{ee}\). The asymptotic componenet is calculated + via the ~bord_vector~ and the electron-electron rescale factor ~rescale_factor_kappa~. + + \[ +f_{ee} = \sum_{i,jjastrow.factor_ee, ctx->electron.walk_num*sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide :noexport: + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_factor_ee(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_factor_ee(qmckl_context context) +{ + + qmckl_exit_code rc; + + 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); + + /* Check if ee rescaled distance is provided */ + rc = qmckl_provide_ee_distance_rescaled(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.factor_ee_date) { + + /* Allocate array */ + if (ctx->jastrow.factor_ee == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->electron.walk_num * sizeof(double); + double* factor_ee = (double*) qmckl_malloc(context, mem_info); + + if (factor_ee == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_provide_factor_ee", + NULL); + } + ctx->jastrow.factor_ee = factor_ee; + } + + qmckl_exit_code rc = + qmckl_compute_factor_ee(context, + ctx->electron.walk_num, + ctx->electron.num, + ctx->electron.up_num, + ctx->jastrow.bord_num, + ctx->jastrow.bord_vector, + ctx->electron.ee_distance_rescaled, + ctx->jastrow.asymp_jasb, + ctx->jastrow.factor_ee); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.factor_ee_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute + :PROPERTIES: + :Name: qmckl_compute_factor_ee + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_factor_ee_args + | qmckl_context | context | in | Global state | + | int64_t | walk_num | in | Number of walkers | + | int64_t | elec_num | in | Number of electrons | + | int64_t | up_num | in | Number of alpha electrons | + | int64_t | bord_num | in | Number of coefficients | + | double | bord_vector[bord_num + 1] | in | List of coefficients | + | double | ee_distance_rescaled[walk_num][elec_num][elec_num] | in | Electron-electron distances | + | double | asymp_jasb[2] | in | Electron-electron distances | + | double | factor_ee[walk_num] | out | Electron-electron distances | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_factor_ee_f(context, walk_num, elec_num, up_num, bord_num, & + bord_vector, ee_distance_rescaled, asymp_jasb, factor_ee) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: walk_num, elec_num, bord_num, up_num + double precision , intent(in) :: bord_vector(bord_num) + double precision , intent(in) :: ee_distance_rescaled(walk_num, elec_num, elec_num) + double precision , intent(in) :: asymp_jasb(2) + double precision , intent(out) :: factor_ee(walk_num) + + integer*8 :: i, j, p, ipar, nw + double precision :: pow_ser, x, spin_fact, power_ser + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (walk_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (elec_num <= 0) then + info = QMCKL_INVALID_ARG_3 + return + endif + + if (bord_num <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + factor_ee = 0.0d0 + + do nw =1, walk_num + do j = 1, elec_num + do i = 1, j - 1 + x = ee_distance_rescaled(nw,i,j) + power_ser = 0.0d0 + spin_fact = 1.0d0 + ipar = 1 + + do p = 2, bord_num + x = x * ee_distance_rescaled(nw,i,j) + power_ser = power_ser + bord_vector(p + 1) * x + end do + + if(j .LE. up_num .OR. i .GT. up_num) then + spin_fact = 0.5d0 + ipar = 2 + endif + + factor_ee(nw) = factor_ee(nw) + spin_fact * bord_vector(1) * & + ee_distance_rescaled(nw,i,j) / & + (1.0d0 + bord_vector(2) * & + ee_distance_rescaled(nw,i,j)) & + -asymp_jasb(ipar) + power_ser + + end do + end do + end do + +end function qmckl_compute_factor_ee_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_factor_ee ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t up_num, + const int64_t bord_num, + const double* bord_vector, + const double* ee_distance_rescaled, + const double* asymp_jasb, + double* const factor_ee ); + #+end_src + + + #+CALL: generate_c_interface(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_factor_ee & + (context, & + walk_num, & + elec_num, & + up_num, & + bord_num, & + bord_vector, & + ee_distance_rescaled, & + asymp_jasb, & + factor_ee) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: walk_num + integer (c_int64_t) , intent(in) , value :: elec_num + integer (c_int64_t) , intent(in) , value :: up_num + integer (c_int64_t) , intent(in) , value :: bord_num + real (c_double ) , intent(in) :: bord_vector(bord_num + 1) + real (c_double ) , intent(in) :: ee_distance_rescaled(elec_num,elec_num,walk_num) + real (c_double ) , intent(in) :: asymp_jasb(2) + real (c_double ) , intent(out) :: factor_ee(walk_num) + + integer(c_int32_t), external :: qmckl_compute_factor_ee_f + info = qmckl_compute_factor_ee_f & + (context, & + walk_num, & + elec_num, & + up_num, & + bord_num, & + bord_vector, & + ee_distance_rescaled, & + asymp_jasb, & + factor_ee) + + end function qmckl_compute_factor_ee + #+end_src + +*** Test + #+begin_src python :results output :exports none :noweb yes +import numpy as np + +<> + +<> + +factor_ee = 0.0 +for i in range(0,elec_num): + for j in range(0,i): + x = ee_distance_rescaled[i][j] + pow_ser = 0.0 + spin_fact = 1.0 + ipar = 0 + + for p in range(1,bord_num): + x = x * ee_distance_rescaled[i][j] + pow_ser = pow_ser + bord_vector[p + 1] * x + + if(i < up_num or j >= up_num): + spin_fact = 0.5 + ipar = 1 + + factor_ee = factor_ee + spin_fact * bord_vector[0] * ee_distance_rescaled[i][j] \ + / (1.0 + bord_vector[1] * ee_distance_rescaled[i][j]) \ + - asymp_jasb[ipar] + pow_ser +print("factor_ee :",factor_ee) + + #+end_src + + #+RESULTS: + : asym_one : 0.43340325572525706 + : asymp_jasb[0] : 0.5323750557252571 + : asymp_jasb[1] : 0.31567342786262853 + : factor_ee : -4.282760865958113 + + + #+begin_src c :tangle (eval c_test) +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +double factor_ee[walk_num]; +rc = qmckl_get_jastrow_factor_ee(context, factor_ee); + +// calculate factor_ee +assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); + + #+end_src + + * End of files :noexport: #+begin_src c :tangle (eval h_private_type) From c9decf482fc6b68a9ba68dea91b6875ed8782e04 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Mon, 5 Jul 2021 22:58:04 +0530 Subject: [PATCH 32/92] Working on factor_ee_deriv_e. #22 --- org/qmckl_jastrow.org | 408 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 404 insertions(+), 4 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index df09b9c..52e8d90 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1297,12 +1297,10 @@ assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); #+end_src - ** Electron-electron component \(f_{ee}\) - Calculate the asymptotic component ~asymp_jasb~ to be substracted from the final - electron-electron jastrow factor \(f_{ee}\). The asymptotic componenet is calculated - via the ~bord_vector~ and the electron-electron rescale factor ~rescale_factor_kappa~. + Calculate the electron-electron jastrow component ~factor_ee~ using the ~asymp_jasb~ + componenet and the electron-electron rescaled distances ~ee_distance_rescaled~. \[ f_{ee} = \sum_{i,jjastrow.factor_ee_deriv_e, ctx->electron.walk_num*sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide :noexport: + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_factor_ee_deriv_e(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_factor_ee_deriv_e(qmckl_context context) +{ + + qmckl_exit_code rc; + + 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); + + /* Check if ee rescaled distance is provided */ + rc = qmckl_provide_ee_distance_rescaled(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.factor_ee_date) { + + /* Allocate array */ + if (ctx->jastrow.factor_ee_deriv_e == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->electron.walk_num * sizeof(double); + double* factor_ee_deriv_e = (double*) qmckl_malloc(context, mem_info); + + if (factor_ee_deriv_e == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_provide_factor_ee_deriv_e", + NULL); + } + ctx->jastrow.factor_ee_deriv_e = factor_ee_deriv_e; + } + + qmckl_exit_code rc = + qmckl_compute_factor_ee_deriv_e(context, + ctx->electron.walk_num, + ctx->electron.num, + ctx->electron.up_num, + ctx->jastrow.bord_num, + ctx->jastrow.bord_vector, + ctx->electron.ee_distance_rescaled, + ctx->electron.ee_distance_rescaled_deriv_e, + ctx->jastrow.asymp_jasb, + ctx->jastrow.factor_ee_deriv_e); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.factor_ee_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute + :PROPERTIES: + :Name: qmckl_compute_factor_ee_deriv_e + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_factor_ee_deriv_e_args + | qmckl_context | context | in | Global state | + | int64_t | walk_num | in | Number of walkers | + | int64_t | elec_num | in | Number of electrons | + | int64_t | up_num | in | Number of alpha electrons | + | int64_t | bord_num | in | Number of coefficients | + | double | bord_vector[bord_num + 1] | in | List of coefficients | + | double | ee_distance_rescaled[walk_num][elec_num][elec_num] | in | Electron-electron distances | + | double | ee_distance_rescaled_deriv_e[4][walk_num][elec_num][elec_num] | in | Electron-electron distances | + | double | asymp_jasb[2] | in | Electron-electron distances | + | double | factor_ee_deriv_e[walk_num] | out | Electron-electron distances | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_factor_ee_deriv_e_f(context, walk_num, elec_num, up_num, bord_num, & + bord_vector, ee_distance_rescaled, ee_distance_rescaled_deriv_e, & + asymp_jasb, factor_ee_deriv_e) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: walk_num, elec_num, bord_num, up_num + double precision , intent(in) :: bord_vector(bord_num) + double precision , intent(in) :: ee_distance_rescaled(walk_num, elec_num, elec_num) + double precision , intent(in) :: ee_distance_rescaled_deriv_e(walk_num, 4, elec_num, elec_num) + double precision , intent(in) :: asymp_jasb(2) + double precision , intent(out) :: factor_ee_deriv_e(walk_num, 4, elec_num) + + integer*8 :: i, j, p, ipar, nw, ii + double precision :: x, spin_fact, y + double precision :: den, invden, invden2, invden3, xinv + double precision :: lap1, lap2, lap3, third + double precision, dimension(3) :: pow_ser_g + double precision, dimension(4) :: dx + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (walk_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (elec_num <= 0) then + info = QMCKL_INVALID_ARG_3 + return + endif + + if (bord_num <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + factor_ee_deriv_e = 0.0d0 + third = 1.0d0 / 3.0d0 + + do nw =1, walk_num + do j = 1, elec_num + do i = 1, elec_num + x = ee_distance_rescaled(nw,i,j) + pow_ser_g = 0.0d0 + spin_fact = 1.0d0 + den = 1.0d0 + bord_vector(2) * ee_distance_rescaled(nw, i, j) + invden = 1.0d0 / den + invden2 = invden * invden + invden3 = invden2 * invden + xinv = 1.0d0 / (ee_distance_rescaled(nw, i, j) + 1.0d0-18) + ipar = 1 + + do ii = 1, 4 + dx(ii) = ee_distance_rescaled_deriv_e(nw, ii, j, i) + end do + + if((i .LE. up_num .AND. j .LE. up_num ) .OR. & + (i .GT. up_num .AND. j .GT. up_num)) then + spin_fact = 0.5d0 + endif + + lap1 = 0.0d0 + lap2 = 0.0d0 + lap3 = 0.0d0 + do ii = 1, 3 + x = ee_distance_rescaled(nw, i, j) + do p = 2, bord_num + y = p * bord_vector(p + 1) * x + pow_ser_g(ii) = pow_ser_g(ii) + y * dx(ii) + lap1 = lap1 + (p - 1) * y * xinv * dx(ii) * dx(ii) + lap2 = lap2 + y + x = x * ee_distance_rescaled(nw, i, j) + end do + + lap3 = lap3 - 2.0d0 * bord_vector(2) * dx(ii) * dx(ii) + + factor_ee_deriv_e(nw, ii, j) = factor_ee_deriv_e(nw, ii, j) + spin_fact * bord_vector(1) * & + dx(ii) * invden + pow_ser_g(ii) + end do + + ii = 4 + lap2 = lap2 * dx(ii) * third + lap3 = lap3 + den * dx(ii) + lap3 = lap3 + spin_fact * bord_vector(1) * invden3 + factor_ee_deriv_e(nw, ii, j) = factor_ee_deriv_e(nw, ii, j) + lap1 + lap2 + lap3 + + end do + end do + end do + +end function qmckl_compute_factor_ee_deriv_e_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_factor_ee_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_factor_ee_deriv_e ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t up_num, + const int64_t bord_num, + const double* bord_vector, + const double* ee_distance_rescaled, + const double* ee_distance_rescaled_deriv_e, + const double* asymp_jasb, + double* const factor_ee_deriv_e ); + #+end_src + + + #+CALL: generate_c_interface(table=qmckl_factor_ee_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_factor_ee_deriv_e & + (context, & + walk_num, & + elec_num, & + up_num, & + bord_num, & + bord_vector, & + ee_distance_rescaled, & + ee_distance_rescaled_deriv_e, & + asymp_jasb, & + factor_ee_deriv_e) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: walk_num + integer (c_int64_t) , intent(in) , value :: elec_num + integer (c_int64_t) , intent(in) , value :: up_num + integer (c_int64_t) , intent(in) , value :: bord_num + real (c_double ) , intent(in) :: bord_vector(bord_num + 1) + real (c_double ) , intent(in) :: ee_distance_rescaled(elec_num,elec_num,walk_num) + real (c_double ) , intent(in) :: ee_distance_rescaled_deriv_e(elec_num,elec_num,walk_num,4) + real (c_double ) , intent(in) :: asymp_jasb(2) + real (c_double ) , intent(out) :: factor_ee_deriv_e(walk_num) + + integer(c_int32_t), external :: qmckl_compute_factor_ee_deriv_e_f + info = qmckl_compute_factor_ee_deriv_e_f & + (context, & + walk_num, & + elec_num, & + up_num, & + bord_num, & + bord_vector, & + ee_distance_rescaled, & + ee_distance_rescaled_deriv_e, & + asymp_jasb, & + factor_ee_deriv_e) + + end function qmckl_compute_factor_ee_deriv_e + #+end_src + +*** Test + #+begin_src python :results output :exports none :noweb yes +import numpy as np + +<> + +<> + +kappa = 1.0 + +elec_coord = np.array(elec_coord)[0] +elec_dist = np.zeros(shape=(elec_num, elec_num),dtype=float) +for i in range(elec_num): + for j in range(elec_num): + elec_dist[i, j] = np.linalg.norm(np.abs(elec_coord[i] - elec_coord[j])) + +elec_dist_deriv_e = np.zeros(shape=(4,elec_num, elec_num),dtype=float) +for j in range(elec_num): + for i in range(elec_num): + rij_inv = 1.0 / elec_dist[i, j] + for ii in range(3): + elec_dist_deriv_e[ii, i, j] = (elec_coord[i][ii] - elec_coord[j][ii]) * rij_inv + elec_dist_deriv_e[3, i, j] = 2.0 * rij_inv + elec_dist_deriv_e[:, j, j] = 0.0 + +ee_distance_rescaled_deriv_e = np.zeros(shape=(4,elec_num,elec_num),dtype=float) +for i in range(elec_num): + for j in range(elec_num): + f = 1.0 - kappa * ee_distance_rescaled[i][j] + for ii in range(4): + ee_distance_rescaled_deriv_e[ii][i][j] = elec_dist_deriv_e[ii][i][j] + ee_distance_rescaled_deriv_e[3][i][j] = ee_distance_rescaled_deriv_e[3][i][j] + \ + (-kappa * ee_distance_rescaled_deriv_e[0][i][j]**2) + \ + (-kappa * ee_distance_rescaled_deriv_e[1][i][j]**2) + \ + (-kappa * ee_distance_rescaled_deriv_e[2][i][j]**2) + for ii in range(4): + ee_distance_rescaled_deriv_e[ii][i][j] = ee_distance_rescaled_deriv_e[ii][i][j] * f + + +third = 1.0 / 3.0 +factor_ee_deriv_e = np.zeros(shape=(4,elec_num),dtype=float) +dx = np.zeros(shape=(4),dtype=float) +pow_ser_g = np.zeros(shape=(4),dtype=float) +for i in range(elec_num): + for j in range(elec_num): + x = ee_distance_rescaled[i][j] + pow_ser_g = np.zeros(shape=(4),dtype=float) + spin_fact = 1.0 + den = 1.0 + bord_vector[1] * ee_distance_rescaled[i][j] + invden = 1.0 / den + invden2 = invden * invden + invden3 = invden2 * invden + xinv = 1.0 / (ee_distance_rescaled[i][j] + 1.0-18) + ipar = 1 + + for ii in range(4): + dx[ii] = ee_distance_rescaled_deriv_e[ii][j][i] + + if((i <= up_num and j <= up_num ) or \ + (i > up_num and j > up_num)): + spin_fact = 0.5 + + lap1 = 0.0 + lap2 = 0.0 + lap3 = 0.0 + for ii in range(3): + x = ee_distance_rescaled[i][j] + for p in range(1,bord_num): + y = p * bord_vector[p + 1] * x + pow_ser_g[ii] = pow_ser_g[ii] + y * dx[ii] + lap1 = lap1 + (p - 1) * y * xinv * dx[ii] * dx[ii] + lap2 = lap2 + y + x = x * ee_distance_rescaled[i][j] + + lap3 = lap3 - 2.0 * bord_vector[1] * dx[ii] * dx[ii] + + factor_ee_deriv_e[ii][j] = factor_ee_deriv_e[ii][j] + spin_fact * bord_vector[0] * \ + dx[ii] * invden + pow_ser_g[ii] + + ii = 3 + lap2 = lap2 * dx[ii] * third + lap3 = lap3 + den * dx[ii] + lap3 = lap3 + spin_fact * bord_vector[1] * invden3 + factor_ee_deriv_e[ii][j] = factor_ee_deriv_e[ii][j] + lap1 + lap2 + lap3 + +print("factor_ee_deriv_e:",factor_ee_deriv_e) + + + #+end_src + + #+RESULTS: + #+begin_example + asym_one : 0.43340325572525706 + asymp_jasb[0] : 0.5323750557252571 + asymp_jasb[1] : 0.31567342786262853 + factor_ee_deriv_e: [[-0.98933561 -1.90335162 1.55808557 -0.4175529 0.61492377 -0.39831866 + -0.39927944 0.65028576 -0.3615353 0.18529135] + [ 1.63379825 -0.20386723 -0.68681515 -0.12852739 -0.26752663 -0.38482884 + -0.08399636 0.0271138 0.47700861 -0.15444407] + [-1.50784905 -0.77857073 -2.65602338 0.47954785 2.47647536 -0.73979109 + -1.45880891 -0.57274462 0.20895041 0.22564652] + [ 3.33386195 2.70852681 -4.1135207 7.24473889 -1.68083113 6.11612348 + 3.74311012 0.3229593 7.21394604 2.7578531 ]] + #+end_example + + + #+begin_src c :tangle (eval c_test) +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +double factor_ee_deriv_e[walk_num]; +rc = qmckl_get_jastrow_factor_ee_deriv_e(context, factor_ee_deriv_e); + +// calculate factor_ee_deriv_e +assert(fabs(factor_ee_deriv_e[0]+4.282760865958113) < 1.e-12); + + #+end_src + * End of files :noexport: From 0df816c0babc2b85621ffe7f543527e643bcba2b Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 6 Jul 2021 12:57:14 +0530 Subject: [PATCH 33/92] Finished ee_deriv_e. #20 --- org/qmckl_jastrow.org | 133 ++++++++++++++++++++++++++---------------- tools/lib.org | 1 + 2 files changed, 83 insertions(+), 51 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 52e8d90..c731d8e 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -88,8 +88,11 @@ int main() { | ~double~ | ~factor_een[walk_num]~ | out | Jastrow factor: electron-electron-nucleus part | | ~double~ | ~factor_een_date~ | out | Jastrow factor: electron-electron-nucleus part | | ~double~ | ~factor_ee_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_ee_deriv_e_date~ | out | Keep track of the date for the derivative | | ~double~ | ~factor_en_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_en_deriv_e_date~ | out | Keep track of the date for the en derivative | | ~double~ | ~factor_een_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_een_deriv_e_date~ | out | Keep track of the date for the een derivative | computed data: @@ -169,6 +172,10 @@ ee_distance_rescaled = [ 0.956034127544344 ,0.931221472309472 ,0.540903688625053 , 0.000000000000000E+000]] +# symmetrize it +for i in range(elec_num): + for j in range(elec_num): + ee_distance_rescaled[i][j] = ee_distance_rescaled[j][i] type_nucl_num = 1 aord_num = 5 @@ -250,6 +257,9 @@ typedef struct qmckl_jastrow_struct{ int64_t factor_ee_date; int64_t factor_en_date; int64_t factor_een_date; + int64_t factor_ee_deriv_e_date; + int64_t factor_en_deriv_e_date; + int64_t factor_een_deriv_e_date; double * aord_vector; double * bord_vector; double * cord_vector; @@ -1625,7 +1635,8 @@ qmckl_exit_code qmckl_get_jastrow_factor_ee_deriv_e(qmckl_context context, doubl qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - memcpy(factor_ee_deriv_e, ctx->jastrow.factor_ee_deriv_e, ctx->electron.walk_num*sizeof(double)); + int64_t sze = ctx->electron.walk_num * 4 * ctx->electron.num; + memcpy(factor_ee_deriv_e, ctx->jastrow.factor_ee_deriv_e, sze * sizeof(double)); return QMCKL_SUCCESS; } @@ -1653,14 +1664,18 @@ qmckl_exit_code qmckl_provide_factor_ee_deriv_e(qmckl_context context) rc = qmckl_provide_ee_distance_rescaled(context); if(rc != QMCKL_SUCCESS) return rc; + /* Check if ee rescaled distance deriv e is provided */ + rc = qmckl_provide_ee_distance_rescaled_deriv_e(context); + if(rc != QMCKL_SUCCESS) return rc; + /* Compute if necessary */ - if (ctx->date > ctx->jastrow.factor_ee_date) { + if (ctx->date > ctx->jastrow.factor_ee_deriv_e_date) { /* Allocate array */ if (ctx->jastrow.factor_ee_deriv_e == NULL) { qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; - mem_info.size = ctx->electron.walk_num * sizeof(double); + mem_info.size = ctx->electron.walk_num * 4 * ctx->electron.num * sizeof(double); double* factor_ee_deriv_e = (double*) qmckl_malloc(context, mem_info); if (factor_ee_deriv_e == NULL) { @@ -1709,9 +1724,9 @@ qmckl_exit_code qmckl_provide_factor_ee_deriv_e(qmckl_context context) | int64_t | bord_num | in | Number of coefficients | | double | bord_vector[bord_num + 1] | in | List of coefficients | | double | ee_distance_rescaled[walk_num][elec_num][elec_num] | in | Electron-electron distances | - | double | ee_distance_rescaled_deriv_e[4][walk_num][elec_num][elec_num] | in | Electron-electron distances | + | double | ee_distance_rescaled_deriv_e[walk_num][4][elec_num][elec_num] | in | Electron-electron distances | | double | asymp_jasb[2] | in | Electron-electron distances | - | double | factor_ee_deriv_e[walk_num] | out | Electron-electron distances | + | double | factor_ee_deriv_e[walk_num][4][elec_num] | out | Electron-electron distances | #+begin_src f90 :comments org :tangle (eval f) :noweb yes integer function qmckl_compute_factor_ee_deriv_e_f(context, walk_num, elec_num, up_num, bord_num, & @@ -1726,7 +1741,7 @@ integer function qmckl_compute_factor_ee_deriv_e_f(context, walk_num, elec_num, double precision , intent(in) :: ee_distance_rescaled(walk_num, elec_num, elec_num) double precision , intent(in) :: ee_distance_rescaled_deriv_e(walk_num, 4, elec_num, elec_num) double precision , intent(in) :: asymp_jasb(2) - double precision , intent(out) :: factor_ee_deriv_e(walk_num, 4, elec_num) + double precision , intent(out) :: factor_ee_deriv_e(elec_num,4,walk_num) integer*8 :: i, j, p, ipar, nw, ii double precision :: x, spin_fact, y @@ -1763,18 +1778,19 @@ integer function qmckl_compute_factor_ee_deriv_e_f(context, walk_num, elec_num, do nw =1, walk_num do j = 1, elec_num do i = 1, elec_num - x = ee_distance_rescaled(nw,i,j) + x = ee_distance_rescaled(nw, i, j) + if(abs(x) < 1.0d-18) cycle pow_ser_g = 0.0d0 spin_fact = 1.0d0 - den = 1.0d0 + bord_vector(2) * ee_distance_rescaled(nw, i, j) + den = 1.0d0 + bord_vector(2) * x invden = 1.0d0 / den invden2 = invden * invden invden3 = invden2 * invden - xinv = 1.0d0 / (ee_distance_rescaled(nw, i, j) + 1.0d0-18) + xinv = 1.0d0 / (x + 1.0d-18) ipar = 1 do ii = 1, 4 - dx(ii) = ee_distance_rescaled_deriv_e(nw, ii, j, i) + dx(ii) = ee_distance_rescaled_deriv_e(nw, ii, i, j) end do if((i .LE. up_num .AND. j .LE. up_num ) .OR. & @@ -1787,6 +1803,7 @@ integer function qmckl_compute_factor_ee_deriv_e_f(context, walk_num, elec_num, lap3 = 0.0d0 do ii = 1, 3 x = ee_distance_rescaled(nw, i, j) + if(abs(x) < 1.0d-18) cycle do p = 2, bord_num y = p * bord_vector(p + 1) * x pow_ser_g(ii) = pow_ser_g(ii) + y * dx(ii) @@ -1797,15 +1814,15 @@ integer function qmckl_compute_factor_ee_deriv_e_f(context, walk_num, elec_num, lap3 = lap3 - 2.0d0 * bord_vector(2) * dx(ii) * dx(ii) - factor_ee_deriv_e(nw, ii, j) = factor_ee_deriv_e(nw, ii, j) + spin_fact * bord_vector(1) * & - dx(ii) * invden + pow_ser_g(ii) + factor_ee_deriv_e( j, ii, nw) = factor_ee_deriv_e( j, ii, nw) + spin_fact * bord_vector(1) * & + dx(ii) * invden2 + pow_ser_g(ii) end do ii = 4 lap2 = lap2 * dx(ii) * third lap3 = lap3 + den * dx(ii) - lap3 = lap3 + spin_fact * bord_vector(1) * invden3 - factor_ee_deriv_e(nw, ii, j) = factor_ee_deriv_e(nw, ii, j) + lap1 + lap2 + lap3 + lap3 = lap3 * (spin_fact * bord_vector(1) * invden3) + factor_ee_deriv_e( j, ii, nw) = factor_ee_deriv_e( j, ii, nw) + lap1 + lap2 + lap3 end do end do @@ -1859,9 +1876,9 @@ end function qmckl_compute_factor_ee_deriv_e_f integer (c_int64_t) , intent(in) , value :: bord_num real (c_double ) , intent(in) :: bord_vector(bord_num + 1) real (c_double ) , intent(in) :: ee_distance_rescaled(elec_num,elec_num,walk_num) - real (c_double ) , intent(in) :: ee_distance_rescaled_deriv_e(elec_num,elec_num,walk_num,4) + real (c_double ) , intent(in) :: ee_distance_rescaled_deriv_e(elec_num,elec_num,4,walk_num) real (c_double ) , intent(in) :: asymp_jasb(2) - real (c_double ) , intent(out) :: factor_ee_deriv_e(walk_num) + real (c_double ) , intent(out) :: factor_ee_deriv_e(elec_num,4,walk_num) integer(c_int32_t), external :: qmckl_compute_factor_ee_deriv_e_f info = qmckl_compute_factor_ee_deriv_e_f & @@ -1893,79 +1910,85 @@ elec_coord = np.array(elec_coord)[0] elec_dist = np.zeros(shape=(elec_num, elec_num),dtype=float) for i in range(elec_num): for j in range(elec_num): - elec_dist[i, j] = np.linalg.norm(np.abs(elec_coord[i] - elec_coord[j])) + elec_dist[i, j] = np.linalg.norm(elec_coord[i] - elec_coord[j]) elec_dist_deriv_e = np.zeros(shape=(4,elec_num, elec_num),dtype=float) for j in range(elec_num): for i in range(elec_num): rij_inv = 1.0 / elec_dist[i, j] for ii in range(3): - elec_dist_deriv_e[ii, i, j] = (elec_coord[i][ii] - elec_coord[j][ii]) * rij_inv + elec_dist_deriv_e[ii, i, j] = (elec_coord[j][ii] - elec_coord[i][ii]) * rij_inv elec_dist_deriv_e[3, i, j] = 2.0 * rij_inv elec_dist_deriv_e[:, j, j] = 0.0 ee_distance_rescaled_deriv_e = np.zeros(shape=(4,elec_num,elec_num),dtype=float) -for i in range(elec_num): - for j in range(elec_num): +for j in range(elec_num): + for i in range(elec_num): f = 1.0 - kappa * ee_distance_rescaled[i][j] for ii in range(4): ee_distance_rescaled_deriv_e[ii][i][j] = elec_dist_deriv_e[ii][i][j] ee_distance_rescaled_deriv_e[3][i][j] = ee_distance_rescaled_deriv_e[3][i][j] + \ - (-kappa * ee_distance_rescaled_deriv_e[0][i][j]**2) + \ - (-kappa * ee_distance_rescaled_deriv_e[1][i][j]**2) + \ - (-kappa * ee_distance_rescaled_deriv_e[2][i][j]**2) + (-kappa * ee_distance_rescaled_deriv_e[0][i][j] * ee_distance_rescaled_deriv_e[0][i][j]) + \ + (-kappa * ee_distance_rescaled_deriv_e[1][i][j] * ee_distance_rescaled_deriv_e[1][i][j]) + \ + (-kappa * ee_distance_rescaled_deriv_e[2][i][j] * ee_distance_rescaled_deriv_e[2][i][j]) for ii in range(4): ee_distance_rescaled_deriv_e[ii][i][j] = ee_distance_rescaled_deriv_e[ii][i][j] * f - third = 1.0 / 3.0 factor_ee_deriv_e = np.zeros(shape=(4,elec_num),dtype=float) dx = np.zeros(shape=(4),dtype=float) pow_ser_g = np.zeros(shape=(4),dtype=float) -for i in range(elec_num): - for j in range(elec_num): - x = ee_distance_rescaled[i][j] +for j in range(elec_num): + for i in range(elec_num): + x = ee_distance_rescaled[j][i] + if abs(x) < 1e-18: + continue pow_ser_g = np.zeros(shape=(4),dtype=float) spin_fact = 1.0 - den = 1.0 + bord_vector[1] * ee_distance_rescaled[i][j] + den = 1.0 + bord_vector[1] * ee_distance_rescaled[j][i] invden = 1.0 / den invden2 = invden * invden invden3 = invden2 * invden - xinv = 1.0 / (ee_distance_rescaled[i][j] + 1.0-18) + xinv = 1.0 / (ee_distance_rescaled[j][i] + 1.0E-18) ipar = 1 for ii in range(4): dx[ii] = ee_distance_rescaled_deriv_e[ii][j][i] - if((i <= up_num and j <= up_num ) or \ - (i > up_num and j > up_num)): + if((i <= (up_num-1) and j <= (up_num-1) ) or \ + (i > (up_num-1) and j > (up_num-1))): spin_fact = 0.5 lap1 = 0.0 lap2 = 0.0 lap3 = 0.0 for ii in range(3): - x = ee_distance_rescaled[i][j] - for p in range(1,bord_num): - y = p * bord_vector[p + 1] * x + x = ee_distance_rescaled[j][i] + if x < 1e-18: + continue + for p in range(2,bord_num+1): + y = p * bord_vector[(p-1) + 1] * x pow_ser_g[ii] = pow_ser_g[ii] + y * dx[ii] lap1 = lap1 + (p - 1) * y * xinv * dx[ii] * dx[ii] lap2 = lap2 + y - x = x * ee_distance_rescaled[i][j] + x = x * ee_distance_rescaled[j][i] lap3 = lap3 - 2.0 * bord_vector[1] * dx[ii] * dx[ii] factor_ee_deriv_e[ii][j] = factor_ee_deriv_e[ii][j] + spin_fact * bord_vector[0] * \ - dx[ii] * invden + pow_ser_g[ii] + dx[ii] * invden2 + pow_ser_g[ii] ii = 3 lap2 = lap2 * dx[ii] * third lap3 = lap3 + den * dx[ii] - lap3 = lap3 + spin_fact * bord_vector[1] * invden3 + lap3 = lap3 * (spin_fact * bord_vector[0] * invden3) factor_ee_deriv_e[ii][j] = factor_ee_deriv_e[ii][j] + lap1 + lap2 + lap3 -print("factor_ee_deriv_e:",factor_ee_deriv_e) - +print("factor_ee_deriv_e[0][0]:",factor_ee_deriv_e[0][0]) +print("factor_ee_deriv_e[1][0]:",factor_ee_deriv_e[1][0]) +print("factor_ee_deriv_e[2][0]:",factor_ee_deriv_e[2][0]) +print("factor_ee_deriv_e[3][0]:",factor_ee_deriv_e[3][0]) +print(factor_ee_deriv_e) #+end_src @@ -1974,14 +1997,18 @@ print("factor_ee_deriv_e:",factor_ee_deriv_e) asym_one : 0.43340325572525706 asymp_jasb[0] : 0.5323750557252571 asymp_jasb[1] : 0.31567342786262853 - factor_ee_deriv_e: [[-0.98933561 -1.90335162 1.55808557 -0.4175529 0.61492377 -0.39831866 - -0.39927944 0.65028576 -0.3615353 0.18529135] - [ 1.63379825 -0.20386723 -0.68681515 -0.12852739 -0.26752663 -0.38482884 - -0.08399636 0.0271138 0.47700861 -0.15444407] - [-1.50784905 -0.77857073 -2.65602338 0.47954785 2.47647536 -0.73979109 - -1.45880891 -0.57274462 0.20895041 0.22564652] - [ 3.33386195 2.70852681 -4.1135207 7.24473889 -1.68083113 6.11612348 - 3.74311012 0.3229593 7.21394604 2.7578531 ]] + factor_ee_deriv_e[0][0]: 0.16364894652107934 + factor_ee_deriv_e[1][0]: -0.6927548119830084 + factor_ee_deriv_e[2][0]: 0.073267755223968 + factor_ee_deriv_e[3][0]: 1.5111672803213185 + [[ 0.16364895 0.60354957 -0.19825547 0.02359797 -0.13123153 -0.18789233 + 0.07762515 -0.42459184 0.27920265 -0.2056531 ] + [-0.69275481 0.15690393 0.09831069 0.18490587 0.04361723 0.3250686 + 0.12657961 -0.01736522 -0.40149005 0.17622416] + [ 0.07326776 -0.27532276 0.22396943 0.18771633 -0.34506246 0.07298062 + 0.63302352 -0.00910198 -0.30238713 -0.25908332] + [ 1.51116728 1.5033247 0.00325003 2.89377255 0.1338393 2.15893795 + 1.74732003 0.23561147 2.67455607 0.82810434]] #+end_example @@ -1989,11 +2016,15 @@ print("factor_ee_deriv_e:",factor_ee_deriv_e) /* Check if Jastrow is properly initialized */ assert(qmckl_jastrow_provided(context)); -double factor_ee_deriv_e[walk_num]; -rc = qmckl_get_jastrow_factor_ee_deriv_e(context, factor_ee_deriv_e); - // calculate factor_ee_deriv_e -assert(fabs(factor_ee_deriv_e[0]+4.282760865958113) < 1.e-12); +double factor_ee_deriv_e[walk_num][4][elec_num]; +rc = qmckl_get_jastrow_factor_ee_deriv_e(context, &(factor_ee_deriv_e[0][0][0])); + +// check factor_ee_deriv_e +assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); #+end_src diff --git a/tools/lib.org b/tools/lib.org index ec9a2c5..01d86fb 100644 --- a/tools/lib.org +++ b/tools/lib.org @@ -258,3 +258,4 @@ return results #+begin_src f90 :tangle (eval fh_func) :comments org :exports none #+end_src + From 7c226d0a99fc33f425dab73e4e1f7872f0bfd814 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 6 Jul 2021 15:51:51 +0530 Subject: [PATCH 34/92] Finished factor_en. #22 --- org/qmckl_distance.org | 2 +- org/qmckl_jastrow.org | 482 +++++++++++++++++++++++++++++++++++++---- tests/n2.h | 6 +- 3 files changed, 444 insertions(+), 46 deletions(-) diff --git a/org/qmckl_distance.org b/org/qmckl_distance.org index 082209b..1465012 100644 --- a/org/qmckl_distance.org +++ b/org/qmckl_distance.org @@ -923,7 +923,7 @@ integer function qmckl_distance_rescaled_f(context, transa, transb, m, n, & if (transb == 'N' .or. transb == 'n') then continue - else if (transa == 'T' .or. transa == 't') then + else if (transb == 'T' .or. transb == 't') then transab = transab + 2 else transab = -100 diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index c731d8e..461a445 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -72,27 +72,28 @@ int main() { The following data stored in the context: #+NAME: qmckl_jastrow_args - |------------+--------------------------------------------+-----+-------------------------------------------------------------------| - | ~int32_t~ | ~uninitialized~ | in | Keeps bit set for uninitialized data | - | ~int64_t~ | ~aord_num~ | in | The number of a coeffecients | - | ~int64_t~ | ~bord_num~ | in | The number of b coeffecients | - | ~int64_t~ | ~cord_num~ | in | The number of c coeffecients | - | ~uint64_t~ | ~type_nucl_num~ | in | Number of Nucleii types | - | ~double~ | ~aord_vector[aord_num + 1][type_nucl_num]~ | in | Order of a polynomial coefficients | - | ~double~ | ~bord_vector[bord_num + 1]~ | in | Order of b polynomial coefficients | - | ~double~ | ~cord_vector[cord_num][type_nucl_num]~ | in | Order of c polynomial coefficients | - | ~double~ | ~factor_ee[walk_num]~ | out | Jastrow factor: electron-electron part | - | ~double~ | ~factor_ee_date~ | out | Jastrow factor: electron-electron part | - | ~double~ | ~factor_en[walk_num]~ | out | Jastrow factor: electron-nucleus part | - | ~double~ | ~factor_en_date~ | out | Jastrow factor: electron-nucleus part | - | ~double~ | ~factor_een[walk_num]~ | out | Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_een_date~ | out | Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_ee_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_ee_deriv_e_date~ | out | Keep track of the date for the derivative | - | ~double~ | ~factor_en_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_en_deriv_e_date~ | out | Keep track of the date for the en derivative | - | ~double~ | ~factor_een_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_een_deriv_e_date~ | out | Keep track of the date for the een derivative | + |-----------+--------------------------------------------+-----+-------------------------------------------------------------------| + | ~int32_t~ | ~uninitialized~ | in | Keeps bit set for uninitialized data | + | ~int64_t~ | ~aord_num~ | in | The number of a coeffecients | + | ~int64_t~ | ~bord_num~ | in | The number of b coeffecients | + | ~int64_t~ | ~cord_num~ | in | The number of c coeffecients | + | ~int64_t~ | ~type_nucl_num~ | in | Number of Nucleii types | + | ~int64_t~ | ~type_nucl_vector[nucl_num]~ | in | IDs of types of Nucleii | + | ~double~ | ~aord_vector[aord_num + 1][type_nucl_num]~ | in | Order of a polynomial coefficients | + | ~double~ | ~bord_vector[bord_num + 1]~ | in | Order of b polynomial coefficients | + | ~double~ | ~cord_vector[cord_num][type_nucl_num]~ | in | Order of c polynomial coefficients | + | ~double~ | ~factor_ee[walk_num]~ | out | Jastrow factor: electron-electron part | + | ~double~ | ~factor_ee_date~ | out | Jastrow factor: electron-electron part | + | ~double~ | ~factor_en[walk_num]~ | out | Jastrow factor: electron-nucleus part | + | ~double~ | ~factor_en_date~ | out | Jastrow factor: electron-nucleus part | + | ~double~ | ~factor_een[walk_num]~ | out | Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_een_date~ | out | Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_ee_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_ee_deriv_e_date~ | out | Keep track of the date for the derivative | + | ~double~ | ~factor_en_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_en_deriv_e_date~ | out | Keep track of the date for the en derivative | + | ~double~ | ~factor_een_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_een_deriv_e_date~ | out | Keep track of the date for the een derivative | computed data: @@ -172,6 +173,16 @@ ee_distance_rescaled = [ 0.956034127544344 ,0.931221472309472 ,0.540903688625053 , 0.000000000000000E+000]] +en_distance_rescaled = np.transpose(np.array([ +[ 0.443570948411811 , 0.467602196999105 , 0.893870160799932 , + 0.864347190364447 , 0.976608182392358 , 0.187563183468210 , + 0.426404699872689 , 0.665107090128166 , 0.885246991424583 , + 0.924902909715270 ], +[ 0.899360150637444 , 0.860035135365386 , 0.979659405613798 , + 6.140678415933776E-002, 0.835118398056681 , 0.884071658981068 , + 0.923860000907362 , 0.905203414522289 , 0.211286300932359 , + 0.492104840907350 ]])) + # symmetrize it for i in range(elec_num): for j in range(elec_num): @@ -182,8 +193,15 @@ aord_num = 5 bord_num = 5 cord_num = 23 dim_cord_vec = 23 -aord_vector = [ 0.000000000000000E+000, 0.000000000000000E+000, -0.380512000000000E+000, - -0.157996000000000E+000, -3.155800000000000E-002, 2.151200000000000E-002] +type_nucl_vector = [ 1, 1] +aord_vector = [ +[0.000000000000000E+000], +[0.000000000000000E+000], +[-0.380512000000000E+000], +[-0.157996000000000E+000], +[-3.155800000000000E-002], +[2.151200000000000E-002]] + bord_vector = [ 0.500000000000000E-000, 0.153660000000000E-000, 6.722620000000000E-002, 2.157000000000000E-002, 7.309600000000000E-003, 2.866000000000000E-003] cord_vector = [ 0.571702000000000E-000, -0.514253000000000E-000, -0.513043000000000E-000, @@ -260,6 +278,7 @@ typedef struct qmckl_jastrow_struct{ int64_t factor_ee_deriv_e_date; int64_t factor_en_deriv_e_date; int64_t factor_een_deriv_e_date; + int64_t* type_nucl_vector; double * aord_vector; double * bord_vector; double * cord_vector; @@ -301,7 +320,7 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - ctx->jastrow.uninitialized = (1 << 5) - 1; + ctx->jastrow.uninitialized = (1 << 6) - 1; /* Default values */ @@ -312,13 +331,14 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) { ** Access functions #+begin_src c :comments org :tangle (eval h_func) :exports none -qmckl_exit_code qmckl_get_jastrow_aord_num (qmckl_context context, int64_t* const aord_num); -qmckl_exit_code qmckl_get_jastrow_bord_num (qmckl_context context, int64_t* const bord_num); -qmckl_exit_code qmckl_get_jastrow_cord_num (qmckl_context context, int64_t* const bord_num); -qmckl_exit_code qmckl_get_jastrow_type_nucl_num (qmckl_context context, int64_t* const type_nucl_num); -qmckl_exit_code qmckl_get_jastrow_aord_vector (qmckl_context context, double * const aord_vector); -qmckl_exit_code qmckl_get_jastrow_bord_vector (qmckl_context context, double * const bord_vector); -qmckl_exit_code qmckl_get_jastrow_cord_vector (qmckl_context context, double * const cord_vector); +qmckl_exit_code qmckl_get_jastrow_aord_num (qmckl_context context, int64_t* const aord_num); +qmckl_exit_code qmckl_get_jastrow_bord_num (qmckl_context context, int64_t* const bord_num); +qmckl_exit_code qmckl_get_jastrow_cord_num (qmckl_context context, int64_t* const bord_num); +qmckl_exit_code qmckl_get_jastrow_type_nucl_num (qmckl_context context, int64_t* const type_nucl_num); +qmckl_exit_code qmckl_get_jastrow_type_nucl_vector (qmckl_context context, int64_t* const type_nucl_num); +qmckl_exit_code qmckl_get_jastrow_aord_vector (qmckl_context context, double * const aord_vector); +qmckl_exit_code qmckl_get_jastrow_bord_vector (qmckl_context context, double * const bord_vector); +qmckl_exit_code qmckl_get_jastrow_cord_vector (qmckl_context context, double * const cord_vector); #+end_src Along with these core functions, calculation of the jastrow factor @@ -462,6 +482,33 @@ qmckl_exit_code qmckl_get_jastrow_type_nucl_num (const qmckl_context context, in return QMCKL_SUCCESS; } +qmckl_exit_code qmckl_get_jastrow_type_nucl_vector (const qmckl_context context, int64_t * const type_nucl_vector) { + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return (char) 0; + } + + if (type_nucl_vector == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_get_jastrow_type_nucl_vector", + "type_nucl_vector is a null pointer"); + } + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int32_t mask = 1 << 2; + + if ( (ctx->jastrow.uninitialized & mask) != 0) { + return QMCKL_NOT_PROVIDED; + } + + assert (ctx->jastrow.type_nucl_vector != NULL); + memcpy(type_nucl_vector, ctx->jastrow.type_nucl_vector, ctx->jastrow.type_nucl_num*sizeof(int64_t)); + return QMCKL_SUCCESS; +} + qmckl_exit_code qmckl_get_jastrow_aord_vector (const qmckl_context context, double * const aord_vector) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { @@ -478,7 +525,7 @@ qmckl_exit_code qmckl_get_jastrow_aord_vector (const qmckl_context context, doub qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 2; + int32_t mask = 1 << 3; if ( (ctx->jastrow.uninitialized & mask) != 0) { return QMCKL_NOT_PROVIDED; @@ -505,7 +552,7 @@ qmckl_exit_code qmckl_get_jastrow_bord_vector (const qmckl_context context, doub qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 3; + int32_t mask = 1 << 4; if ( (ctx->jastrow.uninitialized & mask) != 0) { return QMCKL_NOT_PROVIDED; @@ -532,7 +579,7 @@ qmckl_exit_code qmckl_get_jastrow_cord_vector (const qmckl_context context, doub qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int32_t mask = 1 << 4; + int32_t mask = 1 << 5; if ( (ctx->jastrow.uninitialized & mask) != 0) { return QMCKL_NOT_PROVIDED; @@ -551,12 +598,13 @@ qmckl_exit_code qmckl_get_jastrow_cord_vector (const qmckl_context context, doub called. #+begin_src c :comments org :tangle (eval h_func) -qmckl_exit_code qmckl_set_jastrow_ord_num (qmckl_context context, const int64_t aord_num, const int64_t bord_num, const int64_t cord_num); -qmckl_exit_code qmckl_set_jastrow_type_nucl_num (qmckl_context context, const int64_t type_nucl_num); -qmckl_exit_code qmckl_set_jastrow_aord_vector (qmckl_context context, const double * aord_vector); -qmckl_exit_code qmckl_set_jastrow_bord_vector (qmckl_context context, const double * bord_vector); -qmckl_exit_code qmckl_set_jastrow_cord_vector (qmckl_context context, const double * cord_vector); -qmckl_exit_code qmckl_set_jastrow_dependencies (qmckl_context context); +qmckl_exit_code qmckl_set_jastrow_ord_num (qmckl_context context, const int64_t aord_num, const int64_t bord_num, const int64_t cord_num); +qmckl_exit_code qmckl_set_jastrow_type_nucl_num (qmckl_context context, const int64_t type_nucl_num); +qmckl_exit_code qmckl_set_jastrow_type_nucl_vector (qmckl_context context, const int64_t* type_nucl_vector, const int64_t nucl_num); +qmckl_exit_code qmckl_set_jastrow_aord_vector (qmckl_context context, const double * aord_vector); +qmckl_exit_code qmckl_set_jastrow_bord_vector (qmckl_context context, const double * bord_vector); +qmckl_exit_code qmckl_set_jastrow_cord_vector (qmckl_context context, const double * cord_vector); +qmckl_exit_code qmckl_set_jastrow_dependencies (qmckl_context context); #+end_src #+NAME:pre2 @@ -630,11 +678,61 @@ qmckl_exit_code qmckl_set_jastrow_type_nucl_num(qmckl_context context, const int <> } -qmckl_exit_code qmckl_set_jastrow_aord_vector(qmckl_context context, double const * aord_vector) { +qmckl_exit_code qmckl_set_jastrow_type_nucl_vector(qmckl_context context, int64_t const * type_nucl_vector, const int64_t nucl_num) { <> int32_t mask = 1 << 2; + int64_t type_nucl_num; + qmckl_exit_code rc = qmckl_get_jastrow_type_nucl_num(context, &type_nucl_num); + if (rc != QMCKL_SUCCESS) return rc; + + if (type_nucl_num == 0) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_jastrow_type_nucl_vector", + "type_nucl_num is not set"); + } + + if (type_nucl_vector == NULL) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_2, + "qmckl_set_jastrow_type_nucl_vector", + "type_nucl_vector = NULL"); + } + + if (ctx->jastrow.type_nucl_vector != NULL) { + qmckl_exit_code rc = qmckl_free(context, ctx->jastrow.type_nucl_vector); + if (rc != QMCKL_SUCCESS) { + return qmckl_failwith( context, rc, + "qmckl_set_type_nucl_vector", + 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_jastrow_type_nucl_vector", + NULL); + } + + memcpy(new_array, type_nucl_vector, mem_info.size); + + ctx->jastrow.type_nucl_vector = new_array; + + <> +} + +qmckl_exit_code qmckl_set_jastrow_aord_vector(qmckl_context context, double const * aord_vector) { +<> + + int32_t mask = 1 << 3; + int64_t aord_num; qmckl_exit_code rc = qmckl_get_jastrow_aord_num(context, &aord_num); if (rc != QMCKL_SUCCESS) return rc; @@ -687,7 +785,7 @@ qmckl_exit_code qmckl_set_jastrow_aord_vector(qmckl_context context, double cons qmckl_exit_code qmckl_set_jastrow_bord_vector(qmckl_context context, double const * bord_vector) { <> - int32_t mask = 1 << 3; + int32_t mask = 1 << 4; int64_t bord_num; qmckl_exit_code rc = qmckl_get_jastrow_bord_num(context, &bord_num); @@ -737,7 +835,7 @@ qmckl_exit_code qmckl_set_jastrow_bord_vector(qmckl_context context, double cons qmckl_exit_code qmckl_set_jastrow_cord_vector(qmckl_context context, double const * cord_vector) { <> - int32_t mask = 1 << 4; + int32_t mask = 1 << 5; int64_t cord_num; qmckl_exit_code rc = qmckl_get_jastrow_cord_num(context, &cord_num); @@ -807,7 +905,7 @@ qmckl_exit_code qmckl_set_jastrow_dependencies(qmckl_context context) { NULL); } - int32_t mask = 1 << 5; + int32_t mask = 1 << 6; <> } @@ -1272,6 +1370,7 @@ print("asymp_jasb[1] : ", asymp_jasb[1]) #+begin_src c :tangle (eval c_test) assert(qmckl_electron_provided(context)); +int64_t* type_nucl_vector = &(n2_type_nucl_vector[0]); double* aord_vector = &(n2_aord_vector[0][0]); double* bord_vector = &(n2_bord_vector[0]); double* cord_vector = &(n2_cord_vector[0][0]); @@ -1285,6 +1384,8 @@ rc = qmckl_set_jastrow_ord_num(context, n2_aord_num, n2_bord_num, n2_cord_num); assert(rc == QMCKL_SUCCESS); rc = qmckl_set_jastrow_type_nucl_num(context, n2_type_nucl_num); assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_type_nucl_vector(context, n2_type_nucl_vector, nucl_num); +assert(rc == QMCKL_SUCCESS); rc = qmckl_set_jastrow_aord_vector(context, aord_vector); assert(rc == QMCKL_SUCCESS); rc = qmckl_set_jastrow_bord_vector(context, bord_vector); @@ -2029,6 +2130,299 @@ assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); #+end_src +** Electron-nucleus component \(f_{en}\) + + Calculate the electron-electron jastrow component ~factor_en~ using the ~aord_vector~ + coeffecients and the electron-nucleus rescaled distances ~en_distance_rescaled~. + + \[ +f_{en} = \sum_{i,jjastrow.factor_en, ctx->electron.walk_num*sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide :noexport: + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_factor_en(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_factor_en(qmckl_context context) +{ + + qmckl_exit_code rc; + + 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); + + /* Check if en rescaled distance is provided */ + rc = qmckl_provide_en_distance_rescaled(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.factor_en_date) { + + /* Allocate array */ + if (ctx->jastrow.factor_en == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->electron.walk_num * sizeof(double); + double* factor_en = (double*) qmckl_malloc(context, mem_info); + + if (factor_en == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_provide_factor_en", + NULL); + } + ctx->jastrow.factor_en = factor_en; + } + + qmckl_exit_code rc = + qmckl_compute_factor_en(context, + ctx->electron.walk_num, + ctx->electron.num, + ctx->nucleus.num, + ctx->jastrow.type_nucl_num, + ctx->jastrow.type_nucl_vector, + ctx->jastrow.aord_num, + ctx->jastrow.aord_vector, + ctx->electron.en_distance_rescaled, + ctx->jastrow.factor_en); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.factor_en_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute + :PROPERTIES: + :Name: qmckl_compute_factor_en + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_factor_en_args + | qmckl_context | context | in | Global state | + | int64_t | walk_num | in | Number of walkers | + | int64_t | elec_num | in | Number of electrons | + | int64_t | nucl_num | in | Number of nucleii | + | int64_t | type_nucl_num | in | Number of unique nuclei | + | int64_t | type_nucl_vector[type_nucl_num] | in | IDs of unique nucleii | + | int64_t | aord_num | in | Number of coefficients | + | double | aord_vector[aord_num + 1][type_nucl_num] | in | List of coefficients | + | double | en_distance_rescaled[walk_num][nucl_num][elec_num] | in | Electron-nucleus distances | + | double | factor_en[walk_num] | out | Electron-nucleus jastrow | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_factor_en_f(context, walk_num, elec_num, nucl_num, type_nucl_num, & + type_nucl_vector, aord_num, aord_vector, & + en_distance_rescaled, factor_en) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: walk_num, elec_num, aord_num, nucl_num, type_nucl_num + integer*8 , intent(in) :: type_nucl_vector(type_nucl_num) + double precision , intent(in) :: aord_vector(aord_num, nucl_num) + double precision , intent(in) :: en_distance_rescaled(walk_num, elec_num, nucl_num) + double precision , intent(out) :: factor_en(walk_num) + + integer*8 :: i, a, p, ipar, nw + double precision :: x, spin_fact, power_ser + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (walk_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (elec_num <= 0) then + info = QMCKL_INVALID_ARG_3 + return + endif + + if (nucl_num <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + if (aord_num <= 0) then + info = QMCKL_INVALID_ARG_7 + return + endif + + factor_en = 0.0d0 + + do nw =1, walk_num + do a = 1, nucl_num + do i = 1, elec_num + x = en_distance_rescaled(nw, i, a) + power_ser = 0.0d0 + + do p = 2, aord_num + x = x * en_distance_rescaled(nw, i, a) + power_ser = power_ser + aord_vector(p + 1, type_nucl_vector(a)) * x + end do + + factor_en(nw) = factor_en(nw) + aord_vector(1, type_nucl_vector(a)) * & + en_distance_rescaled(nw, i, a) / & + (1.0d0 + aord_vector(2, type_nucl_vector(a)) * & + en_distance_rescaled(nw, i, a)) & + + power_ser + + end do + end do + end do + +end function qmckl_compute_factor_en_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_factor_en_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_factor_en ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t type_nucl_num, + const int64_t* type_nucl_vector, + const int64_t aord_num, + const double* aord_vector, + const double* en_distance_rescaled, + double* const factor_en ); + #+end_src + + + #+CALL: generate_c_interface(table=qmckl_factor_en_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_factor_en & + (context, & + walk_num, & + elec_num, & + nucl_num, & + type_nucl_num, & + type_nucl_vector, & + aord_num, & + aord_vector, & + en_distance_rescaled, & + factor_en) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: walk_num + integer (c_int64_t) , intent(in) , value :: elec_num + integer (c_int64_t) , intent(in) , value :: nucl_num + integer (c_int64_t) , intent(in) , value :: type_nucl_num + integer (c_int64_t) , intent(in) :: type_nucl_vector(type_nucl_num) + integer (c_int64_t) , intent(in) , value :: aord_num + real (c_double ) , intent(in) :: aord_vector(type_nucl_num,aord_num + 1) + real (c_double ) , intent(in) :: en_distance_rescaled(elec_num,nucl_num,walk_num) + real (c_double ) , intent(out) :: factor_en(walk_num) + + integer(c_int32_t), external :: qmckl_compute_factor_en_f + info = qmckl_compute_factor_en_f & + (context, & + walk_num, & + elec_num, & + nucl_num, & + type_nucl_num, & + type_nucl_vector, & + aord_num, & + aord_vector, & + en_distance_rescaled, & + factor_en) + + end function qmckl_compute_factor_en + #+end_src + +*** Test + #+begin_src python :results output :exports none :noweb yes +import numpy as np + +<> + +factor_en = 0.0 +for a in range(0,nucl_num): + for i in range(0,elec_num): + x = en_distance_rescaled[i][a] + pow_ser = 0.0 + + for p in range(2,aord_num+1): + x = x * en_distance_rescaled[i][a] + pow_ser = pow_ser + aord_vector[(p-1) + 1][type_nucl_vector[a]-1] * x + + factor_en = factor_en + aord_vector[0][type_nucl_vector[a]-1] * en_distance_rescaled[i][a] \ + / (1.0 + aord_vector[1][type_nucl_vector[a]-1] * en_distance_rescaled[i][a]) \ + + pow_ser +print("factor_en :",factor_en) + + #+end_src + + #+RESULTS: + : factor_en : -5.865822569188727 + + + #+begin_src c :tangle (eval c_test) +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +double factor_en[walk_num]; +rc = qmckl_get_jastrow_factor_en(context, factor_en); + +// calculate factor_en +assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); + + #+end_src + + * End of files :noexport: #+begin_src c :tangle (eval h_private_type) diff --git a/tests/n2.h b/tests/n2.h index 80f887a..ad675c0 100644 --- a/tests/n2.h +++ b/tests/n2.h @@ -5,7 +5,7 @@ double n2_charge[n2_nucl_num] = { 5., 5.}; double n2_nucl_coord[3][n2_nucl_num] = { {0.000000, 0.000000 }, {0.000000, 0.000000 }, - {2.059801, 2.059801 } }; + {0.000000, 2.059801 } }; #define n2_elec_up_num ((int64_t) 5) #define n2_elec_dn_num ((int64_t) 5) @@ -32,6 +32,10 @@ double n2_elec_coord[n2_walk_num][n2_elec_num][3] = { { #define n2_cord_num ((int64_t) 23) #define n2_dim_cord_vec ((int64_t) 23) +int64_t n2_type_nucl_vector[n2_nucl_num] = { + 1, + 1}; + double n2_aord_vector[n2_aord_num + 1][n2_type_nucl_num] = { { 0. }, { 0. }, From 0f761ae86c8b21f8796a2d8825a08e44a967ce2f Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 6 Jul 2021 16:20:17 +0530 Subject: [PATCH 35/92] Working on factor_en_deriv_e. #22 --- org/qmckl_electron.org | 48 +++--- org/qmckl_jastrow.org | 328 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 351 insertions(+), 25 deletions(-) diff --git a/org/qmckl_electron.org b/org/qmckl_electron.org index 284f3ef..8e9a298 100644 --- a/org/qmckl_electron.org +++ b/org/qmckl_electron.org @@ -63,29 +63,29 @@ int main() { The following data stored in the context: - | ~uninitialized~ | ~int32_t~ | Keeps bit set for uninitialized data | - | ~num~ | ~int64_t~ | Total number of electrons | - | ~up_num~ | ~int64_t~ | Number of up-spin electrons | - | ~down_num~ | ~int64_t~ | Number of down-spin electrons | - | ~walk_num~ | ~int64_t~ | Number of walkers | - | ~rescale_factor_kappa_ee~ | ~double~ | The distance scaling factor | - | ~rescale_factor_kappa_en~ | ~double~ | The distance scaling factor | - | ~provided~ | ~bool~ | If true, ~electron~ is valid | - | ~coord_new~ | ~double[walk_num][3][num]~ | New set of electron coordinates | - | ~coord_old~ | ~double[walk_num][3][num]~ | Old set of electron coordinates | - | ~coord_new_date~ | ~uint64_t~ | Last modification date of the coordinates | - | ~ee_distance~ | ~double[walk_num][num][num]~ | Electron-electron distances | - | ~ee_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~en_distance~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | - | ~en_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~ee_distance_rescaled~ | ~double[walk_num][num][num]~ | Electron-electron rescaled distances | - | ~ee_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~ee_distance_rescaled_deriv_e~ | ~double[walk_num][4][num][num]~ | Electron-electron rescaled distances derivatives | - | ~ee_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | - | ~en_distance_rescaled~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | - | ~en_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~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 | + | ~uninitialized~ | ~int32_t~ | Keeps bit set for uninitialized data | + | ~num~ | ~int64_t~ | Total number of electrons | + | ~up_num~ | ~int64_t~ | Number of up-spin electrons | + | ~down_num~ | ~int64_t~ | Number of down-spin electrons | + | ~walk_num~ | ~int64_t~ | Number of walkers | + | ~rescale_factor_kappa_ee~ | ~double~ | The distance scaling factor | + | ~rescale_factor_kappa_en~ | ~double~ | The distance scaling factor | + | ~provided~ | ~bool~ | If true, ~electron~ is valid | + | ~coord_new~ | ~double[walk_num][3][num]~ | New set of electron coordinates | + | ~coord_old~ | ~double[walk_num][3][num]~ | Old set of electron coordinates | + | ~coord_new_date~ | ~uint64_t~ | Last modification date of the coordinates | + | ~ee_distance~ | ~double[walk_num][num][num]~ | Electron-electron distances | + | ~ee_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~en_distance~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | + | ~en_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~ee_distance_rescaled~ | ~double[walk_num][num][num]~ | Electron-electron rescaled distances | + | ~ee_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~ee_distance_rescaled_deriv_e~ | ~double[walk_num][4][num][num]~ | Electron-electron rescaled distances derivatives | + | ~ee_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | + | ~en_distance_rescaled~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | + | ~en_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~en_distance_rescaled_deriv_e~ | ~double[walk_num][4][nucl_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 @@ -2112,7 +2112,7 @@ assert(fabs(en_distance_rescaled[1][0][1] - 0.9584331688679852) < 1.e-12); The rescaled distances which is given as $R = (1 - \exp{-\kappa r})/\kappa$ needs to be perturbed with respect to the nuclear coordinates. This data is stored in the ~en_distance_rescaled_deriv_e~ tensor. The - The first three elements of this three index tensor ~[4][num][num]~ gives the + The first three elements of this three index tensor ~[4][nucl_num][elec_num]~ gives the derivatives in the x, y, and z directions $dx, dy, dz$ and the last index gives the Laplacian $\partial x^2 + \partial y^2 + \partial z^2$. diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 461a445..d0da070 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2129,7 +2129,6 @@ assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); #+end_src - ** Electron-nucleus component \(f_{en}\) Calculate the electron-electron jastrow component ~factor_en~ using the ~aord_vector~ @@ -2422,6 +2421,333 @@ assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); #+end_src +** Electron-nucleus component derivative \(f'_{en}\) + + Calculate the electron-electron jastrow component ~factor_en_deriv_e~ derivative + with respect to the electron coordinates using the ~en_distance_rescaled~ and + ~en_distance_rescaled_deriv_e~ which are already calculated previously. + + TODO: write equations. + +*** Get + #+begin_src c :comments org :tangle (eval h_func) :noweb yes +qmckl_exit_code qmckl_get_jastrow_factor_en_deriv_e(qmckl_context context, double* const factor_en_deriv_e); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_get_jastrow_factor_en_deriv_e(qmckl_context context, double* const factor_en_deriv_e) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_factor_en_deriv_e(context); + if (rc != QMCKL_SUCCESS) return rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + memcpy(factor_en_deriv_e, ctx->jastrow.factor_en_deriv_e, ctx->electron.walk_num*sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide :noexport: + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_factor_en_deriv_e(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_factor_en_deriv_e(qmckl_context context) +{ + + qmckl_exit_code rc; + + 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); + + /* Check if en rescaled distance is provided */ + rc = qmckl_provide_en_distance_rescaled(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.factor_en_deriv_e_date) { + + /* Allocate array */ + if (ctx->jastrow.factor_en_deriv_e == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->electron.walk_num * sizeof(double); + double* factor_en_deriv_e = (double*) qmckl_malloc(context, mem_info); + + if (factor_en_deriv_e == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_provide_factor_en_deriv_e", + NULL); + } + ctx->jastrow.factor_en_deriv_e = factor_en_deriv_e; + } + + qmckl_exit_code rc = + qmckl_compute_factor_en_deriv_e(context, + ctx->electron.walk_num, + ctx->electron.num, + ctx->nucleus.num, + ctx->jastrow.type_nucl_num, + ctx->jastrow.type_nucl_vector, + ctx->jastrow.aord_num, + ctx->jastrow.aord_vector, + ctx->electron.en_distance_rescaled, + ctx->electron.en_distance_rescaled_deriv_e, + ctx->jastrow.factor_en_deriv_e); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.factor_en_deriv_e_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute + :PROPERTIES: + :Name: qmckl_compute_factor_en_deriv_e + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_factor_en_deriv_e_args + | qmckl_context | context | in | Global state | + | int64_t | walk_num | in | Number of walkers | + | int64_t | elec_num | in | Number of electrons | + | int64_t | nucl_num | in | Number of nucleii | + | int64_t | type_nucl_num | in | Number of unique nuclei | + | int64_t | type_nucl_vector[type_nucl_num] | in | IDs of unique nucleii | + | int64_t | aord_num | in | Number of coefficients | + | double | aord_vector[aord_num + 1][type_nucl_num] | in | List of coefficients | + | double | en_distance_rescaled[walk_num][nucl_num][elec_num] | in | Electron-nucleus distances | + | double | en_distance_rescaled_deriv_e[walk_num][4][nucl_num][elec_num] | in | Electron-nucleus distance derivatives | + | double | factor_en_deriv_e[walk_num][4][elec_num] | out | Electron-nucleus jastrow | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_factor_en_deriv_e_f(context, walk_num, elec_num, nucl_num, type_nucl_num, & + type_nucl_vector, aord_num, aord_vector, & + en_distance_rescaled, en_distance_rescaled_deriv_e, factor_en_deriv_e) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: walk_num, elec_num, aord_num, nucl_num, type_nucl_num + integer*8 , intent(in) :: type_nucl_vector(type_nucl_num) + double precision , intent(in) :: aord_vector(aord_num, nucl_num) + double precision , intent(in) :: en_distance_rescaled(walk_num, elec_num, nucl_num) + double precision , intent(in) :: en_distance_rescaled_deriv_e(walk_num, 4, elec_num, nucl_num) + double precision , intent(out) :: factor_en_deriv_e(walk_num,4,elec_num) + + integer*8 :: i, a, p, ipar, nw, ii + double precision :: x, spin_fact, den, invden, invden2, invden3, xinv + double precision :: y, lap1, lap2, lap3, third + double precision, dimension(3) :: power_ser_g + double precision, dimension(4) :: dx + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (walk_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (elec_num <= 0) then + info = QMCKL_INVALID_ARG_3 + return + endif + + if (nucl_num <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + if (aord_num <= 0) then + info = QMCKL_INVALID_ARG_7 + return + endif + + factor_en_deriv_e = 0.0d0 + third = 1.0d0 / 3.0d0 + + do nw =1, walk_num + do a = 1, nucl_num + do i = 1, elec_num + x = en_distance_rescaled(nw, i, a) + if(abs(x) < 1.0d-18) continue + power_ser_g = 0.0d0 + den = 1.0d0 + aord_vector(2, type_nucl_vector(a)) * x + invden = 1.0d0 / den + invden2 = invden * invden + invden3 = invden2 * invden + xinv = 1.0d0 / x + + do ii = 1, 4 + dx(ii) = en_distance_rescaled_deriv_e(nw, ii, i, a) + end do + + lap1 = 0.0d0 + lap2 = 0.0d0 + lap3 = 0.0d0 + do ii = 1, 3 + x = en_distance_rescaled(nw, i, a) + do p = 2, aord_num + y = p * aord_vector(p + 1, type_nucl_vector(a)) * x + power_ser_g(ii) = power_ser_g(ii) + y * dx(ii) + lap1 = lap1 + (p - 1) * y * xinv * dx(ii) * dx(ii) + lap2 = lap2 + y + x = x * en_distance_rescaled(nw, i, a) + end do + + lap3 = lap3 - 2.0d0 * aord_vector(2, type_nucl_vector(a)) * dx(ii) * dx(ii) + + factor_en_deriv_e(nw, ii, i) = factor_en_deriv_e(nw, ii, i) + aord_vector(1, type_nucl_vector(a)) & + * dx(ii) * invden2 & + + power_ser_g(ii) + + end do + + ii = 4 + lap2 = lap2 * dx(ii) * third + lap3 = lap3 + den * dx(ii) + lap3 = lap3 * aord_vector(1, type_nucl_vector(a)) * invden3 + factor_en_deriv_e(nw, ii, i) = factor_en_deriv_e(nw, ii, i) + lap1 + lap2 + lap3 + + end do + end do + end do + +end function qmckl_compute_factor_en_deriv_e_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_factor_en_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_factor_en_deriv_e ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t type_nucl_num, + const int64_t* type_nucl_vector, + const int64_t aord_num, + const double* aord_vector, + const double* en_distance_rescaled, + const double* en_distance_rescaled_deriv_e, + double* const factor_en_deriv_e ); + #+end_src + + + #+CALL: generate_c_interface(table=qmckl_factor_en_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_factor_en_deriv_e & + (context, & + walk_num, & + elec_num, & + nucl_num, & + type_nucl_num, & + type_nucl_vector, & + aord_num, & + aord_vector, & + en_distance_rescaled, & + en_distance_rescaled_deriv_e, & + factor_en_deriv_e) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: walk_num + integer (c_int64_t) , intent(in) , value :: elec_num + integer (c_int64_t) , intent(in) , value :: nucl_num + integer (c_int64_t) , intent(in) , value :: type_nucl_num + integer (c_int64_t) , intent(in) :: type_nucl_vector(type_nucl_num) + integer (c_int64_t) , intent(in) , value :: aord_num + real (c_double ) , intent(in) :: aord_vector(type_nucl_num,aord_num + 1) + real (c_double ) , intent(in) :: en_distance_rescaled(elec_num,nucl_num,walk_num) + real (c_double ) , intent(in) :: en_distance_rescaled_deriv_e(elec_num,nucl_num,4,walk_num) + real (c_double ) , intent(out) :: factor_en_deriv_e(elec_num,4,walk_num) + + integer(c_int32_t), external :: qmckl_compute_factor_en_deriv_e_f + info = qmckl_compute_factor_en_deriv_e_f & + (context, & + walk_num, & + elec_num, & + nucl_num, & + type_nucl_num, & + type_nucl_vector, & + aord_num, & + aord_vector, & + en_distance_rescaled, & + en_distance_rescaled_deriv_e, & + factor_en_deriv_e) + + end function qmckl_compute_factor_en_deriv_e + #+end_src + +*** Test + #+begin_src python :results output :exports none :noweb yes +import numpy as np + +<> + +factor_en = 0.0 +for a in range(0,nucl_num): + for i in range(0,elec_num): + x = en_distance_rescaled[i][a] + pow_ser = 0.0 + + for p in range(2,aord_num+1): + x = x * en_distance_rescaled[i][a] + pow_ser = pow_ser + aord_vector[(p-1) + 1][type_nucl_vector[a]-1] * x + + factor_en = factor_en + aord_vector[0][type_nucl_vector[a]-1] * en_distance_rescaled[i][a] \ + / (1.0 + aord_vector[1][type_nucl_vector[a]-1] * en_distance_rescaled[i][a]) \ + + pow_ser +print("factor_en :",factor_en) + + #+end_src + + #+RESULTS: + : factor_en : -5.865822569188727 + + + #+begin_src c :tangle (eval c_test) +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +//double factor_en[walk_num]; +//rc = qmckl_get_jastrow_factor_en(context, factor_en); +// +//// calculate factor_en +//assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); + + #+end_src + * End of files :noexport: From a5a1e6dc2ffc545df38edd5e10a95c0f92e7c75c Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 6 Jul 2021 17:12:31 +0530 Subject: [PATCH 36/92] Fixed unused variables warning. #22 --- org/qmckl_jastrow.org | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index d0da070..9601b51 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1370,7 +1370,11 @@ print("asymp_jasb[1] : ", asymp_jasb[1]) #+begin_src c :tangle (eval c_test) assert(qmckl_electron_provided(context)); +int64_t type_nucl_num = n2_type_nucl_num; int64_t* type_nucl_vector = &(n2_type_nucl_vector[0]); +int64_t aord_num = n2_aord_num; +int64_t bord_num = n2_bord_num; +int64_t cord_num = n2_cord_num; double* aord_vector = &(n2_aord_vector[0][0]); double* bord_vector = &(n2_bord_vector[0]); double* cord_vector = &(n2_cord_vector[0][0]); @@ -1380,11 +1384,11 @@ rc = qmckl_init_jastrow(context); assert(!qmckl_jastrow_provided(context)); /* Set the data */ -rc = qmckl_set_jastrow_ord_num(context, n2_aord_num, n2_bord_num, n2_cord_num); +rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_type_nucl_num(context, n2_type_nucl_num); +rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_type_nucl_vector(context, n2_type_nucl_vector, nucl_num); +rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); assert(rc == QMCKL_SUCCESS); rc = qmckl_set_jastrow_aord_vector(context, aord_vector); assert(rc == QMCKL_SUCCESS); From b0f4069c5be31f80ec65661e082e8cbe7be60700 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 6 Jul 2021 17:13:39 +0530 Subject: [PATCH 37/92] Removed asserts for checking github build. #22 --- org/qmckl_jastrow.org | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 9601b51..561511e 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1706,7 +1706,7 @@ double factor_ee[walk_num]; rc = qmckl_get_jastrow_factor_ee(context, factor_ee); // calculate factor_ee -assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); +//assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); #+end_src @@ -2126,10 +2126,10 @@ double factor_ee_deriv_e[walk_num][4][elec_num]; rc = qmckl_get_jastrow_factor_ee_deriv_e(context, &(factor_ee_deriv_e[0][0][0])); // check factor_ee_deriv_e -assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); -assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); -assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); -assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); +//assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); +//assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); +//assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); +//assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); #+end_src @@ -2421,7 +2421,7 @@ double factor_en[walk_num]; rc = qmckl_get_jastrow_factor_en(context, factor_en); // calculate factor_en -assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); +//assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); #+end_src From 9df44ee0262fc9bb67e8d7463f0e0b5d495a0ce4 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 6 Jul 2021 18:57:14 +0530 Subject: [PATCH 38/92] Finished factor_en_deriv_e. #22 --- org/qmckl_jastrow.org | 141 ++++++++++++++++++++++++++++++++---------- 1 file changed, 108 insertions(+), 33 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 561511e..5c90528 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -116,9 +116,9 @@ elec_num = 10 nucl_num = 2 up_num = 5 down_num = 5 -nucl_coord = [ [0.000000, 0.000000 ], +nucl_coord = np.array([ [0.000000, 0.000000 ], [0.000000, 0.000000 ], - [2.059801, 2.059801 ] ] + [0.000000, 2.059801 ] ]) elec_coord = [[[-0.250655104764153 , 0.503070975550133 , -0.166554344502303], [-0.587812193472177 , -0.128751981129274 , 0.187773606533075], @@ -1706,10 +1706,10 @@ double factor_ee[walk_num]; rc = qmckl_get_jastrow_factor_ee(context, factor_ee); // calculate factor_ee -//assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); +assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); #+end_src - + ** Electron-electron component derivative \(f'_{ee}\) Calculate the derivative of the ~factor_ee~ using the ~ee_distance_rescaled~ and @@ -2126,10 +2126,10 @@ double factor_ee_deriv_e[walk_num][4][elec_num]; rc = qmckl_get_jastrow_factor_ee_deriv_e(context, &(factor_ee_deriv_e[0][0][0])); // check factor_ee_deriv_e -//assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); -//assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); -//assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); -//assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); #+end_src @@ -2421,12 +2421,11 @@ double factor_en[walk_num]; rc = qmckl_get_jastrow_factor_en(context, factor_en); // calculate factor_en -//assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); +assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); #+end_src ** Electron-nucleus component derivative \(f'_{en}\) - Calculate the electron-electron jastrow component ~factor_en_deriv_e~ derivative with respect to the electron coordinates using the ~en_distance_rescaled~ and ~en_distance_rescaled_deriv_e~ which are already calculated previously. @@ -2453,7 +2452,8 @@ qmckl_exit_code qmckl_get_jastrow_factor_en_deriv_e(qmckl_context context, doubl qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - memcpy(factor_en_deriv_e, ctx->jastrow.factor_en_deriv_e, ctx->electron.walk_num*sizeof(double)); + int64_t sze = ctx->electron.walk_num * 4 * ctx->electron.num; + memcpy(factor_en_deriv_e, ctx->jastrow.factor_en_deriv_e, sze*sizeof(double)); return QMCKL_SUCCESS; } @@ -2481,6 +2481,10 @@ qmckl_exit_code qmckl_provide_factor_en_deriv_e(qmckl_context context) rc = qmckl_provide_en_distance_rescaled(context); if(rc != QMCKL_SUCCESS) return rc; + /* Check if en rescaled distance derivatives is provided */ + rc = qmckl_provide_en_distance_rescaled_deriv_e(context); + if(rc != QMCKL_SUCCESS) return rc; + /* Compute if necessary */ if (ctx->date > ctx->jastrow.factor_en_deriv_e_date) { @@ -2556,7 +2560,7 @@ integer function qmckl_compute_factor_en_deriv_e_f(context, walk_num, elec_num, double precision , intent(in) :: aord_vector(aord_num, nucl_num) double precision , intent(in) :: en_distance_rescaled(walk_num, elec_num, nucl_num) double precision , intent(in) :: en_distance_rescaled_deriv_e(walk_num, 4, elec_num, nucl_num) - double precision , intent(out) :: factor_en_deriv_e(walk_num,4,elec_num) + double precision , intent(out) :: factor_en_deriv_e(elec_num,4,walk_num) integer*8 :: i, a, p, ipar, nw, ii double precision :: x, spin_fact, den, invden, invden2, invden3, xinv @@ -2625,7 +2629,7 @@ integer function qmckl_compute_factor_en_deriv_e_f(context, walk_num, elec_num, lap3 = lap3 - 2.0d0 * aord_vector(2, type_nucl_vector(a)) * dx(ii) * dx(ii) - factor_en_deriv_e(nw, ii, i) = factor_en_deriv_e(nw, ii, i) + aord_vector(1, type_nucl_vector(a)) & + factor_en_deriv_e(i, ii, nw) = factor_en_deriv_e(i, ii, nw) + aord_vector(1, type_nucl_vector(a)) & * dx(ii) * invden2 & + power_ser_g(ii) @@ -2635,7 +2639,7 @@ integer function qmckl_compute_factor_en_deriv_e_f(context, walk_num, elec_num, lap2 = lap2 * dx(ii) * third lap3 = lap3 + den * dx(ii) lap3 = lap3 * aord_vector(1, type_nucl_vector(a)) * invden3 - factor_en_deriv_e(nw, ii, i) = factor_en_deriv_e(nw, ii, i) + lap1 + lap2 + lap3 + factor_en_deriv_e(i, ii, nw) = factor_en_deriv_e(i, ii, nw) + lap1 + lap2 + lap3 end do end do @@ -2719,36 +2723,107 @@ import numpy as np <> -factor_en = 0.0 -for a in range(0,nucl_num): - for i in range(0,elec_num): - x = en_distance_rescaled[i][a] - pow_ser = 0.0 - - for p in range(2,aord_num+1): - x = x * en_distance_rescaled[i][a] - pow_ser = pow_ser + aord_vector[(p-1) + 1][type_nucl_vector[a]-1] * x +kappa = 1.0 + +elec_coord = np.array(elec_coord)[0] +nucl_coord = np.array(nucl_coord) +elnuc_dist = np.zeros(shape=(elec_num, nucl_num),dtype=float) +for i in range(elec_num): + for j in range(nucl_num): + elnuc_dist[i, j] = np.linalg.norm(elec_coord[i] - nucl_coord[:,j]) + +elnuc_dist_deriv_e = np.zeros(shape=(4, elec_num, nucl_num),dtype=float) +for a in range(nucl_num): + for i in range(elec_num): + rij_inv = 1.0 / elnuc_dist[i, a] + for ii in range(3): + elnuc_dist_deriv_e[ii, i, a] = (elec_coord[i][ii] - nucl_coord[ii][a]) * rij_inv + elnuc_dist_deriv_e[3, i, a] = 2.0 * rij_inv + +en_distance_rescaled_deriv_e = np.zeros(shape=(4,elec_num,nucl_num),dtype=float) +for a in range(nucl_num): + for i in range(elec_num): + f = 1.0 - kappa * en_distance_rescaled[i][a] + for ii in range(4): + en_distance_rescaled_deriv_e[ii][i][a] = elnuc_dist_deriv_e[ii][i][a] + en_distance_rescaled_deriv_e[3][i][a] = en_distance_rescaled_deriv_e[3][i][a] + \ + (-kappa * en_distance_rescaled_deriv_e[0][i][a] * en_distance_rescaled_deriv_e[0][i][a]) + \ + (-kappa * en_distance_rescaled_deriv_e[1][i][a] * en_distance_rescaled_deriv_e[1][i][a]) + \ + (-kappa * en_distance_rescaled_deriv_e[2][i][a] * en_distance_rescaled_deriv_e[2][i][a]) + for ii in range(4): + en_distance_rescaled_deriv_e[ii][i][a] = en_distance_rescaled_deriv_e[ii][i][a] * f + +third = 1.0 / 3.0 +factor_en_deriv_e = np.zeros(shape=(4,elec_num),dtype=float) +dx = np.zeros(shape=(4),dtype=float) +pow_ser_g = np.zeros(shape=(3),dtype=float) +for a in range(nucl_num): + for i in range(elec_num): + x = en_distance_rescaled[i][a] + if abs(x) < 1e-18: + continue + pow_ser_g = np.zeros(shape=(3),dtype=float) + den = 1.0 + aord_vector[1][type_nucl_vector[a]-1] * x + invden = 1.0 / den + invden2 = invden * invden + invden3 = invden2 * invden + xinv = 1.0 / (x + 1.0E-18) + + for ii in range(4): + dx[ii] = en_distance_rescaled_deriv_e[ii][i][a] + + lap1 = 0.0 + lap2 = 0.0 + lap3 = 0.0 + for ii in range(3): + x = en_distance_rescaled[i][a] + if x < 1e-18: + continue + for p in range(2,aord_num+1): + y = p * aord_vector[(p-1) + 1][type_nucl_vector[a]-1] * x + pow_ser_g[ii] = pow_ser_g[ii] + y * dx[ii] + lap1 = lap1 + (p - 1) * y * xinv * dx[ii] * dx[ii] + lap2 = lap2 + y + x = x * en_distance_rescaled[i][a] + + lap3 = lap3 - 2.0 * aord_vector[1][type_nucl_vector[a]-1] * dx[ii] * dx[ii] + + factor_en_deriv_e[ii][i] = factor_en_deriv_e[ii][i] + aord_vector[0][type_nucl_vector[a]-1] * \ + dx[ii] * invden2 + pow_ser_g[ii] + + ii = 3 + lap2 = lap2 * dx[ii] * third + lap3 = lap3 + den * dx[ii] + lap3 = lap3 * (aord_vector[0][type_nucl_vector[a]-1] * invden3) + factor_en_deriv_e[ii][i] = factor_en_deriv_e[ii][i] + lap1 + lap2 + lap3 + +print("factor_en_deriv_e[0][0]:",factor_en_deriv_e[0][0]) +print("factor_en_deriv_e[1][0]:",factor_en_deriv_e[1][0]) +print("factor_en_deriv_e[2][0]:",factor_en_deriv_e[2][0]) +print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) - factor_en = factor_en + aord_vector[0][type_nucl_vector[a]-1] * en_distance_rescaled[i][a] \ - / (1.0 + aord_vector[1][type_nucl_vector[a]-1] * en_distance_rescaled[i][a]) \ - + pow_ser -print("factor_en :",factor_en) #+end_src #+RESULTS: - : factor_en : -5.865822569188727 + : factor_en_deriv_e[0][0]: 0.11609919541763383 + : factor_en_deriv_e[1][0]: -0.23301394780804574 + : factor_en_deriv_e[2][0]: 0.17548337641865783 + : factor_en_deriv_e[3][0]: -0.9667363412285741 #+begin_src c :tangle (eval c_test) /* Check if Jastrow is properly initialized */ assert(qmckl_jastrow_provided(context)); -//double factor_en[walk_num]; -//rc = qmckl_get_jastrow_factor_en(context, factor_en); -// -//// calculate factor_en -//assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); +double factor_en_deriv_e[walk_num][4][elec_num]; +rc = qmckl_get_jastrow_factor_en_deriv_e(context, &(factor_en_deriv_e[0][0][0])); + +// calculate factor_en +assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); +assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); +assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); +assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); #+end_src From 4c20982d6f58b501e5a349dd74601cea0efcad76 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 6 Jul 2021 19:49:22 +0530 Subject: [PATCH 39/92] Fixed memory lead in malloc caught by valgrind. #22 --- org/qmckl_jastrow.org | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 5c90528..e05c37a 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2492,7 +2492,7 @@ qmckl_exit_code qmckl_provide_factor_en_deriv_e(qmckl_context context) if (ctx->jastrow.factor_en_deriv_e == NULL) { qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; - mem_info.size = ctx->electron.walk_num * sizeof(double); + mem_info.size = ctx->electron.walk_num * 4 * ctx->electron.num * sizeof(double); double* factor_en_deriv_e = (double*) qmckl_malloc(context, mem_info); if (factor_en_deriv_e == NULL) { @@ -2816,10 +2816,11 @@ print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) /* Check if Jastrow is properly initialized */ assert(qmckl_jastrow_provided(context)); +// calculate factor_en_deriv_e double factor_en_deriv_e[walk_num][4][elec_num]; rc = qmckl_get_jastrow_factor_en_deriv_e(context, &(factor_en_deriv_e[0][0][0])); -// calculate factor_en +// check factor_en_deriv_e assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); From 9b55720fa04725948c1c172797a69d3d3bc02f5a Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 6 Jul 2021 20:05:03 +0530 Subject: [PATCH 40/92] Removed jastrow tests for checking github ci. #22 --- org/qmckl_jastrow.org | 490 +++++++++++++++++++++--------------------- 1 file changed, 245 insertions(+), 245 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index e05c37a..ebf9c36 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -969,172 +969,172 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { ** Test #+begin_src c :tangle (eval c_test) -/* Reference input data */ -int64_t walk_num = n2_walk_num; -int64_t elec_num = n2_elec_num; -int64_t elec_up_num = n2_elec_up_num; -int64_t elec_dn_num = n2_elec_dn_num; -double rescale_factor_kappa_ee = 1.0; -double rescale_factor_kappa_en = 1.0; -double nucl_rescale_factor_kappa = 1.0; -double* elec_coord = &(n2_elec_coord[0][0][0]); - -const double* nucl_charge = n2_charge; -int64_t nucl_num = n2_nucl_num; -double* charge = n2_charge; -double* nucl_coord = &(n2_nucl_coord[0][0]); - -/* Provide Electron data */ - +///* Reference input data */ +//int64_t walk_num = n2_walk_num; +//int64_t elec_num = n2_elec_num; +//int64_t elec_up_num = n2_elec_up_num; +//int64_t elec_dn_num = n2_elec_dn_num; +//double rescale_factor_kappa_ee = 1.0; +//double rescale_factor_kappa_en = 1.0; +//double nucl_rescale_factor_kappa = 1.0; +//double* elec_coord = &(n2_elec_coord[0][0][0]); +// +//const double* nucl_charge = n2_charge; +//int64_t nucl_num = n2_nucl_num; +//double* charge = n2_charge; +//double* nucl_coord = &(n2_nucl_coord[0][0]); +// +///* Provide Electron data */ +// qmckl_exit_code rc; - -assert(!qmckl_electron_provided(context)); - -int64_t n; -rc = qmckl_get_electron_num (context, &n); -assert(rc == QMCKL_NOT_PROVIDED); - -rc = qmckl_get_electron_up_num (context, &n); -assert(rc == QMCKL_NOT_PROVIDED); - -rc = qmckl_get_electron_down_num (context, &n); -assert(rc == QMCKL_NOT_PROVIDED); - - -rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num); -assert(rc == QMCKL_SUCCESS); -assert(!qmckl_electron_provided(context)); - -rc = qmckl_get_electron_up_num (context, &n); -assert(rc == QMCKL_SUCCESS); -assert(n == elec_up_num); - -rc = qmckl_get_electron_down_num (context, &n); -assert(rc == QMCKL_SUCCESS); -assert(n == elec_dn_num); - -rc = qmckl_get_electron_num (context, &n); -assert(rc == QMCKL_SUCCESS); -assert(n == elec_num); - -double k_ee = 0.; -double k_en = 0.; -rc = qmckl_get_electron_rescale_factor_ee (context, &k_ee); -assert(rc == QMCKL_SUCCESS); -assert(k_ee == 1.0); - -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_electron_rescale_factor_en (context, &k_en); -assert(rc == QMCKL_SUCCESS); -assert(k_en == rescale_factor_kappa_en); - - -int64_t w; -rc = qmckl_get_electron_walk_num (context, &w); -assert(rc == QMCKL_NOT_PROVIDED); - - -rc = qmckl_set_electron_walk_num (context, walk_num); -assert(rc == QMCKL_SUCCESS); - -rc = qmckl_get_electron_walk_num (context, &w); -assert(rc == QMCKL_SUCCESS); -assert(w == walk_num); - -assert(qmckl_electron_provided(context)); - -rc = qmckl_set_electron_coord (context, 'N', elec_coord); -assert(rc == QMCKL_SUCCESS); - -double elec_coord2[walk_num*3*elec_num]; - -rc = qmckl_get_electron_coord (context, 'N', elec_coord2); -assert(rc == QMCKL_SUCCESS); -for (int64_t i=0 ; i<3*elec_num ; ++i) { - assert( elec_coord[i] == elec_coord2[i] ); - } - - -/* Provide Nucleus data */ - -assert(!qmckl_nucleus_provided(context)); - -rc = qmckl_get_nucleus_num (context, &n); -assert(rc == QMCKL_NOT_PROVIDED); - - -rc = qmckl_set_nucleus_num (context, nucl_num); -assert(rc == QMCKL_SUCCESS); -assert(!qmckl_nucleus_provided(context)); - -rc = qmckl_get_nucleus_num (context, &n); -assert(rc == QMCKL_SUCCESS); -assert(n == nucl_num); - -double k; -rc = qmckl_get_nucleus_rescale_factor (context, &k); -assert(rc == QMCKL_SUCCESS); -assert(k == 1.0); - - -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); - -double nucl_coord2[3*nucl_num]; - -rc = qmckl_get_nucleus_coord (context, 'T', nucl_coord2); -assert(rc == QMCKL_NOT_PROVIDED); - -rc = qmckl_set_nucleus_coord (context, 'T', &(nucl_coord[0])); -assert(rc == QMCKL_SUCCESS); - -assert(!qmckl_nucleus_provided(context)); - -rc = qmckl_get_nucleus_coord (context, 'N', nucl_coord2); -assert(rc == QMCKL_SUCCESS); -for (size_t k=0 ; k<3 ; ++k) { - for (size_t i=0 ; i Date: Tue, 6 Jul 2021 20:37:08 +0530 Subject: [PATCH 41/92] Fixed issue with tests header. Reinstated Jastrow tests. #22 --- Makefile.am | 3 +- org/qmckl_jastrow.org | 490 +++++++++++++++++++++--------------------- org/qmckl_tests.org | 156 ++++++++++++++ tests/n2.h | 1 - 4 files changed, 403 insertions(+), 247 deletions(-) diff --git a/Makefile.am b/Makefile.am index 57ad20b..ca045b9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,7 +52,7 @@ test_qmckl_f = tests/qmckl_f.f90 test_qmckl_fo = tests/qmckl_f.o src_qmckl_f = src/qmckl_f.f90 src_qmckl_fo = src/qmckl_f.o -header_tests = tests/chbrclf.h +header_tests = tests/chbrclf.h tests/n2.h fortrandir = $(datadir)/$(PACKAGE_NAME)/fortran/ dist_fortran_DATA = $(qmckl_f) @@ -157,6 +157,7 @@ $(htmlize_el): tests/chbrclf.h: $(qmckl_h) +tests/n2.h: $(qmckl_h) generated.mk: $(ORG_FILES) $(PYTHON) $(srcdir)/tools/build_makefile.py diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index ebf9c36..e05c37a 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -969,172 +969,172 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { ** Test #+begin_src c :tangle (eval c_test) -///* Reference input data */ -//int64_t walk_num = n2_walk_num; -//int64_t elec_num = n2_elec_num; -//int64_t elec_up_num = n2_elec_up_num; -//int64_t elec_dn_num = n2_elec_dn_num; -//double rescale_factor_kappa_ee = 1.0; -//double rescale_factor_kappa_en = 1.0; -//double nucl_rescale_factor_kappa = 1.0; -//double* elec_coord = &(n2_elec_coord[0][0][0]); -// -//const double* nucl_charge = n2_charge; -//int64_t nucl_num = n2_nucl_num; -//double* charge = n2_charge; -//double* nucl_coord = &(n2_nucl_coord[0][0]); -// -///* Provide Electron data */ -// +/* Reference input data */ +int64_t walk_num = n2_walk_num; +int64_t elec_num = n2_elec_num; +int64_t elec_up_num = n2_elec_up_num; +int64_t elec_dn_num = n2_elec_dn_num; +double rescale_factor_kappa_ee = 1.0; +double rescale_factor_kappa_en = 1.0; +double nucl_rescale_factor_kappa = 1.0; +double* elec_coord = &(n2_elec_coord[0][0][0]); + +const double* nucl_charge = n2_charge; +int64_t nucl_num = n2_nucl_num; +double* charge = n2_charge; +double* nucl_coord = &(n2_nucl_coord[0][0]); + +/* Provide Electron data */ + qmckl_exit_code rc; -// -//assert(!qmckl_electron_provided(context)); -// -//int64_t n; -//rc = qmckl_get_electron_num (context, &n); -//assert(rc == QMCKL_NOT_PROVIDED); -// -//rc = qmckl_get_electron_up_num (context, &n); -//assert(rc == QMCKL_NOT_PROVIDED); -// -//rc = qmckl_get_electron_down_num (context, &n); -//assert(rc == QMCKL_NOT_PROVIDED); -// -// -//rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num); -//assert(rc == QMCKL_SUCCESS); -//assert(!qmckl_electron_provided(context)); -// -//rc = qmckl_get_electron_up_num (context, &n); -//assert(rc == QMCKL_SUCCESS); -//assert(n == elec_up_num); -// -//rc = qmckl_get_electron_down_num (context, &n); -//assert(rc == QMCKL_SUCCESS); -//assert(n == elec_dn_num); -// -//rc = qmckl_get_electron_num (context, &n); -//assert(rc == QMCKL_SUCCESS); -//assert(n == elec_num); -// -//double k_ee = 0.; -//double k_en = 0.; -//rc = qmckl_get_electron_rescale_factor_ee (context, &k_ee); -//assert(rc == QMCKL_SUCCESS); -//assert(k_ee == 1.0); -// -//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_electron_rescale_factor_en (context, &k_en); -//assert(rc == QMCKL_SUCCESS); -//assert(k_en == rescale_factor_kappa_en); -// -// -//int64_t w; -//rc = qmckl_get_electron_walk_num (context, &w); -//assert(rc == QMCKL_NOT_PROVIDED); -// -// -//rc = qmckl_set_electron_walk_num (context, walk_num); -//assert(rc == QMCKL_SUCCESS); -// -//rc = qmckl_get_electron_walk_num (context, &w); -//assert(rc == QMCKL_SUCCESS); -//assert(w == walk_num); -// -//assert(qmckl_electron_provided(context)); -// -//rc = qmckl_set_electron_coord (context, 'N', elec_coord); -//assert(rc == QMCKL_SUCCESS); -// -//double elec_coord2[walk_num*3*elec_num]; -// -//rc = qmckl_get_electron_coord (context, 'N', elec_coord2); -//assert(rc == QMCKL_SUCCESS); -//for (int64_t i=0 ; i<3*elec_num ; ++i) { -// assert( elec_coord[i] == elec_coord2[i] ); -// } -// -// -///* Provide Nucleus data */ -// -//assert(!qmckl_nucleus_provided(context)); -// -//rc = qmckl_get_nucleus_num (context, &n); -//assert(rc == QMCKL_NOT_PROVIDED); -// -// -//rc = qmckl_set_nucleus_num (context, nucl_num); -//assert(rc == QMCKL_SUCCESS); -//assert(!qmckl_nucleus_provided(context)); -// -//rc = qmckl_get_nucleus_num (context, &n); -//assert(rc == QMCKL_SUCCESS); -//assert(n == nucl_num); -// -//double k; -//rc = qmckl_get_nucleus_rescale_factor (context, &k); -//assert(rc == QMCKL_SUCCESS); -//assert(k == 1.0); -// -// -//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); -// -//double nucl_coord2[3*nucl_num]; -// -//rc = qmckl_get_nucleus_coord (context, 'T', nucl_coord2); -//assert(rc == QMCKL_NOT_PROVIDED); -// -//rc = qmckl_set_nucleus_coord (context, 'T', &(nucl_coord[0])); -//assert(rc == QMCKL_SUCCESS); -// -//assert(!qmckl_nucleus_provided(context)); -// -//rc = qmckl_get_nucleus_coord (context, 'N', nucl_coord2); -//assert(rc == QMCKL_SUCCESS); -//for (size_t k=0 ; k<3 ; ++k) { -// for (size_t i=0 ; i Date: Tue, 6 Jul 2021 20:46:47 +0530 Subject: [PATCH 42/92] Removed n2.h file. #22 --- tests/n2.h | 109 ----------------------------------------------------- 1 file changed, 109 deletions(-) delete mode 100644 tests/n2.h diff --git a/tests/n2.h b/tests/n2.h deleted file mode 100644 index 86370e5..0000000 --- a/tests/n2.h +++ /dev/null @@ -1,109 +0,0 @@ -#define n2_nucl_num ((int64_t) 2) - -double n2_charge[n2_nucl_num] = { 5., 5.}; - -double n2_nucl_coord[3][n2_nucl_num] = -{ {0.000000, 0.000000 }, - {0.000000, 0.000000 }, - {0.000000, 2.059801 } }; - -#define n2_elec_up_num ((int64_t) 5) -#define n2_elec_dn_num ((int64_t) 5) -#define n2_elec_num ((int64_t) 10) -#define n2_walk_num ((int64_t) 1) - -double n2_elec_coord[n2_walk_num][n2_elec_num][3] = { { - {-0.250655104764153 , 0.503070975550133 , -0.166554344502303}, - {-0.587812193472177 , -0.128751981129274 , 0.187773606533075}, - { 1.61335569047166 , -0.615556732874863 , -1.43165470979934 }, - {-4.901239896295210E-003 , -1.120440036458986E-002 , 1.99761909330422 }, - { 0.766647499681200 , -0.293515395797937 , 3.66454589201239 }, - {-0.127732483187947 , -0.138975497694196 , -8.669850480215846E-002}, - {-0.232271834949124 , -1.059321673434182E-002 , -0.504862241464867}, - { 1.09360863531826 , -2.036103063808752E-003 , -2.702796910818986E-002}, - {-0.108090166832043 , 0.189161729653261 , 2.15398313919894}, - { 0.397978144318712 , -0.254277292595981 , 2.54553335476344}}}; - -/* Jastrow related */ - -#define n2_type_nucl_num ((int64_t) 1) -#define n2_aord_num ((int64_t) 5) -#define n2_bord_num ((int64_t) 5) -#define n2_cord_num ((int64_t) 23) -#define n2_dim_cord_vec ((int64_t) 23) - -int64_t n2_type_nucl_vector[n2_nucl_num] = { - 1, - 1}; - -double n2_aord_vector[n2_aord_num + 1][n2_type_nucl_num] = { - { 0. }, - { 0. }, - {-0.380512}, - {-0.157996}, - {-0.031558}, - { 0.021512}}; - -double n2_bord_vector[n2_bord_num + 1] = { - 0.5 , - 0.15366 , - 0.0672262 , - 0.02157 , - 0.0073096 , - 0.002866 }; - -double n2_cord_vector[n2_cord_num][n2_type_nucl_num] = { - { 5.717020e-01}, - {-5.142530e-01}, - {-5.130430e-01}, - { 9.486000e-03}, - {-4.205000e-03}, - { 4.263258e-01}, - { 8.288150e-02}, - { 5.118600e-03}, - {-2.997800e-03}, - {-5.270400e-03}, - {-7.500000e-05}, - {-8.301650e-02}, - { 1.454340e-02}, - { 5.143510e-02}, - { 9.250000e-04}, - {-4.099100e-03}, - { 4.327600e-03}, - {-1.654470e-03}, - { 2.614000e-03}, - {-1.477000e-03}, - {-1.137000e-03}, - {-4.010475e-02}, - { 6.106710e-03}}; - -double n2_cord_vector_full[n2_dim_cord_vec][n2_nucl_num] = { - { 5.717020e-01, 5.717020e-01}, - {-5.142530e-01, -5.142530e-01}, - {-5.130430e-01, -5.130430e-01}, - { 9.486000e-03, 9.486000e-03}, - {-4.205000e-03, -4.205000e-03}, - { 4.263258e-01, 4.263258e-01}, - { 8.288150e-02, 8.288150e-02}, - { 5.118600e-03, 5.118600e-03}, - {-2.997800e-03, -2.997800e-03}, - {-5.270400e-03, -5.270400e-03}, - {-7.500000e-05, -7.500000e-05}, - {-8.301650e-02, -8.301650e-02}, - { 1.454340e-02, 1.454340e-02}, - { 5.143510e-02, 5.143510e-02}, - { 9.250000e-04, 9.250000e-04}, - {-4.099100e-03, -4.099100e-03}, - { 4.327600e-03, 4.327600e-03}, - {-1.654470e-03, -1.654470e-03}, - { 2.614000e-03, 2.614000e-03}, - {-1.477000e-03, -1.477000e-03}, - {-1.137000e-03, -1.137000e-03}, - {-4.010475e-02, -4.010475e-02}, - { 6.106710e-03, 6.106710e-03}}; - -double n2_lkpm_of_cindex[4][n2_dim_cord_vec] = { - {1, 1, 2, 0, 0, 0, 2, 1, 1, 2, 3, 0, 2, 1, 3, 0, 0, 1, 3, 1, 1, 0, 3}, - {1, 1, 3, 4, 0, 2, 2, 4, 0, 0, 2, 4, 1, 3, 1, 4, 0, 1, 1, 4, 1, 2, 0}, - {4, 1, 0, 0, 4, 2, 1, 4, 5, 0, 2, 3, 5, 0, 0, 3, 5, 1, 3, 2, 5, 0, 1}, - {2, 5, 1, 4, 1, 5, 0, 2, 1, 5, 1, 0, 1, 5, 2, 3, 0, 5, 1, 1, 0, 5, 2}}; From 5d179923393a45d3e5ad11d036e718183228e51d Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 6 Jul 2021 20:55:15 +0530 Subject: [PATCH 43/92] Removed n2 header from jastrow tests. #22 --- org/qmckl_jastrow.org | 488 +++++++++++++++++++++--------------------- 1 file changed, 244 insertions(+), 244 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index e05c37a..e2f4a23 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -28,7 +28,7 @@ these factors along with their derivatives. #endif #include -#include "n2.h" +//#include "n2.h" int main() { qmckl_context context; @@ -969,172 +969,172 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { ** Test #+begin_src c :tangle (eval c_test) -/* Reference input data */ -int64_t walk_num = n2_walk_num; -int64_t elec_num = n2_elec_num; -int64_t elec_up_num = n2_elec_up_num; -int64_t elec_dn_num = n2_elec_dn_num; -double rescale_factor_kappa_ee = 1.0; -double rescale_factor_kappa_en = 1.0; -double nucl_rescale_factor_kappa = 1.0; -double* elec_coord = &(n2_elec_coord[0][0][0]); - -const double* nucl_charge = n2_charge; -int64_t nucl_num = n2_nucl_num; -double* charge = n2_charge; -double* nucl_coord = &(n2_nucl_coord[0][0]); - -/* Provide Electron data */ +///* Reference input data */ +//int64_t walk_num = n2_walk_num; +//int64_t elec_num = n2_elec_num; +//int64_t elec_up_num = n2_elec_up_num; +//int64_t elec_dn_num = n2_elec_dn_num; +//double rescale_factor_kappa_ee = 1.0; +//double rescale_factor_kappa_en = 1.0; +//double nucl_rescale_factor_kappa = 1.0; +//double* elec_coord = &(n2_elec_coord[0][0][0]); +// +//const double* nucl_charge = n2_charge; +//int64_t nucl_num = n2_nucl_num; +//double* charge = n2_charge; +//double* nucl_coord = &(n2_nucl_coord[0][0]); +// +///* Provide Electron data */ qmckl_exit_code rc; -assert(!qmckl_electron_provided(context)); - -int64_t n; -rc = qmckl_get_electron_num (context, &n); -assert(rc == QMCKL_NOT_PROVIDED); - -rc = qmckl_get_electron_up_num (context, &n); -assert(rc == QMCKL_NOT_PROVIDED); - -rc = qmckl_get_electron_down_num (context, &n); -assert(rc == QMCKL_NOT_PROVIDED); - - -rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num); -assert(rc == QMCKL_SUCCESS); -assert(!qmckl_electron_provided(context)); - -rc = qmckl_get_electron_up_num (context, &n); -assert(rc == QMCKL_SUCCESS); -assert(n == elec_up_num); - -rc = qmckl_get_electron_down_num (context, &n); -assert(rc == QMCKL_SUCCESS); -assert(n == elec_dn_num); - -rc = qmckl_get_electron_num (context, &n); -assert(rc == QMCKL_SUCCESS); -assert(n == elec_num); - -double k_ee = 0.; -double k_en = 0.; -rc = qmckl_get_electron_rescale_factor_ee (context, &k_ee); -assert(rc == QMCKL_SUCCESS); -assert(k_ee == 1.0); - -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_electron_rescale_factor_en (context, &k_en); -assert(rc == QMCKL_SUCCESS); -assert(k_en == rescale_factor_kappa_en); - - -int64_t w; -rc = qmckl_get_electron_walk_num (context, &w); -assert(rc == QMCKL_NOT_PROVIDED); - - -rc = qmckl_set_electron_walk_num (context, walk_num); -assert(rc == QMCKL_SUCCESS); - -rc = qmckl_get_electron_walk_num (context, &w); -assert(rc == QMCKL_SUCCESS); -assert(w == walk_num); - -assert(qmckl_electron_provided(context)); - -rc = qmckl_set_electron_coord (context, 'N', elec_coord); -assert(rc == QMCKL_SUCCESS); - -double elec_coord2[walk_num*3*elec_num]; - -rc = qmckl_get_electron_coord (context, 'N', elec_coord2); -assert(rc == QMCKL_SUCCESS); -for (int64_t i=0 ; i<3*elec_num ; ++i) { - assert( elec_coord[i] == elec_coord2[i] ); - } - - -/* Provide Nucleus data */ - -assert(!qmckl_nucleus_provided(context)); - -rc = qmckl_get_nucleus_num (context, &n); -assert(rc == QMCKL_NOT_PROVIDED); - - -rc = qmckl_set_nucleus_num (context, nucl_num); -assert(rc == QMCKL_SUCCESS); -assert(!qmckl_nucleus_provided(context)); - -rc = qmckl_get_nucleus_num (context, &n); -assert(rc == QMCKL_SUCCESS); -assert(n == nucl_num); - -double k; -rc = qmckl_get_nucleus_rescale_factor (context, &k); -assert(rc == QMCKL_SUCCESS); -assert(k == 1.0); - - -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); - -double nucl_coord2[3*nucl_num]; - -rc = qmckl_get_nucleus_coord (context, 'T', nucl_coord2); -assert(rc == QMCKL_NOT_PROVIDED); - -rc = qmckl_set_nucleus_coord (context, 'T', &(nucl_coord[0])); -assert(rc == QMCKL_SUCCESS); - -assert(!qmckl_nucleus_provided(context)); - -rc = qmckl_get_nucleus_coord (context, 'N', nucl_coord2); -assert(rc == QMCKL_SUCCESS); -for (size_t k=0 ; k<3 ; ++k) { - for (size_t i=0 ; i Date: Tue, 6 Jul 2021 20:58:11 +0530 Subject: [PATCH 44/92] Testing include of n2 file. #22 --- org/qmckl_jastrow.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index e2f4a23..c8a3ca2 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -28,7 +28,7 @@ these factors along with their derivatives. #endif #include -//#include "n2.h" +#include "n2.h" int main() { qmckl_context context; From 2055cc59be4999f4d630eb22a8a33b1f5e19cdf3 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Tue, 6 Jul 2021 21:24:44 +0530 Subject: [PATCH 45/92] Reinstated some tests. #22 --- org/qmckl_jastrow.org | 326 +++++++++++++++++++++--------------------- 1 file changed, 163 insertions(+), 163 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index c8a3ca2..0e08e83 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -969,172 +969,172 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { ** Test #+begin_src c :tangle (eval c_test) -///* Reference input data */ -//int64_t walk_num = n2_walk_num; -//int64_t elec_num = n2_elec_num; -//int64_t elec_up_num = n2_elec_up_num; -//int64_t elec_dn_num = n2_elec_dn_num; -//double rescale_factor_kappa_ee = 1.0; -//double rescale_factor_kappa_en = 1.0; -//double nucl_rescale_factor_kappa = 1.0; -//double* elec_coord = &(n2_elec_coord[0][0][0]); -// -//const double* nucl_charge = n2_charge; -//int64_t nucl_num = n2_nucl_num; -//double* charge = n2_charge; -//double* nucl_coord = &(n2_nucl_coord[0][0]); -// -///* Provide Electron data */ +/* Reference input data */ +int64_t walk_num = n2_walk_num; +int64_t elec_num = n2_elec_num; +int64_t elec_up_num = n2_elec_up_num; +int64_t elec_dn_num = n2_elec_dn_num; +double rescale_factor_kappa_ee = 1.0; +double rescale_factor_kappa_en = 1.0; +double nucl_rescale_factor_kappa = 1.0; +double* elec_coord = &(n2_elec_coord[0][0][0]); + +const double* nucl_charge = n2_charge; +int64_t nucl_num = n2_nucl_num; +double* charge = n2_charge; +double* nucl_coord = &(n2_nucl_coord[0][0]); + +/* Provide Electron data */ qmckl_exit_code rc; -//assert(!qmckl_electron_provided(context)); -// -//int64_t n; -//rc = qmckl_get_electron_num (context, &n); -//assert(rc == QMCKL_NOT_PROVIDED); -// -//rc = qmckl_get_electron_up_num (context, &n); -//assert(rc == QMCKL_NOT_PROVIDED); -// -//rc = qmckl_get_electron_down_num (context, &n); -//assert(rc == QMCKL_NOT_PROVIDED); -// -// -//rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num); -//assert(rc == QMCKL_SUCCESS); -//assert(!qmckl_electron_provided(context)); -// -//rc = qmckl_get_electron_up_num (context, &n); -//assert(rc == QMCKL_SUCCESS); -//assert(n == elec_up_num); -// -//rc = qmckl_get_electron_down_num (context, &n); -//assert(rc == QMCKL_SUCCESS); -//assert(n == elec_dn_num); -// -//rc = qmckl_get_electron_num (context, &n); -//assert(rc == QMCKL_SUCCESS); -//assert(n == elec_num); -// -//double k_ee = 0.; -//double k_en = 0.; -//rc = qmckl_get_electron_rescale_factor_ee (context, &k_ee); -//assert(rc == QMCKL_SUCCESS); -//assert(k_ee == 1.0); -// -//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_electron_rescale_factor_en (context, &k_en); -//assert(rc == QMCKL_SUCCESS); -//assert(k_en == rescale_factor_kappa_en); -// -// -//int64_t w; -//rc = qmckl_get_electron_walk_num (context, &w); -//assert(rc == QMCKL_NOT_PROVIDED); -// -// -//rc = qmckl_set_electron_walk_num (context, walk_num); -//assert(rc == QMCKL_SUCCESS); -// -//rc = qmckl_get_electron_walk_num (context, &w); -//assert(rc == QMCKL_SUCCESS); -//assert(w == walk_num); -// -//assert(qmckl_electron_provided(context)); -// -//rc = qmckl_set_electron_coord (context, 'N', elec_coord); -//assert(rc == QMCKL_SUCCESS); -// -//double elec_coord2[walk_num*3*elec_num]; -// -//rc = qmckl_get_electron_coord (context, 'N', elec_coord2); -//assert(rc == QMCKL_SUCCESS); -//for (int64_t i=0 ; i<3*elec_num ; ++i) { -// assert( elec_coord[i] == elec_coord2[i] ); -// } -// -// -///* Provide Nucleus data */ -// -//assert(!qmckl_nucleus_provided(context)); -// -//rc = qmckl_get_nucleus_num (context, &n); -//assert(rc == QMCKL_NOT_PROVIDED); -// -// -//rc = qmckl_set_nucleus_num (context, nucl_num); -//assert(rc == QMCKL_SUCCESS); -//assert(!qmckl_nucleus_provided(context)); -// -//rc = qmckl_get_nucleus_num (context, &n); -//assert(rc == QMCKL_SUCCESS); -//assert(n == nucl_num); -// -//double k; -//rc = qmckl_get_nucleus_rescale_factor (context, &k); -//assert(rc == QMCKL_SUCCESS); -//assert(k == 1.0); -// -// -//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); -// -//double nucl_coord2[3*nucl_num]; -// -//rc = qmckl_get_nucleus_coord (context, 'T', nucl_coord2); -//assert(rc == QMCKL_NOT_PROVIDED); -// -//rc = qmckl_set_nucleus_coord (context, 'T', &(nucl_coord[0])); -//assert(rc == QMCKL_SUCCESS); -// -//assert(!qmckl_nucleus_provided(context)); -// -//rc = qmckl_get_nucleus_coord (context, 'N', nucl_coord2); -//assert(rc == QMCKL_SUCCESS); -//for (size_t k=0 ; k<3 ; ++k) { -// for (size_t i=0 ; i Date: Tue, 6 Jul 2021 21:29:42 +0530 Subject: [PATCH 46/92] Reinstated all tests. #22 --- org/qmckl_electron.org | 54 ++++++++------ org/qmckl_jastrow.org | 160 ++++++++++++++++++++--------------------- 2 files changed, 111 insertions(+), 103 deletions(-) diff --git a/org/qmckl_electron.org b/org/qmckl_electron.org index 8e9a298..dab2ae6 100644 --- a/org/qmckl_electron.org +++ b/org/qmckl_electron.org @@ -63,29 +63,33 @@ int main() { The following data stored in the context: - | ~uninitialized~ | ~int32_t~ | Keeps bit set for uninitialized data | - | ~num~ | ~int64_t~ | Total number of electrons | - | ~up_num~ | ~int64_t~ | Number of up-spin electrons | - | ~down_num~ | ~int64_t~ | Number of down-spin electrons | - | ~walk_num~ | ~int64_t~ | Number of walkers | - | ~rescale_factor_kappa_ee~ | ~double~ | The distance scaling factor | - | ~rescale_factor_kappa_en~ | ~double~ | The distance scaling factor | - | ~provided~ | ~bool~ | If true, ~electron~ is valid | - | ~coord_new~ | ~double[walk_num][3][num]~ | New set of electron coordinates | - | ~coord_old~ | ~double[walk_num][3][num]~ | Old set of electron coordinates | - | ~coord_new_date~ | ~uint64_t~ | Last modification date of the coordinates | - | ~ee_distance~ | ~double[walk_num][num][num]~ | Electron-electron distances | - | ~ee_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~en_distance~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | - | ~en_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~ee_distance_rescaled~ | ~double[walk_num][num][num]~ | Electron-electron rescaled distances | - | ~ee_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~ee_distance_rescaled_deriv_e~ | ~double[walk_num][4][num][num]~ | Electron-electron rescaled distances derivatives | - | ~ee_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | - | ~en_distance_rescaled~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | - | ~en_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~en_distance_rescaled_deriv_e~ | ~double[walk_num][4][nucl_num][num]~ | Electron-electron rescaled distances derivatives | - | ~en_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | + | ~uninitialized~ | ~int32_t~ | Keeps bit set for uninitialized data | + | ~num~ | ~int64_t~ | Total number of electrons | + | ~up_num~ | ~int64_t~ | Number of up-spin electrons | + | ~down_num~ | ~int64_t~ | Number of down-spin electrons | + | ~walk_num~ | ~int64_t~ | Number of walkers | + | ~rescale_factor_kappa_ee~ | ~double~ | The distance scaling factor | + | ~rescale_factor_kappa_en~ | ~double~ | The distance scaling factor | + | ~provided~ | ~bool~ | If true, ~electron~ is valid | + | ~coord_new~ | ~double[walk_num][3][num]~ | New set of electron coordinates | + | ~coord_old~ | ~double[walk_num][3][num]~ | Old set of electron coordinates | + | ~coord_new_date~ | ~uint64_t~ | Last modification date of the coordinates | + | ~ee_distance~ | ~double[walk_num][num][num]~ | Electron-electron distances | + | ~ee_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~en_distance~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | + | ~en_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~ee_distance_rescaled~ | ~double[walk_num][num][num]~ | Electron-electron rescaled distances | + | ~ee_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~ee_distance_rescaled_deriv_e~ | ~double[walk_num][4][num][num]~ | Electron-electron rescaled distances derivatives | + | ~ee_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | + | ~en_distance_rescaled~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | + | ~en_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~en_distance_rescaled_deriv_e~ | ~double[walk_num][4][nucl_num][num]~ | Electron-electron rescaled distances derivatives | + | ~en_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | + | ~een_distance_rescaled~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | + | ~een_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~een_distance_rescaled_deriv_e~ | ~double[walk_num][4][nucl_num][num]~ | Electron-electron rescaled distances derivatives | + | ~een_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | ** Data structure @@ -100,10 +104,12 @@ typedef struct qmckl_electron_struct { int64_t coord_new_date; int64_t ee_distance_date; int64_t en_distance_date; + int64_t een_distance_date; int64_t ee_distance_rescaled_date; int64_t ee_distance_rescaled_deriv_e_date; int64_t en_distance_rescaled_date; int64_t en_distance_rescaled_deriv_e_date; + int64_t een_distance_rescaled_deriv_e_date; double* coord_new; double* coord_old; double* ee_distance; @@ -112,6 +118,8 @@ typedef struct qmckl_electron_struct { double* ee_distance_rescaled_deriv_e; double* en_distance_rescaled; double* en_distance_rescaled_deriv_e; + double* een_distance_rescaled; + double* een_distance_rescaled_deriv_e; int32_t uninitialized; bool provided; } qmckl_electron_struct; diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 0e08e83..e05c37a 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1368,46 +1368,46 @@ print("asymp_jasb[1] : ", asymp_jasb[1]) : asymp_jasb[1] : 0.31567342786262853 #+begin_src c :tangle (eval c_test) -//assert(qmckl_electron_provided(context)); -// -//int64_t type_nucl_num = n2_type_nucl_num; -//int64_t* type_nucl_vector = &(n2_type_nucl_vector[0]); -//int64_t aord_num = n2_aord_num; -//int64_t bord_num = n2_bord_num; -//int64_t cord_num = n2_cord_num; -//double* aord_vector = &(n2_aord_vector[0][0]); -//double* bord_vector = &(n2_bord_vector[0]); -//double* cord_vector = &(n2_cord_vector[0][0]); -// -///* Initialize the Jastrow data */ -//rc = qmckl_init_jastrow(context); -//assert(!qmckl_jastrow_provided(context)); -// -///* Set the data */ -//rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_aord_vector(context, aord_vector); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_bord_vector(context, bord_vector); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_cord_vector(context, cord_vector); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_dependencies(context); -//assert(rc == QMCKL_SUCCESS); -// -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//double asymp_jasb[2]; -//rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); -// -//// calculate asymp_jasb -//assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); -//assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); +assert(qmckl_electron_provided(context)); + +int64_t type_nucl_num = n2_type_nucl_num; +int64_t* type_nucl_vector = &(n2_type_nucl_vector[0]); +int64_t aord_num = n2_aord_num; +int64_t bord_num = n2_bord_num; +int64_t cord_num = n2_cord_num; +double* aord_vector = &(n2_aord_vector[0][0]); +double* bord_vector = &(n2_bord_vector[0]); +double* cord_vector = &(n2_cord_vector[0][0]); + +/* Initialize the Jastrow data */ +rc = qmckl_init_jastrow(context); +assert(!qmckl_jastrow_provided(context)); + +/* Set the data */ +rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_aord_vector(context, aord_vector); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_bord_vector(context, bord_vector); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_cord_vector(context, cord_vector); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_dependencies(context); +assert(rc == QMCKL_SUCCESS); + +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +double asymp_jasb[2]; +rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); + +// calculate asymp_jasb +assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); +assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); #+end_src @@ -1699,14 +1699,14 @@ print("factor_ee :",factor_ee) #+begin_src c :tangle (eval c_test) -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//double factor_ee[walk_num]; -//rc = qmckl_get_jastrow_factor_ee(context, factor_ee); -// -//// calculate factor_ee -//assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +double factor_ee[walk_num]; +rc = qmckl_get_jastrow_factor_ee(context, factor_ee); + +// calculate factor_ee +assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); #+end_src @@ -2118,18 +2118,18 @@ print(factor_ee_deriv_e) #+begin_src c :tangle (eval c_test) -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//// calculate factor_ee_deriv_e -//double factor_ee_deriv_e[walk_num][4][elec_num]; -//rc = qmckl_get_jastrow_factor_ee_deriv_e(context, &(factor_ee_deriv_e[0][0][0])); -// -//// check factor_ee_deriv_e -//assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); -//assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); -//assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); -//assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +// calculate factor_ee_deriv_e +double factor_ee_deriv_e[walk_num][4][elec_num]; +rc = qmckl_get_jastrow_factor_ee_deriv_e(context, &(factor_ee_deriv_e[0][0][0])); + +// check factor_ee_deriv_e +assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); #+end_src @@ -2414,14 +2414,14 @@ print("factor_en :",factor_en) #+begin_src c :tangle (eval c_test) -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//double factor_en[walk_num]; -//rc = qmckl_get_jastrow_factor_en(context, factor_en); -// -//// calculate factor_en -//assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +double factor_en[walk_num]; +rc = qmckl_get_jastrow_factor_en(context, factor_en); + +// calculate factor_en +assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); #+end_src @@ -2813,18 +2813,18 @@ print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) #+begin_src c :tangle (eval c_test) -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//// calculate factor_en_deriv_e -//double factor_en_deriv_e[walk_num][4][elec_num]; -//rc = qmckl_get_jastrow_factor_en_deriv_e(context, &(factor_en_deriv_e[0][0][0])); -// -//// check factor_en_deriv_e -//assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +// calculate factor_en_deriv_e +double factor_en_deriv_e[walk_num][4][elec_num]; +rc = qmckl_get_jastrow_factor_en_deriv_e(context, &(factor_en_deriv_e[0][0][0])); + +// check factor_en_deriv_e +assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); +assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); +assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); +assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); #+end_src From a7c1fe526e18e6284ed3a1bb4e29126a0b0d071a Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 11:23:04 +0530 Subject: [PATCH 47/92] Working on factor_een. #22 --- org/qmckl_electron.org | 55 +++---- org/qmckl_jastrow.org | 355 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 361 insertions(+), 49 deletions(-) diff --git a/org/qmckl_electron.org b/org/qmckl_electron.org index dab2ae6..d125803 100644 --- a/org/qmckl_electron.org +++ b/org/qmckl_electron.org @@ -63,33 +63,29 @@ int main() { The following data stored in the context: - | ~uninitialized~ | ~int32_t~ | Keeps bit set for uninitialized data | - | ~num~ | ~int64_t~ | Total number of electrons | - | ~up_num~ | ~int64_t~ | Number of up-spin electrons | - | ~down_num~ | ~int64_t~ | Number of down-spin electrons | - | ~walk_num~ | ~int64_t~ | Number of walkers | - | ~rescale_factor_kappa_ee~ | ~double~ | The distance scaling factor | - | ~rescale_factor_kappa_en~ | ~double~ | The distance scaling factor | - | ~provided~ | ~bool~ | If true, ~electron~ is valid | - | ~coord_new~ | ~double[walk_num][3][num]~ | New set of electron coordinates | - | ~coord_old~ | ~double[walk_num][3][num]~ | Old set of electron coordinates | - | ~coord_new_date~ | ~uint64_t~ | Last modification date of the coordinates | - | ~ee_distance~ | ~double[walk_num][num][num]~ | Electron-electron distances | - | ~ee_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~en_distance~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | - | ~en_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~ee_distance_rescaled~ | ~double[walk_num][num][num]~ | Electron-electron rescaled distances | - | ~ee_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~ee_distance_rescaled_deriv_e~ | ~double[walk_num][4][num][num]~ | Electron-electron rescaled distances derivatives | - | ~ee_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | - | ~en_distance_rescaled~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | - | ~en_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~en_distance_rescaled_deriv_e~ | ~double[walk_num][4][nucl_num][num]~ | Electron-electron rescaled distances derivatives | - | ~en_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | - | ~een_distance_rescaled~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | - | ~een_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~een_distance_rescaled_deriv_e~ | ~double[walk_num][4][nucl_num][num]~ | Electron-electron rescaled distances derivatives | - | ~een_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | + | ~uninitialized~ | ~int32_t~ | Keeps bit set for uninitialized data | + | ~num~ | ~int64_t~ | Total number of electrons | + | ~up_num~ | ~int64_t~ | Number of up-spin electrons | + | ~down_num~ | ~int64_t~ | Number of down-spin electrons | + | ~walk_num~ | ~int64_t~ | Number of walkers | + | ~rescale_factor_kappa_ee~ | ~double~ | The distance scaling factor | + | ~rescale_factor_kappa_en~ | ~double~ | The distance scaling factor | + | ~provided~ | ~bool~ | If true, ~electron~ is valid | + | ~coord_new~ | ~double[walk_num][3][num]~ | New set of electron coordinates | + | ~coord_old~ | ~double[walk_num][3][num]~ | Old set of electron coordinates | + | ~coord_new_date~ | ~uint64_t~ | Last modification date of the coordinates | + | ~ee_distance~ | ~double[walk_num][num][num]~ | Electron-electron distances | + | ~ee_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~en_distance~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | + | ~en_distance_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~ee_distance_rescaled~ | ~double[walk_num][num][num]~ | Electron-electron rescaled distances | + | ~ee_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~ee_distance_rescaled_deriv_e~ | ~double[walk_num][4][num][num]~ | Electron-electron rescaled distances derivatives | + | ~ee_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | + | ~en_distance_rescaled~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | + | ~en_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | + | ~en_distance_rescaled_deriv_e~ | ~double[walk_num][4][nucl_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 @@ -104,12 +100,10 @@ typedef struct qmckl_electron_struct { int64_t coord_new_date; int64_t ee_distance_date; int64_t en_distance_date; - int64_t een_distance_date; int64_t ee_distance_rescaled_date; int64_t ee_distance_rescaled_deriv_e_date; int64_t en_distance_rescaled_date; int64_t en_distance_rescaled_deriv_e_date; - int64_t een_distance_rescaled_deriv_e_date; double* coord_new; double* coord_old; double* ee_distance; @@ -118,8 +112,6 @@ typedef struct qmckl_electron_struct { double* ee_distance_rescaled_deriv_e; double* en_distance_rescaled; double* en_distance_rescaled_deriv_e; - double* een_distance_rescaled; - double* een_distance_rescaled_deriv_e; int32_t uninitialized; bool provided; } qmckl_electron_struct; @@ -1559,7 +1551,6 @@ rc = qmckl_get_electron_ee_distance_rescaled_deriv_e(context, ee_distance_rescal #+end_src - ** Electron-nucleus distances *** Get diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index e05c37a..340fd36 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -83,28 +83,32 @@ int main() { | ~double~ | ~bord_vector[bord_num + 1]~ | in | Order of b polynomial coefficients | | ~double~ | ~cord_vector[cord_num][type_nucl_num]~ | in | Order of c polynomial coefficients | | ~double~ | ~factor_ee[walk_num]~ | out | Jastrow factor: electron-electron part | - | ~double~ | ~factor_ee_date~ | out | Jastrow factor: electron-electron part | + | ~int64_t~ | ~factor_ee_date~ | out | Jastrow factor: electron-electron part | | ~double~ | ~factor_en[walk_num]~ | out | Jastrow factor: electron-nucleus part | - | ~double~ | ~factor_en_date~ | out | Jastrow factor: electron-nucleus part | + | ~int64_t~ | ~factor_en_date~ | out | Jastrow factor: electron-nucleus part | | ~double~ | ~factor_een[walk_num]~ | out | Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_een_date~ | out | Jastrow factor: electron-electron-nucleus part | + | ~int64_t~ | ~factor_een_date~ | out | Jastrow factor: electron-electron-nucleus part | | ~double~ | ~factor_ee_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_ee_deriv_e_date~ | out | Keep track of the date for the derivative | + | ~int64_t~ | ~factor_ee_deriv_e_date~ | out | Keep track of the date for the derivative | | ~double~ | ~factor_en_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_en_deriv_e_date~ | out | Keep track of the date for the en derivative | + | ~int64_t~ | ~factor_en_deriv_e_date~ | out | Keep track of the date for the en derivative | | ~double~ | ~factor_een_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_een_deriv_e_date~ | out | Keep track of the date for the een derivative | + | ~int64_t~ | ~factor_een_deriv_e_date~ | out | Keep track of the date for the een derivative | computed data: - |-----------+-------------------------------------------------------------+-------------------------------------------------| - | ~int64_t~ | ~dim_cord_vec~ | Number of unique C coefficients | - | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | - | ~int64_t~ | ~asymp_jasb_date~ | Asymptotic component | - | ~double~ | ~coord_vect_full[dim_cord_vec][nucl_num]~ | vector of non-zero coefficients | - | ~int64_t~ | ~lkpm_of_cindex[4][dim_cord_vec]~ | Transform l,k,p, and m into consecutive indices | - | ~double~ | ~tmp_c[elec_num][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | - | ~double~ | ~dtmp_c[elec_num][4][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | + |-----------+-------------------------------------------------------------+-------------------------------------------------------------------------------| + | ~int64_t~ | ~dim_cord_vec~ | Number of unique C coefficients | + | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | + | ~int64_t~ | ~asymp_jasb_date~ | Asymptotic component | + | ~double~ | ~coord_vect_full[dim_cord_vec][nucl_num]~ | vector of non-zero coefficients | + | ~int64_t~ | ~lkpm_of_cindex[4][dim_cord_vec]~ | Transform l,k,p, and m into consecutive indices | + | ~double~ | ~tmp_c[elec_num][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | + | ~double~ | ~dtmp_c[elec_num][4][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | + | ~double~ | ~een_rescaled_e[walk_num][elec_num][elec_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | + | ~int64_t~ | ~een_rescaled_e_date~ | Keep track of the date of creation | + | ~double~ | ~een_rescaled_n[walk_num][elec_num][nucl_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | + | ~int64_t~ | ~een_rescaled_n_date~ | Keep track of the date of creation | For H2O we have the following data: @@ -293,6 +297,10 @@ typedef struct qmckl_jastrow_struct{ double * coord_vect_full; double * tmp_c; double * dtmp_c; + double * een_rescaled_e; + double * een_rescaled_n; + int64_t een_rescaled_e_date; + int64_t een_rescaled_n_date; bool provided; char * type; } qmckl_jastrow_struct; @@ -1147,7 +1155,7 @@ assert(qmckl_nucleus_provided(context)); the dependencies are more recent than the date of the data to compute. If it is the case, then the data is recomputed and the current date is stored. - + ** Asymptotic component for \(f_{ee}\) Calculate the asymptotic component ~asymp_jasb~ to be substracted from the final @@ -1411,9 +1419,8 @@ assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); #+end_src - ** Electron-electron component \(f_{ee}\) - + Calculate the electron-electron jastrow component ~factor_ee~ using the ~asymp_jasb~ componenet and the electron-electron rescaled distances ~ee_distance_rescaled~. @@ -2829,6 +2836,320 @@ assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); #+end_src +** Electron-electron rescaled distances for each order + + ~een_rescaled_e~ stores the table of the rescaled distances between all + pairs of electrons and raised to the power \(p\) defined by ~cord_num~: + + \[ + C_{ij,p} = \left( 1 - \exp{-\kappa C_{ij}} \right)^p + \] + + where \(C_{ij}\) is the matrix of electron-electron distances. + +*** Get + + #+begin_src c :comments org :tangle (eval h_func) :noweb yes +qmckl_exit_code qmckl_get_jastrow_een_rescaled_e(qmckl_context context, double* const distance_rescaled); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_get_jastrow_een_rescaled_e(qmckl_context context, double* const distance_rescaled) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_een_rescaled_e(context); + if (rc != QMCKL_SUCCESS) return rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + size_t sze = ctx->electron.num * ctx->electron.num * ctx->electron.walk_num * (ctx->jastrow.cord_num + 1); + memcpy(distance_rescaled, ctx->jastrow.een_rescaled_e, sze * sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide :noexport: + + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_een_rescaled_e(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_een_rescaled_e(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); + + /* Check if ee distance is provided */ + qmckl_exit_code rc = qmckl_provide_ee_distance(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.een_rescaled_e_date) { + + /* Allocate array */ + if (ctx->jastrow.een_rescaled_e == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->electron.num * ctx->electron.num * + ctx->electron.walk_num * (ctx->jastrow.cord_num + 1) * sizeof(double); + double* een_rescaled_e = (double*) qmckl_malloc(context, mem_info); + + if (een_rescaled_e == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_een_rescaled_e", + NULL); + } + ctx->jastrow.een_rescaled_e = een_rescaled_e; + } + + qmckl_exit_code rc = + qmckl_compute_een_rescaled_e(context, + ctx->electron.walk_num, + ctx->electron.num, + ctx->jastrow.cord_num, + ctx->electron.rescale_factor_kappa_ee, + ctx->electron.ee_distance, + ctx->jastrow.een_rescaled_e); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.een_rescaled_e_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute + :PROPERTIES: + :Name: qmckl_compute_een_rescaled_e + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_factor_een_rescaled_e_args + | qmckl_context | context | in | Global state | + | int64_t | walk_num | in | Number of walkers | + | int64_t | elec_num | in | Number of electrons | + | int64_t | cord_num | in | Order of polynomials | + | double | rescale_factor_kappa_ee | in | Factor to rescale ee distances | + | double | ee_distance[walk_num][elec_num][elec_num] | in | Electron-electron distances | + | double | een_rescaled_e[walk_num][elec_num][elec_num][0:cord_num] | out | Electron-electron rescaled distances | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_een_rescaled_e_f(context, walk_num, elec_num, cord_num, rescale_factor_kappa_ee, & + ee_distance, een_rescaled_e) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: walk_num + integer*8 , intent(in) :: elec_num + integer*8 , intent(in) :: cord_num + double precision , intent(in) :: rescale_factor_kappa_ee + double precision , intent(in) :: ee_distance(elec_num,elec_num,walk_num) + double precision , intent(out) :: een_rescaled_e(0:cord_num,elec_num,elec_num,walk_num) + double precision,dimension(:,:),allocatable :: een_rescaled_e_ij + double precision :: x + integer*8 :: i, j, k, l, nw + + allocate(een_rescaled_e_ij(elec_num * (elec_num - 1) / 2, cord_num + 1)) + + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (walk_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (elec_num <= 0) then + info = QMCKL_INVALID_ARG_3 + return + endif + + if (cord_num <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + een_rescaled_e_ij(:, 1) = 1.0d0 + + ! Prepare table of exponentiated distances raised to appropriate power + do nw = 1, walk_num + k = 0 + do j = 1, elec_num + do i = 1, j - 1 + k = k + 1 + een_rescaled_e_ij(k, 2) = dexp(-rescale_factor_kappa_ee * ee_distance(i, j, nw)) + end do + end do + + do l = 2, cord_num + do k = 1, elec_num * (elec_num - 1)/2 + een_rescaled_e_ij(k, l + 1) = een_rescaled_e_ij(k, l + 1 - 1) * een_rescaled_e_ij(k, 1) + end do + end do + + ! prepare the actual een table + een_rescaled_e = 0.0d0 + een_rescaled_e(0, :, :, :) = 1.0d0 + do l = 1, cord_num + k = 0 + do j = 1, elec_num + do i = 1, j - 1 + k = k + 1 + x = een_rescaled_e_ij(k, l + 1) + een_rescaled_e(l, i, j, nw) = x + een_rescaled_e(l, j, i, nw) = x + end do + end do + end do + end do + +end function qmckl_compute_een_rescaled_e_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_factor_een_rescaled_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_een_rescaled_e ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t cord_num, + const double rescale_factor_kappa_ee, + const double* ee_distance, + double* const een_rescaled_e ); + #+end_src + + #+CALL: generate_c_interface(table=qmckl_factor_een_rescaled_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_een_rescaled_e & + (context, walk_num, elec_num, cord_num, rescale_factor_kappa_ee, ee_distance, een_rescaled_e) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: walk_num + integer (c_int64_t) , intent(in) , value :: elec_num + integer (c_int64_t) , intent(in) , value :: cord_num + real (c_double ) , intent(in) , value :: rescale_factor_kappa_ee + real (c_double ) , intent(in) :: ee_distance(elec_num,elec_num,walk_num) + real (c_double ) , intent(out) :: een_rescaled_e(0:cord_num,elec_num,elec_num,walk_num) + + integer(c_int32_t), external :: qmckl_compute_een_rescaled_e_f + info = qmckl_compute_een_rescaled_e_f & + (context, walk_num, elec_num, cord_num, rescale_factor_kappa_ee, ee_distance, een_rescaled_e) + + end function qmckl_compute_een_rescaled_e + #+end_src + +*** Test + + #+begin_src python :results output :exports none :noweb yes +import numpy as np + +<> + +elec_coord = np.array(elec_coord)[0] +elec_dist = np.zeros(shape=(elec_num, elec_num),dtype=float) +for i in range(elec_num): + for j in range(elec_num): + elec_dist[i, j] = np.linalg.norm(elec_coord[i] - elec_coord[j]) + +kappa = 1.0 + +een_rescaled_e_ij = np.zeros(shape=(elec_num * (elec_num - 1)//2, cord_num+1), dtype=float) +een_rescaled_e_ij[:,0] = 1.0 + +k = 0 +for j in range(elec_num): + for i in range(j - 1): + een_rescaled_e_ij[k, 1] = np.exp(-kappa * elec_dist[i, j]) + k = k + 1 + +for l in range(2, cord_num + 1): + for k in range(elec_num * (elec_num - 1)//2): + een_rescaled_e_ij[k, l] = een_rescaled_e_ij[k, l - 1] * een_rescaled_e_ij[k, 1] + +een_rescaled_e = np.zeros(shape=(elec_num, elec_num, cord_num + 1), dtype=float) +een_rescaled_e[:,:,0] = 1.0 + +for l in range(1,cord_num+1): + k = 0 + for j in range(elec_num): + for i in range(j - 1): + x = een_rescaled_e_ij[k, l] + een_rescaled_e[i, j, l] = x + een_rescaled_e[j, i, l] = x + k = k + 1 + +print(" een_rescaled_e[0, 2, 1] = ",een_rescaled_e[0, 2, 1]) +print(" een_rescaled_e[0, 3, 1] = ",een_rescaled_e[0, 3, 1]) +print(" een_rescaled_e[0, 4, 1] = ",een_rescaled_e[0, 4, 1]) +print(" een_rescaled_e[1, 3, 2] = ",een_rescaled_e[1, 3, 2]) +print(" een_rescaled_e[1, 4, 2] = ",een_rescaled_e[1, 4, 2]) +print(" een_rescaled_e[1, 5, 2] = ",een_rescaled_e[1, 5, 2]) + #+end_src + + #+RESULTS: + : een_rescaled_e[0, 2, 1] = 0.08084493981483197 + : een_rescaled_e[0, 3, 1] = 0.1066745707571846 + : een_rescaled_e[0, 4, 1] = 0.01754273169464735 + : een_rescaled_e[1, 3, 2] = 0.02214680362033448 + : een_rescaled_e[1, 4, 2] = 0.0005700154999202759 + : een_rescaled_e[1, 5, 2] = 0.3424402276009091 + + #+begin_src c :tangle (eval c_test) +assert(qmckl_electron_provided(context)); + + +double een_rescaled_e[walk_num][elec_num][elec_num][(cord_num + 1)]; +rc = qmckl_get_jastrow_een_rescaled_e(context, &(een_rescaled_e[0][0][0][0])); + +// value of (0,2,1) +//printf("%10.15f = \n", een_rescaled_e[0][0][2][1]); +//printf("%10.15f = \n", een_rescaled_e[0][0][3][1]); +//printf("%10.15f = \n", een_rescaled_e[0][0][4][1]); +//printf("%10.15f = \n", een_rescaled_e[0][1][3][2]); +//printf("%10.15f = \n", een_rescaled_e[0][1][4][2]); +//printf("%10.15f = \n", een_rescaled_e[0][1][5][2]); +//assert(fabs(een_rescaled_e[0][0][2][1]-) < 1.e-12); +//assert(fabs(een_rescaled_e[0][0][3][1]-) < 1.e-12); +//assert(fabs(een_rescaled_e[0][0][4][1]-) < 1.e-12); +//assert(fabs(een_rescaled_e[0][1][3][2]-) < 1.e-12); +//assert(fabs(een_rescaled_e[0][1][4][2]-) < 1.e-12); +//assert(fabs(een_rescaled_e[0][1][5][2]-) < 1.e-12); + + #+end_src + + * End of files :noexport: #+begin_src c :tangle (eval h_private_type) From b6bb9be3591e9bc39b30f65fa0cc5dda7f64f711 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 12:40:23 +0530 Subject: [PATCH 48/92] Finished een_rescale_n. #22 --- org/qmckl_jastrow.org | 339 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 318 insertions(+), 21 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 340fd36..a927c53 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2835,7 +2835,7 @@ assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); #+end_src - + ** Electron-electron rescaled distances for each order ~een_rescaled_e~ stores the table of the rescaled distances between all @@ -2846,7 +2846,7 @@ assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); \] where \(C_{ij}\) is the matrix of electron-electron distances. - + *** Get #+begin_src c :comments org :tangle (eval h_func) :noweb yes @@ -2993,10 +2993,12 @@ integer function qmckl_compute_een_rescaled_e_f(context, walk_num, elec_num, cor return endif + ! Prepare table of exponentiated distances raised to appropriate power + een_rescaled_e = 0.0d0 + do nw = 1, walk_num + een_rescaled_e_ij = 0.0d0 een_rescaled_e_ij(:, 1) = 1.0d0 - ! Prepare table of exponentiated distances raised to appropriate power - do nw = 1, walk_num k = 0 do j = 1, elec_num do i = 1, j - 1 @@ -3007,13 +3009,12 @@ integer function qmckl_compute_een_rescaled_e_f(context, walk_num, elec_num, cor do l = 2, cord_num do k = 1, elec_num * (elec_num - 1)/2 - een_rescaled_e_ij(k, l + 1) = een_rescaled_e_ij(k, l + 1 - 1) * een_rescaled_e_ij(k, 1) + een_rescaled_e_ij(k, l + 1) = een_rescaled_e_ij(k, l + 1 - 1) * een_rescaled_e_ij(k, 2) end do end do ! prepare the actual een table - een_rescaled_e = 0.0d0 - een_rescaled_e(0, :, :, :) = 1.0d0 + een_rescaled_e(0, :, :, nw) = 1.0d0 do l = 1, cord_num k = 0 do j = 1, elec_num @@ -3090,7 +3091,7 @@ een_rescaled_e_ij[:,0] = 1.0 k = 0 for j in range(elec_num): - for i in range(j - 1): + for i in range(j): een_rescaled_e_ij[k, 1] = np.exp(-kappa * elec_dist[i, j]) k = k + 1 @@ -3104,7 +3105,7 @@ een_rescaled_e[:,:,0] = 1.0 for l in range(1,cord_num+1): k = 0 for j in range(elec_num): - for i in range(j - 1): + for i in range(j): x = een_rescaled_e_ij[k, l] een_rescaled_e[i, j, l] = x een_rescaled_e[j, i, l] = x @@ -3134,18 +3135,314 @@ double een_rescaled_e[walk_num][elec_num][elec_num][(cord_num + 1)]; rc = qmckl_get_jastrow_een_rescaled_e(context, &(een_rescaled_e[0][0][0][0])); // value of (0,2,1) -//printf("%10.15f = \n", een_rescaled_e[0][0][2][1]); -//printf("%10.15f = \n", een_rescaled_e[0][0][3][1]); -//printf("%10.15f = \n", een_rescaled_e[0][0][4][1]); -//printf("%10.15f = \n", een_rescaled_e[0][1][3][2]); -//printf("%10.15f = \n", een_rescaled_e[0][1][4][2]); -//printf("%10.15f = \n", een_rescaled_e[0][1][5][2]); -//assert(fabs(een_rescaled_e[0][0][2][1]-) < 1.e-12); -//assert(fabs(een_rescaled_e[0][0][3][1]-) < 1.e-12); -//assert(fabs(een_rescaled_e[0][0][4][1]-) < 1.e-12); -//assert(fabs(een_rescaled_e[0][1][3][2]-) < 1.e-12); -//assert(fabs(een_rescaled_e[0][1][4][2]-) < 1.e-12); -//assert(fabs(een_rescaled_e[0][1][5][2]-) < 1.e-12); +assert(fabs(een_rescaled_e[0][0][2][1]-0.08084493981483197) < 1.e-12); +assert(fabs(een_rescaled_e[0][0][3][1]-0.1066745707571846) < 1.e-12); +assert(fabs(een_rescaled_e[0][0][4][1]-0.01754273169464735) < 1.e-12); +assert(fabs(een_rescaled_e[0][1][3][2]-0.02214680362033448) < 1.e-12); +assert(fabs(een_rescaled_e[0][1][4][2]-0.0005700154999202759) < 1.e-12); +assert(fabs(een_rescaled_e[0][1][5][2]-0.3424402276009091) < 1.e-12); + + #+end_src + +** Electron-nucleus rescaled distances for each order + + ~een_rescaled_n~ stores the table of the rescaled distances between + electrons and nucleii raised to the power \(p\) defined by ~cord_num~: + + \[ + C_{ia,p} = \left( 1 - \exp{-\kappa C_{ia}} \right)^p + \] + + where \(C_{ia}\) is the matrix of electron-nucleus distances. + +*** Get + + #+begin_src c :comments org :tangle (eval h_func) :noweb yes +qmckl_exit_code qmckl_get_jastrow_een_rescaled_n(qmckl_context context, double* const distance_rescaled); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_get_jastrow_een_rescaled_n(qmckl_context context, double* const distance_rescaled) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_een_rescaled_n(context); + if (rc != QMCKL_SUCCESS) return rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + size_t sze = ctx->electron.num * ctx->nucleus.num * ctx->electron.walk_num * (ctx->jastrow.cord_num + 1); + memcpy(distance_rescaled, ctx->jastrow.een_rescaled_n, sze * sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide :noexport: + + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_een_rescaled_n(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_een_rescaled_n(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); + + /* Check if ee distance is provided */ + qmckl_exit_code rc = qmckl_provide_en_distance(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.een_rescaled_n_date) { + + /* Allocate array */ + if (ctx->jastrow.een_rescaled_n == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->electron.num * ctx->nucleus.num * + ctx->electron.walk_num * (ctx->jastrow.cord_num + 1) * sizeof(double); + double* een_rescaled_n = (double*) qmckl_malloc(context, mem_info); + + if (een_rescaled_n == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_een_rescaled_n", + NULL); + } + ctx->jastrow.een_rescaled_n = een_rescaled_n; + } + + qmckl_exit_code rc = + qmckl_compute_een_rescaled_n(context, + ctx->electron.walk_num, + ctx->electron.num, + ctx->nucleus.num, + ctx->jastrow.cord_num, + ctx->electron.rescale_factor_kappa_en, + ctx->electron.en_distance, + ctx->jastrow.een_rescaled_n); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.een_rescaled_n_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute + :PROPERTIES: + :Name: qmckl_compute_een_rescaled_n + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_factor_een_rescaled_n_args + | qmckl_context | context | in | Global state | + | int64_t | walk_num | in | Number of walkers | + | int64_t | elec_num | in | Number of electrons | + | int64_t | nucl_num | in | Number of atoms | + | int64_t | cord_num | in | Order of polynomials | + | double | rescale_factor_kappa_en | in | Factor to rescale ee distances | + | double | en_distance[walk_num][elec_num][nucl_num] | in | Electron-nucleus distances | + | double | een_rescaled_n[walk_num][elec_num][nucl_num][0:cord_num] | out | Electron-nucleus rescaled distances | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_een_rescaled_n_f(context, walk_num, elec_num, nucl_num, cord_num, rescale_factor_kappa_en, & + en_distance, een_rescaled_n) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: walk_num + integer*8 , intent(in) :: elec_num + integer*8 , intent(in) :: nucl_num + integer*8 , intent(in) :: cord_num + double precision , intent(in) :: rescale_factor_kappa_en + double precision , intent(in) :: en_distance(elec_num,nucl_num,walk_num) + double precision , intent(out) :: een_rescaled_n(0:cord_num,nucl_num,elec_num,walk_num) + double precision :: x + integer*8 :: i, a, k, l, nw + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (walk_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (elec_num <= 0) then + info = QMCKL_INVALID_ARG_3 + return + endif + + if (nucl_num <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + if (cord_num <= 0) then + info = QMCKL_INVALID_ARG_5 + return + endif + + ! Prepare table of exponentiated distances raised to appropriate power + een_rescaled_n = 0.0d0 + do nw = 1, walk_num + + ! prepare the actual een table + een_rescaled_n(0, :, :, nw) = 1.0d0 + + do a = 1, nucl_num + do i = 1, elec_num + een_rescaled_n(1, a, i, nw) = dexp(-rescale_factor_kappa_en * en_distance(i, a, nw)) + end do + end do + + do l = 2, cord_num + do a = 1, nucl_num + do i = 1, elec_num + een_rescaled_n(l, a, i, nw) = een_rescaled_n(l - 1, a, i, nw) * een_rescaled_n(1, a, i, nw) + end do + end do + end do + end do + +end function qmckl_compute_een_rescaled_n_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_factor_een_rescaled_n_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_een_rescaled_n ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t cord_num, + const double rescale_factor_kappa_en, + const double* en_distance, + double* const een_rescaled_n ); + #+end_src + + #+CALL: generate_c_interface(table=qmckl_factor_een_rescaled_n_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_een_rescaled_n & + (context, & + walk_num, & + elec_num, & + nucl_num, & + cord_num, & + rescale_factor_kappa_en, & + en_distance, & + een_rescaled_n) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: walk_num + integer (c_int64_t) , intent(in) , value :: elec_num + integer (c_int64_t) , intent(in) , value :: nucl_num + integer (c_int64_t) , intent(in) , value :: cord_num + real (c_double ) , intent(in) , value :: rescale_factor_kappa_en + real (c_double ) , intent(in) :: en_distance(nucl_num,elec_num,walk_num) + real (c_double ) , intent(out) :: een_rescaled_n(0:cord_num,nucl_num,elec_num,walk_num) + + integer(c_int32_t), external :: qmckl_compute_een_rescaled_n_f + info = qmckl_compute_een_rescaled_n_f & + (context, & + walk_num, & + elec_num, & + nucl_num, & + cord_num, & + rescale_factor_kappa_en, & + en_distance, & + een_rescaled_n) + + end function qmckl_compute_een_rescaled_n + #+end_src + +*** Test + + #+begin_src python :results output :exports none :noweb yes +import numpy as np + +<> + +elec_coord = np.array(elec_coord)[0] +nucl_coord = np.array(nucl_coord) +elnuc_dist = np.zeros(shape=(elec_num, nucl_num),dtype=float) +for i in range(elec_num): + for a in range(nucl_num): + elnuc_dist[i, a] = np.linalg.norm(elec_coord[i] - nucl_coord[:,a]) + +kappa = 1.0 + +een_rescaled_n = np.zeros(shape=(nucl_num, elec_num, cord_num + 1), dtype=float) +een_rescaled_n[:,:,0] = 1.0 + +for a in range(nucl_num): + for i in range(elec_num): + een_rescaled_n[a, i, 1] = np.exp(-kappa * elnuc_dist[i, a]) + +for l in range(2,cord_num+1): + for a in range(nucl_num): + for i in range(elec_num): + een_rescaled_n[a, i, l] = een_rescaled_n[a, i, l - 1] * een_rescaled_n[a, i, 1] + +print(" een_rescaled_n[0, 2, 1] = ",een_rescaled_n[0, 2, 1]) +print(" een_rescaled_n[0, 3, 1] = ",een_rescaled_n[0, 3, 1]) +print(" een_rescaled_n[0, 4, 1] = ",een_rescaled_n[0, 4, 1]) +print(" een_rescaled_n[1, 3, 2] = ",een_rescaled_n[1, 3, 2]) +print(" een_rescaled_n[1, 4, 2] = ",een_rescaled_n[1, 4, 2]) +print(" een_rescaled_n[1, 5, 2] = ",een_rescaled_n[1, 5, 2]) + #+end_src + + #+RESULTS: + : een_rescaled_n[0, 2, 1] = 0.10612983920006765 + : een_rescaled_n[0, 3, 1] = 0.135652809635553 + : een_rescaled_n[0, 4, 1] = 0.023391817607642338 + : een_rescaled_n[1, 3, 2] = 0.880957224822116 + : een_rescaled_n[1, 4, 2] = 0.027185942659395074 + : een_rescaled_n[1, 5, 2] = 0.01343938025140174 + + #+begin_src c :tangle (eval c_test) +assert(qmckl_electron_provided(context)); + +double een_rescaled_n[walk_num][elec_num][nucl_num][(cord_num + 1)]; +rc = qmckl_get_jastrow_een_rescaled_n(context, &(een_rescaled_n[0][0][0][0])); + +// value of (0,2,1) +assert(fabs(een_rescaled_n[0][2][0][1]-0.10612983920006765) < 1.e-12); +assert(fabs(een_rescaled_n[0][3][0][1]-0.135652809635553) < 1.e-12); +assert(fabs(een_rescaled_n[0][4][0][1]-0.023391817607642338) < 1.e-12); +assert(fabs(een_rescaled_n[0][3][1][2]-0.880957224822116) < 1.e-12); +assert(fabs(een_rescaled_n[0][4][1][2]-0.027185942659395074) < 1.e-12); +assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); #+end_src From e0a291d4a71bc4a492cd4dce5c59cbda7c48d0d8 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 13:40:28 +0530 Subject: [PATCH 49/92] Finalizing things before factor_een. #22 --- org/qmckl_jastrow.org | 616 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 607 insertions(+), 9 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index a927c53..3cb3d73 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -98,11 +98,14 @@ int main() { computed data: |-----------+-------------------------------------------------------------+-------------------------------------------------------------------------------| - | ~int64_t~ | ~dim_cord_vec~ | Number of unique C coefficients | + | ~int64_t~ | ~dim_cord_vect~ | Number of unique C coefficients | + | ~int64_t~ | ~dim_cord_vect_date~ | Number of unique C coefficients | | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | | ~int64_t~ | ~asymp_jasb_date~ | Asymptotic component | - | ~double~ | ~coord_vect_full[dim_cord_vec][nucl_num]~ | vector of non-zero coefficients | - | ~int64_t~ | ~lkpm_of_cindex[4][dim_cord_vec]~ | Transform l,k,p, and m into consecutive indices | + | ~double~ | ~cord_vect_full[dim_cord_vect][nucl_num]~ | vector of non-zero coefficients | + | ~int64_t~ | ~cord_vect_full_date~ | Keep track of changes here | + | ~int64_t~ | ~lkpm_combined_index[4][dim_cord_vect]~ | Transform l,k,p, and m into consecutive indices | + | ~int64_t~ | ~lkpm_combined_index_date~ | Transform l,k,p, and m into consecutive indices | | ~double~ | ~tmp_c[elec_num][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | | ~double~ | ~dtmp_c[elec_num][4][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | | ~double~ | ~een_rescaled_e[walk_num][elec_num][elec_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | @@ -196,7 +199,7 @@ type_nucl_num = 1 aord_num = 5 bord_num = 5 cord_num = 23 -dim_cord_vec = 23 +dim_cord_vect= 23 type_nucl_vector = [ 1, 1] aord_vector = [ [0.000000000000000E+000], @@ -234,7 +237,7 @@ cord_vector_full = [ 2.614000000000000E-003, -1.477000000000000E-003, -1.137000000000000E-003, -4.010475000000000E-002, 6.106710000000000E-003 ], ] -lkpm_of_cindex = [[1 , 1 , 2 , 0], +lkpm_combined_index = [[1 , 1 , 2 , 0], [0 , 0 , 2 , 1], [1 , 2 , 3 , 0], [2 , 1 , 3 , 0], @@ -293,8 +296,12 @@ typedef struct qmckl_jastrow_struct{ double * factor_ee_deriv_e; double * factor_en_deriv_e; double * factor_een_deriv_e; - int64_t dim_cord_vec; - double * coord_vect_full; + int64_t dim_cord_vect; + int64_t dim_cord_vect_date; + double * cord_vect_full; + int64_t cord_vect_full_date; + int64_t* lkpm_combined_index; + int64_t lkpm_combined_index_date; double * tmp_c; double * dtmp_c; double * een_rescaled_e; @@ -974,7 +981,7 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { } #+end_src - + ** Test #+begin_src c :tangle (eval c_test) /* Reference input data */ @@ -2834,7 +2841,6 @@ assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); #+end_src - ** Electron-electron rescaled distances for each order @@ -3446,6 +3452,598 @@ assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); #+end_src +** Prepare for electron-electron-nucleus Jastrow \(f_{een}\) + + Prepare ~cord_vect_full~ and ~lkpm_combined_index~ tables required for the + calculation of the three-body jastrow ~factor_een~. + +*** Get + + #+begin_src c :comments org :tangle (eval h_func) :noweb yes +qmckl_exit_code qmckl_get_jastrow_dim_cord_vect(qmckl_context context, int64_t* const dim_cord_vect); +qmckl_exit_code qmckl_get_jastrow_cord_vect_full(qmckl_context context, double* const cord_vect_full); +qmckl_exit_code qmckl_get_jastrow_lkpm_combined_index(qmckl_context context, int64_t* const lkpm_combined_index); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_get_jastrow_dim_cord_vect(qmckl_context context, int64_t* const dim_cord_vect) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_dim_cord_vect(context); + if (rc != QMCKL_SUCCESS) return rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + *dim_cord_vect = ctx->jastrow.dim_cord_vect; + + return QMCKL_SUCCESS; +} + +qmckl_exit_code qmckl_get_jastrow_cord_vect_full(qmckl_context context, double* const cord_vect_full) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_dim_cord_vect(context); + if (rc != QMCKL_SUCCESS) return rc; + + rc = qmckl_provide_cord_vect_full(context); + if (rc != QMCKL_SUCCESS) return rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + size_t sze = ctx->jastrow.dim_cord_vect * ctx->nucleus.num; + memcpy(cord_vect_full, ctx->jastrow.cord_vect_full, sze * sizeof(double)); + + return QMCKL_SUCCESS; +} + +qmckl_exit_code qmckl_get_jastrow_lkpm_combined_index(qmckl_context context, int64_t* const lkpm_combined_index) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_dim_cord_vect(context); + if (rc != QMCKL_SUCCESS) return rc; + + rc = qmckl_provide_cord_vect_full(context); + if (rc != QMCKL_SUCCESS) return rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + size_t sze = ctx->jastrow.dim_cord_vect * 4; + memcpy(lkpm_combined_index, ctx->jastrow.lkpm_combined_index, sze * sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide :noexport: + + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_dim_cord_vect(qmckl_context context); +qmckl_exit_code qmckl_provide_cord_vect_full(qmckl_context context); +qmckl_exit_code qmckl_provide_lkpm_combined_index(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_dim_cord_vect(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); + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.dim_cord_vect_date) { + + qmckl_exit_code rc = + qmckl_compute_dim_cord_vect(context, + ctx->jastrow.cord_num, + &(ctx->jastrow.dim_cord_vect)); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.dim_cord_vect_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + +qmckl_exit_code qmckl_provide_cord_vect_full(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); + + /* Check if dim_cord_vect is provided */ + qmckl_exit_code rc = qmckl_provide_dim_cord_vect(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.cord_vect_full_date) { + + /* Allocate array */ + if (ctx->jastrow.cord_vect_full == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->jastrow.dim_cord_vect * ctx->nucleus.num * sizeof(double); + double* cord_vect_full = (double*) qmckl_malloc(context, mem_info); + + if (cord_vect_full == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_provide_cord_vect_full", + NULL); + } + ctx->jastrow.cord_vect_full = cord_vect_full; + } + + qmckl_exit_code rc = + qmckl_compute_cord_vect_full(context, + ctx->nucleus.num, + ctx->jastrow.cord_num, + ctx->jastrow.dim_cord_vect, + ctx->jastrow.type_nucl_num, + ctx->jastrow.type_nucl_vector, + ctx->jastrow.cord_vector, + ctx->jastrow.cord_vect_full); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.cord_vect_full_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + +qmckl_exit_code qmckl_provide_lkpm_combined_index(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); + + /* Check if dim_cord_vect is provided */ + qmckl_exit_code rc = qmckl_provide_dim_cord_vect(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.lkpm_combined_index_date) { + + /* Allocate array */ + if (ctx->jastrow.lkpm_combined_index == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = 4 * ctx->jastrow.dim_cord_vect * sizeof(double); + int64_t* lkpm_combined_index = (int64_t*) qmckl_malloc(context, mem_info); + + if (lkpm_combined_index == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_provide_lkpm_combined_index", + NULL); + } + ctx->jastrow.lkpm_combined_index = lkpm_combined_index; + } + + qmckl_exit_code rc = + qmckl_compute_lkpm_combined_index(context, + ctx->jastrow.cord_num, + ctx->jastrow.dim_cord_vect, + ctx->jastrow.lkpm_combined_index); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.lkpm_combined_index_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute dim_cord_vect + :PROPERTIES: + :Name: qmckl_compute_dim_cord_vect + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_factor_dim_cord_vect_args + | qmckl_context | context | in | Global state | + | int64_t | cord_num | in | Order of polynomials | + | int64_t | dim_cord_vect | out | dimension of cord_vect_full table | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_dim_cord_vect_f(context, cord_num, dim_cord_vect) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: cord_num + integer*8 , intent(out) :: dim_cord_vect + double precision :: x + integer*8 :: i, a, k, l, p, lmax + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (cord_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + dim_cord_vect = 0 + + do p = 2, cord_num + do k = p - 1, 0, -1 + if (k .ne. 0) then + lmax = p - k + else + lmax = p - k - 2 + endif + do l = lmax, 0, -1 + if (iand(p - k - l, 1) == 1) cycle + dim_cord_vect = dim_cord_vect + 1 + end do + end do + end do + +end function qmckl_compute_dim_cord_vect_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_factor_dim_cord_vect_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_dim_cord_vect ( + const qmckl_context context, + const int64_t cord_num, + int64_t* const dim_cord_vect ); + #+end_src + + + #+CALL: generate_c_interface(table=qmckl_factor_dim_cord_vect_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_dim_cord_vect & + (context, cord_num, dim_cord_vect) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: cord_num + integer (c_int64_t) , intent(out) :: dim_cord_vect + + integer(c_int32_t), external :: qmckl_compute_dim_cord_vect_f + info = qmckl_compute_dim_cord_vect_f & + (context, cord_num, dim_cord_vect) + + end function qmckl_compute_dim_cord_vect + #+end_src + +*** Compute cord_vect_full + :PROPERTIES: + :Name: qmckl_compute_cord_vect_full + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_factor_cord_vect_full_args + | qmckl_context | context | in | Global state | + | int64_t | nucl_num | in | Number of atoms | + | int64_t | cord_num | in | Order of polynomials | + | int64_t | dim_cord_vect | in | dimension of cord full table | + | int64_t | type_nucl_num | in | dimension of cord full table | + | int64_t | type_nucl_vector[nucl_num] | in | dimension of cord full table | + | double | cord_vector[cord_num][type_nucl_num] | in | dimension of cord full table | + | double | cord_vect_full[dim_cord_vect][nucl_num] | out | Full list of coefficients | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_cord_vect_full_f(context, nucl_num, cord_num, dim_cord_vect, type_nucl_num, & + type_nucl_vector, cord_vector, cord_vect_full) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: nucl_num + integer*8 , intent(in) :: cord_num + integer*8 , intent(in) :: dim_cord_vect + integer*8 , intent(in) :: type_nucl_num + integer*8 , intent(in) :: type_nucl_vector(nucl_num) + double precision , intent(in) :: cord_vector(cord_num, type_nucl_num) + double precision , intent(out) :: cord_vect_full(nucl_num,dim_cord_vect) + double precision :: x + integer*8 :: i, a, k, l, nw + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (nucl_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (cord_num <= 0) then + info = QMCKL_INVALID_ARG_3 + return + endif + + if (type_nucl_num <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + if (dim_cord_vect <= 0) then + info = QMCKL_INVALID_ARG_5 + return + endif + + + do a = 1, nucl_num + cord_vect_full(1:dim_cord_vect,a) = cord_vector(1:dim_cord_vect,type_nucl_vector(a)) + end do + +end function qmckl_compute_cord_vect_full_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_factor_cord_vect_full_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_cord_vect_full ( + const qmckl_context context, + const int64_t nucl_num, + const int64_t cord_num, + const int64_t dim_cord_vect, + const int64_t type_nucl_num, + const int64_t* type_nucl_vector, + const double* cord_vector, + double* const cord_vect_full ); + #+end_src + + + #+CALL: generate_c_interface(table=qmckl_factor_cord_vect_full_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_cord_vect_full & + (context, & + nucl_num, & + cord_num, & + dim_cord_vect, & + type_nucl_num, & + type_nucl_vector, & + cord_vector, & + cord_vect_full) & + 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 :: nucl_num + integer (c_int64_t) , intent(in) , value :: cord_num + integer (c_int64_t) , intent(in) , value :: dim_cord_vect + integer (c_int64_t) , intent(in) , value :: type_nucl_num + integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num) + real (c_double ) , intent(in) :: cord_vector(type_nucl_num,cord_num) + real (c_double ) , intent(out) :: cord_vect_full(nucl_num,dim_cord_vect) + + integer(c_int32_t), external :: qmckl_compute_cord_vect_full_f + info = qmckl_compute_cord_vect_full_f & + (context, & + nucl_num, & + cord_num, & + dim_cord_vect, & + type_nucl_num, & + type_nucl_vector, & + cord_vector, & + cord_vect_full) + + end function qmckl_compute_cord_vect_full + #+end_src + +*** Compute lkpm_combined_index + :PROPERTIES: + :Name: qmckl_compute_lkpm_combined_index + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_factor_lkpm_combined_index_args + | qmckl_context | context | in | Global state | + | int64_t | cord_num | in | Order of polynomials | + | int64_t | dim_cord_vect | in | dimension of cord full table | + | int64_t | lpkm_combined_index[4][dim_cord_vect] | out | Full list of combined indices | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_lkpm_combined_index_f(context, cord_num, dim_cord_vect, & + lkpm_combined_index) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: cord_num + integer*8 , intent(in) :: dim_cord_vect + double precision , intent(out) :: lkpm_combined_index(dim_cord_vect,4) + double precision :: x + integer*8 :: i, a, k, l, kk, p, lmax, m + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (cord_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (dim_cord_vect <= 0) then + info = QMCKL_INVALID_ARG_3 + return + endif + + + do p = 2, cord_num + do k = p - 1, 0, -1 + if (k .ne. 0) then + lmax = p - k + else + lmax = p - k - 2 + end if + do l = lmax, 0, -1 + if (iand(p - k - l, 1) .eq. 1) cycle + m = (p - k - l)/2 + kk = kk + 1 + lkpm_combined_index(1, kk) = l + lkpm_combined_index(2, kk) = k + lkpm_combined_index(3, kk) = p + lkpm_combined_index(4, kk) = m + end do + end do + end do + +end function qmckl_compute_lkpm_combined_index_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_factor_lkpm_combined_index_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_lkpm_combined_index ( + const qmckl_context context, + const int64_t cord_num, + const int64_t dim_cord_vect, + int64_t* const lpkm_combined_index ); + #+end_src + + + #+CALL: generate_c_interface(table=qmckl_factor_lkpm_combined_index_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_lkpm_combined_index & + (context, cord_num, dim_cord_vect, lpkm_combined_index) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: cord_num + integer (c_int64_t) , intent(in) , value :: dim_cord_vect + integer (c_int64_t) , intent(out) :: lpkm_combined_index(dim_cord_vect,4) + + integer(c_int32_t), external :: qmckl_compute_lkpm_combined_index_f + info = qmckl_compute_lkpm_combined_index_f & + (context, cord_num, dim_cord_vect, lpkm_combined_index) + + end function qmckl_compute_lkpm_combined_index + #+end_src + + +*** Test + + #+begin_src python :results output :exports none :noweb yes +import numpy as np + +<> + +elec_coord = np.array(elec_coord)[0] +nucl_coord = np.array(nucl_coord) +elnuc_dist = np.zeros(shape=(elec_num, nucl_num),dtype=float) +for i in range(elec_num): + for a in range(nucl_num): + elnuc_dist[i, a] = np.linalg.norm(elec_coord[i] - nucl_coord[:,a]) + +kappa = 1.0 + +een_rescaled_n = np.zeros(shape=(nucl_num, elec_num, cord_num + 1), dtype=float) +een_rescaled_n[:,:,0] = 1.0 + +for a in range(nucl_num): + for i in range(elec_num): + een_rescaled_n[a, i, 1] = np.exp(-kappa * elnuc_dist[i, a]) + +for l in range(2,cord_num+1): + for a in range(nucl_num): + for i in range(elec_num): + een_rescaled_n[a, i, l] = een_rescaled_n[a, i, l - 1] * een_rescaled_n[a, i, 1] + +print(" een_rescaled_n[0, 2, 1] = ",een_rescaled_n[0, 2, 1]) +print(" een_rescaled_n[0, 3, 1] = ",een_rescaled_n[0, 3, 1]) +print(" een_rescaled_n[0, 4, 1] = ",een_rescaled_n[0, 4, 1]) +print(" een_rescaled_n[1, 3, 2] = ",een_rescaled_n[1, 3, 2]) +print(" een_rescaled_n[1, 4, 2] = ",een_rescaled_n[1, 4, 2]) +print(" een_rescaled_n[1, 5, 2] = ",een_rescaled_n[1, 5, 2]) + #+end_src + + #+RESULTS: + : een_rescaled_n[0, 2, 1] = 0.10612983920006765 + : een_rescaled_n[0, 3, 1] = 0.135652809635553 + : een_rescaled_n[0, 4, 1] = 0.023391817607642338 + : een_rescaled_n[1, 3, 2] = 0.880957224822116 + : een_rescaled_n[1, 4, 2] = 0.027185942659395074 + : een_rescaled_n[1, 5, 2] = 0.01343938025140174 + + #+begin_src c :tangle (eval c_test) +assert(qmckl_electron_provided(context)); + +//double een_rescaled_n[walk_num][elec_num][nucl_num][(cord_num + 1)]; +//rc = qmckl_get_jastrow_een_rescaled_n(context, &(een_rescaled_n[0][0][0][0])); +// +//// value of (0,2,1) +//assert(fabs(een_rescaled_n[0][2][0][1]-0.10612983920006765) < 1.e-12); +//assert(fabs(een_rescaled_n[0][3][0][1]-0.135652809635553) < 1.e-12); +//assert(fabs(een_rescaled_n[0][4][0][1]-0.023391817607642338) < 1.e-12); +//assert(fabs(een_rescaled_n[0][3][1][2]-0.880957224822116) < 1.e-12); +//assert(fabs(een_rescaled_n[0][4][1][2]-0.027185942659395074) < 1.e-12); +//assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); + + #+end_src + * End of files :noexport: From 55ac5b3787967995e2297bd0c9c5b160a2570838 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 14:06:18 +0530 Subject: [PATCH 50/92] Added factor_een. #22 --- org/qmckl_jastrow.org | 397 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 390 insertions(+), 7 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 3cb3d73..2bbd004 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -3641,7 +3641,7 @@ qmckl_exit_code qmckl_provide_lkpm_combined_index(qmckl_context context) if (ctx->jastrow.lkpm_combined_index == NULL) { qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; - mem_info.size = 4 * ctx->jastrow.dim_cord_vect * sizeof(double); + mem_info.size = 4 * ctx->jastrow.dim_cord_vect * sizeof(int64_t); int64_t* lkpm_combined_index = (int64_t*) qmckl_malloc(context, mem_info); if (lkpm_combined_index == NULL) { @@ -3904,7 +3904,7 @@ integer function qmckl_compute_lkpm_combined_index_f(context, cord_num, dim_cord integer(qmckl_context), intent(in) :: context integer*8 , intent(in) :: cord_num integer*8 , intent(in) :: dim_cord_vect - double precision , intent(out) :: lkpm_combined_index(dim_cord_vect,4) + integer*8 , intent(out) :: lkpm_combined_index(dim_cord_vect, 4) double precision :: x integer*8 :: i, a, k, l, kk, p, lmax, m @@ -3937,10 +3937,10 @@ integer function qmckl_compute_lkpm_combined_index_f(context, cord_num, dim_cord if (iand(p - k - l, 1) .eq. 1) cycle m = (p - k - l)/2 kk = kk + 1 - lkpm_combined_index(1, kk) = l - lkpm_combined_index(2, kk) = k - lkpm_combined_index(3, kk) = p - lkpm_combined_index(4, kk) = m + lkpm_combined_index(kk, 1) = l + lkpm_combined_index(kk, 2) = k + lkpm_combined_index(kk, 3) = p + lkpm_combined_index(kk, 4) = m end do end do end do @@ -3983,7 +3983,7 @@ end function qmckl_compute_lkpm_combined_index_f end function qmckl_compute_lkpm_combined_index #+end_src - + *** Test #+begin_src python :results output :exports none :noweb yes @@ -4045,6 +4045,389 @@ assert(qmckl_electron_provided(context)); #+end_src +** Electron-electron-nucleus Jastrow \(f_{een}\) + + Calculate the electron-electron-nuclear three-body jastrow component ~factor_een~ + using the above prepared tables. + + TODO: write equations. + +*** Get + #+begin_src c :comments org :tangle (eval h_func) :noweb yes +qmckl_exit_code qmckl_get_jastrow_factor_een(qmckl_context context, double* const factor_een); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_get_jastrow_factor_een(qmckl_context context, double* const factor_een) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_factor_een(context); + if (rc != QMCKL_SUCCESS) return rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int64_t sze = ctx->electron.walk_num * ctx->electron.num; + memcpy(factor_een, ctx->jastrow.factor_een, sze*sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide :noexport: + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_factor_een(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_factor_een(qmckl_context context) +{ + + qmckl_exit_code rc; + + 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); + + /* Check if en rescaled distance is provided */ + rc = qmckl_provide_een_rescaled_e(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Check if en rescaled distance derivatives is provided */ + rc = qmckl_provide_een_rescaled_n(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Check if en rescaled distance derivatives is provided */ + rc = qmckl_provide_cord_vect_full(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Check if en rescaled distance derivatives is provided */ + rc = qmckl_provide_lkpm_combined_index(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.factor_een_date) { + + /* Allocate array */ + if (ctx->jastrow.factor_een == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->electron.walk_num * sizeof(double); + double* factor_een = (double*) qmckl_malloc(context, mem_info); + + if (factor_een == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_provide_factor_een", + NULL); + } + ctx->jastrow.factor_een = factor_een; + } + + qmckl_exit_code rc = + qmckl_compute_factor_een(context, + ctx->electron.walk_num, + ctx->electron.num, + ctx->nucleus.num, + ctx->jastrow.cord_num, + ctx->jastrow.dim_cord_vect, + ctx->jastrow.cord_vect_full, + ctx->jastrow.lkpm_combined_index, + ctx->jastrow.een_rescaled_e, + ctx->jastrow.een_rescaled_n, + ctx->jastrow.factor_een); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.factor_en_deriv_e_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute + :PROPERTIES: + :Name: qmckl_compute_factor_een + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_factor_een_args + | qmckl_context | context | in | Global state | + | int64_t | walk_num | in | Number of walkers | + | int64_t | elec_num | in | Number of electrons | + | int64_t | nucl_num | in | Number of nucleii | + | int64_t | cord_num | in | order of polynomials | + | int64_t | dim_cord_vect | in | dimension of full coefficient vector | + | double | cord_vect_full[dim_cord_vect][nucl_num] | in | full coefficient vector | + | int64_t | lkpm_combined_index[4][dim_cord_vect] | in | combined indices | + | double | een_rescaled_e[walk_num][elec_num][elec_num][0:cord_num] | in | Electron-nucleus rescaled | + | double | een_rescaled_n[walk_num][elec_num][nucl_num][0:cord_num] | in | Electron-nucleus rescaled factor | + | double | factor_een[walk_num] | out | Electron-nucleus jastrow | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_factor_een_f(context, walk_num, elec_num, nucl_num, cord_num, dim_cord_vect, & + cord_vect_full, lkpm_combined_index, & + een_rescaled_e, een_rescaled_n, factor_een) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: walk_num, elec_num, cord_num, nucl_num, dim_cord_vect + integer*8 , intent(in) :: lkpm_combined_index(4,dim_cord_vect) + double precision , intent(in) :: cord_vect_full(dim_cord_vect, nucl_num) + double precision , intent(in) :: een_rescaled_e(walk_num, elec_num, elec_num, 0:cord_num) + double precision , intent(in) :: een_rescaled_n(walk_num, elec_num, nucl_num, 0:cord_num) + double precision , intent(out) :: factor_een(walk_num) + + integer*8 :: i, a, j, l, k, p, m, n, nw + double precision :: accu, accu2, cn + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (walk_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (elec_num <= 0) then + info = QMCKL_INVALID_ARG_3 + return + endif + + if (nucl_num <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + if (cord_num <= 0) then + info = QMCKL_INVALID_ARG_5 + return + endif + + factor_een = 0.0d0 + + do nw =1, walk_num + do n = 1, dim_cord_vect + l = lkpm_combined_index(1, n) + k = lkpm_combined_index(2, n) + p = lkpm_combined_index(3, n) + m = lkpm_combined_index(4, n) + + do a = 1, nucl_num + accu2 = 0.0d0 + cn = cord_vect_full(n, a) + do j = 1, elec_num + accu = 0.0d0 + do i = 1, elec_num + accu = accu + een_rescaled_e(nw, i, j, k) * & + een_rescaled_n(nw, i, a, m) + end do + accu2 = accu2 + accu * een_rescaled_n(nw, j, a, m + l) + end do + factor_een(nw) = factor_een(nw) + accu2 + cn + end do + end do + end do + +end function qmckl_compute_factor_een_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_factor_een_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_factor_een ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t cord_num, + const int64_t dim_cord_vect, + const double* cord_vect_full, + const int64_t* lkpm_combined_index, + const double* een_rescaled_e, + const double* een_rescaled_n, + double* const factor_een ); + #+end_src + + + #+CALL: generate_c_interface(table=qmckl_factor_een_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_factor_een & + (context, & + walk_num, & + elec_num, & + nucl_num, & + cord_num, & + dim_cord_vect, & + cord_vect_full, & + lkpm_combined_index, & + een_rescaled_e, & + een_rescaled_n, & + factor_een) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: walk_num + integer (c_int64_t) , intent(in) , value :: elec_num + integer (c_int64_t) , intent(in) , value :: nucl_num + integer (c_int64_t) , intent(in) , value :: cord_num + integer (c_int64_t) , intent(in) , value :: dim_cord_vect + real (c_double ) , intent(in) :: cord_vect_full(nucl_num,dim_cord_vect) + integer (c_int64_t) , intent(in) :: lkpm_combined_index(dim_cord_vect,4) + real (c_double ) , intent(in) :: een_rescaled_e(0:cord_num,elec_num,elec_num,walk_num) + real (c_double ) , intent(in) :: een_rescaled_n(0:cord_num,nucl_num,elec_num,walk_num) + real (c_double ) , intent(out) :: factor_een(walk_num) + + integer(c_int32_t), external :: qmckl_compute_factor_een_f + info = qmckl_compute_factor_een_f & + (context, & + walk_num, & + elec_num, & + nucl_num, & + cord_num, & + dim_cord_vect, & + cord_vect_full, & + lkpm_combined_index, & + een_rescaled_e, & + een_rescaled_n, & + factor_een) + + end function qmckl_compute_factor_een + #+end_src + +*** Test + #+begin_src python :results output :exports none :noweb yes +import numpy as np + +<> + +kappa = 1.0 + +elec_coord = np.array(elec_coord)[0] +nucl_coord = np.array(nucl_coord) +elnuc_dist = np.zeros(shape=(elec_num, nucl_num),dtype=float) +for i in range(elec_num): + for j in range(nucl_num): + elnuc_dist[i, j] = np.linalg.norm(elec_coord[i] - nucl_coord[:,j]) + +elnuc_dist_deriv_e = np.zeros(shape=(4, elec_num, nucl_num),dtype=float) +for a in range(nucl_num): + for i in range(elec_num): + rij_inv = 1.0 / elnuc_dist[i, a] + for ii in range(3): + elnuc_dist_deriv_e[ii, i, a] = (elec_coord[i][ii] - nucl_coord[ii][a]) * rij_inv + elnuc_dist_deriv_e[3, i, a] = 2.0 * rij_inv + +en_distance_rescaled_deriv_e = np.zeros(shape=(4,elec_num,nucl_num),dtype=float) +for a in range(nucl_num): + for i in range(elec_num): + f = 1.0 - kappa * en_distance_rescaled[i][a] + for ii in range(4): + en_distance_rescaled_deriv_e[ii][i][a] = elnuc_dist_deriv_e[ii][i][a] + en_distance_rescaled_deriv_e[3][i][a] = en_distance_rescaled_deriv_e[3][i][a] + \ + (-kappa * en_distance_rescaled_deriv_e[0][i][a] * en_distance_rescaled_deriv_e[0][i][a]) + \ + (-kappa * en_distance_rescaled_deriv_e[1][i][a] * en_distance_rescaled_deriv_e[1][i][a]) + \ + (-kappa * en_distance_rescaled_deriv_e[2][i][a] * en_distance_rescaled_deriv_e[2][i][a]) + for ii in range(4): + en_distance_rescaled_deriv_e[ii][i][a] = en_distance_rescaled_deriv_e[ii][i][a] * f + +third = 1.0 / 3.0 +factor_en_deriv_e = np.zeros(shape=(4,elec_num),dtype=float) +dx = np.zeros(shape=(4),dtype=float) +pow_ser_g = np.zeros(shape=(3),dtype=float) +for a in range(nucl_num): + for i in range(elec_num): + x = en_distance_rescaled[i][a] + if abs(x) < 1e-18: + continue + pow_ser_g = np.zeros(shape=(3),dtype=float) + den = 1.0 + aord_vector[1][type_nucl_vector[a]-1] * x + invden = 1.0 / den + invden2 = invden * invden + invden3 = invden2 * invden + xinv = 1.0 / (x + 1.0E-18) + + for ii in range(4): + dx[ii] = en_distance_rescaled_deriv_e[ii][i][a] + + lap1 = 0.0 + lap2 = 0.0 + lap3 = 0.0 + for ii in range(3): + x = en_distance_rescaled[i][a] + if x < 1e-18: + continue + for p in range(2,aord_num+1): + y = p * aord_vector[(p-1) + 1][type_nucl_vector[a]-1] * x + pow_ser_g[ii] = pow_ser_g[ii] + y * dx[ii] + lap1 = lap1 + (p - 1) * y * xinv * dx[ii] * dx[ii] + lap2 = lap2 + y + x = x * en_distance_rescaled[i][a] + + lap3 = lap3 - 2.0 * aord_vector[1][type_nucl_vector[a]-1] * dx[ii] * dx[ii] + + factor_en_deriv_e[ii][i] = factor_en_deriv_e[ii][i] + aord_vector[0][type_nucl_vector[a]-1] * \ + dx[ii] * invden2 + pow_ser_g[ii] + + ii = 3 + lap2 = lap2 * dx[ii] * third + lap3 = lap3 + den * dx[ii] + lap3 = lap3 * (aord_vector[0][type_nucl_vector[a]-1] * invden3) + factor_en_deriv_e[ii][i] = factor_en_deriv_e[ii][i] + lap1 + lap2 + lap3 + +print("factor_en_deriv_e[0][0]:",factor_en_deriv_e[0][0]) +print("factor_en_deriv_e[1][0]:",factor_en_deriv_e[1][0]) +print("factor_en_deriv_e[2][0]:",factor_en_deriv_e[2][0]) +print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) + + + #+end_src + + #+RESULTS: + : factor_en_deriv_e[0][0]: 0.11609919541763383 + : factor_en_deriv_e[1][0]: -0.23301394780804574 + : factor_en_deriv_e[2][0]: 0.17548337641865783 + : factor_en_deriv_e[3][0]: -0.9667363412285741 + + + #+begin_src c :tangle (eval c_test) +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +// calculate factor_en_deriv_e +double factor_een[walk_num]; +rc = qmckl_get_jastrow_factor_een(context, &(factor_een[0])); + +//// check factor_en_deriv_e +//assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); +//assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); +//assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); +//assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); + + #+end_src + * End of files :noexport: #+begin_src c :tangle (eval h_private_type) From 9b697278d7aa3bd45d26d0c344b137a8a0911a43 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 17:49:03 +0530 Subject: [PATCH 51/92] Added derivatives of rescale_een_e and rescale_een_n. #22 --- org/qmckl_jastrow.org | 717 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 700 insertions(+), 17 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 2bbd004..cea8541 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -97,21 +97,25 @@ int main() { computed data: - |-----------+-------------------------------------------------------------+-------------------------------------------------------------------------------| - | ~int64_t~ | ~dim_cord_vect~ | Number of unique C coefficients | - | ~int64_t~ | ~dim_cord_vect_date~ | Number of unique C coefficients | - | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | - | ~int64_t~ | ~asymp_jasb_date~ | Asymptotic component | - | ~double~ | ~cord_vect_full[dim_cord_vect][nucl_num]~ | vector of non-zero coefficients | - | ~int64_t~ | ~cord_vect_full_date~ | Keep track of changes here | - | ~int64_t~ | ~lkpm_combined_index[4][dim_cord_vect]~ | Transform l,k,p, and m into consecutive indices | - | ~int64_t~ | ~lkpm_combined_index_date~ | Transform l,k,p, and m into consecutive indices | - | ~double~ | ~tmp_c[elec_num][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | - | ~double~ | ~dtmp_c[elec_num][4][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | - | ~double~ | ~een_rescaled_e[walk_num][elec_num][elec_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | - | ~int64_t~ | ~een_rescaled_e_date~ | Keep track of the date of creation | - | ~double~ | ~een_rescaled_n[walk_num][elec_num][nucl_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | - | ~int64_t~ | ~een_rescaled_n_date~ | Keep track of the date of creation | + |-----------+-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------| + | ~int64_t~ | ~dim_cord_vect~ | Number of unique C coefficients | + | ~int64_t~ | ~dim_cord_vect_date~ | Number of unique C coefficients | + | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | + | ~int64_t~ | ~asymp_jasb_date~ | Asymptotic component | + | ~double~ | ~cord_vect_full[dim_cord_vect][nucl_num]~ | vector of non-zero coefficients | + | ~int64_t~ | ~cord_vect_full_date~ | Keep track of changes here | + | ~int64_t~ | ~lkpm_combined_index[4][dim_cord_vect]~ | Transform l,k,p, and m into consecutive indices | + | ~int64_t~ | ~lkpm_combined_index_date~ | Transform l,k,p, and m into consecutive indices | + | ~double~ | ~tmp_c[elec_num][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | + | ~double~ | ~dtmp_c[elec_num][4][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | + | ~double~ | ~een_rescaled_e[walk_num][elec_num][elec_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | + | ~int64_t~ | ~een_rescaled_e_date~ | Keep track of the date of creation | + | ~double~ | ~een_rescaled_n[walk_num][elec_num][nucl_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | + | ~int64_t~ | ~een_rescaled_n_date~ | Keep track of the date of creation | + | ~double~ | ~een_rescaled_e_deriv_e[walk_num][elec_num][4][elec_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons | + | ~int64_t~ | ~een_rescaled_e_deriv_e_date~ | Keep track of the date of creation | + | ~double~ | ~een_rescaled_n_deriv_e[walk_num][elec_num][4][nucl_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons | + | ~int64_t~ | ~een_rescaled_n_deriv_e_date~ | Keep track of the date of creation | For H2O we have the following data: @@ -308,6 +312,10 @@ typedef struct qmckl_jastrow_struct{ double * een_rescaled_n; int64_t een_rescaled_e_date; int64_t een_rescaled_n_date; + double * een_rescaled_e_deriv_e; + double * een_rescaled_n_deriv_e; + int64_t een_rescaled_e_deriv_e_date; + int64_t een_rescaled_n_deriv_e_date; bool provided; char * type; } qmckl_jastrow_struct; @@ -3150,6 +3158,340 @@ assert(fabs(een_rescaled_e[0][1][5][2]-0.3424402276009091) < 1.e-12); #+end_src +** Electron-electron rescaled distances for each order and derivatives + + ~een_rescaled_e~ stores the table of the rescaled distances between all + pairs of electrons and raised to the power \(p\) defined by ~cord_num~. + Here we take its derivatives required for the een jastrow. + + TODO: write formulae + + +*** Get + + #+begin_src c :comments org :tangle (eval h_func) :noweb yes +qmckl_exit_code qmckl_get_jastrow_een_rescaled_e_deriv_e(qmckl_context context, double* const distance_rescaled); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_get_jastrow_een_rescaled_e_deriv_e(qmckl_context context, double* const distance_rescaled) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_een_rescaled_e_deriv_e(context); + if (rc != QMCKL_SUCCESS) return rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + size_t sze = ctx->electron.num * 4 * ctx->electron.num * ctx->electron.walk_num * (ctx->jastrow.cord_num + 1); + memcpy(distance_rescaled, ctx->jastrow.een_rescaled_e_deriv_e, sze * sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide :noexport: + + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_een_rescaled_e_deriv_e(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_een_rescaled_e_deriv_e(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); + + /* Check if ee distance is provided */ + qmckl_exit_code rc = qmckl_provide_een_rescaled_e(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.een_rescaled_e_deriv_e_date) { + + /* Allocate array */ + if (ctx->jastrow.een_rescaled_e_deriv_e == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->electron.num * 4 * ctx->electron.num * + ctx->electron.walk_num * (ctx->jastrow.cord_num + 1) * sizeof(double); + double* een_rescaled_e_deriv_e = (double*) qmckl_malloc(context, mem_info); + + if (een_rescaled_e_deriv_e == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_een_rescaled_e_deriv_e", + NULL); + } + ctx->jastrow.een_rescaled_e_deriv_e = een_rescaled_e_deriv_e; + } + + qmckl_exit_code rc = + qmckl_compute_factor_een_rescaled_e_deriv_e(context, + ctx->electron.walk_num, + ctx->electron.num, + ctx->jastrow.cord_num, + ctx->electron.rescale_factor_kappa_ee, + ctx->electron.coord_new, + ctx->electron.ee_distance, + ctx->jastrow.een_rescaled_e, + ctx->jastrow.een_rescaled_e_deriv_e); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.een_rescaled_e_deriv_e_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute + :PROPERTIES: + :Name: qmckl_compute_een_rescaled_e_deriv_e + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_factor_een_rescaled_e_deriv_e_args + | qmckl_context | context | in | Global state | + | int64_t | walk_num | in | Number of walkers | + | int64_t | elec_num | in | Number of electrons | + | int64_t | cord_num | in | Order of polynomials | + | double | rescale_factor_kappa_ee | in | Factor to rescale ee distances | + | double | coord_new[walk_num][3][elec_num] | in | Electron coordinates | + | double | ee_distance[walk_num][elec_num][elec_num] | in | Electron-electron distances | + | double | een_rescaled_e[walk_num][elec_num][elec_num][0:cord_num] | in | Electron-electron distances | + | double | een_rescaled_e_deriv_e[walk_num][elec_num][4][elec_num][0:cord_num] | out | Electron-electron rescaled distances | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_factor_een_rescaled_e_deriv_e_f(context, walk_num, elec_num, cord_num, rescale_factor_kappa_ee, & + coord_new, ee_distance, een_rescaled_e, een_rescaled_e_deriv_e) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: walk_num + integer*8 , intent(in) :: elec_num + integer*8 , intent(in) :: cord_num + double precision , intent(in) :: rescale_factor_kappa_ee + double precision , intent(in) :: coord_new(elec_num,3,walk_num) + double precision , intent(in) :: ee_distance(elec_num,elec_num,walk_num) + double precision , intent(in) :: een_rescaled_e(0:cord_num,elec_num,elec_num,walk_num) + double precision , intent(out) :: een_rescaled_e_deriv_e(0:cord_num,elec_num,4,elec_num,walk_num) + double precision,dimension(:,:,:),allocatable :: elec_dist_deriv_e + double precision :: x, rij_inv, kappa_l + integer*8 :: i, j, k, l, nw, ii + + allocate(elec_dist_deriv_e(4,elec_num,elec_num)) + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (walk_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (elec_num <= 0) then + info = QMCKL_INVALID_ARG_3 + return + endif + + if (cord_num <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + ! Prepare table of exponentiated distances raised to appropriate power + een_rescaled_e_deriv_e = 0.0d0 + do nw = 1, walk_num + do j = 1, elec_num + do i = 1, elec_num + rij_inv = 1.0d0 / ee_distance(i, j, nw) + do ii = 1, 3 + elec_dist_deriv_e(ii, i, j) = (coord_new(i, ii, nw) - coord_new(j, ii, nw)) * rij_inv + end do + elec_dist_deriv_e(4, i, j) = 2.0d0 * rij_inv + end do + elec_dist_deriv_e(:, j, j) = 0.0d0 + end do + + ! prepare the actual een table + do l = 1, cord_num + kappa_l = - dble(l) * rescale_factor_kappa_ee + do j = 1, elec_num + do i = 1, elec_num + do ii = 1, 4 + een_rescaled_e_deriv_e(l, i, ii, j, nw) = kappa_l * elec_dist_deriv_e(ii, i, j) + end do + + een_rescaled_e_deriv_e(l, i, 4, j, nw) = een_rescaled_e_deriv_e(l, i, 4, j, nw) & + + een_rescaled_e_deriv_e(l, i, 1, j, nw) * een_rescaled_e_deriv_e(l, i, 1, j, nw) & + + een_rescaled_e_deriv_e(l, i, 2, j, nw) * een_rescaled_e_deriv_e(l, i, 2, j, nw) & + + een_rescaled_e_deriv_e(l, i, 3, j, nw) * een_rescaled_e_deriv_e(l, i, 3, j, nw) + + do ii = 1, 4 + een_rescaled_e_deriv_e(l, i, ii, j, nw) = een_rescaled_e_deriv_e(l, i, ii, j, nw) * & + een_rescaled_e(l, i, j, nw) + end do + end do + end do + end do + end do + +end function qmckl_compute_factor_een_rescaled_e_deriv_e_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_factor_een_rescaled_e_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_factor_een_rescaled_e_deriv_e ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t cord_num, + const double rescale_factor_kappa_ee, + const double* coord_new, + const double* ee_distance, + const double* een_rescaled_e, + double* const een_rescaled_e_deriv_e ); + #+end_src + + + #+CALL: generate_c_interface(table=qmckl_factor_een_rescaled_e_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_factor_een_rescaled_e_deriv_e & + (context, & + walk_num, & + elec_num, & + cord_num, & + rescale_factor_kappa_ee, & + coord_new, & + ee_distance, & + een_rescaled_e, & + een_rescaled_e_deriv_e) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: walk_num + integer (c_int64_t) , intent(in) , value :: elec_num + integer (c_int64_t) , intent(in) , value :: cord_num + real (c_double ) , intent(in) , value :: rescale_factor_kappa_ee + real (c_double ) , intent(in) :: coord_new(elec_num,3,walk_num) + real (c_double ) , intent(in) :: ee_distance(elec_num,elec_num,walk_num) + real (c_double ) , intent(in) :: een_rescaled_e(0:cord_num,elec_num,elec_num,walk_num) + real (c_double ) , intent(out) :: een_rescaled_e_deriv_e(0:cord_num,elec_num,4,elec_num,walk_num) + + integer(c_int32_t), external :: qmckl_compute_factor_een_rescaled_e_deriv_e_f + info = qmckl_compute_factor_een_rescaled_e_deriv_e_f & + (context, & + walk_num, & + elec_num, & + cord_num, & + rescale_factor_kappa_ee, & + coord_new, & + ee_distance, & + een_rescaled_e, & + een_rescaled_e_deriv_e) + + end function qmckl_compute_factor_een_rescaled_e_deriv_e + #+end_src + +*** Test + + #+begin_src python :results output :exports none :noweb yes +import numpy as np + +<> + +elec_coord = np.array(elec_coord)[0] +elec_dist = np.zeros(shape=(elec_num, elec_num),dtype=float) +for i in range(elec_num): + for j in range(elec_num): + elec_dist[i, j] = np.linalg.norm(elec_coord[i] - elec_coord[j]) + +kappa = 1.0 + +een_rescaled_e_ij = np.zeros(shape=(elec_num * (elec_num - 1)//2, cord_num+1), dtype=float) +een_rescaled_e_ij[:,0] = 1.0 + +k = 0 +for j in range(elec_num): + for i in range(j): + een_rescaled_e_ij[k, 1] = np.exp(-kappa * elec_dist[i, j]) + k = k + 1 + +for l in range(2, cord_num + 1): + for k in range(elec_num * (elec_num - 1)//2): + een_rescaled_e_ij[k, l] = een_rescaled_e_ij[k, l - 1] * een_rescaled_e_ij[k, 1] + +een_rescaled_e = np.zeros(shape=(elec_num, elec_num, cord_num + 1), dtype=float) +een_rescaled_e[:,:,0] = 1.0 + +for l in range(1,cord_num+1): + k = 0 + for j in range(elec_num): + for i in range(j): + x = een_rescaled_e_ij[k, l] + een_rescaled_e[i, j, l] = x + een_rescaled_e[j, i, l] = x + k = k + 1 + +print(" een_rescaled_e[0, 2, 1] = ",een_rescaled_e[0, 2, 1]) +print(" een_rescaled_e[0, 3, 1] = ",een_rescaled_e[0, 3, 1]) +print(" een_rescaled_e[0, 4, 1] = ",een_rescaled_e[0, 4, 1]) +print(" een_rescaled_e[1, 3, 2] = ",een_rescaled_e[1, 3, 2]) +print(" een_rescaled_e[1, 4, 2] = ",een_rescaled_e[1, 4, 2]) +print(" een_rescaled_e[1, 5, 2] = ",een_rescaled_e[1, 5, 2]) + #+end_src + + #+RESULTS: + : een_rescaled_e[0, 2, 1] = 0.08084493981483197 + : een_rescaled_e[0, 3, 1] = 0.1066745707571846 + : een_rescaled_e[0, 4, 1] = 0.01754273169464735 + : een_rescaled_e[1, 3, 2] = 0.02214680362033448 + : een_rescaled_e[1, 4, 2] = 0.0005700154999202759 + : een_rescaled_e[1, 5, 2] = 0.3424402276009091 + + #+begin_src c :tangle (eval c_test) +//assert(qmckl_electron_provided(context)); +// +// +//double een_rescaled_e[walk_num][elec_num][elec_num][(cord_num + 1)]; +//rc = qmckl_get_jastrow_een_rescaled_e(context, &(een_rescaled_e[0][0][0][0])); +// +//// value of (0,2,1) +//assert(fabs(een_rescaled_e[0][0][2][1]-0.08084493981483197) < 1.e-12); +//assert(fabs(een_rescaled_e[0][0][3][1]-0.1066745707571846) < 1.e-12); +//assert(fabs(een_rescaled_e[0][0][4][1]-0.01754273169464735) < 1.e-12); +//assert(fabs(een_rescaled_e[0][1][3][2]-0.02214680362033448) < 1.e-12); +//assert(fabs(een_rescaled_e[0][1][4][2]-0.0005700154999202759) < 1.e-12); +//assert(fabs(een_rescaled_e[0][1][5][2]-0.3424402276009091) < 1.e-12); + + #+end_src + ** Electron-nucleus rescaled distances for each order ~een_rescaled_n~ stores the table of the rescaled distances between @@ -3452,10 +3794,352 @@ assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); #+end_src +** Electron-nucleus rescaled distances for each order and derivatives + + ~een_rescaled_n_deriv_e~ stores the table of the rescaled distances between + electrons and nucleii raised to the power \(p\) defined by ~cord_num~: + + +*** Get + + #+begin_src c :comments org :tangle (eval h_func) :noweb yes +qmckl_exit_code qmckl_get_jastrow_een_rescaled_n_deriv_e(qmckl_context context, double* const distance_rescaled); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_get_jastrow_een_rescaled_n_deriv_e(qmckl_context context, double* const distance_rescaled) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_een_rescaled_n_deriv_e(context); + if (rc != QMCKL_SUCCESS) return rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + size_t sze = ctx->electron.num * 4 * ctx->nucleus.num * ctx->electron.walk_num * (ctx->jastrow.cord_num + 1); + memcpy(distance_rescaled, ctx->jastrow.een_rescaled_n_deriv_e, sze * sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide :noexport: + + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_een_rescaled_n_deriv_e(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_een_rescaled_n_deriv_e(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); + + /* Check if ee distance is provided */ + qmckl_exit_code rc = qmckl_provide_en_distance(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Check if ee distance is provided */ + rc = qmckl_provide_een_rescaled_n(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.een_rescaled_n_deriv_e_date) { + + /* Allocate array */ + if (ctx->jastrow.een_rescaled_n_deriv_e == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->electron.num * 4 * ctx->nucleus.num * + ctx->electron.walk_num * (ctx->jastrow.cord_num + 1) * sizeof(double); + double* een_rescaled_n_deriv_e = (double*) qmckl_malloc(context, mem_info); + + if (een_rescaled_n_deriv_e == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_een_rescaled_n_deriv_e", + NULL); + } + ctx->jastrow.een_rescaled_n_deriv_e = een_rescaled_n_deriv_e; + } + + qmckl_exit_code rc = + qmckl_compute_factor_een_rescaled_n_deriv_e(context, + ctx->electron.walk_num, + ctx->electron.num, + ctx->nucleus.num, + ctx->jastrow.cord_num, + ctx->electron.rescale_factor_kappa_en, + ctx->electron.coord_new, + ctx->nucleus.coord, + ctx->electron.en_distance, + ctx->jastrow.een_rescaled_n, + ctx->jastrow.een_rescaled_n_deriv_e); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.een_rescaled_n_deriv_e_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute + :PROPERTIES: + :Name: qmckl_compute_factor_een_rescaled_n_deriv_e + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_compute_factor_een_rescaled_n_deriv_e_args + | qmckl_context | context | in | Global state | + | int64_t | walk_num | in | Number of walkers | + | int64_t | elec_num | in | Number of electrons | + | int64_t | nucl_num | in | Number of atoms | + | int64_t | cord_num | in | Order of polynomials | + | double | rescale_factor_kappa_en | in | Factor to rescale ee distances | + | double | coord_new[walk_num][3][elec_num] | in | Electron coordinates | + | double | coord[3][nucl_num] | in | Nuclear coordinates | + | double | en_distance[walk_num][elec_num][nucl_num] | in | Electron-nucleus distances | + | double | een_rescaled_n[walk_num][elec_num][nucl_num][0:cord_num] | in | Electron-nucleus distances | + | double | een_rescaled_n_deriv_e[walk_num][elec_num][4][nucl_num][0:cord_num] | out | Electron-nucleus rescaled distances | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_factor_een_rescaled_n_deriv_e_f(context, walk_num, elec_num, nucl_num, & + cord_num, rescale_factor_kappa_en, & + coord_new, coord, en_distance, een_rescaled_n, een_rescaled_n_deriv_e) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: walk_num + integer*8 , intent(in) :: elec_num + integer*8 , intent(in) :: nucl_num + integer*8 , intent(in) :: cord_num + double precision , intent(in) :: rescale_factor_kappa_en + double precision , intent(in) :: coord_new(elec_num,3,walk_num) + double precision , intent(in) :: coord(nucl_num,3) + double precision , intent(in) :: en_distance(elec_num,nucl_num,walk_num) + double precision , intent(in) :: een_rescaled_n(0:cord_num,nucl_num,elec_num,walk_num) + double precision , intent(out) :: een_rescaled_n_deriv_e(0:cord_num,nucl_num,4,elec_num,walk_num) + double precision,dimension(:,:,:),allocatable :: elnuc_dist_deriv_e + double precision :: x, ria_inv, kappa_l + integer*8 :: i, a, k, l, nw, ii + + allocate(elnuc_dist_deriv_e(4, elec_num, nucl_num)) + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (walk_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (elec_num <= 0) then + info = QMCKL_INVALID_ARG_3 + return + endif + + if (nucl_num <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + if (cord_num <= 0) then + info = QMCKL_INVALID_ARG_5 + return + endif + + ! Prepare table of exponentiated distances raised to appropriate power + een_rescaled_n_deriv_e = 0.0d0 + do nw = 1, walk_num + + ! prepare the actual een table + do a = 1, nucl_num + do i = 1, elec_num + ria_inv = 1.0d0 / en_distance(i, a, nw) + do ii = 1, 3 + elnuc_dist_deriv_e(ii, i, a) = (coord_new(i, ii, nw) - coord(a, ii)) * ria_inv + end do + elnuc_dist_deriv_e(4, i, a) = 2.0d0 * ria_inv + end do + end do + + do l = 0, cord_num + kappa_l = - dble(l) * rescale_factor_kappa_en + do a = 1, nucl_num + do i = 1, elec_num + do ii = 1, 4 + een_rescaled_n_deriv_e(l, a, ii, i, nw) = kappa_l * elnuc_dist_deriv_e(ii, i, a) + end do + + een_rescaled_n_deriv_e(l, a, 4, i, nw) = een_rescaled_n_deriv_e(l, a, 4, i, nw) & + + een_rescaled_n_deriv_e(l, a, 1, i, nw) * een_rescaled_n_deriv_e(l, a, 1, i, nw) & + + een_rescaled_n_deriv_e(l, a, 2, i, nw) * een_rescaled_n_deriv_e(l, a, 2, i, nw) & + + een_rescaled_n_deriv_e(l, a, 3, i, nw) * een_rescaled_n_deriv_e(l, a, 3, i, nw) + + do ii = 1, 4 + een_rescaled_n_deriv_e(l, a, ii, i, nw) = een_rescaled_n_deriv_e(l, a, ii, i, nw) * & + een_rescaled_n(l, a, i, nw) + end do + end do + end do + end do + end do + +end function qmckl_compute_factor_een_rescaled_n_deriv_e_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_compute_factor_een_rescaled_n_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_factor_een_rescaled_n_deriv_e ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t cord_num, + const double rescale_factor_kappa_en, + const double* coord_new, + const double* coord, + const double* en_distance, + const double* een_rescaled_n, + double* const een_rescaled_n_deriv_e ); + #+end_src + + #+CALL: generate_c_interface(table=qmckl_factor_een_rescaled_n_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_factor_een_rescaled_n_deriv_e & + (context, & + walk_num, & + elec_num, & + nucl_num, & + cord_num, & + rescale_factor_kappa_en, & + coord_new, & + coord, & + en_distance, & + een_rescaled_n, & + een_rescaled_n_deriv_e) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: walk_num + integer (c_int64_t) , intent(in) , value :: elec_num + integer (c_int64_t) , intent(in) , value :: nucl_num + integer (c_int64_t) , intent(in) , value :: cord_num + real (c_double ) , intent(in) , value :: rescale_factor_kappa_en + real (c_double ) , intent(in) :: coord_new(elec_num,3,walk_num) + real (c_double ) , intent(in) :: coord(nucl_num,3) + real (c_double ) , intent(in) :: en_distance(nucl_num,elec_num,walk_num) + real (c_double ) , intent(in) :: een_rescaled_n(0:cord_num,nucl_num,elec_num,walk_num) + real (c_double ) , intent(out) :: een_rescaled_n_deriv_e(0:cord_num,nucl_num,4,elec_num,walk_num) + + integer(c_int32_t), external :: qmckl_compute_factor_een_rescaled_n_deriv_e_f + info = qmckl_compute_factor_een_rescaled_n_deriv_e_f & + (context, & + walk_num, & + elec_num, & + nucl_num, & + cord_num, & + rescale_factor_kappa_en, & + coord_new, & + coord, & + en_distance, & + een_rescaled_n, & + een_rescaled_n_deriv_e) + + end function qmckl_compute_factor_een_rescaled_n_deriv_e + #+end_src + +*** Test + + #+begin_src python :results output :exports none :noweb yes +import numpy as np + +<> + +elec_coord = np.array(elec_coord)[0] +nucl_coord = np.array(nucl_coord) +elnuc_dist = np.zeros(shape=(elec_num, nucl_num),dtype=float) +for i in range(elec_num): + for a in range(nucl_num): + elnuc_dist[i, a] = np.linalg.norm(elec_coord[i] - nucl_coord[:,a]) + +kappa = 1.0 + +een_rescaled_n = np.zeros(shape=(nucl_num, elec_num, cord_num + 1), dtype=float) +een_rescaled_n[:,:,0] = 1.0 + +for a in range(nucl_num): + for i in range(elec_num): + een_rescaled_n[a, i, 1] = np.exp(-kappa * elnuc_dist[i, a]) + +for l in range(2,cord_num+1): + for a in range(nucl_num): + for i in range(elec_num): + een_rescaled_n[a, i, l] = een_rescaled_n[a, i, l - 1] * een_rescaled_n[a, i, 1] + +print(" een_rescaled_n[0, 2, 1] = ",een_rescaled_n[0, 2, 1]) +print(" een_rescaled_n[0, 3, 1] = ",een_rescaled_n[0, 3, 1]) +print(" een_rescaled_n[0, 4, 1] = ",een_rescaled_n[0, 4, 1]) +print(" een_rescaled_n[1, 3, 2] = ",een_rescaled_n[1, 3, 2]) +print(" een_rescaled_n[1, 4, 2] = ",een_rescaled_n[1, 4, 2]) +print(" een_rescaled_n[1, 5, 2] = ",een_rescaled_n[1, 5, 2]) + #+end_src + + #+RESULTS: + : een_rescaled_n[0, 2, 1] = 0.10612983920006765 + : een_rescaled_n[0, 3, 1] = 0.135652809635553 + : een_rescaled_n[0, 4, 1] = 0.023391817607642338 + : een_rescaled_n[1, 3, 2] = 0.880957224822116 + : een_rescaled_n[1, 4, 2] = 0.027185942659395074 + : een_rescaled_n[1, 5, 2] = 0.01343938025140174 + + #+begin_src c :tangle (eval c_test) +//assert(qmckl_electron_provided(context)); +// +//double een_rescaled_n[walk_num][elec_num][nucl_num][(cord_num + 1)]; +//rc = qmckl_get_jastrow_een_rescaled_n(context, &(een_rescaled_n[0][0][0][0])); +// +//// value of (0,2,1) +//assert(fabs(een_rescaled_n[0][2][0][1]-0.10612983920006765) < 1.e-12); +//assert(fabs(een_rescaled_n[0][3][0][1]-0.135652809635553) < 1.e-12); +//assert(fabs(een_rescaled_n[0][4][0][1]-0.023391817607642338) < 1.e-12); +//assert(fabs(een_rescaled_n[0][3][1][2]-0.880957224822116) < 1.e-12); +//assert(fabs(een_rescaled_n[0][4][1][2]-0.027185942659395074) < 1.e-12); +//assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); + + #+end_src + ** Prepare for electron-electron-nucleus Jastrow \(f_{een}\) Prepare ~cord_vect_full~ and ~lkpm_combined_index~ tables required for the - calculation of the three-body jastrow ~factor_een~. + calculation of the three-body jastrow ~factor_een~ and its derivative + ~factor_een_deriv_e~. *** Get @@ -4044,7 +4728,6 @@ assert(qmckl_electron_provided(context)); #+end_src - ** Electron-electron-nucleus Jastrow \(f_{een}\) Calculate the electron-electron-nuclear three-body jastrow component ~factor_een~ From 1b74243155f07d9a0d922c7ebeb13f5fc4547ca5 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 18:08:56 +0530 Subject: [PATCH 52/92] Done with factor_een_deriv_e. Needs testing. #22 --- org/qmckl_jastrow.org | 429 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 428 insertions(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index cea8541..d73b18e 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -4831,7 +4831,7 @@ qmckl_exit_code qmckl_provide_factor_een(qmckl_context context) return rc; } - ctx->jastrow.factor_en_deriv_e_date = ctx->date; + ctx->jastrow.factor_een_date = ctx->date; } return QMCKL_SUCCESS; @@ -5103,6 +5103,433 @@ assert(qmckl_jastrow_provided(context)); double factor_een[walk_num]; rc = qmckl_get_jastrow_factor_een(context, &(factor_een[0])); +//// check factor_en_deriv_e +//assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); +//assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); +//assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); +//assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); + + #+end_src + +** Electron-electron-nucleus Jastrow \(f_{een}\) derivative + + Calculate the electron-electron-nuclear three-body jastrow component ~factor_een_deriv_e~ + using the above prepared tables. + + TODO: write equations. + +*** Get + #+begin_src c :comments org :tangle (eval h_func) :noweb yes +qmckl_exit_code qmckl_get_jastrow_factor_een_deriv_e(qmckl_context context, double* const factor_een_deriv_e); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_get_jastrow_factor_een_deriv_e(qmckl_context context, double* const factor_een_deriv_e) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_factor_een_deriv_e(context); + if (rc != QMCKL_SUCCESS) return rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int64_t sze = ctx->electron.walk_num * ctx->electron.num; + memcpy(factor_een_deriv_e, ctx->jastrow.factor_een_deriv_e, sze*sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + +*** Provide :noexport: + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_factor_een_deriv_e(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_factor_een_deriv_e(qmckl_context context) +{ + + qmckl_exit_code rc; + + 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); + + /* Check if en rescaled distance is provided */ + rc = qmckl_provide_een_rescaled_e(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Check if en rescaled distance derivatives is provided */ + rc = qmckl_provide_een_rescaled_n(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Check if en rescaled distance is provided */ + rc = qmckl_provide_een_rescaled_e_deriv_e(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Check if en rescaled distance derivatives is provided */ + rc = qmckl_provide_een_rescaled_n_deriv_e(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Check if en rescaled distance derivatives is provided */ + rc = qmckl_provide_cord_vect_full(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Check if en rescaled distance derivatives is provided */ + rc = qmckl_provide_lkpm_combined_index(context); + if(rc != QMCKL_SUCCESS) return rc; + + /* Compute if necessary */ + if (ctx->date > ctx->jastrow.factor_een_deriv_e_date) { + + /* Allocate array */ + if (ctx->jastrow.factor_een_deriv_e == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = 4 * ctx->electron.num * ctx->electron.walk_num * sizeof(double); + double* factor_een_deriv_e = (double*) qmckl_malloc(context, mem_info); + + if (factor_een_deriv_e == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_provide_factor_een_deriv_e", + NULL); + } + ctx->jastrow.factor_een_deriv_e = factor_een_deriv_e; + } + + qmckl_exit_code rc = + qmckl_compute_factor_een_deriv_e(context, + ctx->electron.walk_num, + ctx->electron.num, + ctx->nucleus.num, + ctx->jastrow.cord_num, + ctx->jastrow.dim_cord_vect, + ctx->jastrow.cord_vect_full, + ctx->jastrow.lkpm_combined_index, + ctx->jastrow.een_rescaled_e, + ctx->jastrow.een_rescaled_n, + ctx->jastrow.een_rescaled_e_deriv_e, + ctx->jastrow.een_rescaled_n_deriv_e, + ctx->jastrow.factor_een_deriv_e); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->jastrow.factor_een_deriv_e_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** Compute + :PROPERTIES: + :Name: qmckl_compute_factor_een_deriv_e + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_factor_een_deriv_e_args + | qmckl_context | context | in | Global state | + | int64_t | walk_num | in | Number of walkers | + | int64_t | elec_num | in | Number of electrons | + | int64_t | nucl_num | in | Number of nucleii | + | int64_t | cord_num | in | order of polynomials | + | int64_t | dim_cord_vect | in | dimension of full coefficient vector | + | double | cord_vect_full[dim_cord_vect][nucl_num] | in | full coefficient vector | + | int64_t | lkpm_combined_index[4][dim_cord_vect] | in | combined indices | + | double | een_rescaled_e[walk_num][elec_num][elec_num][0:cord_num] | in | Electron-nucleus rescaled | + | double | een_rescaled_n[walk_num][elec_num][nucl_num][0:cord_num] | in | Electron-nucleus rescaled factor | + | double | een_rescaled_e_deriv_e[walk_num][elec_num][4][elec_num][0:cord_num] | in | Electron-nucleus rescaled | + | double | een_rescaled_n_deriv_e[walk_num][elec_num][4][nucl_num][0:cord_num] | in | Electron-nucleus rescaled factor | + | double | factor_een_deriv_e[walk_num][4][elec_num] | out | Electron-nucleus jastrow | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_factor_een_deriv_e_f(context, walk_num, elec_num, nucl_num, cord_num, dim_cord_vect, & + cord_vect_full, lkpm_combined_index, & + een_rescaled_e, een_rescaled_n, & + een_rescaled_e_deriv_e, een_rescaled_n_deriv_e, factor_een_deriv_e) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: walk_num, elec_num, cord_num, nucl_num, dim_cord_vect + integer*8 , intent(in) :: lkpm_combined_index(4,dim_cord_vect) + double precision , intent(in) :: cord_vect_full(dim_cord_vect, nucl_num) + double precision , intent(in) :: een_rescaled_e(walk_num, elec_num, elec_num, 0:cord_num) + double precision , intent(in) :: een_rescaled_n(walk_num, elec_num, nucl_num, 0:cord_num) + double precision , intent(in) :: een_rescaled_e_deriv_e(walk_num, elec_num, 4, elec_num, 0:cord_num) + double precision , intent(in) :: een_rescaled_n_deriv_e(walk_num, elec_num, 4, nucl_num, 0:cord_num) + double precision , intent(out) :: factor_een_deriv_e(elec_num, 4, walk_num) + + integer*8 :: i, a, j, l, k, p, m, n, nw + double precision :: accu, accu2, cn + double precision :: daccu(1:4), daccu2(1:4) + + info = QMCKL_SUCCESS + + if (context == QMCKL_NULL_CONTEXT) then + info = QMCKL_INVALID_CONTEXT + return + endif + + if (walk_num <= 0) then + info = QMCKL_INVALID_ARG_2 + return + endif + + if (elec_num <= 0) then + info = QMCKL_INVALID_ARG_3 + return + endif + + if (nucl_num <= 0) then + info = QMCKL_INVALID_ARG_4 + return + endif + + if (cord_num <= 0) then + info = QMCKL_INVALID_ARG_5 + return + endif + + factor_een_deriv_e = 0.0d0 + + do nw =1, walk_num + do n = 1, dim_cord_vect + l = lkpm_combined_index(1, n) + k = lkpm_combined_index(2, n) + p = lkpm_combined_index(3, n) + m = lkpm_combined_index(4, n) + + do a = 1, nucl_num + cn = cord_vect_full(n, a) + do j = 1, elec_num + accu = 0.0d0 + accu2 = 0.0d0 + daccu = 0.0d0 + daccu2 = 0.0d0 + do i = 1, elec_num + accu = accu + een_rescaled_e(nw, i, j, k) * & + een_rescaled_n(nw, i, a, m) + accu2 = accu2 + een_rescaled_e(nw, i, j, k) * & + een_rescaled_n(nw, i, a, m + l) + daccu(1:4) = daccu(1:4) + een_rescaled_e_deriv_e(nw, j, 1:4, i, k) * & + een_rescaled_n(nw, i, a, m) + daccu2(1:4) = daccu2(1:4) + een_rescaled_e_deriv_e(nw, j, 1:4, i, k) * & + een_rescaled_n(nw, i, a, m + l) + end do + factor_een_deriv_e(j, 1:4, nw) = factor_een_deriv_e(j, 1:4, nw) + & + (accu * een_rescaled_n_deriv_e(nw, j, 1:4, a, m + l) & + + daccu(1:4) * een_rescaled_n(nw, j, a, m + l) & + + daccu2(1:4) * een_rescaled_n(nw, j, a, m) & + + accu2 * een_rescaled_n_deriv_e(nw, j, 1:4, a, m)) * cn + + factor_een_deriv_e(j, 4, nw) = factor_een_deriv_e(j, 4, nw) + 2.0d0 * ( & + daccu (1) * een_rescaled_n_deriv_e(nw, j, 1, a, m + l) + & + daccu (2) * een_rescaled_n_deriv_e(nw, j, 2, a, m + l) + & + daccu (3) * een_rescaled_n_deriv_e(nw, j, 3, a, m + l) + & + daccu2(1) * een_rescaled_n_deriv_e(nw, j, 1, a, m ) + & + daccu2(2) * een_rescaled_n_deriv_e(nw, j, 2, a, m ) + & + daccu2(3) * een_rescaled_n_deriv_e(nw, j, 3, a, m ) ) * cn + + end do + end do + end do + end do + +end function qmckl_compute_factor_een_deriv_e_f + #+end_src + + #+CALL: generate_c_header(table=qmckl_factor_een_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_factor_een_deriv_e ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t cord_num, + const int64_t dim_cord_vect, + const double* cord_vect_full, + const int64_t* lkpm_combined_index, + const double* een_rescaled_e, + const double* een_rescaled_n, + const double* een_rescaled_e_deriv_e, + const double* een_rescaled_n_deriv_e, + double* const factor_een_deriv_e ); + #+end_src + + + #+CALL: generate_c_interface(table=qmckl_factor_een_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_factor_een_deriv_e & + (context, & + walk_num, & + elec_num, & + nucl_num, & + cord_num, & + dim_cord_vect, & + cord_vect_full, & + lkpm_combined_index, & + een_rescaled_e, & + een_rescaled_n, & + een_rescaled_e_deriv_e, & + een_rescaled_n_deriv_e, & + factor_een_deriv_e) & + bind(C) result(info) + + use, intrinsic :: iso_c_binding + implicit none + + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: walk_num + integer (c_int64_t) , intent(in) , value :: elec_num + integer (c_int64_t) , intent(in) , value :: nucl_num + integer (c_int64_t) , intent(in) , value :: cord_num + integer (c_int64_t) , intent(in) , value :: dim_cord_vect + real (c_double ) , intent(in) :: cord_vect_full(nucl_num,dim_cord_vect) + integer (c_int64_t) , intent(in) :: lkpm_combined_index(dim_cord_vect,4) + real (c_double ) , intent(in) :: een_rescaled_e(0:cord_num,elec_num,elec_num,walk_num) + real (c_double ) , intent(in) :: een_rescaled_n(0:cord_num,nucl_num,elec_num,walk_num) + real (c_double ) , intent(in) :: een_rescaled_e_deriv_e(0:cord_num,elec_num,4,elec_num,walk_num) + real (c_double ) , intent(in) :: een_rescaled_n_deriv_e(0:cord_num,nucl_num,4,elec_num,walk_num) + real (c_double ) , intent(out) :: factor_een_deriv_e(elec_num,4,walk_num) + + integer(c_int32_t), external :: qmckl_compute_factor_een_deriv_e_f + info = qmckl_compute_factor_een_deriv_e_f & + (context, & + walk_num, & + elec_num, & + nucl_num, & + cord_num, & + dim_cord_vect, & + cord_vect_full, & + lkpm_combined_index, & + een_rescaled_e, & + een_rescaled_n, & + een_rescaled_e_deriv_e, & + een_rescaled_n_deriv_e, & + factor_een_deriv_e) + + end function qmckl_compute_factor_een_deriv_e + #+end_src + +*** Test + #+begin_src python :results output :exports none :noweb yes +import numpy as np + +<> + +kappa = 1.0 + +elec_coord = np.array(elec_coord)[0] +nucl_coord = np.array(nucl_coord) +elnuc_dist = np.zeros(shape=(elec_num, nucl_num),dtype=float) +for i in range(elec_num): + for j in range(nucl_num): + elnuc_dist[i, j] = np.linalg.norm(elec_coord[i] - nucl_coord[:,j]) + +elnuc_dist_deriv_e = np.zeros(shape=(4, elec_num, nucl_num),dtype=float) +for a in range(nucl_num): + for i in range(elec_num): + rij_inv = 1.0 / elnuc_dist[i, a] + for ii in range(3): + elnuc_dist_deriv_e[ii, i, a] = (elec_coord[i][ii] - nucl_coord[ii][a]) * rij_inv + elnuc_dist_deriv_e[3, i, a] = 2.0 * rij_inv + +en_distance_rescaled_deriv_e = np.zeros(shape=(4,elec_num,nucl_num),dtype=float) +for a in range(nucl_num): + for i in range(elec_num): + f = 1.0 - kappa * en_distance_rescaled[i][a] + for ii in range(4): + en_distance_rescaled_deriv_e[ii][i][a] = elnuc_dist_deriv_e[ii][i][a] + en_distance_rescaled_deriv_e[3][i][a] = en_distance_rescaled_deriv_e[3][i][a] + \ + (-kappa * en_distance_rescaled_deriv_e[0][i][a] * en_distance_rescaled_deriv_e[0][i][a]) + \ + (-kappa * en_distance_rescaled_deriv_e[1][i][a] * en_distance_rescaled_deriv_e[1][i][a]) + \ + (-kappa * en_distance_rescaled_deriv_e[2][i][a] * en_distance_rescaled_deriv_e[2][i][a]) + for ii in range(4): + en_distance_rescaled_deriv_e[ii][i][a] = en_distance_rescaled_deriv_e[ii][i][a] * f + +third = 1.0 / 3.0 +factor_en_deriv_e = np.zeros(shape=(4,elec_num),dtype=float) +dx = np.zeros(shape=(4),dtype=float) +pow_ser_g = np.zeros(shape=(3),dtype=float) +for a in range(nucl_num): + for i in range(elec_num): + x = en_distance_rescaled[i][a] + if abs(x) < 1e-18: + continue + pow_ser_g = np.zeros(shape=(3),dtype=float) + den = 1.0 + aord_vector[1][type_nucl_vector[a]-1] * x + invden = 1.0 / den + invden2 = invden * invden + invden3 = invden2 * invden + xinv = 1.0 / (x + 1.0E-18) + + for ii in range(4): + dx[ii] = en_distance_rescaled_deriv_e[ii][i][a] + + lap1 = 0.0 + lap2 = 0.0 + lap3 = 0.0 + for ii in range(3): + x = en_distance_rescaled[i][a] + if x < 1e-18: + continue + for p in range(2,aord_num+1): + y = p * aord_vector[(p-1) + 1][type_nucl_vector[a]-1] * x + pow_ser_g[ii] = pow_ser_g[ii] + y * dx[ii] + lap1 = lap1 + (p - 1) * y * xinv * dx[ii] * dx[ii] + lap2 = lap2 + y + x = x * en_distance_rescaled[i][a] + + lap3 = lap3 - 2.0 * aord_vector[1][type_nucl_vector[a]-1] * dx[ii] * dx[ii] + + factor_en_deriv_e[ii][i] = factor_en_deriv_e[ii][i] + aord_vector[0][type_nucl_vector[a]-1] * \ + dx[ii] * invden2 + pow_ser_g[ii] + + ii = 3 + lap2 = lap2 * dx[ii] * third + lap3 = lap3 + den * dx[ii] + lap3 = lap3 * (aord_vector[0][type_nucl_vector[a]-1] * invden3) + factor_en_deriv_e[ii][i] = factor_en_deriv_e[ii][i] + lap1 + lap2 + lap3 + +print("factor_en_deriv_e[0][0]:",factor_en_deriv_e[0][0]) +print("factor_en_deriv_e[1][0]:",factor_en_deriv_e[1][0]) +print("factor_en_deriv_e[2][0]:",factor_en_deriv_e[2][0]) +print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) + + + #+end_src + + #+RESULTS: + : factor_en_deriv_e[0][0]: 0.11609919541763383 + : factor_en_deriv_e[1][0]: -0.23301394780804574 + : factor_en_deriv_e[2][0]: 0.17548337641865783 + : factor_en_deriv_e[3][0]: -0.9667363412285741 + + + #+begin_src c :tangle (eval c_test) +/* Check if Jastrow is properly initialized */ +//assert(qmckl_jastrow_provided(context)); +// +//// calculate factor_en_deriv_e +//double factor_een[walk_num]; +//rc = qmckl_get_jastrow_factor_een(context, &(factor_een[0])); + //// check factor_en_deriv_e //assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); //assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); From b4c7a8b0ac67f5d0f7f004c48990e8a4e3f0099a Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 19:18:11 +0530 Subject: [PATCH 53/92] Removed jastrow tests for debugging github ci. #22 --- org/qmckl_jastrow.org | 544 +++++++++++++++++++++--------------------- 1 file changed, 272 insertions(+), 272 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index d73b18e..9dfe3c8 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -28,7 +28,7 @@ these factors along with their derivatives. #endif #include -#include "n2.h" +//#include "n2.h" int main() { qmckl_context context; @@ -993,171 +993,171 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { ** Test #+begin_src c :tangle (eval c_test) /* Reference input data */ -int64_t walk_num = n2_walk_num; -int64_t elec_num = n2_elec_num; -int64_t elec_up_num = n2_elec_up_num; -int64_t elec_dn_num = n2_elec_dn_num; -double rescale_factor_kappa_ee = 1.0; -double rescale_factor_kappa_en = 1.0; -double nucl_rescale_factor_kappa = 1.0; -double* elec_coord = &(n2_elec_coord[0][0][0]); - -const double* nucl_charge = n2_charge; -int64_t nucl_num = n2_nucl_num; -double* charge = n2_charge; -double* nucl_coord = &(n2_nucl_coord[0][0]); +//int64_t walk_num = n2_walk_num; +//int64_t elec_num = n2_elec_num; +//int64_t elec_up_num = n2_elec_up_num; +//int64_t elec_dn_num = n2_elec_dn_num; +//double rescale_factor_kappa_ee = 1.0; +//double rescale_factor_kappa_en = 1.0; +//double nucl_rescale_factor_kappa = 1.0; +//double* elec_coord = &(n2_elec_coord[0][0][0]); +// +//const double* nucl_charge = n2_charge; +//int64_t nucl_num = n2_nucl_num; +//double* charge = n2_charge; +//double* nucl_coord = &(n2_nucl_coord[0][0]); /* Provide Electron data */ qmckl_exit_code rc; -assert(!qmckl_electron_provided(context)); - -int64_t n; -rc = qmckl_get_electron_num (context, &n); -assert(rc == QMCKL_NOT_PROVIDED); - -rc = qmckl_get_electron_up_num (context, &n); -assert(rc == QMCKL_NOT_PROVIDED); - -rc = qmckl_get_electron_down_num (context, &n); -assert(rc == QMCKL_NOT_PROVIDED); - - -rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num); -assert(rc == QMCKL_SUCCESS); -assert(!qmckl_electron_provided(context)); - -rc = qmckl_get_electron_up_num (context, &n); -assert(rc == QMCKL_SUCCESS); -assert(n == elec_up_num); - -rc = qmckl_get_electron_down_num (context, &n); -assert(rc == QMCKL_SUCCESS); -assert(n == elec_dn_num); - -rc = qmckl_get_electron_num (context, &n); -assert(rc == QMCKL_SUCCESS); -assert(n == elec_num); - -double k_ee = 0.; -double k_en = 0.; -rc = qmckl_get_electron_rescale_factor_ee (context, &k_ee); -assert(rc == QMCKL_SUCCESS); -assert(k_ee == 1.0); - -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_electron_rescale_factor_en (context, &k_en); -assert(rc == QMCKL_SUCCESS); -assert(k_en == rescale_factor_kappa_en); - - -int64_t w; -rc = qmckl_get_electron_walk_num (context, &w); -assert(rc == QMCKL_NOT_PROVIDED); - - -rc = qmckl_set_electron_walk_num (context, walk_num); -assert(rc == QMCKL_SUCCESS); - -rc = qmckl_get_electron_walk_num (context, &w); -assert(rc == QMCKL_SUCCESS); -assert(w == walk_num); - -assert(qmckl_electron_provided(context)); - -rc = qmckl_set_electron_coord (context, 'N', elec_coord); -assert(rc == QMCKL_SUCCESS); - -double elec_coord2[walk_num*3*elec_num]; - -rc = qmckl_get_electron_coord (context, 'N', elec_coord2); -assert(rc == QMCKL_SUCCESS); -for (int64_t i=0 ; i<3*elec_num ; ++i) { - assert( elec_coord[i] == elec_coord2[i] ); - } - - -/* Provide Nucleus data */ - -assert(!qmckl_nucleus_provided(context)); - -rc = qmckl_get_nucleus_num (context, &n); -assert(rc == QMCKL_NOT_PROVIDED); - - -rc = qmckl_set_nucleus_num (context, nucl_num); -assert(rc == QMCKL_SUCCESS); -assert(!qmckl_nucleus_provided(context)); - -rc = qmckl_get_nucleus_num (context, &n); -assert(rc == QMCKL_SUCCESS); -assert(n == nucl_num); - -double k; -rc = qmckl_get_nucleus_rescale_factor (context, &k); -assert(rc == QMCKL_SUCCESS); -assert(k == 1.0); - - -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); - -double nucl_coord2[3*nucl_num]; - -rc = qmckl_get_nucleus_coord (context, 'T', nucl_coord2); -assert(rc == QMCKL_NOT_PROVIDED); - -rc = qmckl_set_nucleus_coord (context, 'T', &(nucl_coord[0])); -assert(rc == QMCKL_SUCCESS); - -assert(!qmckl_nucleus_provided(context)); - -rc = qmckl_get_nucleus_coord (context, 'N', nucl_coord2); -assert(rc == QMCKL_SUCCESS); -for (size_t k=0 ; k<3 ; ++k) { - for (size_t i=0 ; i Date: Wed, 7 Jul 2021 19:22:15 +0530 Subject: [PATCH 54/92] Fix for kind in call to iand. #22 --- org/qmckl_jastrow.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 9dfe3c8..88b467c 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -4398,7 +4398,7 @@ integer function qmckl_compute_dim_cord_vect_f(context, cord_num, dim_cord_vect) lmax = p - k - 2 endif do l = lmax, 0, -1 - if (iand(p - k - l, 1) == 1) cycle + if (iand(p - k - l, 1_8) == 1) cycle dim_cord_vect = dim_cord_vect + 1 end do end do @@ -4618,7 +4618,7 @@ integer function qmckl_compute_lkpm_combined_index_f(context, cord_num, dim_cord lmax = p - k - 2 end if do l = lmax, 0, -1 - if (iand(p - k - l, 1) .eq. 1) cycle + if (iand(p - k - l, 1_8) .eq. 1) cycle m = (p - k - l)/2 kk = kk + 1 lkpm_combined_index(kk, 1) = l From 852e12ce91e320099b281e4c8d7d03a65dfc0e63 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 19:37:58 +0530 Subject: [PATCH 55/92] Fixed names of argument lists. #22 --- org/qmckl_jastrow.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 88b467c..fb85bfc 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -4025,7 +4025,7 @@ end function qmckl_compute_factor_een_rescaled_n_deriv_e_f double* const een_rescaled_n_deriv_e ); #+end_src - #+CALL: generate_c_interface(table=qmckl_factor_een_rescaled_n_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + #+CALL: generate_c_interface(table=qmckl_compute_factor_een_rescaled_n_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+RESULTS: #+begin_src f90 :tangle (eval f) :comments org :exports none From 48436607d65d7e16be7a240d35bee4c4a986b235 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 19:42:07 +0530 Subject: [PATCH 56/92] Activated header. #22 --- org/qmckl_jastrow.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index fb85bfc..c72b452 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -28,7 +28,7 @@ these factors along with their derivatives. #endif #include -//#include "n2.h" +#include "n2.h" int main() { qmckl_context context; From 9d46ed28c522e2636c160476fb51f28f8489af53 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 19:46:18 +0530 Subject: [PATCH 57/92] Activated tests 1. #22 --- org/qmckl_jastrow.org | 320 +++++++++++++++++++++--------------------- 1 file changed, 160 insertions(+), 160 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index c72b452..a0054a7 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -993,171 +993,171 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { ** Test #+begin_src c :tangle (eval c_test) /* Reference input data */ -//int64_t walk_num = n2_walk_num; -//int64_t elec_num = n2_elec_num; -//int64_t elec_up_num = n2_elec_up_num; -//int64_t elec_dn_num = n2_elec_dn_num; -//double rescale_factor_kappa_ee = 1.0; -//double rescale_factor_kappa_en = 1.0; -//double nucl_rescale_factor_kappa = 1.0; -//double* elec_coord = &(n2_elec_coord[0][0][0]); -// -//const double* nucl_charge = n2_charge; -//int64_t nucl_num = n2_nucl_num; -//double* charge = n2_charge; -//double* nucl_coord = &(n2_nucl_coord[0][0]); +int64_t walk_num = n2_walk_num; +int64_t elec_num = n2_elec_num; +int64_t elec_up_num = n2_elec_up_num; +int64_t elec_dn_num = n2_elec_dn_num; +double rescale_factor_kappa_ee = 1.0; +double rescale_factor_kappa_en = 1.0; +double nucl_rescale_factor_kappa = 1.0; +double* elec_coord = &(n2_elec_coord[0][0][0]); + +const double* nucl_charge = n2_charge; +int64_t nucl_num = n2_nucl_num; +double* charge = n2_charge; +double* nucl_coord = &(n2_nucl_coord[0][0]); /* Provide Electron data */ qmckl_exit_code rc; -//assert(!qmckl_electron_provided(context)); -// -//int64_t n; -//rc = qmckl_get_electron_num (context, &n); -//assert(rc == QMCKL_NOT_PROVIDED); -// -//rc = qmckl_get_electron_up_num (context, &n); -//assert(rc == QMCKL_NOT_PROVIDED); -// -//rc = qmckl_get_electron_down_num (context, &n); -//assert(rc == QMCKL_NOT_PROVIDED); -// -// -//rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num); -//assert(rc == QMCKL_SUCCESS); -//assert(!qmckl_electron_provided(context)); -// -//rc = qmckl_get_electron_up_num (context, &n); -//assert(rc == QMCKL_SUCCESS); -//assert(n == elec_up_num); -// -//rc = qmckl_get_electron_down_num (context, &n); -//assert(rc == QMCKL_SUCCESS); -//assert(n == elec_dn_num); -// -//rc = qmckl_get_electron_num (context, &n); -//assert(rc == QMCKL_SUCCESS); -//assert(n == elec_num); -// -//double k_ee = 0.; -//double k_en = 0.; -//rc = qmckl_get_electron_rescale_factor_ee (context, &k_ee); -//assert(rc == QMCKL_SUCCESS); -//assert(k_ee == 1.0); -// -//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_electron_rescale_factor_en (context, &k_en); -//assert(rc == QMCKL_SUCCESS); -//assert(k_en == rescale_factor_kappa_en); -// -// -//int64_t w; -//rc = qmckl_get_electron_walk_num (context, &w); -//assert(rc == QMCKL_NOT_PROVIDED); -// -// -//rc = qmckl_set_electron_walk_num (context, walk_num); -//assert(rc == QMCKL_SUCCESS); -// -//rc = qmckl_get_electron_walk_num (context, &w); -//assert(rc == QMCKL_SUCCESS); -//assert(w == walk_num); -// -//assert(qmckl_electron_provided(context)); -// -//rc = qmckl_set_electron_coord (context, 'N', elec_coord); -//assert(rc == QMCKL_SUCCESS); -// -//double elec_coord2[walk_num*3*elec_num]; -// -//rc = qmckl_get_electron_coord (context, 'N', elec_coord2); -//assert(rc == QMCKL_SUCCESS); -//for (int64_t i=0 ; i<3*elec_num ; ++i) { -// assert( elec_coord[i] == elec_coord2[i] ); -// } -// -// -///* Provide Nucleus data */ -// -//assert(!qmckl_nucleus_provided(context)); -// -//rc = qmckl_get_nucleus_num (context, &n); -//assert(rc == QMCKL_NOT_PROVIDED); -// -// -//rc = qmckl_set_nucleus_num (context, nucl_num); -//assert(rc == QMCKL_SUCCESS); -//assert(!qmckl_nucleus_provided(context)); -// -//rc = qmckl_get_nucleus_num (context, &n); -//assert(rc == QMCKL_SUCCESS); -//assert(n == nucl_num); -// -//double k; -//rc = qmckl_get_nucleus_rescale_factor (context, &k); -//assert(rc == QMCKL_SUCCESS); -//assert(k == 1.0); -// -// -//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); -// -//double nucl_coord2[3*nucl_num]; -// -//rc = qmckl_get_nucleus_coord (context, 'T', nucl_coord2); -//assert(rc == QMCKL_NOT_PROVIDED); -// -//rc = qmckl_set_nucleus_coord (context, 'T', &(nucl_coord[0])); -//assert(rc == QMCKL_SUCCESS); -// -//assert(!qmckl_nucleus_provided(context)); -// -//rc = qmckl_get_nucleus_coord (context, 'N', nucl_coord2); -//assert(rc == QMCKL_SUCCESS); -//for (size_t k=0 ; k<3 ; ++k) { -// for (size_t i=0 ; i Date: Wed, 7 Jul 2021 19:56:58 +0530 Subject: [PATCH 58/92] Activated all tests. #22 --- org/qmckl_jastrow.org | 257 ++++++++++++++++++------------------------ 1 file changed, 112 insertions(+), 145 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index a0054a7..00b4769 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1391,46 +1391,46 @@ print("asymp_jasb[1] : ", asymp_jasb[1]) : asymp_jasb[1] : 0.31567342786262853 #+begin_src c :tangle (eval c_test) -//assert(qmckl_electron_provided(context)); -// -//int64_t type_nucl_num = n2_type_nucl_num; -//int64_t* type_nucl_vector = &(n2_type_nucl_vector[0]); -//int64_t aord_num = n2_aord_num; -//int64_t bord_num = n2_bord_num; -//int64_t cord_num = n2_cord_num; -//double* aord_vector = &(n2_aord_vector[0][0]); -//double* bord_vector = &(n2_bord_vector[0]); -//double* cord_vector = &(n2_cord_vector[0][0]); -// -///* Initialize the Jastrow data */ -//rc = qmckl_init_jastrow(context); -//assert(!qmckl_jastrow_provided(context)); -// -///* Set the data */ -//rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_aord_vector(context, aord_vector); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_bord_vector(context, bord_vector); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_cord_vector(context, cord_vector); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_dependencies(context); -//assert(rc == QMCKL_SUCCESS); -// -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//double asymp_jasb[2]; -//rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); -// -//// calculate asymp_jasb -//assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); -//assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); +assert(qmckl_electron_provided(context)); + +int64_t type_nucl_num = n2_type_nucl_num; +int64_t* type_nucl_vector = &(n2_type_nucl_vector[0]); +int64_t aord_num = n2_aord_num; +int64_t bord_num = n2_bord_num; +int64_t cord_num = n2_cord_num; +double* aord_vector = &(n2_aord_vector[0][0]); +double* bord_vector = &(n2_bord_vector[0]); +double* cord_vector = &(n2_cord_vector[0][0]); + +/* Initialize the Jastrow data */ +rc = qmckl_init_jastrow(context); +assert(!qmckl_jastrow_provided(context)); + +/* Set the data */ +rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_aord_vector(context, aord_vector); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_bord_vector(context, bord_vector); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_cord_vector(context, cord_vector); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_dependencies(context); +assert(rc == QMCKL_SUCCESS); + +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +double asymp_jasb[2]; +rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); + +// calculate asymp_jasb +assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); +assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); #+end_src @@ -1721,14 +1721,14 @@ print("factor_ee :",factor_ee) #+begin_src c :tangle (eval c_test) -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//double factor_ee[walk_num]; -//rc = qmckl_get_jastrow_factor_ee(context, factor_ee); -// -//// calculate factor_ee -//assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +double factor_ee[walk_num]; +rc = qmckl_get_jastrow_factor_ee(context, factor_ee); + +// calculate factor_ee +assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); #+end_src @@ -2140,18 +2140,18 @@ print(factor_ee_deriv_e) #+begin_src c :tangle (eval c_test) -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//// calculate factor_ee_deriv_e -//double factor_ee_deriv_e[walk_num][4][elec_num]; -//rc = qmckl_get_jastrow_factor_ee_deriv_e(context, &(factor_ee_deriv_e[0][0][0])); -// -//// check factor_ee_deriv_e -//assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); -//assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); -//assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); -//assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +// calculate factor_ee_deriv_e +double factor_ee_deriv_e[walk_num][4][elec_num]; +rc = qmckl_get_jastrow_factor_ee_deriv_e(context, &(factor_ee_deriv_e[0][0][0])); + +// check factor_ee_deriv_e +assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); #+end_src @@ -2436,14 +2436,14 @@ print("factor_en :",factor_en) #+begin_src c :tangle (eval c_test) -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//double factor_en[walk_num]; -//rc = qmckl_get_jastrow_factor_en(context, factor_en); -// -//// calculate factor_en -//assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +double factor_en[walk_num]; +rc = qmckl_get_jastrow_factor_en(context, factor_en); + +// calculate factor_en +assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); #+end_src @@ -2835,18 +2835,18 @@ print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) #+begin_src c :tangle (eval c_test) -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//// calculate factor_en_deriv_e -//double factor_en_deriv_e[walk_num][4][elec_num]; -//rc = qmckl_get_jastrow_factor_en_deriv_e(context, &(factor_en_deriv_e[0][0][0])); -// -//// check factor_en_deriv_e -//assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +// calculate factor_en_deriv_e +double factor_en_deriv_e[walk_num][4][elec_num]; +rc = qmckl_get_jastrow_factor_en_deriv_e(context, &(factor_en_deriv_e[0][0][0])); + +// check factor_en_deriv_e +assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); +assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); +assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); +assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); #+end_src @@ -3142,19 +3142,19 @@ print(" een_rescaled_e[1, 5, 2] = ",een_rescaled_e[1, 5, 2]) : een_rescaled_e[1, 5, 2] = 0.3424402276009091 #+begin_src c :tangle (eval c_test) -//assert(qmckl_electron_provided(context)); -// -// -//double een_rescaled_e[walk_num][elec_num][elec_num][(cord_num + 1)]; -//rc = qmckl_get_jastrow_een_rescaled_e(context, &(een_rescaled_e[0][0][0][0])); -// -//// value of (0,2,1) -//assert(fabs(een_rescaled_e[0][0][2][1]-0.08084493981483197) < 1.e-12); -//assert(fabs(een_rescaled_e[0][0][3][1]-0.1066745707571846) < 1.e-12); -//assert(fabs(een_rescaled_e[0][0][4][1]-0.01754273169464735) < 1.e-12); -//assert(fabs(een_rescaled_e[0][1][3][2]-0.02214680362033448) < 1.e-12); -//assert(fabs(een_rescaled_e[0][1][4][2]-0.0005700154999202759) < 1.e-12); -//assert(fabs(een_rescaled_e[0][1][5][2]-0.3424402276009091) < 1.e-12); +assert(qmckl_electron_provided(context)); + + +double een_rescaled_e[walk_num][elec_num][elec_num][(cord_num + 1)]; +rc = qmckl_get_jastrow_een_rescaled_e(context, &(een_rescaled_e[0][0][0][0])); + +// value of (0,2,1) +assert(fabs(een_rescaled_e[0][0][2][1]-0.08084493981483197) < 1.e-12); +assert(fabs(een_rescaled_e[0][0][3][1]-0.1066745707571846) < 1.e-12); +assert(fabs(een_rescaled_e[0][0][4][1]-0.01754273169464735) < 1.e-12); +assert(fabs(een_rescaled_e[0][1][3][2]-0.02214680362033448) < 1.e-12); +assert(fabs(een_rescaled_e[0][1][4][2]-0.0005700154999202759) < 1.e-12); +assert(fabs(een_rescaled_e[0][1][5][2]-0.3424402276009091) < 1.e-12); #+end_src @@ -3477,18 +3477,6 @@ print(" een_rescaled_e[1, 5, 2] = ",een_rescaled_e[1, 5, 2]) #+begin_src c :tangle (eval c_test) //assert(qmckl_electron_provided(context)); -// -// -//double een_rescaled_e[walk_num][elec_num][elec_num][(cord_num + 1)]; -//rc = qmckl_get_jastrow_een_rescaled_e(context, &(een_rescaled_e[0][0][0][0])); -// -//// value of (0,2,1) -//assert(fabs(een_rescaled_e[0][0][2][1]-0.08084493981483197) < 1.e-12); -//assert(fabs(een_rescaled_e[0][0][3][1]-0.1066745707571846) < 1.e-12); -//assert(fabs(een_rescaled_e[0][0][4][1]-0.01754273169464735) < 1.e-12); -//assert(fabs(een_rescaled_e[0][1][3][2]-0.02214680362033448) < 1.e-12); -//assert(fabs(een_rescaled_e[0][1][4][2]-0.0005700154999202759) < 1.e-12); -//assert(fabs(een_rescaled_e[0][1][5][2]-0.3424402276009091) < 1.e-12); #+end_src @@ -3779,18 +3767,18 @@ print(" een_rescaled_n[1, 5, 2] = ",een_rescaled_n[1, 5, 2]) : een_rescaled_n[1, 5, 2] = 0.01343938025140174 #+begin_src c :tangle (eval c_test) -//assert(qmckl_electron_provided(context)); -// -//double een_rescaled_n[walk_num][elec_num][nucl_num][(cord_num + 1)]; -//rc = qmckl_get_jastrow_een_rescaled_n(context, &(een_rescaled_n[0][0][0][0])); -// -//// value of (0,2,1) -//assert(fabs(een_rescaled_n[0][2][0][1]-0.10612983920006765) < 1.e-12); -//assert(fabs(een_rescaled_n[0][3][0][1]-0.135652809635553) < 1.e-12); -//assert(fabs(een_rescaled_n[0][4][0][1]-0.023391817607642338) < 1.e-12); -//assert(fabs(een_rescaled_n[0][3][1][2]-0.880957224822116) < 1.e-12); -//assert(fabs(een_rescaled_n[0][4][1][2]-0.027185942659395074) < 1.e-12); -//assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); +assert(qmckl_electron_provided(context)); + +double een_rescaled_n[walk_num][elec_num][nucl_num][(cord_num + 1)]; +rc = qmckl_get_jastrow_een_rescaled_n(context, &(een_rescaled_n[0][0][0][0])); + +// value of (0,2,1) +assert(fabs(een_rescaled_n[0][2][0][1]-0.10612983920006765) < 1.e-12); +assert(fabs(een_rescaled_n[0][3][0][1]-0.135652809635553) < 1.e-12); +assert(fabs(een_rescaled_n[0][4][0][1]-0.023391817607642338) < 1.e-12); +assert(fabs(een_rescaled_n[0][3][1][2]-0.880957224822116) < 1.e-12); +assert(fabs(een_rescaled_n[0][4][1][2]-0.027185942659395074) < 1.e-12); +assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); #+end_src @@ -4121,17 +4109,6 @@ print(" een_rescaled_n[1, 5, 2] = ",een_rescaled_n[1, 5, 2]) #+begin_src c :tangle (eval c_test) //assert(qmckl_electron_provided(context)); -// -//double een_rescaled_n[walk_num][elec_num][nucl_num][(cord_num + 1)]; -//rc = qmckl_get_jastrow_een_rescaled_n(context, &(een_rescaled_n[0][0][0][0])); -// -//// value of (0,2,1) -//assert(fabs(een_rescaled_n[0][2][0][1]-0.10612983920006765) < 1.e-12); -//assert(fabs(een_rescaled_n[0][3][0][1]-0.135652809635553) < 1.e-12); -//assert(fabs(een_rescaled_n[0][4][0][1]-0.023391817607642338) < 1.e-12); -//assert(fabs(een_rescaled_n[0][3][1][2]-0.880957224822116) < 1.e-12); -//assert(fabs(een_rescaled_n[0][4][1][2]-0.027185942659395074) < 1.e-12); -//assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); #+end_src @@ -4714,17 +4691,7 @@ print(" een_rescaled_n[1, 5, 2] = ",een_rescaled_n[1, 5, 2]) #+begin_src c :tangle (eval c_test) //assert(qmckl_electron_provided(context)); - -//double een_rescaled_n[walk_num][elec_num][nucl_num][(cord_num + 1)]; -//rc = qmckl_get_jastrow_een_rescaled_n(context, &(een_rescaled_n[0][0][0][0])); // -//// value of (0,2,1) -//assert(fabs(een_rescaled_n[0][2][0][1]-0.10612983920006765) < 1.e-12); -//assert(fabs(een_rescaled_n[0][3][0][1]-0.135652809635553) < 1.e-12); -//assert(fabs(een_rescaled_n[0][4][0][1]-0.023391817607642338) < 1.e-12); -//assert(fabs(een_rescaled_n[0][3][1][2]-0.880957224822116) < 1.e-12); -//assert(fabs(een_rescaled_n[0][4][1][2]-0.027185942659395074) < 1.e-12); -//assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); #+end_src @@ -5097,11 +5064,11 @@ print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) #+begin_src c :tangle (eval c_test) /* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//// calculate factor_en_deriv_e -//double factor_een[walk_num]; -//rc = qmckl_get_jastrow_factor_een(context, &(factor_een[0])); +assert(qmckl_jastrow_provided(context)); + +// calculate factor_en_deriv_e +double factor_een[walk_num]; +rc = qmckl_get_jastrow_factor_een(context, &(factor_een[0])); //// check factor_en_deriv_e //assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); @@ -5523,13 +5490,13 @@ print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) #+begin_src c :tangle (eval c_test) -/* Check if Jastrow is properly initialized */ +///* Check if Jastrow is properly initialized */ //assert(qmckl_jastrow_provided(context)); // //// calculate factor_en_deriv_e //double factor_een[walk_num]; //rc = qmckl_get_jastrow_factor_een(context, &(factor_een[0])); - +// //// check factor_en_deriv_e //assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); //assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); From 1fb561503505cf9fc273e5c94fb83ad8912f18aa Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 20:17:45 +0530 Subject: [PATCH 59/92] Commented some tests. #22 --- org/qmckl_jastrow.org | 130 +++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 00b4769..63b03dd 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1721,14 +1721,14 @@ print("factor_ee :",factor_ee) #+begin_src c :tangle (eval c_test) -/* Check if Jastrow is properly initialized */ -assert(qmckl_jastrow_provided(context)); - -double factor_ee[walk_num]; -rc = qmckl_get_jastrow_factor_ee(context, factor_ee); - -// calculate factor_ee -assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); +///* Check if Jastrow is properly initialized */ +//assert(qmckl_jastrow_provided(context)); +// +//double factor_ee[walk_num]; +//rc = qmckl_get_jastrow_factor_ee(context, factor_ee); +// +//// calculate factor_ee +//assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); #+end_src @@ -2140,18 +2140,18 @@ print(factor_ee_deriv_e) #+begin_src c :tangle (eval c_test) -/* Check if Jastrow is properly initialized */ -assert(qmckl_jastrow_provided(context)); - -// calculate factor_ee_deriv_e -double factor_ee_deriv_e[walk_num][4][elec_num]; -rc = qmckl_get_jastrow_factor_ee_deriv_e(context, &(factor_ee_deriv_e[0][0][0])); - -// check factor_ee_deriv_e -assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); -assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); -assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); -assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); +///* Check if Jastrow is properly initialized */ +//assert(qmckl_jastrow_provided(context)); +// +//// calculate factor_ee_deriv_e +//double factor_ee_deriv_e[walk_num][4][elec_num]; +//rc = qmckl_get_jastrow_factor_ee_deriv_e(context, &(factor_ee_deriv_e[0][0][0])); +// +//// check factor_ee_deriv_e +//assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); +//assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); +//assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); +//assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); #+end_src @@ -2436,14 +2436,14 @@ print("factor_en :",factor_en) #+begin_src c :tangle (eval c_test) -/* Check if Jastrow is properly initialized */ -assert(qmckl_jastrow_provided(context)); - -double factor_en[walk_num]; -rc = qmckl_get_jastrow_factor_en(context, factor_en); - -// calculate factor_en -assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); +///* Check if Jastrow is properly initialized */ +//assert(qmckl_jastrow_provided(context)); +// +//double factor_en[walk_num]; +//rc = qmckl_get_jastrow_factor_en(context, factor_en); +// +//// calculate factor_en +//assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); #+end_src @@ -2835,18 +2835,18 @@ print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) #+begin_src c :tangle (eval c_test) -/* Check if Jastrow is properly initialized */ -assert(qmckl_jastrow_provided(context)); - -// calculate factor_en_deriv_e -double factor_en_deriv_e[walk_num][4][elec_num]; -rc = qmckl_get_jastrow_factor_en_deriv_e(context, &(factor_en_deriv_e[0][0][0])); - -// check factor_en_deriv_e -assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); -assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); -assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); -assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); +///* Check if Jastrow is properly initialized */ +//assert(qmckl_jastrow_provided(context)); +// +//// calculate factor_en_deriv_e +//double factor_en_deriv_e[walk_num][4][elec_num]; +//rc = qmckl_get_jastrow_factor_en_deriv_e(context, &(factor_en_deriv_e[0][0][0])); +// +//// check factor_en_deriv_e +//assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); +//assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); +//assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); +//assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); #+end_src @@ -3142,19 +3142,19 @@ print(" een_rescaled_e[1, 5, 2] = ",een_rescaled_e[1, 5, 2]) : een_rescaled_e[1, 5, 2] = 0.3424402276009091 #+begin_src c :tangle (eval c_test) -assert(qmckl_electron_provided(context)); - - -double een_rescaled_e[walk_num][elec_num][elec_num][(cord_num + 1)]; -rc = qmckl_get_jastrow_een_rescaled_e(context, &(een_rescaled_e[0][0][0][0])); - -// value of (0,2,1) -assert(fabs(een_rescaled_e[0][0][2][1]-0.08084493981483197) < 1.e-12); -assert(fabs(een_rescaled_e[0][0][3][1]-0.1066745707571846) < 1.e-12); -assert(fabs(een_rescaled_e[0][0][4][1]-0.01754273169464735) < 1.e-12); -assert(fabs(een_rescaled_e[0][1][3][2]-0.02214680362033448) < 1.e-12); -assert(fabs(een_rescaled_e[0][1][4][2]-0.0005700154999202759) < 1.e-12); -assert(fabs(een_rescaled_e[0][1][5][2]-0.3424402276009091) < 1.e-12); +//assert(qmckl_electron_provided(context)); +// +// +//double een_rescaled_e[walk_num][elec_num][elec_num][(cord_num + 1)]; +//rc = qmckl_get_jastrow_een_rescaled_e(context, &(een_rescaled_e[0][0][0][0])); +// +//// value of (0,2,1) +//assert(fabs(een_rescaled_e[0][0][2][1]-0.08084493981483197) < 1.e-12); +//assert(fabs(een_rescaled_e[0][0][3][1]-0.1066745707571846) < 1.e-12); +//assert(fabs(een_rescaled_e[0][0][4][1]-0.01754273169464735) < 1.e-12); +//assert(fabs(een_rescaled_e[0][1][3][2]-0.02214680362033448) < 1.e-12); +//assert(fabs(een_rescaled_e[0][1][4][2]-0.0005700154999202759) < 1.e-12); +//assert(fabs(een_rescaled_e[0][1][5][2]-0.3424402276009091) < 1.e-12); #+end_src @@ -3767,18 +3767,18 @@ print(" een_rescaled_n[1, 5, 2] = ",een_rescaled_n[1, 5, 2]) : een_rescaled_n[1, 5, 2] = 0.01343938025140174 #+begin_src c :tangle (eval c_test) -assert(qmckl_electron_provided(context)); - -double een_rescaled_n[walk_num][elec_num][nucl_num][(cord_num + 1)]; -rc = qmckl_get_jastrow_een_rescaled_n(context, &(een_rescaled_n[0][0][0][0])); - -// value of (0,2,1) -assert(fabs(een_rescaled_n[0][2][0][1]-0.10612983920006765) < 1.e-12); -assert(fabs(een_rescaled_n[0][3][0][1]-0.135652809635553) < 1.e-12); -assert(fabs(een_rescaled_n[0][4][0][1]-0.023391817607642338) < 1.e-12); -assert(fabs(een_rescaled_n[0][3][1][2]-0.880957224822116) < 1.e-12); -assert(fabs(een_rescaled_n[0][4][1][2]-0.027185942659395074) < 1.e-12); -assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); +//assert(qmckl_electron_provided(context)); +// +//double een_rescaled_n[walk_num][elec_num][nucl_num][(cord_num + 1)]; +//rc = qmckl_get_jastrow_een_rescaled_n(context, &(een_rescaled_n[0][0][0][0])); +// +//// value of (0,2,1) +//assert(fabs(een_rescaled_n[0][2][0][1]-0.10612983920006765) < 1.e-12); +//assert(fabs(een_rescaled_n[0][3][0][1]-0.135652809635553) < 1.e-12); +//assert(fabs(een_rescaled_n[0][4][0][1]-0.023391817607642338) < 1.e-12); +//assert(fabs(een_rescaled_n[0][3][1][2]-0.880957224822116) < 1.e-12); +//assert(fabs(een_rescaled_n[0][4][1][2]-0.027185942659395074) < 1.e-12); +//assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); #+end_src From acf2dc217e9e86eb3313f7e8d1dd1416f9959fda Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 20:22:51 +0530 Subject: [PATCH 60/92] Checking tests. #22 --- org/qmckl_jastrow.org | 90 +++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 63b03dd..e657ce4 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1391,46 +1391,46 @@ print("asymp_jasb[1] : ", asymp_jasb[1]) : asymp_jasb[1] : 0.31567342786262853 #+begin_src c :tangle (eval c_test) -assert(qmckl_electron_provided(context)); - -int64_t type_nucl_num = n2_type_nucl_num; -int64_t* type_nucl_vector = &(n2_type_nucl_vector[0]); -int64_t aord_num = n2_aord_num; -int64_t bord_num = n2_bord_num; -int64_t cord_num = n2_cord_num; -double* aord_vector = &(n2_aord_vector[0][0]); -double* bord_vector = &(n2_bord_vector[0]); -double* cord_vector = &(n2_cord_vector[0][0]); - -/* Initialize the Jastrow data */ -rc = qmckl_init_jastrow(context); -assert(!qmckl_jastrow_provided(context)); - -/* Set the data */ -rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); -assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); -assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); -assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_aord_vector(context, aord_vector); -assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_bord_vector(context, bord_vector); -assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_cord_vector(context, cord_vector); -assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_dependencies(context); -assert(rc == QMCKL_SUCCESS); - -/* Check if Jastrow is properly initialized */ -assert(qmckl_jastrow_provided(context)); - -double asymp_jasb[2]; -rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); - -// calculate asymp_jasb -assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); -assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); +//assert(qmckl_electron_provided(context)); +// +//int64_t type_nucl_num = n2_type_nucl_num; +//int64_t* type_nucl_vector = &(n2_type_nucl_vector[0]); +//int64_t aord_num = n2_aord_num; +//int64_t bord_num = n2_bord_num; +//int64_t cord_num = n2_cord_num; +//double* aord_vector = &(n2_aord_vector[0][0]); +//double* bord_vector = &(n2_bord_vector[0]); +//double* cord_vector = &(n2_cord_vector[0][0]); +// +///* Initialize the Jastrow data */ +//rc = qmckl_init_jastrow(context); +//assert(!qmckl_jastrow_provided(context)); +// +///* Set the data */ +//rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); +//assert(rc == QMCKL_SUCCESS); +//rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); +//assert(rc == QMCKL_SUCCESS); +//rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); +//assert(rc == QMCKL_SUCCESS); +//rc = qmckl_set_jastrow_aord_vector(context, aord_vector); +//assert(rc == QMCKL_SUCCESS); +//rc = qmckl_set_jastrow_bord_vector(context, bord_vector); +//assert(rc == QMCKL_SUCCESS); +//rc = qmckl_set_jastrow_cord_vector(context, cord_vector); +//assert(rc == QMCKL_SUCCESS); +//rc = qmckl_set_jastrow_dependencies(context); +//assert(rc == QMCKL_SUCCESS); +// +///* Check if Jastrow is properly initialized */ +//assert(qmckl_jastrow_provided(context)); +// +//double asymp_jasb[2]; +//rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); +// +//// calculate asymp_jasb +//assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); +//assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); #+end_src @@ -5064,11 +5064,11 @@ print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) #+begin_src c :tangle (eval c_test) /* Check if Jastrow is properly initialized */ -assert(qmckl_jastrow_provided(context)); - -// calculate factor_en_deriv_e -double factor_een[walk_num]; -rc = qmckl_get_jastrow_factor_een(context, &(factor_een[0])); +//assert(qmckl_jastrow_provided(context)); +// +//// calculate factor_en_deriv_e +//double factor_een[walk_num]; +//rc = qmckl_get_jastrow_factor_een(context, &(factor_een[0])); //// check factor_en_deriv_e //assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); From dce0d9373ed18dc97503087a97ba24f1473a3897 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 20:30:19 +0530 Subject: [PATCH 61/92] Part 1 test. #22 --- org/qmckl_jastrow.org | 80 +++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index e657ce4..2bce0e4 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1391,46 +1391,46 @@ print("asymp_jasb[1] : ", asymp_jasb[1]) : asymp_jasb[1] : 0.31567342786262853 #+begin_src c :tangle (eval c_test) -//assert(qmckl_electron_provided(context)); -// -//int64_t type_nucl_num = n2_type_nucl_num; -//int64_t* type_nucl_vector = &(n2_type_nucl_vector[0]); -//int64_t aord_num = n2_aord_num; -//int64_t bord_num = n2_bord_num; -//int64_t cord_num = n2_cord_num; -//double* aord_vector = &(n2_aord_vector[0][0]); -//double* bord_vector = &(n2_bord_vector[0]); -//double* cord_vector = &(n2_cord_vector[0][0]); -// -///* Initialize the Jastrow data */ -//rc = qmckl_init_jastrow(context); -//assert(!qmckl_jastrow_provided(context)); -// -///* Set the data */ -//rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_aord_vector(context, aord_vector); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_bord_vector(context, bord_vector); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_cord_vector(context, cord_vector); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_dependencies(context); -//assert(rc == QMCKL_SUCCESS); -// -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//double asymp_jasb[2]; -//rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); -// -//// calculate asymp_jasb -//assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); -//assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); +assert(qmckl_electron_provided(context)); + +int64_t type_nucl_num = n2_type_nucl_num; +int64_t* type_nucl_vector = &(n2_type_nucl_vector[0]); +int64_t aord_num = n2_aord_num; +int64_t bord_num = n2_bord_num; +int64_t cord_num = n2_cord_num; +double* aord_vector = &(n2_aord_vector[0][0]); +double* bord_vector = &(n2_bord_vector[0]); +double* cord_vector = &(n2_cord_vector[0][0]); + +/* Initialize the Jastrow data */ +rc = qmckl_init_jastrow(context); +assert(!qmckl_jastrow_provided(context)); + +/* Set the data */ +rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_aord_vector(context, aord_vector); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_bord_vector(context, bord_vector); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_cord_vector(context, cord_vector); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_dependencies(context); +assert(rc == QMCKL_SUCCESS); + +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +double asymp_jasb[2]; +rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); + +// calculate asymp_jasb +assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); +assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); #+end_src From 22c8f01baba2d53a342842d17862a94831e279be Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 20:41:25 +0530 Subject: [PATCH 62/92] Testing. #22 --- org/qmckl_jastrow.org | 58 +++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 2bce0e4..f87d6be 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1402,35 +1402,35 @@ double* aord_vector = &(n2_aord_vector[0][0]); double* bord_vector = &(n2_bord_vector[0]); double* cord_vector = &(n2_cord_vector[0][0]); -/* Initialize the Jastrow data */ -rc = qmckl_init_jastrow(context); -assert(!qmckl_jastrow_provided(context)); - -/* Set the data */ -rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); -assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); -assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); -assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_aord_vector(context, aord_vector); -assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_bord_vector(context, bord_vector); -assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_cord_vector(context, cord_vector); -assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_jastrow_dependencies(context); -assert(rc == QMCKL_SUCCESS); - -/* Check if Jastrow is properly initialized */ -assert(qmckl_jastrow_provided(context)); - -double asymp_jasb[2]; -rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); - -// calculate asymp_jasb -assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); -assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); +///* Initialize the Jastrow data */ +//rc = qmckl_init_jastrow(context); +//assert(!qmckl_jastrow_provided(context)); +// +///* Set the data */ +//rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); +//assert(rc == QMCKL_SUCCESS); +//rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); +//assert(rc == QMCKL_SUCCESS); +//rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); +//assert(rc == QMCKL_SUCCESS); +//rc = qmckl_set_jastrow_aord_vector(context, aord_vector); +//assert(rc == QMCKL_SUCCESS); +//rc = qmckl_set_jastrow_bord_vector(context, bord_vector); +//assert(rc == QMCKL_SUCCESS); +//rc = qmckl_set_jastrow_cord_vector(context, cord_vector); +//assert(rc == QMCKL_SUCCESS); +//rc = qmckl_set_jastrow_dependencies(context); +//assert(rc == QMCKL_SUCCESS); +// +///* Check if Jastrow is properly initialized */ +//assert(qmckl_jastrow_provided(context)); +// +//double asymp_jasb[2]; +//rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); +// +//// calculate asymp_jasb +//assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); +//assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); #+end_src From 478ce7cc386a56115217db73de0f3b8c0abfb843 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 20:45:55 +0530 Subject: [PATCH 63/92] Testing - II. #22 --- org/qmckl_jastrow.org | 44 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index f87d6be..d1f51ac 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1402,28 +1402,28 @@ double* aord_vector = &(n2_aord_vector[0][0]); double* bord_vector = &(n2_bord_vector[0]); double* cord_vector = &(n2_cord_vector[0][0]); -///* Initialize the Jastrow data */ -//rc = qmckl_init_jastrow(context); -//assert(!qmckl_jastrow_provided(context)); -// -///* Set the data */ -//rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_aord_vector(context, aord_vector); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_bord_vector(context, bord_vector); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_cord_vector(context, cord_vector); -//assert(rc == QMCKL_SUCCESS); -//rc = qmckl_set_jastrow_dependencies(context); -//assert(rc == QMCKL_SUCCESS); -// -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); +/* Initialize the Jastrow data */ +rc = qmckl_init_jastrow(context); +assert(!qmckl_jastrow_provided(context)); + +/* Set the data */ +rc = qmckl_set_jastrow_ord_num(context, aord_num, bord_num, cord_num); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_type_nucl_num(context, type_nucl_num); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_type_nucl_vector(context, type_nucl_vector, nucl_num); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_aord_vector(context, aord_vector); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_bord_vector(context, bord_vector); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_cord_vector(context, cord_vector); +assert(rc == QMCKL_SUCCESS); +rc = qmckl_set_jastrow_dependencies(context); +assert(rc == QMCKL_SUCCESS); + +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); // //double asymp_jasb[2]; //rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); From 49a3b3d414cb09a3cefb006a185e84d825e76c65 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 20:48:49 +0530 Subject: [PATCH 64/92] Testing - III. #22 --- org/qmckl_jastrow.org | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index d1f51ac..2bce0e4 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1424,13 +1424,13 @@ assert(rc == QMCKL_SUCCESS); /* Check if Jastrow is properly initialized */ assert(qmckl_jastrow_provided(context)); -// -//double asymp_jasb[2]; -//rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); -// -//// calculate asymp_jasb -//assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); -//assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); + +double asymp_jasb[2]; +rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); + +// calculate asymp_jasb +assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); +assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); #+end_src From e821fab575ef197f5fbbfecf4b1b32a78d37c977 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 20:53:10 +0530 Subject: [PATCH 65/92] Testing - IV. #22 --- org/qmckl_jastrow.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 2bce0e4..350bdc7 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1428,9 +1428,9 @@ assert(qmckl_jastrow_provided(context)); double asymp_jasb[2]; rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); -// calculate asymp_jasb +//// calculate asymp_jasb assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); -assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); +//assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); #+end_src From c4b60c25f6165833e729bb3883b01fe64afd980b Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 20:55:46 +0530 Subject: [PATCH 66/92] Testing - V. #22 --- org/qmckl_jastrow.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 350bdc7..ffdc571 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1429,7 +1429,7 @@ double asymp_jasb[2]; rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); //// calculate asymp_jasb -assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); +//assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); //assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); #+end_src From 0391efe5b8241cd1955d3c0629b0a1855248d9c7 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 21:04:33 +0530 Subject: [PATCH 67/92] Testing - VI. #22 --- org/qmckl_jastrow.org | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index ffdc571..d30b674 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1423,10 +1423,10 @@ rc = qmckl_set_jastrow_dependencies(context); assert(rc == QMCKL_SUCCESS); /* Check if Jastrow is properly initialized */ -assert(qmckl_jastrow_provided(context)); +//assert(qmckl_jastrow_provided(context)); -double asymp_jasb[2]; -rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); +//double asymp_jasb[2]; +//rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); //// calculate asymp_jasb //assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); From a09c29eb64ef7567eabf4f8a077ab70e08e63cc8 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 22:02:27 +0530 Subject: [PATCH 68/92] Testing - VII. #22 --- org/qmckl_jastrow.org | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index d30b674..b0df92a 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1423,10 +1423,10 @@ rc = qmckl_set_jastrow_dependencies(context); assert(rc == QMCKL_SUCCESS); /* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); +assert(qmckl_jastrow_provided(context)); -//double asymp_jasb[2]; -//rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); +double asymp_jasb[2]; +rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); //// calculate asymp_jasb //assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); @@ -1721,14 +1721,14 @@ print("factor_ee :",factor_ee) #+begin_src c :tangle (eval c_test) -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//double factor_ee[walk_num]; -//rc = qmckl_get_jastrow_factor_ee(context, factor_ee); -// -//// calculate factor_ee -//assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +double factor_ee[walk_num]; +rc = qmckl_get_jastrow_factor_ee(context, factor_ee); + +// calculate factor_ee +assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); #+end_src From 0383b29b881bac4d72a09f821b1557dd5b31f61e Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Wed, 7 Jul 2021 22:09:08 +0530 Subject: [PATCH 69/92] Testing - VIII. #22 --- org/qmckl_jastrow.org | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index b0df92a..62c49ff 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1722,13 +1722,13 @@ print("factor_ee :",factor_ee) #+begin_src c :tangle (eval c_test) /* Check if Jastrow is properly initialized */ -assert(qmckl_jastrow_provided(context)); - -double factor_ee[walk_num]; -rc = qmckl_get_jastrow_factor_ee(context, factor_ee); - -// calculate factor_ee -assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); +//assert(qmckl_jastrow_provided(context)); +// +//double factor_ee[walk_num]; +//rc = qmckl_get_jastrow_factor_ee(context, factor_ee); +// +//// calculate factor_ee +//assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); #+end_src From 8710a14d5afb8d4264a778501b17f66c0fb74650 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 7 Jul 2021 19:09:03 +0200 Subject: [PATCH 70/92] Download test-suite.log as artifact --- .github/workflows/test-build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index cbaeab1..2032472 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -23,6 +23,11 @@ jobs: make -j 8 make -j check make distcheck + - name: Archive test log file + uses: actions/upload-artifact@v2 + with: + name: test-suite.log + path: test-suite.log # x86_macos: # From 3ac753cc0a8e82d63d455c54ed1b651da0238ca4 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 8 Jul 2021 01:25:09 +0200 Subject: [PATCH 71/92] Debugging AOs --- org/qmckl_ao.org | 141 ++++++++++++++++++++++++++++++----------------- 1 file changed, 89 insertions(+), 52 deletions(-) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index 1bd3de0..21d9b72 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -108,18 +108,19 @@ int main() { 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 | - | ~shell_vgl~ | ~[prim_num][5][walk_num][elec_num]~ | Value, gradients, Laplacian of the primitives at electron positions | - | ~shell_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the shells 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 | + |--------------------------+-------------------------------------+-----------------------------------------------------------------------------------------------| + | ~coefficient_normalized~ | ~[prim_num]~ | Normalized primitive coefficients | + | ~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 | + | ~shell_vgl~ | ~[prim_num][5][walk_num][elec_num]~ | Value, gradients, Laplacian of the primitives at electron positions | + | ~shell_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the shells 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, @@ -180,12 +181,14 @@ typedef struct qmckl_ao_basis_struct { 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 ; + + int64_t * nucleus_prim_index; + double * coefficient_normalized ; double * primitive_vgl; int64_t primitive_vgl_date; double * shell_vgl; @@ -1009,26 +1012,59 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) { 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); + { + 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); + 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); + if (ctx->ao_basis.nucleus_prim_index == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "ao_basis.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; } - - 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 */ + /* Normalize coefficients */ + { + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->ao_basis.prim_num * sizeof(double); + + ctx->ao_basis.coefficient_normalized = (double *) qmckl_malloc(context, mem_info); + + if (ctx->ao_basis.coefficient_normalized == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "ao_basis.coefficient_normalized", + NULL); + } + +/* + for (int64_t i=0 ; i < ctx->ao_basis.prim_num ; ++i) { + ctx->ao_basis.coefficient_normalized[i] = + ctx->ao_basis.coefficient[i] * ctx->ao_basis.prim_factor[i]; + } + */ + for (int64_t ishell=0 ; ishell < ctx->ao_basis.shell_num ; ++ishell) { + for (int64_t iprim=ctx->ao_basis.shell_prim_index[ishell] ; + iprim < ctx->ao_basis.shell_prim_index[ishell]+ctx->ao_basis.shell_prim_num[ishell] ; + ++iprim) { + ctx->ao_basis.coefficient_normalized[iprim] = + ctx->ao_basis.coefficient[iprim] * ctx->ao_basis.prim_factor[iprim] * + ctx->ao_basis.shell_factor[ishell]; + } + } + } + + /* TODO : sort the basis set here */ return QMCKL_SUCCESS; } #+end_src @@ -1921,7 +1957,7 @@ qmckl_exit_code qmckl_provide_ao_basis_shell_vgl(qmckl_context context) ctx->electron.coord_new, ctx->nucleus.coord, ctx->ao_basis.exponent, - ctx->ao_basis.coefficient, + ctx->ao_basis.coefficient_normalized, ctx->ao_basis.shell_vgl); } else { return qmckl_failwith( context, @@ -1961,14 +1997,14 @@ qmckl_exit_code qmckl_provide_ao_basis_shell_vgl(qmckl_context context) | ~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~ | ~coef[prim_num]~ | in | Coefficients of the primitives | + | ~double~ | ~coef_normalized[prim_num]~ | in | Coefficients of the primitives | | ~double~ | ~shell_vgl[shell_num][5][walk_num][elec_num]~ | out | Value, gradients and Laplacian of the shells | #+begin_src f90 :comments org :tangle (eval f) :noweb yes integer function qmckl_compute_ao_basis_shell_gaussian_vgl_f(context, & prim_num, shell_num, elec_num, nucl_num, walk_num, & nucleus_shell_num, nucleus_index, shell_prim_index, shell_prim_num, & - elec_coord, nucl_coord, expo, coef, shell_vgl) & + elec_coord, nucl_coord, expo, coef_normalized, shell_vgl) & result(info) use qmckl implicit none @@ -1985,7 +2021,7 @@ integer function qmckl_compute_ao_basis_shell_gaussian_vgl_f(context, & 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(in) :: coef(prim_num) + double precision , intent(in) :: coef_normalized(prim_num) double precision , intent(out) :: shell_vgl(elec_num,walk_num,5,shell_num) integer*8 :: inucl, iprim, iwalk, ielec, ishell @@ -2019,7 +2055,7 @@ integer function qmckl_compute_ao_basis_shell_gaussian_vgl_f(context, & cycle end if - v = coef(iprim) * dexp(-ar2) + v = coef_normalized(iprim) * dexp(-ar2) two_a = -2.d0 * expo(iprim) * v shell_vgl(ielec, iwalk, 1, ishell) = & @@ -2064,7 +2100,7 @@ qmckl_exit_code qmckl_compute_ao_basis_shell_gaussian_vgl( const double* elec_coord, const double* nucl_coord, const double* expo, - const double* coef, + const double* coef_normalized, double* const shell_vgl); #+end_src @@ -2086,7 +2122,7 @@ qmckl_exit_code qmckl_compute_ao_basis_shell_gaussian_vgl( elec_coord, & nucl_coord, & expo, & - coef, & + coef_normalized, & shell_vgl) & bind(C) result(info) @@ -2106,7 +2142,7 @@ qmckl_exit_code qmckl_compute_ao_basis_shell_gaussian_vgl( 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(in) :: coef(prim_num) + real (c_double ) , intent(in) :: coef_normalized(prim_num) real (c_double ) , intent(out) :: shell_vgl(elec_num,walk_num,5,shell_num) integer(c_int32_t), external :: qmckl_compute_ao_basis_shell_gaussian_vgl_f @@ -2124,7 +2160,7 @@ qmckl_exit_code qmckl_compute_ao_basis_shell_gaussian_vgl( elec_coord, & nucl_coord, & expo, & - coef, & + coef_normalized, & shell_vgl) end function qmckl_compute_ao_basis_shell_gaussian_vgl @@ -2235,11 +2271,11 @@ double shell_vgl[shell_num][5][walk_num][elec_num]; rc = qmckl_get_ao_basis_shell_vgl(context, &(shell_vgl[0][0][0][0])); assert (rc == QMCKL_SUCCESS); -printf(" shell_vgl[1][0][0][26] %25.15e\n", shell_vgl[1][0][0][26]); -printf(" shell_vgl[1][1][0][26] %25.15e\n", shell_vgl[1][1][0][26]); -printf(" shell_vgl[1][2][0][26] %25.15e\n", shell_vgl[1][2][0][26]); -printf(" shell_vgl[1][3][0][26] %25.15e\n", shell_vgl[1][3][0][26]); -printf(" shell_vgl[1][4][0][26] %25.15e\n", shell_vgl[1][4][0][26]); +printf(" shell_vgl[1][0][0][26] %25.15e\n", shell_vgl[1][0][0][26]); +printf(" shell_vgl[1][1][0][26] %25.15e\n", shell_vgl[1][1][0][26]); +printf(" shell_vgl[1][2][0][26] %25.15e\n", shell_vgl[1][2][0][26]); +printf(" shell_vgl[1][3][0][26] %25.15e\n", shell_vgl[1][3][0][26]); +printf(" shell_vgl[1][4][0][26] %25.15e\n", shell_vgl[1][4][0][26]); printf(" shell_vgl[14][0][1][15] %25.15e\n", shell_vgl[14][0][1][15]); printf(" shell_vgl[14][1][1][15] %25.15e\n", shell_vgl[14][1][1][15]); @@ -2247,18 +2283,19 @@ printf(" shell_vgl[14][2][1][15] %25.15e\n", shell_vgl[14][2][1][15]); printf(" shell_vgl[14][3][1][15] %25.15e\n", shell_vgl[14][3][1][15]); printf(" shell_vgl[14][4][1][15] %25.15e\n", shell_vgl[14][4][1][15]); -assert( fabs(shell_vgl[1][0][0][26] - ( 1.875568658202993e-01)) < 1.e-14 ); -assert( fabs(shell_vgl[1][1][0][26] - ( -2.615250164814435e-02)) < 1.e-14 ); -assert( fabs(shell_vgl[1][2][0][26] - ( -1.333535498894419e-01)) < 1.e-14 ); -assert( fabs(shell_vgl[1][3][0][26] - ( 1.218482800201208e-01)) < 1.e-14 ); -assert( fabs(shell_vgl[1][4][0][26] - ( 3.197054084474042e-02)) < 1.e-14 ); +assert( fabs(shell_vgl[1][0][0][26] - ( 3.564393437193868e-02)) < 1.e-14 ); +assert( fabs(shell_vgl[1][1][0][26] - (-6.030177987072189e-03)) < 1.e-14 ); +assert( fabs(shell_vgl[1][2][0][26] - (-3.074832579537582e-02)) < 1.e-14 ); +assert( fabs(shell_vgl[1][3][0][26] - ( 2.809546963519935e-02)) < 1.e-14 ); +assert( fabs(shell_vgl[1][4][0][26] - ( 1.896046117183968e-02)) < 1.e-14 ); -assert( fabs(shell_vgl[14][0][1][15] - ( 4.509748459243634e-02)) < 1.e-14 ); -assert( fabs(shell_vgl[14][1][1][15] - ( 3.203917730584210e-02)) < 1.e-14 ); -assert( fabs(shell_vgl[14][2][1][15] - ( 2.887080725789477e-02)) < 1.e-14 ); -assert( fabs(shell_vgl[14][3][1][15] - ( 5.836910453297223e-03)) < 1.e-14 ); -assert( fabs(shell_vgl[14][4][1][15] - ( 1.572966698871693e-02)) < 1.e-14 ); +assert( fabs(shell_vgl[14][0][1][15] - ( 5.928089771361000e-03)) < 1.e-14 ); +assert( fabs(shell_vgl[14][1][1][15] - ( 4.355862296021654e-03)) < 1.e-14 ); +assert( fabs(shell_vgl[14][2][1][15] - ( 3.925108924923650e-03)) < 1.e-14 ); +assert( fabs(shell_vgl[14][3][1][15] - ( 7.935527784022099e-04)) < 1.e-14 ); +assert( fabs(shell_vgl[14][4][1][15] - ( 2.708246573703548e-03)) < 1.e-14 ); } + #+end_src * Polynomial part From 751d918147e50c13308225015f420854817bab0c Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 10:28:15 +0530 Subject: [PATCH 72/92] Fixed size_t to int64_t. #22 --- org/qmckl_jastrow.org | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 62c49ff..2b76cbc 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1132,15 +1132,15 @@ assert(!qmckl_nucleus_provided(context)); rc = qmckl_get_nucleus_coord (context, 'N', nucl_coord2); assert(rc == QMCKL_SUCCESS); -for (size_t k=0 ; k<3 ; ++k) { - for (size_t i=0 ; i Date: Thu, 8 Jul 2021 10:40:24 +0530 Subject: [PATCH 73/92] Fixed some warnings. #22 --- org/qmckl_jastrow.org | 117 +++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 2b76cbc..6b17687 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -72,50 +72,50 @@ int main() { The following data stored in the context: #+NAME: qmckl_jastrow_args - |-----------+--------------------------------------------+-----+-------------------------------------------------------------------| - | ~int32_t~ | ~uninitialized~ | in | Keeps bit set for uninitialized data | - | ~int64_t~ | ~aord_num~ | in | The number of a coeffecients | - | ~int64_t~ | ~bord_num~ | in | The number of b coeffecients | - | ~int64_t~ | ~cord_num~ | in | The number of c coeffecients | - | ~int64_t~ | ~type_nucl_num~ | in | Number of Nucleii types | - | ~int64_t~ | ~type_nucl_vector[nucl_num]~ | in | IDs of types of Nucleii | - | ~double~ | ~aord_vector[aord_num + 1][type_nucl_num]~ | in | Order of a polynomial coefficients | - | ~double~ | ~bord_vector[bord_num + 1]~ | in | Order of b polynomial coefficients | - | ~double~ | ~cord_vector[cord_num][type_nucl_num]~ | in | Order of c polynomial coefficients | - | ~double~ | ~factor_ee[walk_num]~ | out | Jastrow factor: electron-electron part | - | ~int64_t~ | ~factor_ee_date~ | out | Jastrow factor: electron-electron part | - | ~double~ | ~factor_en[walk_num]~ | out | Jastrow factor: electron-nucleus part | - | ~int64_t~ | ~factor_en_date~ | out | Jastrow factor: electron-nucleus part | - | ~double~ | ~factor_een[walk_num]~ | out | Jastrow factor: electron-electron-nucleus part | - | ~int64_t~ | ~factor_een_date~ | out | Jastrow factor: electron-electron-nucleus part | - | ~double~ | ~factor_ee_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~int64_t~ | ~factor_ee_deriv_e_date~ | out | Keep track of the date for the derivative | - | ~double~ | ~factor_en_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~int64_t~ | ~factor_en_deriv_e_date~ | out | Keep track of the date for the en derivative | - | ~double~ | ~factor_een_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | - | ~int64_t~ | ~factor_een_deriv_e_date~ | out | Keep track of the date for the een derivative | + |------------+--------------------------------------------+-----+-------------------------------------------------------------------| + | ~int32_t~ | ~uninitialized~ | in | Keeps bit set for uninitialized data | + | ~int64_t~ | ~aord_num~ | in | The number of a coeffecients | + | ~int64_t~ | ~bord_num~ | in | The number of b coeffecients | + | ~int64_t~ | ~cord_num~ | in | The number of c coeffecients | + | ~int64_t~ | ~type_nucl_num~ | in | Number of Nucleii types | + | ~int64_t~ | ~type_nucl_vector[nucl_num]~ | in | IDs of types of Nucleii | + | ~double~ | ~aord_vector[aord_num + 1][type_nucl_num]~ | in | Order of a polynomial coefficients | + | ~double~ | ~bord_vector[bord_num + 1]~ | in | Order of b polynomial coefficients | + | ~double~ | ~cord_vector[cord_num][type_nucl_num]~ | in | Order of c polynomial coefficients | + | ~double~ | ~factor_ee[walk_num]~ | out | Jastrow factor: electron-electron part | + | ~uint64_t~ | ~factor_ee_date~ | out | Jastrow factor: electron-electron part | + | ~double~ | ~factor_en[walk_num]~ | out | Jastrow factor: electron-nucleus part | + | ~uint64_t~ | ~factor_en_date~ | out | Jastrow factor: electron-nucleus part | + | ~double~ | ~factor_een[walk_num]~ | out | Jastrow factor: electron-electron-nucleus part | + | ~uint64_t~ | ~factor_een_date~ | out | Jastrow factor: electron-electron-nucleus part | + | ~double~ | ~factor_ee_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~uint64_t~ | ~factor_ee_deriv_e_date~ | out | Keep track of the date for the derivative | + | ~double~ | ~factor_en_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~uint64_t~ | ~factor_en_deriv_e_date~ | out | Keep track of the date for the en derivative | + | ~double~ | ~factor_een_deriv_e[4][nelec][walk_num]~ | out | Derivative of the Jastrow factor: electron-electron-nucleus part | + | ~uint64_t~ | ~factor_een_deriv_e_date~ | out | Keep track of the date for the een derivative | computed data: - |-----------+-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------| - | ~int64_t~ | ~dim_cord_vect~ | Number of unique C coefficients | - | ~int64_t~ | ~dim_cord_vect_date~ | Number of unique C coefficients | - | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | - | ~int64_t~ | ~asymp_jasb_date~ | Asymptotic component | - | ~double~ | ~cord_vect_full[dim_cord_vect][nucl_num]~ | vector of non-zero coefficients | - | ~int64_t~ | ~cord_vect_full_date~ | Keep track of changes here | - | ~int64_t~ | ~lkpm_combined_index[4][dim_cord_vect]~ | Transform l,k,p, and m into consecutive indices | - | ~int64_t~ | ~lkpm_combined_index_date~ | Transform l,k,p, and m into consecutive indices | - | ~double~ | ~tmp_c[elec_num][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | - | ~double~ | ~dtmp_c[elec_num][4][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | - | ~double~ | ~een_rescaled_e[walk_num][elec_num][elec_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | - | ~int64_t~ | ~een_rescaled_e_date~ | Keep track of the date of creation | - | ~double~ | ~een_rescaled_n[walk_num][elec_num][nucl_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | - | ~int64_t~ | ~een_rescaled_n_date~ | Keep track of the date of creation | - | ~double~ | ~een_rescaled_e_deriv_e[walk_num][elec_num][4][elec_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons | - | ~int64_t~ | ~een_rescaled_e_deriv_e_date~ | Keep track of the date of creation | - | ~double~ | ~een_rescaled_n_deriv_e[walk_num][elec_num][4][nucl_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons | - | ~int64_t~ | ~een_rescaled_n_deriv_e_date~ | Keep track of the date of creation | + |------------+-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------| + | ~int64_t~ | ~dim_cord_vect~ | Number of unique C coefficients | + | ~uint64_t~ | ~dim_cord_vect_date~ | Number of unique C coefficients | + | ~double~ | ~asymp_jasb[2]~ | Asymptotic component | + | ~uint64_t~ | ~asymp_jasb_date~ | Asymptotic component | + | ~double~ | ~cord_vect_full[dim_cord_vect][nucl_num]~ | vector of non-zero coefficients | + | ~uint64_t~ | ~cord_vect_full_date~ | Keep track of changes here | + | ~int64_t~ | ~lkpm_combined_index[4][dim_cord_vect]~ | Transform l,k,p, and m into consecutive indices | + | ~uint64_t~ | ~lkpm_combined_index_date~ | Transform l,k,p, and m into consecutive indices | + | ~double~ | ~tmp_c[elec_num][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | + | ~double~ | ~dtmp_c[elec_num][4][nucl_num][ncord + 1][ncord][walk_num]~ | vector of non-zero coefficients | + | ~double~ | ~een_rescaled_e[walk_num][elec_num][elec_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | + | ~uint64_t~ | ~een_rescaled_e_date~ | Keep track of the date of creation | + | ~double~ | ~een_rescaled_n[walk_num][elec_num][nucl_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | + | ~uint64_t~ | ~een_rescaled_n_date~ | Keep track of the date of creation | + | ~double~ | ~een_rescaled_e_deriv_e[walk_num][elec_num][4][elec_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons | + | ~uint64_t~ | ~een_rescaled_e_deriv_e_date~ | Keep track of the date of creation | + | ~double~ | ~een_rescaled_n_deriv_e[walk_num][elec_num][4][nucl_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons | + | ~uint64_t~ | ~een_rescaled_n_deriv_e_date~ | Keep track of the date of creation | For H2O we have the following data: @@ -280,16 +280,16 @@ typedef struct qmckl_jastrow_struct{ int64_t bord_num; int64_t cord_num; int64_t type_nucl_num; - int64_t asymp_jasb_date; - int64_t tmp_c_date; - int64_t dtmp_c_date; - int64_t factor_ee_date; - int64_t factor_en_date; - int64_t factor_een_date; - int64_t factor_ee_deriv_e_date; - int64_t factor_en_deriv_e_date; - int64_t factor_een_deriv_e_date; - int64_t* type_nucl_vector; + uint64_t asymp_jasb_date; + uint64_t tmp_c_date; + uint64_t dtmp_c_date; + uint64_t factor_ee_date; + uint64_t factor_en_date; + uint64_t factor_een_date; + uint64_t factor_ee_deriv_e_date; + uint64_t factor_en_deriv_e_date; + uint64_t factor_een_deriv_e_date; + uint64_t* type_nucl_vector; double * aord_vector; double * bord_vector; double * cord_vector; @@ -301,21 +301,21 @@ typedef struct qmckl_jastrow_struct{ double * factor_en_deriv_e; double * factor_een_deriv_e; int64_t dim_cord_vect; - int64_t dim_cord_vect_date; + uint64_t dim_cord_vect_date; double * cord_vect_full; - int64_t cord_vect_full_date; + uint64_t cord_vect_full_date; int64_t* lkpm_combined_index; - int64_t lkpm_combined_index_date; + uint64_t lkpm_combined_index_date; double * tmp_c; double * dtmp_c; double * een_rescaled_e; double * een_rescaled_n; - int64_t een_rescaled_e_date; - int64_t een_rescaled_n_date; + uint64_t een_rescaled_e_date; + uint64_t een_rescaled_n_date; double * een_rescaled_e_deriv_e; double * een_rescaled_n_deriv_e; - int64_t een_rescaled_e_deriv_e_date; - int64_t een_rescaled_n_deriv_e_date; + uint64_t een_rescaled_e_deriv_e_date; + uint64_t een_rescaled_n_deriv_e_date; bool provided; char * type; } qmckl_jastrow_struct; @@ -4587,6 +4587,7 @@ integer function qmckl_compute_lkpm_combined_index_f(context, cord_num, dim_cord endif + kk = 0 do p = 2, cord_num do k = p - 1, 0, -1 if (k .ne. 0) then From c838dabe3ca41d61bcef82327c81c55226023f40 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 10:59:24 +0530 Subject: [PATCH 74/92] Fix for type_nucl_vector. #22 --- org/qmckl_jastrow.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 6b17687..7f222a4 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -289,7 +289,7 @@ typedef struct qmckl_jastrow_struct{ uint64_t factor_ee_deriv_e_date; uint64_t factor_en_deriv_e_date; uint64_t factor_een_deriv_e_date; - uint64_t* type_nucl_vector; + int64_t* type_nucl_vector; double * aord_vector; double * bord_vector; double * cord_vector; From 1821089880e4d15540fea9293a0787a4d846dca7 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 11:10:10 +0530 Subject: [PATCH 75/92] Testing IX. #22 --- org/qmckl_jastrow.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 7f222a4..5eba7b7 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1425,8 +1425,8 @@ assert(rc == QMCKL_SUCCESS); /* Check if Jastrow is properly initialized */ assert(qmckl_jastrow_provided(context)); -double asymp_jasb[2]; -rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); +//double asymp_jasb[2]; +//rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); //// calculate asymp_jasb //assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); From dcff0cf4b487baae691da854b4e116815db4e72e Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 11:30:07 +0530 Subject: [PATCH 76/92] Fixed bug in bord_vector dimension. #22 --- org/qmckl_jastrow.org | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 5eba7b7..b02fe06 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1288,7 +1288,7 @@ integer function qmckl_compute_asymp_jasb_f(context, bord_num, bord_vector, resc implicit none integer(qmckl_context), intent(in) :: context integer*8 , intent(in) :: bord_num - double precision , intent(in) :: bord_vector(bord_num) + double precision , intent(in) :: bord_vector(bord_num + 1) double precision , intent(in) :: rescale_factor_kappa_ee double precision , intent(out) :: asymp_jasb(2) @@ -1425,8 +1425,8 @@ assert(rc == QMCKL_SUCCESS); /* Check if Jastrow is properly initialized */ assert(qmckl_jastrow_provided(context)); -//double asymp_jasb[2]; -//rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); +double asymp_jasb[2]; +rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); //// calculate asymp_jasb //assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); From 371b943aac514a112cccae9c7b22da3ff32681fa Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 11:36:47 +0530 Subject: [PATCH 77/92] Fixed some bugs in aord_vector dims. #22 --- org/qmckl_jastrow.org | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index b02fe06..8e2196c 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1428,9 +1428,9 @@ assert(qmckl_jastrow_provided(context)); double asymp_jasb[2]; rc = qmckl_get_jastrow_asymp_jasb(context, asymp_jasb); -//// calculate asymp_jasb -//assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); -//assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); +// calculate asymp_jasb +assert(fabs(asymp_jasb[0]-0.5323750557252571) < 1.e-12); +assert(fabs(asymp_jasb[1]-0.31567342786262853) < 1.e-12); #+end_src @@ -1558,7 +1558,7 @@ integer function qmckl_compute_factor_ee_f(context, walk_num, elec_num, up_num, implicit none integer(qmckl_context), intent(in) :: context integer*8 , intent(in) :: walk_num, elec_num, bord_num, up_num - double precision , intent(in) :: bord_vector(bord_num) + double precision , intent(in) :: bord_vector(bord_num + 1) double precision , intent(in) :: ee_distance_rescaled(walk_num, elec_num, elec_num) double precision , intent(in) :: asymp_jasb(2) double precision , intent(out) :: factor_ee(walk_num) @@ -1864,7 +1864,7 @@ integer function qmckl_compute_factor_ee_deriv_e_f(context, walk_num, elec_num, implicit none integer(qmckl_context), intent(in) :: context integer*8 , intent(in) :: walk_num, elec_num, bord_num, up_num - double precision , intent(in) :: bord_vector(bord_num) + double precision , intent(in) :: bord_vector(bord_num + 1) double precision , intent(in) :: ee_distance_rescaled(walk_num, elec_num, elec_num) double precision , intent(in) :: ee_distance_rescaled_deriv_e(walk_num, 4, elec_num, elec_num) double precision , intent(in) :: asymp_jasb(2) @@ -2283,7 +2283,7 @@ integer function qmckl_compute_factor_en_f(context, walk_num, elec_num, nucl_num integer(qmckl_context), intent(in) :: context integer*8 , intent(in) :: walk_num, elec_num, aord_num, nucl_num, type_nucl_num integer*8 , intent(in) :: type_nucl_vector(type_nucl_num) - double precision , intent(in) :: aord_vector(aord_num, nucl_num) + double precision , intent(in) :: aord_vector(aord_num + 1, type_nucl_num) double precision , intent(in) :: en_distance_rescaled(walk_num, elec_num, nucl_num) double precision , intent(out) :: factor_en(walk_num) @@ -2388,7 +2388,7 @@ end function qmckl_compute_factor_en_f integer (c_int64_t) , intent(in) , value :: type_nucl_num integer (c_int64_t) , intent(in) :: type_nucl_vector(type_nucl_num) integer (c_int64_t) , intent(in) , value :: aord_num - real (c_double ) , intent(in) :: aord_vector(type_nucl_num,aord_num + 1) + real (c_double ) , intent(in) :: aord_vector(aord_num + 1, type_nucl_num) real (c_double ) , intent(in) :: en_distance_rescaled(elec_num,nucl_num,walk_num) real (c_double ) , intent(out) :: factor_en(walk_num) @@ -2579,7 +2579,7 @@ integer function qmckl_compute_factor_en_deriv_e_f(context, walk_num, elec_num, integer(qmckl_context), intent(in) :: context integer*8 , intent(in) :: walk_num, elec_num, aord_num, nucl_num, type_nucl_num integer*8 , intent(in) :: type_nucl_vector(type_nucl_num) - double precision , intent(in) :: aord_vector(aord_num, nucl_num) + double precision , intent(in) :: aord_vector(aord_num + 1, type_nucl_num) double precision , intent(in) :: en_distance_rescaled(walk_num, elec_num, nucl_num) double precision , intent(in) :: en_distance_rescaled_deriv_e(walk_num, 4, elec_num, nucl_num) double precision , intent(out) :: factor_en_deriv_e(elec_num,4,walk_num) @@ -2717,7 +2717,7 @@ end function qmckl_compute_factor_en_deriv_e_f integer (c_int64_t) , intent(in) , value :: type_nucl_num integer (c_int64_t) , intent(in) :: type_nucl_vector(type_nucl_num) integer (c_int64_t) , intent(in) , value :: aord_num - real (c_double ) , intent(in) :: aord_vector(type_nucl_num,aord_num + 1) + real (c_double ) , intent(in) :: aord_vector(aord_num + 1, type_nucl_num) real (c_double ) , intent(in) :: en_distance_rescaled(elec_num,nucl_num,walk_num) real (c_double ) , intent(in) :: en_distance_rescaled_deriv_e(elec_num,nucl_num,4,walk_num) real (c_double ) , intent(out) :: factor_en_deriv_e(elec_num,4,walk_num) From 0342449621b7b983023b6273a325c8ad9c96daaa Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 11:41:32 +0530 Subject: [PATCH 78/92] Reinstate tests for factor_ee. #22 --- org/qmckl_jastrow.org | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 8e2196c..c179ef5 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1722,13 +1722,13 @@ print("factor_ee :",factor_ee) #+begin_src c :tangle (eval c_test) /* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//double factor_ee[walk_num]; -//rc = qmckl_get_jastrow_factor_ee(context, factor_ee); -// -//// calculate factor_ee -//assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); +assert(qmckl_jastrow_provided(context)); + +double factor_ee[walk_num]; +rc = qmckl_get_jastrow_factor_ee(context, factor_ee); + +// calculate factor_ee +assert(fabs(factor_ee[0]+4.282760865958113) < 1.e-12); #+end_src From 0575638e5bf853c91060cdacc10ef54da8b73be3 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 11:49:52 +0530 Subject: [PATCH 79/92] Reinstate tests for factor_ee_deriv_e. #22 --- org/qmckl_jastrow.org | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index c179ef5..79ef6bf 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2140,18 +2140,18 @@ print(factor_ee_deriv_e) #+begin_src c :tangle (eval c_test) -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//// calculate factor_ee_deriv_e -//double factor_ee_deriv_e[walk_num][4][elec_num]; -//rc = qmckl_get_jastrow_factor_ee_deriv_e(context, &(factor_ee_deriv_e[0][0][0])); -// -//// check factor_ee_deriv_e -//assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); -//assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); -//assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); -//assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +// calculate factor_ee_deriv_e +double factor_ee_deriv_e[walk_num][4][elec_num]; +rc = qmckl_get_jastrow_factor_ee_deriv_e(context, &(factor_ee_deriv_e[0][0][0])); + +// check factor_ee_deriv_e +assert(fabs(factor_ee_deriv_e[0][0][0]-0.16364894652107934) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][1][0]+0.6927548119830084 ) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][2][0]-0.073267755223968 ) < 1.e-12); +assert(fabs(factor_ee_deriv_e[0][3][0]-1.5111672803213185 ) < 1.e-12); #+end_src From be341f3afdb319da98cefa30241f11f659731429 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 11:53:13 +0530 Subject: [PATCH 80/92] Reinstated tests for factor_en. #22 --- org/qmckl_jastrow.org | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 79ef6bf..12ef37c 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2436,14 +2436,14 @@ print("factor_en :",factor_en) #+begin_src c :tangle (eval c_test) -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//double factor_en[walk_num]; -//rc = qmckl_get_jastrow_factor_en(context, factor_en); -// -//// calculate factor_en -//assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +double factor_en[walk_num]; +rc = qmckl_get_jastrow_factor_en(context, factor_en); + +// calculate factor_en +assert(fabs(factor_en[0]+5.865822569188727) < 1.e-12); #+end_src From 672f0e771c21aa9db64021c59ccc95fad069cf6b Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 11:58:46 +0530 Subject: [PATCH 81/92] Fixed bug in factor_en. #22 --- org/qmckl_jastrow.org | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 12ef37c..c82c5b4 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2284,7 +2284,7 @@ integer function qmckl_compute_factor_en_f(context, walk_num, elec_num, nucl_num integer*8 , intent(in) :: walk_num, elec_num, aord_num, nucl_num, type_nucl_num integer*8 , intent(in) :: type_nucl_vector(type_nucl_num) double precision , intent(in) :: aord_vector(aord_num + 1, type_nucl_num) - double precision , intent(in) :: en_distance_rescaled(walk_num, elec_num, nucl_num) + double precision , intent(in) :: en_distance_rescaled(elec_num, nucl_num, walk_num) double precision , intent(out) :: factor_en(walk_num) integer*8 :: i, a, p, ipar, nw @@ -2322,18 +2322,18 @@ integer function qmckl_compute_factor_en_f(context, walk_num, elec_num, nucl_num do nw =1, walk_num do a = 1, nucl_num do i = 1, elec_num - x = en_distance_rescaled(nw, i, a) + x = en_distance_rescaled(i, a, nw) power_ser = 0.0d0 do p = 2, aord_num - x = x * en_distance_rescaled(nw, i, a) + x = x * en_distance_rescaled(i, a, nw) power_ser = power_ser + aord_vector(p + 1, type_nucl_vector(a)) * x end do factor_en(nw) = factor_en(nw) + aord_vector(1, type_nucl_vector(a)) * & - en_distance_rescaled(nw, i, a) / & + en_distance_rescaled(i, a, nw) / & (1.0d0 + aord_vector(2, type_nucl_vector(a)) * & - en_distance_rescaled(nw, i, a)) & + en_distance_rescaled(i, a, nw)) & + power_ser end do From 2cd5a31cba1729b0c46098815940a9ed53379be9 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 12:03:42 +0530 Subject: [PATCH 82/92] Fixed bug in type_nucl_vector dim. #22 --- org/qmckl_jastrow.org | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index c82c5b4..6f719f7 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2267,7 +2267,7 @@ qmckl_exit_code qmckl_provide_factor_en(qmckl_context context) | int64_t | elec_num | in | Number of electrons | | int64_t | nucl_num | in | Number of nucleii | | int64_t | type_nucl_num | in | Number of unique nuclei | - | int64_t | type_nucl_vector[type_nucl_num] | in | IDs of unique nucleii | + | int64_t | type_nucl_vector[nucl_num] | in | IDs of unique nucleii | | int64_t | aord_num | in | Number of coefficients | | double | aord_vector[aord_num + 1][type_nucl_num] | in | List of coefficients | | double | en_distance_rescaled[walk_num][nucl_num][elec_num] | in | Electron-nucleus distances | @@ -2282,9 +2282,9 @@ integer function qmckl_compute_factor_en_f(context, walk_num, elec_num, nucl_num implicit none integer(qmckl_context), intent(in) :: context integer*8 , intent(in) :: walk_num, elec_num, aord_num, nucl_num, type_nucl_num - integer*8 , intent(in) :: type_nucl_vector(type_nucl_num) + integer*8 , intent(in) :: type_nucl_vector(nucl_num) double precision , intent(in) :: aord_vector(aord_num + 1, type_nucl_num) - double precision , intent(in) :: en_distance_rescaled(elec_num, nucl_num, walk_num) + double precision , intent(in) :: en_distance_rescaled(walk_num, nucl_num, elec_num) double precision , intent(out) :: factor_en(walk_num) integer*8 :: i, a, p, ipar, nw @@ -2322,18 +2322,18 @@ integer function qmckl_compute_factor_en_f(context, walk_num, elec_num, nucl_num do nw =1, walk_num do a = 1, nucl_num do i = 1, elec_num - x = en_distance_rescaled(i, a, nw) + x = en_distance_rescaled(nw, a, i) power_ser = 0.0d0 do p = 2, aord_num - x = x * en_distance_rescaled(i, a, nw) + x = x * en_distance_rescaled(nw, a, i) power_ser = power_ser + aord_vector(p + 1, type_nucl_vector(a)) * x end do factor_en(nw) = factor_en(nw) + aord_vector(1, type_nucl_vector(a)) * & - en_distance_rescaled(i, a, nw) / & + en_distance_rescaled(nw, a, i) / & (1.0d0 + aord_vector(2, type_nucl_vector(a)) * & - en_distance_rescaled(i, a, nw)) & + en_distance_rescaled(nw, a, i)) & + power_ser end do @@ -2386,10 +2386,10 @@ end function qmckl_compute_factor_en_f integer (c_int64_t) , intent(in) , value :: elec_num integer (c_int64_t) , intent(in) , value :: nucl_num integer (c_int64_t) , intent(in) , value :: type_nucl_num - integer (c_int64_t) , intent(in) :: type_nucl_vector(type_nucl_num) + integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num) integer (c_int64_t) , intent(in) , value :: aord_num real (c_double ) , intent(in) :: aord_vector(aord_num + 1, type_nucl_num) - real (c_double ) , intent(in) :: en_distance_rescaled(elec_num,nucl_num,walk_num) + real (c_double ) , intent(in) :: en_distance_rescaled(walk_num, nucl_num, elec_num) real (c_double ) , intent(out) :: factor_en(walk_num) integer(c_int32_t), external :: qmckl_compute_factor_en_f @@ -2562,7 +2562,7 @@ qmckl_exit_code qmckl_provide_factor_en_deriv_e(qmckl_context context) | int64_t | elec_num | in | Number of electrons | | int64_t | nucl_num | in | Number of nucleii | | int64_t | type_nucl_num | in | Number of unique nuclei | - | int64_t | type_nucl_vector[type_nucl_num] | in | IDs of unique nucleii | + | int64_t | type_nucl_vector[nucl_num] | in | IDs of unique nucleii | | int64_t | aord_num | in | Number of coefficients | | double | aord_vector[aord_num + 1][type_nucl_num] | in | List of coefficients | | double | en_distance_rescaled[walk_num][nucl_num][elec_num] | in | Electron-nucleus distances | @@ -2578,7 +2578,7 @@ integer function qmckl_compute_factor_en_deriv_e_f(context, walk_num, elec_num, implicit none integer(qmckl_context), intent(in) :: context integer*8 , intent(in) :: walk_num, elec_num, aord_num, nucl_num, type_nucl_num - integer*8 , intent(in) :: type_nucl_vector(type_nucl_num) + integer*8 , intent(in) :: type_nucl_vector(nucl_num) double precision , intent(in) :: aord_vector(aord_num + 1, type_nucl_num) double precision , intent(in) :: en_distance_rescaled(walk_num, elec_num, nucl_num) double precision , intent(in) :: en_distance_rescaled_deriv_e(walk_num, 4, elec_num, nucl_num) @@ -2715,7 +2715,7 @@ end function qmckl_compute_factor_en_deriv_e_f integer (c_int64_t) , intent(in) , value :: elec_num integer (c_int64_t) , intent(in) , value :: nucl_num integer (c_int64_t) , intent(in) , value :: type_nucl_num - integer (c_int64_t) , intent(in) :: type_nucl_vector(type_nucl_num) + integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num) integer (c_int64_t) , intent(in) , value :: aord_num real (c_double ) , intent(in) :: aord_vector(aord_num + 1, type_nucl_num) real (c_double ) , intent(in) :: en_distance_rescaled(elec_num,nucl_num,walk_num) From c8aef0d9acb70c5c57378df838d8ec5b8c910922 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 12:07:13 +0530 Subject: [PATCH 83/92] Reinstated tests for factor_en_deriv_e. #22 --- org/qmckl_jastrow.org | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 6f719f7..427e6cd 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2835,18 +2835,18 @@ print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) #+begin_src c :tangle (eval c_test) -///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//// calculate factor_en_deriv_e -//double factor_en_deriv_e[walk_num][4][elec_num]; -//rc = qmckl_get_jastrow_factor_en_deriv_e(context, &(factor_en_deriv_e[0][0][0])); -// -//// check factor_en_deriv_e -//assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); +/* Check if Jastrow is properly initialized */ +assert(qmckl_jastrow_provided(context)); + +// calculate factor_en_deriv_e +double factor_en_deriv_e[walk_num][4][elec_num]; +rc = qmckl_get_jastrow_factor_en_deriv_e(context, &(factor_en_deriv_e[0][0][0])); + +// check factor_en_deriv_e +assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); +assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); +assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); +assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); #+end_src From bcba93ee7e75ca9f54535cfd176caba7801190c2 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 12:09:22 +0530 Subject: [PATCH 84/92] Reinstated tests for een_rescaled_e. #22 --- org/qmckl_jastrow.org | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 427e6cd..2137935 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -3142,19 +3142,19 @@ print(" een_rescaled_e[1, 5, 2] = ",een_rescaled_e[1, 5, 2]) : een_rescaled_e[1, 5, 2] = 0.3424402276009091 #+begin_src c :tangle (eval c_test) -//assert(qmckl_electron_provided(context)); -// -// -//double een_rescaled_e[walk_num][elec_num][elec_num][(cord_num + 1)]; -//rc = qmckl_get_jastrow_een_rescaled_e(context, &(een_rescaled_e[0][0][0][0])); -// -//// value of (0,2,1) -//assert(fabs(een_rescaled_e[0][0][2][1]-0.08084493981483197) < 1.e-12); -//assert(fabs(een_rescaled_e[0][0][3][1]-0.1066745707571846) < 1.e-12); -//assert(fabs(een_rescaled_e[0][0][4][1]-0.01754273169464735) < 1.e-12); -//assert(fabs(een_rescaled_e[0][1][3][2]-0.02214680362033448) < 1.e-12); -//assert(fabs(een_rescaled_e[0][1][4][2]-0.0005700154999202759) < 1.e-12); -//assert(fabs(een_rescaled_e[0][1][5][2]-0.3424402276009091) < 1.e-12); +assert(qmckl_electron_provided(context)); + + +double een_rescaled_e[walk_num][elec_num][elec_num][(cord_num + 1)]; +rc = qmckl_get_jastrow_een_rescaled_e(context, &(een_rescaled_e[0][0][0][0])); + +// value of (0,2,1) +assert(fabs(een_rescaled_e[0][0][2][1]-0.08084493981483197) < 1.e-12); +assert(fabs(een_rescaled_e[0][0][3][1]-0.1066745707571846) < 1.e-12); +assert(fabs(een_rescaled_e[0][0][4][1]-0.01754273169464735) < 1.e-12); +assert(fabs(een_rescaled_e[0][1][3][2]-0.02214680362033448) < 1.e-12); +assert(fabs(een_rescaled_e[0][1][4][2]-0.0005700154999202759) < 1.e-12); +assert(fabs(een_rescaled_e[0][1][5][2]-0.3424402276009091) < 1.e-12); #+end_src From 45bc54d0f9df07c0a86172d483a638fb90360bd2 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 12:11:26 +0530 Subject: [PATCH 85/92] Reinstated tests for een_rescaled_n. #22 --- org/qmckl_jastrow.org | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 2137935..822789f 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -3767,18 +3767,18 @@ print(" een_rescaled_n[1, 5, 2] = ",een_rescaled_n[1, 5, 2]) : een_rescaled_n[1, 5, 2] = 0.01343938025140174 #+begin_src c :tangle (eval c_test) -//assert(qmckl_electron_provided(context)); -// -//double een_rescaled_n[walk_num][elec_num][nucl_num][(cord_num + 1)]; -//rc = qmckl_get_jastrow_een_rescaled_n(context, &(een_rescaled_n[0][0][0][0])); -// -//// value of (0,2,1) -//assert(fabs(een_rescaled_n[0][2][0][1]-0.10612983920006765) < 1.e-12); -//assert(fabs(een_rescaled_n[0][3][0][1]-0.135652809635553) < 1.e-12); -//assert(fabs(een_rescaled_n[0][4][0][1]-0.023391817607642338) < 1.e-12); -//assert(fabs(een_rescaled_n[0][3][1][2]-0.880957224822116) < 1.e-12); -//assert(fabs(een_rescaled_n[0][4][1][2]-0.027185942659395074) < 1.e-12); -//assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); +assert(qmckl_electron_provided(context)); + +double een_rescaled_n[walk_num][elec_num][nucl_num][(cord_num + 1)]; +rc = qmckl_get_jastrow_een_rescaled_n(context, &(een_rescaled_n[0][0][0][0])); + +// value of (0,2,1) +assert(fabs(een_rescaled_n[0][2][0][1]-0.10612983920006765) < 1.e-12); +assert(fabs(een_rescaled_n[0][3][0][1]-0.135652809635553) < 1.e-12); +assert(fabs(een_rescaled_n[0][4][0][1]-0.023391817607642338) < 1.e-12); +assert(fabs(een_rescaled_n[0][3][1][2]-0.880957224822116) < 1.e-12); +assert(fabs(een_rescaled_n[0][4][1][2]-0.027185942659395074) < 1.e-12); +assert(fabs(een_rescaled_n[0][5][1][2]-0.01343938025140174) < 1.e-12); #+end_src From af978e1b031dd20954fedc7ed634286d516133f9 Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Thu, 8 Jul 2021 12:22:28 +0530 Subject: [PATCH 86/92] Everything good. Ready for merge. #22 --- org/qmckl_jastrow.org | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 822789f..118b6f2 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -5067,15 +5067,6 @@ print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) /* Check if Jastrow is properly initialized */ //assert(qmckl_jastrow_provided(context)); // -//// calculate factor_en_deriv_e -//double factor_een[walk_num]; -//rc = qmckl_get_jastrow_factor_een(context, &(factor_een[0])); - -//// check factor_en_deriv_e -//assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); #+end_src @@ -5492,17 +5483,6 @@ print("factor_en_deriv_e[3][0]:",factor_en_deriv_e[3][0]) #+begin_src c :tangle (eval c_test) ///* Check if Jastrow is properly initialized */ -//assert(qmckl_jastrow_provided(context)); -// -//// calculate factor_en_deriv_e -//double factor_een[walk_num]; -//rc = qmckl_get_jastrow_factor_een(context, &(factor_een[0])); -// -//// check factor_en_deriv_e -//assert(fabs(factor_en_deriv_e[0][0][0]-0.11609919541763383) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][1][0]+0.23301394780804574) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][2][0]-0.17548337641865783) < 1.e-12); -//assert(fabs(factor_en_deriv_e[0][3][0]+0.9667363412285741 ) < 1.e-12); #+end_src From e8a5103c92d10b6e767f6a2c7fba47331a383e2a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 8 Jul 2021 19:20:19 +0200 Subject: [PATCH 87/92] Changed order of indices in AOs --- org/qmckl_ao.org | 268 ++++++++++++++++++++++++++---------------- org/qmckl_jastrow.org | 11 +- 2 files changed, 172 insertions(+), 107 deletions(-) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index 0b10745..152e37a 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -93,34 +93,37 @@ int main() { 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 | - | ~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 | + |---------------------+---------------+----------------------------------------------------------------------| + | ~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 | + | ~nucleus_shell_num~ | ~[nucl_num]~ | Number of shells per 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: - |--------------------------+-------------------------------------+-----------------------------------------------------------------------------------------------| - | ~coefficient_normalized~ | ~[prim_num]~ | Normalized primitive coefficients | - | ~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 | - | ~shell_vgl~ | ~[prim_num][5][walk_num][elec_num]~ | Value, gradients, Laplacian of the primitives at electron positions | - | ~shell_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the shells 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 | + |--------------------------+--------------------------------------+-----------------------------------------------------------------------------------------------| + | ~coefficient_normalized~ | ~[prim_num]~ | Normalized primitive coefficients | + | ~nucleus_prim_index~ | ~[nucl_num]~ | Index of the first primitive for each nucleus | + | ~nucleus_max_ang_mom~ | ~[nucl_num]~ | Maximum angular momentum for each nucleus | + | ~nucleus_range~ | ~[nucl_num]~ | Distance beyond which all the AOs are zero | + |--------------------------+--------------------------------------+-----------------------------------------------------------------------------------------------| + | ~primitive_vgl~ | ~[5][walk_num][elec_num][prim_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 | + | ~shell_vgl~ | ~[5][walk_num][elec_num][shell_num]~ | Value, gradients, Laplacian of the primitives at electron positions | + | ~shell_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the shells 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 | For H_2 with the following basis set, @@ -188,7 +191,9 @@ typedef struct qmckl_ao_basis_struct { double * prim_factor ; int64_t * nucleus_prim_index; - double * coefficient_normalized ; + double * coefficient_normalized; + int32_t * nucleus_max_ang_mom; + double * nucleus_range; double * primitive_vgl; int64_t primitive_vgl_date; double * shell_vgl; @@ -1047,12 +1052,6 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) { NULL); } -/* - for (int64_t i=0 ; i < ctx->ao_basis.prim_num ; ++i) { - ctx->ao_basis.coefficient_normalized[i] = - ctx->ao_basis.coefficient[i] * ctx->ao_basis.prim_factor[i]; - } - */ for (int64_t ishell=0 ; ishell < ctx->ao_basis.shell_num ; ++ishell) { for (int64_t iprim=ctx->ao_basis.shell_prim_index[ishell] ; iprim < ctx->ao_basis.shell_prim_index[ishell]+ctx->ao_basis.shell_prim_num[ishell] ; @@ -1064,7 +1063,67 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) { } } - /* TODO : sort the basis set here */ + + /* Find max angular momentum on each nucleus */ + { + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->nucleus.num * sizeof(int32_t); + + ctx->ao_basis.nucleus_max_ang_mom = (int32_t *) qmckl_malloc(context, mem_info); + + if (ctx->ao_basis.nucleus_max_ang_mom == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "ao_basis.nucleus_max_ang_mom", + NULL); + } + + for (int64_t inucl=0 ; inucl < ctx->nucleus.num ; ++inucl) { + ctx->ao_basis.nucleus_max_ang_mom[inucl] = 0; + for (int64_t ishell=ctx->ao_basis.nucleus_index[inucl] ; + ishell < ctx->ao_basis.nucleus_index[inucl] + ctx->ao_basis.nucleus_shell_num[inucl] ; + ++ishell) { + ctx->ao_basis.nucleus_max_ang_mom[inucl] = + ctx->ao_basis.nucleus_max_ang_mom[inucl] > ctx->ao_basis.shell_ang_mom[ishell] ? + ctx->ao_basis.nucleus_max_ang_mom[inucl] : ctx->ao_basis.shell_ang_mom[ishell] ; + } + } + } + + /* Find distance beyond which all AOs are zero. + The distance is obtained by sqrt(log(cutoff)*range) */ + { + if (ctx->ao_basis.type == 'G') { + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->nucleus.num * sizeof(double); + + ctx->ao_basis.nucleus_range = (double *) qmckl_malloc(context, mem_info); + + if (ctx->ao_basis.nucleus_range == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "ao_basis.nucleus_range", + NULL); + } + + for (int64_t inucl=0 ; inucl < ctx->nucleus.num ; ++inucl) { + ctx->ao_basis.nucleus_range[inucl] = 0.; + for (int64_t ishell=ctx->ao_basis.nucleus_index[inucl] ; + ishell < ctx->ao_basis.nucleus_index[inucl] + ctx->ao_basis.nucleus_shell_num[inucl] ; + ++ishell) { + for (int64_t iprim=ctx->ao_basis.shell_prim_index[ishell] ; + iprim < ctx->ao_basis.shell_prim_index[ishell] + ctx->ao_basis.shell_prim_num[ishell] ; + ++iprim) { + double range = 1./ctx->ao_basis.exponent[iprim]; + ctx->ao_basis.nucleus_range[inucl] = + ctx->ao_basis.nucleus_range[inucl] > range ? + ctx->ao_basis.nucleus_range[inucl] : range; + } + } + } + } + } + /* TODO : sort the basis set here */ return QMCKL_SUCCESS; } #+end_src @@ -1281,6 +1340,8 @@ assert(qmckl_ao_basis_provided(context)); #+end_src * Radial part + +** TODO Helper functions to accelerate calculations ** General functions for Gaussian basis functions ~qmckl_ao_gaussian_vgl~ computes the values, gradients and @@ -1494,7 +1555,7 @@ end function test_qmckl_ao_gaussian_vgl ** TODO General functions for Slater basis functions ** TODO General functions for Radial functions on a grid -** DONE Computation of primitives +** Computation of primitives *** Get @@ -1614,7 +1675,7 @@ qmckl_exit_code qmckl_provide_ao_basis_primitive_vgl(qmckl_context context) | 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 | + | double | primitive_vgl[5][walk_num][elec_num][prim_num] | out | Value, gradients and Laplacian of the primitives | #+begin_src f90 :comments org :tangle (eval f) :noweb yes integer function qmckl_compute_ao_basis_primitive_gaussian_vgl_f(context, & @@ -1632,7 +1693,7 @@ integer function qmckl_compute_ao_basis_primitive_gaussian_vgl_f(context, & 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) + double precision , intent(out) :: primitive_vgl(prim_num,elec_num,walk_num,5) integer*8 :: inucl, iprim, iwalk, ielec double precision :: x, y, z, two_a, ar2, r2, v, cutoff @@ -1658,11 +1719,11 @@ integer function qmckl_compute_ao_basis_primitive_gaussian_vgl_f(context, & 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) + primitive_vgl(iprim, ielec, iwalk, 1) = v + primitive_vgl(iprim, ielec, iwalk, 2) = two_a * x + primitive_vgl(iprim, ielec, iwalk, 3) = two_a * y + primitive_vgl(iprim, ielec, iwalk, 4) = two_a * z + primitive_vgl(iprim, ielec, iwalk, 5) = two_a * (3.d0 - 2.d0*ar2) end do end do @@ -1799,22 +1860,22 @@ assert(rc == QMCKL_SUCCESS); -double prim_vgl[prim_num][5][walk_num][elec_num]; +double prim_vgl[5][walk_num][elec_num][prim_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[0][0][26][7] - ( 1.0501570432064878E-003)) < 1.e-14 ); +assert( fabs(prim_vgl[1][0][26][7] - (-7.5014974095310560E-004)) < 1.e-14 ); +assert( fabs(prim_vgl[2][0][26][7] - (-3.8250692897610380E-003)) < 1.e-14 ); +assert( fabs(prim_vgl[3][0][26][7] - ( 3.4950559194080275E-003)) < 1.e-14 ); +assert( fabs(prim_vgl[4][0][26][7] - ( 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 ); +assert( fabs(prim_vgl[0][1][15][39] - ( 1.0825844173157661E-003)) < 1.e-14 ); +assert( fabs(prim_vgl[1][1][15][39] - ( 2.3774237611651531E-003)) < 1.e-14 ); +assert( fabs(prim_vgl[2][1][15][39] - ( 2.1423191526963063E-003)) < 1.e-14 ); +assert( fabs(prim_vgl[3][1][15][39] - ( 4.3312003523048492E-004)) < 1.e-14 ); +assert( fabs(prim_vgl[4][1][15][39] - ( 7.5174404780004771E-003)) < 1.e-14 ); } @@ -2005,7 +2066,7 @@ qmckl_exit_code qmckl_provide_ao_basis_shell_vgl(qmckl_context context) | ~double~ | ~nucl_coord[3][elec_num]~ | in | Nuclear coordinates | | ~double~ | ~expo[prim_num]~ | in | Exponents of the primitives | | ~double~ | ~coef_normalized[prim_num]~ | in | Coefficients of the primitives | - | ~double~ | ~shell_vgl[shell_num][5][walk_num][elec_num]~ | out | Value, gradients and Laplacian of the shells | + | ~double~ | ~shell_vgl[5][walk_num][elec_num][shell_num]~ | out | Value, gradients and Laplacian of the shells | #+begin_src f90 :comments org :tangle (eval f) :noweb yes integer function qmckl_compute_ao_basis_shell_gaussian_vgl_f(context, & @@ -2029,7 +2090,7 @@ integer function qmckl_compute_ao_basis_shell_gaussian_vgl_f(context, & double precision , intent(in) :: nucl_coord(nucl_num,3) double precision , intent(in) :: expo(prim_num) double precision , intent(in) :: coef_normalized(prim_num) - double precision , intent(out) :: shell_vgl(elec_num,walk_num,5,shell_num) + double precision , intent(out) :: shell_vgl(shell_num,elec_num,walk_num,5) integer*8 :: inucl, iprim, iwalk, ielec, ishell double precision :: x, y, z, two_a, ar2, r2, v, cutoff @@ -2041,19 +2102,24 @@ integer function qmckl_compute_ao_basis_shell_gaussian_vgl_f(context, & cutoff = -dlog(1.d-15) do inucl=1,nucl_num - do ishell=nucleus_index(inucl)+1, nucleus_index(inucl)+nucleus_shell_num(inucl) - ! C is zero-based, so shift bounds by one - do iwalk = 1, walk_num - do ielec = 1, elec_num + do iwalk = 1, walk_num + do ielec = 1, elec_num - shell_vgl(ielec, iwalk, 1:5, ishell) = 0.d0 + 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) - 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 - r2 = x*x + y*y + z*z + do ishell=nucleus_index(inucl)+1, nucleus_index(inucl)+nucleus_shell_num(inucl) + ! C is zero-based, so shift bounds by one + + shell_vgl(ishell, ielec, iwalk, 1) = 0.d0 + shell_vgl(ishell, ielec, iwalk, 2) = 0.d0 + shell_vgl(ishell, ielec, iwalk, 3) = 0.d0 + shell_vgl(ishell, ielec, iwalk, 4) = 0.d0 + shell_vgl(ishell, ielec, iwalk, 5) = 0.d0 do iprim = shell_prim_index(ishell)+1, shell_prim_index(ishell)+shell_prim_num(ishell) @@ -2064,24 +2130,24 @@ integer function qmckl_compute_ao_basis_shell_gaussian_vgl_f(context, & v = coef_normalized(iprim) * dexp(-ar2) two_a = -2.d0 * expo(iprim) * v - - shell_vgl(ielec, iwalk, 1, ishell) = & - shell_vgl(ielec, iwalk, 1, ishell) + v - - shell_vgl(ielec, iwalk, 2, ishell) = & - shell_vgl(ielec, iwalk, 2, ishell) + two_a * x - - shell_vgl(ielec, iwalk, 3, ishell) = & - shell_vgl(ielec, iwalk, 3, ishell) + two_a * y - - shell_vgl(ielec, iwalk, 4, ishell) = & - shell_vgl(ielec, iwalk, 4, ishell) + two_a * z - - shell_vgl(ielec, iwalk, 5, ishell) = & - shell_vgl(ielec, iwalk, 5, ishell) + two_a * (3.d0 - 2.d0*ar2) + + shell_vgl(ishell, ielec, iwalk, 1) = & + shell_vgl(ishell, ielec, iwalk, 1) + v + + shell_vgl(ishell, ielec, iwalk, 2) = & + shell_vgl(ishell, ielec, iwalk, 2) + two_a * x + + shell_vgl(ishell, ielec, iwalk, 3) = & + shell_vgl(ishell, ielec, iwalk, 3) + two_a * y + + shell_vgl(ishell, ielec, iwalk, 4) = & + shell_vgl(ishell, ielec, iwalk, 4) + two_a * z + + shell_vgl(ishell, ielec, iwalk, 5) = & + shell_vgl(ishell, ielec, iwalk, 5) + two_a * (3.d0 - 2.d0*ar2) end do - + end do end do @@ -2150,7 +2216,7 @@ qmckl_exit_code qmckl_compute_ao_basis_shell_gaussian_vgl( real (c_double ) , intent(in) :: nucl_coord(elec_num,3) real (c_double ) , intent(in) :: expo(prim_num) real (c_double ) , intent(in) :: coef_normalized(prim_num) - real (c_double ) , intent(out) :: shell_vgl(elec_num,walk_num,5,shell_num) + real (c_double ) , intent(out) :: shell_vgl(shell_num,elec_num,walk_num,5) integer(c_int32_t), external :: qmckl_compute_ao_basis_shell_gaussian_vgl_f info = qmckl_compute_ao_basis_shell_gaussian_vgl_f & @@ -2273,34 +2339,34 @@ rc = qmckl_set_electron_coord (context, 'N', elec_coord); assert(rc == QMCKL_SUCCESS); -double shell_vgl[shell_num][5][walk_num][elec_num]; +double shell_vgl[5][walk_num][elec_num][shell_num]; rc = qmckl_get_ao_basis_shell_vgl(context, &(shell_vgl[0][0][0][0])); assert (rc == QMCKL_SUCCESS); -printf(" shell_vgl[1][0][0][26] %25.15e\n", shell_vgl[1][0][0][26]); -printf(" shell_vgl[1][1][0][26] %25.15e\n", shell_vgl[1][1][0][26]); -printf(" shell_vgl[1][2][0][26] %25.15e\n", shell_vgl[1][2][0][26]); -printf(" shell_vgl[1][3][0][26] %25.15e\n", shell_vgl[1][3][0][26]); -printf(" shell_vgl[1][4][0][26] %25.15e\n", shell_vgl[1][4][0][26]); +printf(" shell_vgl[1][0][0][26] %25.15e\n", shell_vgl[0][0][26][1]); +printf(" shell_vgl[1][1][0][26] %25.15e\n", shell_vgl[1][0][26][1]); +printf(" shell_vgl[1][2][0][26] %25.15e\n", shell_vgl[2][0][26][1]); +printf(" shell_vgl[1][3][0][26] %25.15e\n", shell_vgl[3][0][26][1]); +printf(" shell_vgl[1][4][0][26] %25.15e\n", shell_vgl[4][0][26][1]); -printf(" shell_vgl[14][0][1][15] %25.15e\n", shell_vgl[14][0][1][15]); -printf(" shell_vgl[14][1][1][15] %25.15e\n", shell_vgl[14][1][1][15]); -printf(" shell_vgl[14][2][1][15] %25.15e\n", shell_vgl[14][2][1][15]); -printf(" shell_vgl[14][3][1][15] %25.15e\n", shell_vgl[14][3][1][15]); -printf(" shell_vgl[14][4][1][15] %25.15e\n", shell_vgl[14][4][1][15]); +printf(" shell_vgl[14][0][1][15] %25.15e\n", shell_vgl[0][1][15][14]); +printf(" shell_vgl[14][1][1][15] %25.15e\n", shell_vgl[1][1][15][14]); +printf(" shell_vgl[14][2][1][15] %25.15e\n", shell_vgl[2][1][15][14]); +printf(" shell_vgl[14][3][1][15] %25.15e\n", shell_vgl[3][1][15][14]); +printf(" shell_vgl[14][4][1][15] %25.15e\n", shell_vgl[4][1][15][14]); -assert( fabs(shell_vgl[1][0][0][26] - ( 3.564393437193868e-02)) < 1.e-14 ); -assert( fabs(shell_vgl[1][1][0][26] - (-6.030177987072189e-03)) < 1.e-14 ); -assert( fabs(shell_vgl[1][2][0][26] - (-3.074832579537582e-02)) < 1.e-14 ); -assert( fabs(shell_vgl[1][3][0][26] - ( 2.809546963519935e-02)) < 1.e-14 ); -assert( fabs(shell_vgl[1][4][0][26] - ( 1.896046117183968e-02)) < 1.e-14 ); +assert( fabs(shell_vgl[0][0][26][1] - ( 3.564393437193868e-02)) < 1.e-14 ); +assert( fabs(shell_vgl[1][0][26][1] - (-6.030177987072189e-03)) < 1.e-14 ); +assert( fabs(shell_vgl[2][0][26][1] - (-3.074832579537582e-02)) < 1.e-14 ); +assert( fabs(shell_vgl[3][0][26][1] - ( 2.809546963519935e-02)) < 1.e-14 ); +assert( fabs(shell_vgl[4][0][26][1] - ( 1.896046117183968e-02)) < 1.e-14 ); -assert( fabs(shell_vgl[14][0][1][15] - ( 5.928089771361000e-03)) < 1.e-14 ); -assert( fabs(shell_vgl[14][1][1][15] - ( 4.355862296021654e-03)) < 1.e-14 ); -assert( fabs(shell_vgl[14][2][1][15] - ( 3.925108924923650e-03)) < 1.e-14 ); -assert( fabs(shell_vgl[14][3][1][15] - ( 7.935527784022099e-04)) < 1.e-14 ); -assert( fabs(shell_vgl[14][4][1][15] - ( 2.708246573703548e-03)) < 1.e-14 ); +assert( fabs(shell_vgl[0][1][15][14] - ( 5.928089771361000e-03)) < 1.e-14 ); +assert( fabs(shell_vgl[1][1][15][14] - ( 4.355862296021654e-03)) < 1.e-14 ); +assert( fabs(shell_vgl[2][1][15][14] - ( 3.925108924923650e-03)) < 1.e-14 ); +assert( fabs(shell_vgl[3][1][15][14] - ( 7.935527784022099e-04)) < 1.e-14 ); +assert( fabs(shell_vgl[4][1][15][14] - ( 2.708246573703548e-03)) < 1.e-14 ); } #+end_src diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 118b6f2..27aab31 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -960,7 +960,7 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { /* Check for the electron data 1. elec_num 2. ee_distances_rescaled - */ + ,*/ if (!(ctx->electron.provided)) { return qmckl_failwith( context, QMCKL_NOT_PROVIDED, @@ -971,7 +971,7 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { /* Check for the nucleus data 1. nucl_num 2. en_distances_rescaled - */ + ,*/ if (!(ctx->nucleus.provided)) { return qmckl_failwith( context, QMCKL_NOT_PROVIDED, @@ -980,7 +980,7 @@ qmckl_exit_code qmckl_finalize_jastrow(qmckl_context context) { } qmckl_exit_code rc = QMCKL_FAILURE; - + return rc; /* ----------------------------------- */ /* Start calculation of data */ @@ -1004,7 +1004,6 @@ double* elec_coord = &(n2_elec_coord[0][0][0]); const double* nucl_charge = n2_charge; int64_t nucl_num = n2_nucl_num; -double* charge = n2_charge; double* nucl_coord = &(n2_nucl_coord[0][0]); /* Provide Electron data */ @@ -2267,7 +2266,7 @@ qmckl_exit_code qmckl_provide_factor_en(qmckl_context context) | int64_t | elec_num | in | Number of electrons | | int64_t | nucl_num | in | Number of nucleii | | int64_t | type_nucl_num | in | Number of unique nuclei | - | int64_t | type_nucl_vector[nucl_num] | in | IDs of unique nucleii | + | int64_t | type_nucl_vector[nucl_num] | in | IDs of unique nucleii | | int64_t | aord_num | in | Number of coefficients | | double | aord_vector[aord_num + 1][type_nucl_num] | in | List of coefficients | | double | en_distance_rescaled[walk_num][nucl_num][elec_num] | in | Electron-nucleus distances | @@ -3270,7 +3269,7 @@ qmckl_exit_code qmckl_provide_een_rescaled_e_deriv_e(qmckl_context context) | int64_t | elec_num | in | Number of electrons | | int64_t | cord_num | in | Order of polynomials | | double | rescale_factor_kappa_ee | in | Factor to rescale ee distances | - | double | coord_new[walk_num][3][elec_num] | in | Electron coordinates | + | double | coord_new[walk_num][3][elec_num] | in | Electron coordinates | | double | ee_distance[walk_num][elec_num][elec_num] | in | Electron-electron distances | | double | een_rescaled_e[walk_num][elec_num][elec_num][0:cord_num] | in | Electron-electron distances | | double | een_rescaled_e_deriv_e[walk_num][elec_num][4][elec_num][0:cord_num] | out | Electron-electron rescaled distances | From fba34e49822a7528c764eda23c6e76e6838bacf6 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 9 Jul 2021 00:45:17 +0200 Subject: [PATCH 88/92] Addd AO functions --- org/qmckl_ao.org | 157 +++++++++++++++++++++++++++++++++++++++++--- org/qmckl_tests.org | 80 +++++++++++++++------- 2 files changed, 204 insertions(+), 33 deletions(-) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index 152e37a..02d0bcc 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -106,6 +106,9 @@ int main() { | ~exponent~ | ~[prim_num]~ | Array of exponents | | ~coefficient~ | ~[prim_num]~ | Array of coefficients | | ~prim_factor~ | ~[prim_num]~ | Normalization factors of the primtives | + | ~ao_num~ | | Number of AOs | + | ~ao_factor~ | ~[ao_num]~ | Normalization factor of the AO | + | ~ao_cartesian~ | | If true, use polynomials. Otherwise, use spherical harmonics | Computed data: @@ -177,18 +180,19 @@ prim_factor = [ 1.0006253235944540e+01, 2.4169531573445120e+00, 7.96109248497664 #+begin_src c :comments org :tangle (eval h_private_type) typedef struct qmckl_ao_basis_struct { - int32_t uninitialized; int64_t shell_num; int64_t prim_num; + int64_t ao_num; int64_t * nucleus_index; int64_t * nucleus_shell_num; int32_t * shell_ang_mom; int64_t * shell_prim_num; int64_t * shell_prim_index; double * shell_factor; - double * exponent ; - double * coefficient ; - double * prim_factor ; + double * exponent; + double * coefficient; + double * prim_factor; + double * ao_factor; int64_t * nucleus_prim_index; double * coefficient_normalized; @@ -198,7 +202,10 @@ typedef struct qmckl_ao_basis_struct { int64_t primitive_vgl_date; double * shell_vgl; int64_t shell_vgl_date; + + int32_t uninitialized; bool provided; + bool ao_cartesian; char type; } qmckl_ao_basis_struct; #+end_src @@ -224,11 +231,10 @@ qmckl_exit_code qmckl_init_ao_basis(qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - ctx->ao_basis.uninitialized = (1 << 12) - 1; + ctx->ao_basis.uninitialized = (1 << 14) - 1; /* Default values */ - /* ctx->ao_basis. - ,*/ + ctx->ao_basis.ao_cartesian = true; return QMCKL_SUCCESS; } @@ -240,6 +246,7 @@ qmckl_exit_code qmckl_init_ao_basis(qmckl_context context) { 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_ao_num (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); @@ -248,6 +255,7 @@ 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); +double* qmckl_get_ao_basis_ao_factor (const qmckl_context context); #+end_src When all the data for the AOs have been provided, the following @@ -494,6 +502,44 @@ double* qmckl_get_ao_basis_prim_factor (const qmckl_context context) { } +int64_t qmckl_get_ao_basis_ao_num (const qmckl_context context) { + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return (int64_t) 0; + } + + 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 (int64_t) 0; + } + + assert (ctx->ao_basis.ao_num > (int64_t) 0); + return ctx->ao_basis.ao_num; +} + + +double* qmckl_get_ao_basis_ao_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 << 13; + + if ( (ctx->ao_basis.uninitialized & mask) != 0) { + return NULL; + } + + assert (ctx->ao_basis.ao_factor != NULL); + return ctx->ao_basis.ao_factor; +} + + bool qmckl_ao_basis_provided(const qmckl_context context) { if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { @@ -505,6 +551,9 @@ bool qmckl_ao_basis_provided(const qmckl_context context) { return ctx->ao_basis.provided; } + + + #+end_src ** Initialization functions @@ -516,6 +565,7 @@ bool qmckl_ao_basis_provided(const qmckl_context context) { 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); @@ -525,6 +575,8 @@ qmckl_exit_code qmckl_set_ao_basis_shell_factor (qmckl_context context, con 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 @@ -945,6 +997,7 @@ 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) { <> @@ -986,6 +1039,83 @@ qmckl_exit_code qmckl_set_ao_basis_prim_factor(qmckl_context context, const dou <> } + +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"); + } + + int64_t shell_num = qmckl_get_ao_basis_shell_num(context); + + 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; + + <> +} + + +qmckl_exit_code qmckl_set_ao_basis_ao_factor(qmckl_context context, const double* ao_factor) { + <> + + int32_t mask = 1 << 13; + + const int64_t ao_num = qmckl_get_ao_basis_ao_num(context); + if (ao_num == 0L) { + return qmckl_failwith( context, + QMCKL_FAILURE, + "qmckl_set_ao_basis_ao_factor", + "ao_num is not set"); + } + + + if (ctx->ao_basis.ao_factor != NULL) { + qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.ao_factor); + if (rc != QMCKL_SUCCESS) { + return qmckl_failwith( context, rc, + "qmckl_set_ao_basis_ao_factor", + NULL); + } + } + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ao_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_ao_factor", + NULL); + } + + memcpy(new_array, ao_factor, mem_info.size); + + ctx->ao_basis.ao_factor = new_array; + + <> +} + + +qmckl_exit_code qmckl_set_ao_basis_cartesian(qmckl_context context, const bool t) { + <> + + int32_t mask = 1; + ctx->ao_basis.ao_cartesian = t; + + <> +} #+end_src When the basis set is completely entered, other data structures are @@ -1273,8 +1403,9 @@ assert(rc == QMCKL_SUCCESS); assert(qmckl_nucleus_provided(context)); -const int64_t shell_num = chbrclf_shell_num; -const int64_t prim_num = chbrclf_prim_num; +const int64_t shell_num = chbrclf_shell_num; +const int64_t prim_num = chbrclf_prim_num; +const int64_t ao_num = chbrclf_ao_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]); @@ -1284,6 +1415,7 @@ 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]); +const double * ao_factor = &(chbrclf_basis_ao_factor[0]); char typ = 'G'; @@ -1335,6 +1467,13 @@ assert(!qmckl_ao_basis_provided(context)); rc = qmckl_set_ao_basis_prim_factor (context, prim_factor); 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); +assert(rc == QMCKL_SUCCESS); + assert(qmckl_ao_basis_provided(context)); #+end_src diff --git a/org/qmckl_tests.org b/org/qmckl_tests.org index 0fb684b..7d80c03 100644 --- a/org/qmckl_tests.org +++ b/org/qmckl_tests.org @@ -38,7 +38,7 @@ Br -1.218470 -0.187436 -0.028227 #+END_example Nuclear coordinates are stored in atomic units in transposed format. - + #+begin_src c :tangle ../tests/chbrclf.h #define chbrclf_nucl_num ((int64_t) 5) @@ -526,15 +526,16 @@ F 1 #+begin_src c :tangle ../tests/chbrclf.h #define chbrclf_shell_num 72 #define chbrclf_prim_num 297 +#define chbrclf_ao_num 263 int64_t chbrclf_basis_nucleus_index[chbrclf_nucl_num] = {0, 14, 23, 27, 53}; int64_t chbrclf_basis_nucleus_shell_num[chbrclf_nucl_num] = {14, 9, 14, 16, 19}; int32_t chbrclf_basis_shell_ang_mom[chbrclf_shell_num] = - {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 0, 0, 0, 0, 1, 1, 1, 2, 2, 0, + {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 0, 0, 0, 0, 1, 1, 1, 2, 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, - 2, 2, 2, 3, 3, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3}; + 2, 2, 2, 3, 3, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3}; int64_t chbrclf_basis_shell_prim_num[chbrclf_shell_num] = {10, 10, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 10, @@ -553,7 +554,38 @@ double chbrclf_basis_shell_factor[chbrclf_shell_num] = {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., - 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}; + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}; + +double chbrclf_basis_ao_factor[chbrclf_ao_num] = + {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1.}; + +int64_t chbrclf_basis_ao_shell[chbrclf_ao_num] = + {0, 1, 2, 3, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, + 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 15, 16, 17, 18, 18, 18, 19, 19, 19, 20, + 20, 20, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 23, 24, 25, 26, 27, 28, + 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 32, 32, 32, 33, 33, 33, + 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, + 36, 36, 36, 36, 36, 36, 36, 36, 36, 37, 38, 39, 40, 41, 42, 43, 43, 43, 44, 44, + 44, 45, 45, 45, 46, 46, 46, 47, 47, 47, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49, + 49, 49, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 53, 54, 55, 56, 57, 58, 59, 60, 60, 60, 61, 61, + 61, 62, 62, 62, 63, 63, 63, 64, 64, 64, 65, 65, 65, 66, 66, 66, 66, 66, 66, 67, + 67, 67, 67, 67, 67, 68, 68, 68, 68, 68, 68, 69, 69, 69, 69, 69, 69, 70, 70, 70, + 70, 70, 70, 70, 70, 70, 70, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71}; double chbrclf_basis_exponent[chbrclf_prim_num] = {8.2360000000000000e+03, 1.2350000000000000e+03, 2.8080000000000001e+02, @@ -1017,7 +1049,7 @@ double chbrclf_elec_coord[chbrclf_walk_num][chbrclf_elec_num][3] = { { * N2 - This test is mainly for the Jastrow factor and was supplied by + This test is mainly for the Jastrow factor and was supplied by Ramon Panades Baruetta. The coordinates and Jastrow coefficients have been taken from his fork of IRPJast. The core electrons are treated by pseudopotentials thus excluded from the actual calculation. @@ -1037,7 +1069,7 @@ N2 #+END_example Nuclear coordinates are stored in atomic units in transposed format. - + #+begin_src c :tangle ../tests/n2.h #define n2_nucl_num ((int64_t) 2) @@ -1061,11 +1093,11 @@ double n2_nucl_coord[3][n2_nucl_num] = #define n2_walk_num ((int64_t) 1) double n2_elec_coord[n2_walk_num][n2_elec_num][3] = { { - {-0.250655104764153 , 0.503070975550133 , -0.166554344502303}, - {-0.587812193472177 , -0.128751981129274 , 0.187773606533075}, - { 1.61335569047166 , -0.615556732874863 , -1.43165470979934 }, - {-4.901239896295210E-003 , -1.120440036458986E-002 , 1.99761909330422 }, - { 0.766647499681200 , -0.293515395797937 , 3.66454589201239 }, + {-0.250655104764153 , 0.503070975550133 , -0.166554344502303}, + {-0.587812193472177 , -0.128751981129274 , 0.187773606533075}, + { 1.61335569047166 , -0.615556732874863 , -1.43165470979934 }, + {-4.901239896295210E-003 , -1.120440036458986E-002 , 1.99761909330422 }, + { 0.766647499681200 , -0.293515395797937 , 3.66454589201239 }, {-0.127732483187947 , -0.138975497694196 , -8.669850480215846E-002}, {-0.232271834949124 , -1.059321673434182E-002 , -0.504862241464867}, { 1.09360863531826 , -2.036103063808752E-003 , -2.702796910818986E-002}, @@ -1075,25 +1107,25 @@ double n2_elec_coord[n2_walk_num][n2_elec_num][3] = { { #+end_src ** Jastrow related data - - This test is mainly for the Jastrow factor and was supplied by + + This test is mainly for the Jastrow factor and was supplied by Ramon Panades Baruetta. #+begin_src c :tangle ../tests/n2.h /* Jastrow related */ -#define n2_type_nucl_num ((int64_t) 1) -#define n2_aord_num ((int64_t) 5) -#define n2_bord_num ((int64_t) 5) -#define n2_cord_num ((int64_t) 23) +#define n2_type_nucl_num ((int64_t) 1) +#define n2_aord_num ((int64_t) 5) +#define n2_bord_num ((int64_t) 5) +#define n2_cord_num ((int64_t) 23) #define n2_dim_cord_vec ((int64_t) 23) int64_t n2_type_nucl_vector[n2_nucl_num] = { 1, 1}; -double n2_aord_vector[n2_aord_num + 1][n2_type_nucl_num] = { - { 0. }, +double n2_aord_vector[n2_aord_num + 1][n2_type_nucl_num] = { + { 0. }, { 0. }, {-0.380512}, {-0.157996}, @@ -1105,11 +1137,11 @@ double n2_bord_vector[n2_bord_num + 1] = { 0.15366 , 0.0672262 , 0.02157 , - 0.0073096 , + 0.0073096 , 0.002866 }; -double n2_cord_vector[n2_cord_num][n2_type_nucl_num] = { - { 5.717020e-01}, +double n2_cord_vector[n2_cord_num][n2_type_nucl_num] = { + { 5.717020e-01}, {-5.142530e-01}, {-5.130430e-01}, { 9.486000e-03}, @@ -1155,11 +1187,11 @@ double n2_cord_vector_full[n2_dim_cord_vec][n2_nucl_num] = { { 2.614000e-03, 2.614000e-03}, {-1.477000e-03, -1.477000e-03}, {-1.137000e-03, -1.137000e-03}, - {-4.010475e-02, -4.010475e-02}, + {-4.010475e-02, -4.010475e-02}, { 6.106710e-03, 6.106710e-03}}; double n2_lkpm_of_cindex[4][n2_dim_cord_vec] = { - {1, 1, 2, 0, 0, 0, 2, 1, 1, 2, 3, 0, 2, 1, 3, 0, 0, 1, 3, 1, 1, 0, 3}, + {1, 1, 2, 0, 0, 0, 2, 1, 1, 2, 3, 0, 2, 1, 3, 0, 0, 1, 3, 1, 1, 0, 3}, {1, 1, 3, 4, 0, 2, 2, 4, 0, 0, 2, 4, 1, 3, 1, 4, 0, 1, 1, 4, 1, 2, 0}, {4, 1, 0, 0, 4, 2, 1, 4, 5, 0, 2, 3, 5, 0, 0, 3, 5, 1, 3, 2, 5, 0, 1}, {2, 5, 1, 4, 1, 5, 0, 2, 1, 5, 1, 0, 1, 5, 2, 3, 0, 5, 1, 1, 0, 5, 2}}; From 75a93d12c67a61bc84e06d446883da0f7cd893e0 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sun, 11 Jul 2021 23:20:40 +0200 Subject: [PATCH 89/92] Added AO polynomials --- org/qmckl_ao.org | 704 ++++++++++++++++++++++++++++++++++++++++---- org/qmckl_tests.org | 2 +- tools/lib.org | 2 - 3 files changed, 650 insertions(+), 58 deletions(-) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index 02d0bcc..a01b18a 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -59,6 +59,7 @@ gradients and Laplacian of the atomic basis functions. #include #include #include "chbrclf.h" +#include "qmckl_ao_private_func.h" int main() { qmckl_context context; @@ -107,8 +108,9 @@ int main() { | ~coefficient~ | ~[prim_num]~ | Array of coefficients | | ~prim_factor~ | ~[prim_num]~ | Normalization factors of the primtives | | ~ao_num~ | | Number of AOs | - | ~ao_factor~ | ~[ao_num]~ | Normalization factor of the AO | | ~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: @@ -121,7 +123,9 @@ int main() { | ~primitive_vgl~ | ~[5][walk_num][elec_num][prim_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 | | ~shell_vgl~ | ~[5][walk_num][elec_num][shell_num]~ | Value, gradients, Laplacian of the primitives at electron positions | - | ~shell_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the shells at electron positions | + | ~shell_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the AOs at electron positions | + | ~ao_vgl~ | ~[5][walk_num][elec_num][ao_num]~ | Value, gradients, Laplacian of the primitives at electron positions | + | ~ao_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the AOs 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 | @@ -156,6 +160,7 @@ D 1 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.] @@ -202,6 +207,8 @@ typedef struct qmckl_ao_basis_struct { int64_t primitive_vgl_date; double * shell_vgl; int64_t shell_vgl_date; + double * ao_vgl; + int64_t ao_vgl_date; int32_t uninitialized; bool provided; @@ -248,6 +255,7 @@ 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_ao_num (const qmckl_context context); int64_t* qmckl_get_ao_basis_nucleus_index (const qmckl_context context); +int64_t* qmckl_get_ao_basis_nucleus_shell_num(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); @@ -775,7 +783,7 @@ qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const i qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; - mem_info.size = shell_num * sizeof(char); + mem_info.size = shell_num * sizeof(int32_t); int32_t * new_array = (int32_t*) qmckl_malloc(context, mem_info); if (new_array == NULL) { @@ -1208,7 +1216,7 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) { NULL); } - for (int64_t inucl=0 ; inucl < ctx->nucleus.num ; ++inucl) { + for (int64_t inucl=0 ; inucl < nucl_num ; ++inucl) { ctx->ao_basis.nucleus_max_ang_mom[inucl] = 0; for (int64_t ishell=ctx->ao_basis.nucleus_index[inucl] ; ishell < ctx->ao_basis.nucleus_index[inucl] + ctx->ao_basis.nucleus_shell_num[inucl] ; @@ -1417,7 +1425,7 @@ const double * coefficient = &(chbrclf_basis_coefficient[0]); const double * prim_factor = &(chbrclf_basis_prim_factor[0]); const double * ao_factor = &(chbrclf_basis_ao_factor[0]); -char typ = 'G'; +const char typ = 'G'; assert(!qmckl_ao_basis_provided(context)); @@ -1476,6 +1484,84 @@ assert(rc == QMCKL_SUCCESS); assert(qmckl_ao_basis_provided(context)); +int64_t shell_num_test ; +int64_t prim_num_test ; +int64_t ao_num_test ; +int64_t * nucleus_index_test ; +int64_t * nucleus_shell_num_test; +int32_t * shell_ang_mom_test ; +int64_t * shell_prim_num_test ; +int64_t * shell_prim_index_test ; +double * shell_factor_test ; +double * exponent_test ; +double * coefficient_test ; +double * prim_factor_test ; +double * ao_factor_test ; +char typ_test ; + + +typ_test = qmckl_get_ao_basis_type (context); +assert(typ == typ_test); + +shell_num_test = qmckl_get_ao_basis_shell_num (context); +assert(shell_num == shell_num_test); + +prim_num_test = qmckl_get_ao_basis_prim_num (context); +assert(prim_num == prim_num_test); + +nucleus_index_test = qmckl_get_ao_basis_nucleus_index (context); +for (int64_t i=0 ; i < nucl_num ; ++i) { + assert(nucleus_index_test[i] == nucleus_index[i]); + } + +nucleus_shell_num_test = qmckl_get_ao_basis_nucleus_shell_num (context); +for (int64_t i=0 ; i < nucl_num ; ++i) { + assert(nucleus_shell_num_test[i] == nucleus_shell_num[i]); + } + +shell_ang_mom_test = qmckl_get_ao_basis_shell_ang_mom (context); +for (int64_t i=0 ; i < shell_num ; ++i) { + assert(shell_ang_mom_test[i] == shell_ang_mom[i]); + } + +shell_factor_test = qmckl_get_ao_basis_shell_factor (context); +for (int64_t i=0 ; i < shell_num ; ++i) { + assert(shell_factor_test[i] == shell_factor[i]); +} + +shell_prim_num_test = qmckl_get_ao_basis_shell_prim_num (context); +for (int64_t i=0 ; i < shell_num ; ++i) { + assert(shell_prim_num_test[i] == shell_prim_num[i]); +} + +shell_prim_index_test = qmckl_get_ao_basis_shell_prim_index (context); +for (int64_t i=0 ; i < shell_num ; ++i) { + assert(shell_prim_index_test[i] == shell_prim_index[i]); +} + +exponent_test = qmckl_get_ao_basis_exponent(context); +for (int64_t i=0 ; i < prim_num ; ++i) { + assert(exponent_test[i] == exponent[i]); +} + +coefficient_test = qmckl_get_ao_basis_coefficient(context); +for (int64_t i=0 ; i < prim_num ; ++i) { + assert(coefficient_test[i] == coefficient[i]); +} + +prim_factor_test = qmckl_get_ao_basis_prim_factor (context); +for (int64_t i=0 ; i < prim_num ; ++i) { + assert(prim_factor_test[i] == prim_factor[i]); +} + +ao_num_test = qmckl_get_ao_basis_ao_num(context); +assert(ao_num == ao_num_test); + +ao_factor_test = qmckl_get_ao_basis_ao_factor (context); +for (int64_t i=0 ; i < ao_num ; ++i) { + assert(ao_factor_test[i] == ao_factor[i]); +} + #+end_src * Radial part @@ -2136,7 +2222,7 @@ qmckl_exit_code qmckl_provide_ao_basis_shell_vgl(qmckl_context context) if (ctx->ao_basis.shell_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 * + mem_info.size = ctx->ao_basis.shell_num * 5 * ctx->electron.num * ctx->electron.walk_num * sizeof(double); double* shell_vgl = (double*) qmckl_malloc(context, mem_info); @@ -2296,24 +2382,26 @@ integer function qmckl_compute_ao_basis_shell_gaussian_vgl_f(context, & end function qmckl_compute_ao_basis_shell_gaussian_vgl_f #+end_src +# #+CALL: generate_c_header(table=qmckl_ao_basis_shell_gaussian_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_ao_basis_shell_gaussian_vgl")) - #+begin_src c :tangle (eval h_private_func) :comments org :exports none -qmckl_exit_code qmckl_compute_ao_basis_shell_gaussian_vgl( + #+RESULTS: + #+begin_src c :tangle (eval h_private_func) :comments org + qmckl_exit_code qmckl_compute_ao_basis_shell_gaussian_vgl ( const qmckl_context context, - const int64_t prim_num, - const int64_t shell_num, - const int64_t elec_num, - const int64_t nucl_num, - const int64_t walk_num, + const int64_t prim_num, + const int64_t shell_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t walk_num, const int64_t* nucleus_shell_num, - const int64_t* shell_prim_index, const int64_t* nucleus_index, + const int64_t* shell_prim_index, const int64_t* shell_prim_num, - const double* elec_coord, - const double* nucl_coord, - const double* expo, - const double* coef_normalized, - double* const shell_vgl); + const double* elec_coord, + const double* nucl_coord, + const double* expo, + const double* coef_normalized, + double* const shell_vgl ); #+end_src #+CALL: generate_c_interface(table=qmckl_ao_basis_shell_gaussian_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_ao_basis_shell_gaussian_vgl")) @@ -2408,50 +2496,50 @@ nucl_2 = np.array( [ 1.168459237342663e+00, 1.125660720053393e+00, 2.83337031 #double prim_vgl[prim_num][5][walk_num][elec_num]; x = elec_26_w1 ; y = nucl_1 -a = [( 8.236000E+03, -1.130000E-04 ), - ( 1.235000E+03, -8.780000E-04 ), - ( 2.808000E+02, -4.540000E-03 ), - ( 7.927000E+01, -1.813300E-02 ), - ( 2.559000E+01, -5.576000E-02 ), - ( 8.997000E+00, -1.268950E-01 ), - ( 3.319000E+00, -1.703520E-01 ), - ( 9.059000E-01, 1.403820E-01 ), - ( 3.643000E-01, 5.986840E-01 ), - ( 1.285000E-01, 3.953890E-01 )] +a = [( 8.236000E+03, -1.130000E-04 * 6.1616545431994848e+02 ), + ( 1.235000E+03, -8.780000E-04 * 1.4847738511079908e+02 ), + ( 2.808000E+02, -4.540000E-03 * 4.8888635917437597e+01 ), + ( 7.927000E+01, -1.813300E-02 * 1.8933972232608955e+01 ), + ( 2.559000E+01, -5.576000E-02 * 8.1089160941724145e+00 ), + ( 8.997000E+00, -1.268950E-01 * 3.7024003863155635e+00 ), + ( 3.319000E+00, -1.703520E-01 * 1.7525302846177560e+00 ), + ( 9.059000E-01, 1.403820E-01 * 6.6179013183966806e-01 ), + ( 3.643000E-01, 5.986840E-01 * 3.3419848027174592e-01 ), + ( 1.285000E-01, 3.953890E-01 * 1.5296336817449557e-01 )] -print ( "[1][0][0][26] : %e"% f(a,x,y)) -print ( "[1][1][0][26] : %e"% df(a,x,y,1)) -print ( "[1][2][0][26] : %e"% df(a,x,y,2)) -print ( "[1][3][0][26] : %e"% df(a,x,y,3)) -print ( "[1][4][0][26] : %e"% lf(a,x,y)) +print ( "[1][0][0][26] : %25.15e"% f(a,x,y)) +print ( "[1][1][0][26] : %25.15e"% df(a,x,y,1)) +print ( "[1][2][0][26] : %25.15e"% df(a,x,y,2)) +print ( "[1][3][0][26] : %25.15e"% df(a,x,y,3)) +print ( "[1][4][0][26] : %25.15e"% lf(a,x,y)) x = elec_15_w2 ; y = nucl_2 -a = [(3.387000E+01, 6.068000E-03), - (5.095000E+00, 4.530800E-02), - (1.159000E+00, 2.028220E-01), - (3.258000E-01, 5.039030E-01), - (1.027000E-01, 3.834210E-01)] +a = [(3.387000E+01, 6.068000E-03 *1.0006253235944540e+01), + (5.095000E+00, 4.530800E-02 *2.4169531573445120e+00), + (1.159000E+00, 2.028220E-01 *7.9610924849766440e-01), + (3.258000E-01, 5.039030E-01 *3.0734305383061117e-01), + (1.027000E-01, 3.834210E-01 *1.2929684417481876e-01)] -print ( "[14][0][1][15] : %e"% f(a,x,y)) -print ( "[14][1][1][15] : %e"% df(a,x,y,1)) -print ( "[14][2][1][15] : %e"% df(a,x,y,2)) -print ( "[14][3][1][15] : %e"% df(a,x,y,3)) -print ( "[14][4][1][15] : %e"% lf(a,x,y)) +print ( "[0][1][15][14] : %25.15e"% f(a,x,y)) +print ( "[1][1][15][14] : %25.15e"% df(a,x,y,1)) +print ( "[2][1][15][14] : %25.15e"% df(a,x,y,2)) +print ( "[3][1][15][14] : %25.15e"% df(a,x,y,3)) +print ( "[4][1][15][14] : %25.15e"% lf(a,x,y)) #+end_src #+RESULTS: #+begin_example - [1][0][0][26] : 1.875569e-01 - [1][1][0][26] : -2.615250e-02 - [1][2][0][26] : -1.333535e-01 - [1][3][0][26] : 1.218483e-01 - [1][4][0][26] : 3.227973e-02 - [14][0][1][15] : 4.509748e-02 - [14][1][1][15] : 3.203918e-02 - [14][2][1][15] : 2.887081e-02 - [14][3][1][15] : 5.836910e-03 - [14][4][1][15] : 1.564721e-02 + [1][0][0][26] : 3.564393437193867e-02 + [1][1][0][26] : -6.030177988891605e-03 + [1][2][0][26] : -3.074832579871845e-02 + [1][3][0][26] : 2.809546963133958e-02 + [1][4][0][26] : 1.903338597841753e-02 + [0][1][15][14] : 5.928089771361000e-03 + [1][1][15][14] : 4.355862298893037e-03 + [2][1][15][14] : 3.925108924950765e-03 + [3][1][15][14] : 7.935527764416084e-04 + [4][1][15][14] : 2.697495005143935e-03 #+end_example *** Test @@ -2511,6 +2599,22 @@ assert( fabs(shell_vgl[4][1][15][14] - ( 2.708246573703548e-03)) < 1.e-14 ); #+end_src * Polynomial part + + Going from the atomic basis set to AOs implies a systematic + construction of all the angular functions of each shell. We + consider two cases for the angular functions: the real-valued + spherical harmonics, and the polynomials in Cartesian coordinates. + In the case of spherical harmonics, the AOs are ordered in + increasing magnetic quantum number ($-l \le m \le l$), and in the + case of polynomials we choose the canonical ordering, i.e + + \begin{eqnarray} + p & : & p_x, p_y, p_z \nonumber \\ + d & : & d_{xx}, d_{xy}, d_{xz}, d_{yy}, d_{yz}, d_{zz} \nonumber \\ + f & : & f_{xxx}, f_{xxy}, f_{xxz}, f_{xyy}, f_{xyz}, f_{xzz}, f_{yyy}, f_{yyz}, f_{yzz}, f_{zzz} \nonumber \\ + {\rm etc.} \nonumber + \end{eqnarray} + ** General functions for Powers of $x-X_i$ :PROPERTIES: :Name: qmckl_ao_power @@ -2814,7 +2918,6 @@ integer function qmckl_ao_polynomial_vgl_f(context, X, R, lmax, n, L, ldl, VGL, real*8 :: Y(3) integer :: lmax_array(3) real*8 :: pows(-2:lmax,3) - integer, external :: qmckl_ao_power_f double precision :: xy, yz, xz double precision :: da, db, dc, dd @@ -3084,6 +3187,497 @@ end function test_qmckl_ao_polynomial_vgl #+end_src * Combining radial and polynomial parts + +*** TODO Get + + #+begin_src c :comments org :tangle (eval h_func) :noweb yes +qmckl_exit_code qmckl_get_ao_vgl(qmckl_context context, double* const ao_vgl); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_get_ao_vgl(qmckl_context context, double* const ao_vgl) { + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + qmckl_exit_code rc; + + rc = qmckl_provide_ao_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.ao_num * 5 * ctx->electron.num * ctx->electron.walk_num; + memcpy(ao_vgl, ctx->ao_basis.ao_vgl, sze * sizeof(double)); + + return QMCKL_SUCCESS; +} + #+end_src + + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none + interface + integer(c_int32_t) function qmckl_get_ao_vgl (context, ao_vgl) & + bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + + integer (c_int64_t) , intent(in) , value :: context + double precision, intent(out) :: ao_vgl(*) + end function + end interface + #+end_src + +*** TODO Provide + + #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none +qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code qmckl_provide_ao_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_vgl", + NULL); + } + + if(!(ctx->electron.provided)) { + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_electron", + NULL); + } + + /* Compute if necessary */ + if (ctx->electron.coord_new_date > ctx->ao_basis.ao_vgl_date) { + + qmckl_exit_code rc; + + /* Provide required data */ + rc = qmckl_provide_ao_basis_shell_vgl(context); + if (rc != QMCKL_SUCCESS) { + return qmckl_failwith( context, rc, "qmckl_provide_ao_basis_shell_vgl", NULL); + } + + /* Allocate array */ + if (ctx->ao_basis.ao_vgl == NULL) { + + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->ao_basis.ao_num * 5 * ctx->electron.num * + ctx->electron.walk_num * sizeof(double); + double* ao_vgl = (double*) qmckl_malloc(context, mem_info); + + if (ao_vgl == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_ao_basis_ao_vgl", + NULL); + } + ctx->ao_basis.ao_vgl = ao_vgl; + } + + rc = qmckl_compute_ao_vgl(context, + ctx->ao_basis.ao_num, + ctx->ao_basis.shell_num, + ctx->electron.num, + ctx->nucleus.num, + ctx->electron.walk_num, + ctx->electron.coord_new, + ctx->nucleus.coord, + ctx->ao_basis.nucleus_index, + ctx->ao_basis.nucleus_shell_num, + ctx->ao_basis.nucleus_range, + ctx->ao_basis.nucleus_max_ang_mom, + ctx->ao_basis.shell_ang_mom, + ctx->ao_basis.shell_vgl, + ctx->ao_basis.ao_vgl); + if (rc != QMCKL_SUCCESS) { + return rc; + } + + ctx->ao_basis.ao_vgl_date = ctx->date; + } + + return QMCKL_SUCCESS; +} + #+end_src + +*** TODO Compute + :PROPERTIES: + :Name: qmckl_compute_ao_vgl + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_ao_vgl_args + | ~qmckl_context~ | ~context~ | in | Global state | + | ~int64_t~ | ~ao_num~ | in | Number of AOs | + | ~int64_t~ | ~shell_num~ | in | Number of shells | + | ~int64_t~ | ~elec_num~ | in | Number of electrons | + | ~int64_t~ | ~nucl_num~ | in | Number of nuclei | + | ~int64_t~ | ~walk_num~ | in | Number of walkers | + | ~double~ | ~elec_coord[walk_num][3][elec_num]~ | in | Electron coordinates | + | ~double~ | ~nucl_coord[3][nucl_num]~ | in | Nuclear coordinates | + | ~int64_t~ | ~nucleus_index[nucl_num]~ | in | Index of the 1st shell of each nucleus | + | ~int64_t~ | ~nucleus_shell_num[nucl_num]~ | in | Number of shells per nucleus | + | ~double~ | ~nucleus_range[nucl_num]~ | in | Range beyond which all is zero | + | ~int32_t~ | ~nucleus_max_ang_mom[nucl_num]~ | in | Maximum angular momentum per nucleus | + | ~int32_t~ | ~shell_ang_mom[shell_num]~ | in | Angular momentum of each shell | + | ~double~ | ~shell_vgl[5][walk_num][elec_num][shell_num]~ | in | Value, gradients and Laplacian of the shells | + | ~double~ | ~ao_vgl[5][walk_num][elec_num][ao_num]~ | out | Value, gradients and Laplacian of the AOs | + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes +integer function qmckl_compute_ao_vgl_f(context, & + ao_num, shell_num, elec_num, nucl_num, walk_num, & + elec_coord, nucl_coord, nucleus_index, nucleus_shell_num, & + nucleus_range, nucleus_max_ang_mom, shell_ang_mom, & + shell_vgl, ao_vgl) & + result(info) + use qmckl + implicit none + integer(qmckl_context), intent(in) :: context + integer*8 , intent(in) :: ao_num + integer*8 , intent(in) :: shell_num + integer*8 , intent(in) :: elec_num + integer*8 , intent(in) :: nucl_num + integer*8 , intent(in) :: walk_num + double precision , intent(in) :: elec_coord(elec_num,3,walk_num) + double precision , intent(in) :: nucl_coord(nucl_num,3) + integer*8 , intent(in) :: nucleus_index(nucl_num) + integer*8 , intent(in) :: nucleus_shell_num(nucl_num) + double precision , intent(in) :: nucleus_range(nucl_num) + integer , intent(in) :: nucleus_max_ang_mom(nucl_num) + integer , intent(in) :: shell_ang_mom(shell_num) + double precision , intent(in) :: shell_vgl(shell_num,elec_num,walk_num,5) + double precision , intent(out) :: ao_vgl(ao_num,elec_num,walk_num,5) + + double precision :: e_coord(3), n_coord(3) + integer*8 :: n_poly + integer :: l, il, k + integer*8 :: ielec, inucl, ishell, iwalk + integer :: lstart(0:20) + double precision :: x, y, z, r2 + double precision :: cutoff + integer, external :: qmckl_ao_polynomial_vgl_f + + double precision, allocatable :: poly_vgl(:,:) + integer , allocatable :: powers(:,:) + + allocate(poly_vgl(5,ao_num), powers(3,ao_num)) + + ! Pre-computed data + do l=0,20 + lstart(l) = l*(l+1)*(l+2)/6 +1 + end do + + info = QMCKL_SUCCESS + + ! Don't compute polynomials when the radial part is zero. + ! TODO : Use numerical precision here + cutoff = -dlog(1.d-15) + + do iwalk = 1,walk_num + do ielec = 1, elec_num + e_coord(1) = elec_coord(ielec,1,iwalk) + e_coord(2) = elec_coord(ielec,2,iwalk) + e_coord(3) = elec_coord(ielec,3,iwalk) + k=1 + do inucl=1,nucl_num + n_coord(1) = nucl_coord(inucl,1) + n_coord(2) = nucl_coord(inucl,2) + n_coord(3) = nucl_coord(inucl,3) + + ! Test if the electron is in the range of the nucleus + x = e_coord(1) - n_coord(1) + y = e_coord(2) - n_coord(2) + z = e_coord(3) - n_coord(3) + + r2 = x*x + z*z + z*z + + if (r2 > cutoff*nucleus_range(inucl)) then + cycle + end if + + ! Compute polynomials + info = qmckl_ao_polynomial_vgl_f(context, e_coord, n_coord, & + nucleus_max_ang_mom(inucl), n_poly, powers, 3_8, & + poly_vgl, 5_8) + + ! Loop over shells + do ishell = nucleus_index(inucl)+1, nucleus_index(inucl)+nucleus_shell_num(inucl) + l = shell_ang_mom(ishell) + do il = lstart(l), lstart(l+1)-1 + ! Value + ao_vgl(k,ielec,iwalk,1) = & + poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,1) + + ! Grad_x + ao_vgl(k,ielec,iwalk,2) = & + poly_vgl(2,il) * shell_vgl(ishell,ielec,iwalk,1) + & + poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,2) + + ! Grad_y + ao_vgl(k,ielec,iwalk,3) = & + poly_vgl(3,il) * shell_vgl(ishell,ielec,iwalk,1) + & + poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,3) + + ! Grad_z + ao_vgl(k,ielec,iwalk,4) = & + poly_vgl(4,il) * shell_vgl(ishell,ielec,iwalk,1) + & + poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,4) + + ! Lapl_z + ao_vgl(k,ielec,iwalk,5) = & + poly_vgl(5,il) * shell_vgl(ishell,ielec,iwalk,1) + & + poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,5) + & + 2.d0 * ( & + poly_vgl(2,il) * shell_vgl(ishell,ielec,iwalk,2) + & + poly_vgl(3,il) * shell_vgl(ishell,ielec,iwalk,3) + & + poly_vgl(4,il) * shell_vgl(ishell,ielec,iwalk,4) ) + + k = k+1 + end do + end do + end do + end do + end do + + deallocate(poly_vgl, powers) +end function qmckl_compute_ao_vgl_f + #+end_src + +# #+CALL: generate_c_header(table=qmckl_ao_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_ao_vgl")) + + #+RESULTS: + #+begin_src c :tangle (eval h_private_func) :comments org + qmckl_exit_code qmckl_compute_ao_vgl ( + const qmckl_context context, + const int64_t ao_num, + const int64_t shell_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t walk_num, + const double* elec_coord, + const double* nucl_coord, + const int64_t* nucleus_index, + const int64_t* nucleus_shell_num, + const double* nucleus_range, + const int32_t* nucleus_max_ang_mom, + const int32_t* shell_ang_mom, + const double* shell_vgl, + double* const ao_vgl ); + #+end_src + + #+CALL: generate_c_interface(table=qmckl_ao_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_ao_vgl")) + + #+RESULTS: + #+begin_src f90 :tangle (eval f) :comments org :exports none + integer(c_int32_t) function qmckl_compute_ao_vgl & + (context, & + ao_num, & + shell_num, & + elec_num, & + nucl_num, & + walk_num, & + elec_coord, & + nucl_coord, & + nucleus_index, & + nucleus_shell_num, & + nucleus_range, & + nucleus_max_ang_mom, & + shell_ang_mom, & + shell_vgl, & + ao_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 :: ao_num + integer (c_int64_t) , intent(in) , value :: shell_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 + real (c_double ) , intent(in) :: elec_coord(elec_num,3,walk_num) + real (c_double ) , intent(in) :: nucl_coord(nucl_num,3) + integer (c_int64_t) , intent(in) :: nucleus_index(nucl_num) + integer (c_int64_t) , intent(in) :: nucleus_shell_num(nucl_num) + real (c_double ) , intent(in) :: nucleus_range(nucl_num) + integer (c_int32_t) , intent(in) :: nucleus_max_ang_mom(nucl_num) + integer (c_int32_t) , intent(in) :: shell_ang_mom(shell_num) + real (c_double ) , intent(in) :: shell_vgl(shell_num,elec_num,walk_num,5) + real (c_double ) , intent(out) :: ao_vgl(ao_num,elec_num,walk_num,5) + + integer(c_int32_t), external :: qmckl_compute_ao_vgl_f + info = qmckl_compute_ao_vgl_f & + (context, & + ao_num, & + shell_num, & + elec_num, & + nucl_num, & + walk_num, & + elec_coord, & + nucl_coord, & + nucleus_index, & + nucleus_shell_num, & + nucleus_range, & + nucleus_max_ang_mom, & + shell_ang_mom, & + shell_vgl, & + ao_vgl) + + end function qmckl_compute_ao_vgl + #+end_src + + #+begin_src python :results output :exports none +import numpy as np + +def f(a,x,y): + return np.sum( [c * np.exp( -b*(np.linalg.norm(x-y))**2) for b,c in a] ) + +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( [ -2.302574592081335e+00, -3.542027060505035e-01, -5.334129934317614e-02] ) + +#double prim_vgl[prim_num][5][walk_num][elec_num]; +x = elec_26_w1 ; y = nucl_1 +a = [( 403.830000, 0.001473 * 5.9876577632594533e+04), + ( 121.170000, 0.012672 * 7.2836806319891484e+03), + ( 46.345000, 0.058045 * 1.3549226646722386e+03), + ( 19.721000, 0.170510 * 3.0376315094739988e+02), + ( 8.862400, 0.318596 * 7.4924579607137730e+01), + ( 3.996200, 0.384502 * 1.8590543353806009e+01), + ( 1.763600, 0.273774 * 4.4423176930919421e+00), + ( 0.706190, 0.074397 * 8.9541051939952665e-01)] + +print ( "[0][0][26][219] : %25.15e"%(f(a,x,y) * (x[0] - y[0])**2) ) +print ( "[1][0][26][219] : %25.15e"%(df(a,x,y,1)* (x[0] - y[0]) * (x[1] - y[1]) + 2.*f(a,x,y) * (x[0] - y[0])) ) + +print ( "[0][0][26][220] : %25.15e"%(f(a,x,y) * (x[0] - y[0]) * (x[1] - y[1])) ) +print ( "[1][0][26][220] : %25.15e"%(df(a,x,y,1)* (x[0] - y[0]) * (x[1] - y[1]) + f(a,x,y) * (x[1] - y[1])) ) + +print ( "[0][0][26][221] : %25.15e"%(f(a,x,y) * (x[0] - y[0]) * (x[2] - y[2])) ) +print ( "[1][0][26][221] : %25.15e"%(df(a,x,y,1)* (x[0] - y[0]) * (x[2] - y[2]) + f(a,x,y) * (x[2] - y[2])) ) + +print ( "[0][0][26][222] : %25.15e"%(f(a,x,y) * (x[1] - y[1]) * (x[1] - y[1])) ) +print ( "[1][0][26][222] : %25.15e"%(df(a,x,y,1)* (x[1] - y[1]) * (x[1] - y[1])) ) + +print ( "[0][0][26][223] : %25.15e"%(f(a,x,y) * (x[1] - y[1]) * (x[2] - y[2])) ) +print ( "[1][0][26][223] : %25.15e"%(df(a,x,y,1)* (x[1] - y[1]) * (x[2] - y[2])) ) + +print ( "[0][0][26][224] : %25.15e"%(f(a,x,y) * (x[2] - y[2]) * (x[2] - y[2])) ) +print ( "[1][0][26][224] : %25.15e"%(df(a,x,y,1)* (x[2] - y[2]) * (x[2] - y[2])) ) + + #+end_src + + #+RESULTS: + #+begin_example + [0][0][26][219] : 1.020302912653649e-08 + [1][0][26][219] : -4.153046808203204e-08 + [0][0][26][220] : 8.756380857379661e-09 + [1][0][26][220] : -4.460176677299534e-08 + [0][0][26][221] : -2.705688401075445e-09 + [1][0][26][221] : 1.378177639720419e-08 + [0][0][26][222] : 7.514847283937212e-09 + [1][0][26][222] : -4.025905373647693e-08 + [0][0][26][223] : -2.322059246071533e-09 + [1][0][26][223] : 1.243989457599443e-08 + [0][0][26][224] : 7.175074806631758e-10 + [1][0][26][224] : -3.843880138733679e-09 + #+end_example + +*** TODO Test + + #+begin_src c :tangle (eval c_test) :exports none +{ +#define walk_num chbrclf_walk_num +#define elec_num chbrclf_elec_num +#define shell_num chbrclf_shell_num +#define ao_num chbrclf_ao_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 ao_vgl[5][walk_num][elec_num][ao_num]; + +rc = qmckl_get_ao_vgl(context, &(ao_vgl[0][0][0][0])); +assert (rc == QMCKL_SUCCESS); + +printf("\n"); +printf(" ao_vgl ao_vgl[0][0][26][219] %25.15e\n", ao_vgl[0][0][26][219]); +printf(" ao_vgl ao_vgl[1][0][26][219] %25.15e\n", ao_vgl[1][0][26][219]); +printf(" ao_vgl ao_vgl[0][0][26][220] %25.15e\n", ao_vgl[0][0][26][220]); +printf(" ao_vgl ao_vgl[1][0][26][220] %25.15e\n", ao_vgl[1][0][26][220]); +printf(" ao_vgl ao_vgl[0][0][26][221] %25.15e\n", ao_vgl[0][0][26][221]); +printf(" ao_vgl ao_vgl[1][0][26][221] %25.15e\n", ao_vgl[1][0][26][221]); +printf(" ao_vgl ao_vgl[0][0][26][222] %25.15e\n", ao_vgl[0][0][26][222]); +printf(" ao_vgl ao_vgl[1][0][26][222] %25.15e\n", ao_vgl[1][0][26][222]); +printf(" ao_vgl ao_vgl[0][0][26][223] %25.15e\n", ao_vgl[0][0][26][223]); +printf(" ao_vgl ao_vgl[1][0][26][223] %25.15e\n", ao_vgl[1][0][26][223]); +printf(" ao_vgl ao_vgl[0][0][26][224] %25.15e\n", ao_vgl[0][0][26][224]); +printf(" ao_vgl ao_vgl[1][0][26][224] %25.15e\n", ao_vgl[1][0][26][224]); +printf("\n"); + +assert( fabs(ao_vgl[0][0][26][219] - ( 1.020298798341620e-08)) < 1.e-14 ); +assert( fabs(ao_vgl[1][0][26][219] - ( -4.928035238010602e-08)) < 1.e-14 ); +assert( fabs(ao_vgl[0][0][26][220] - ( 8.756345547784206e-09)) < 1.e-14 ); +assert( fabs(ao_vgl[1][0][26][220] - ( -4.460158690983819e-08)) < 1.e-14 ); +assert( fabs(ao_vgl[0][0][26][221] - ( -2.705677490544664e-09)) < 1.e-14 ); +assert( fabs(ao_vgl[1][0][26][221] - ( 1.378172082017231e-08)) < 1.e-14 ); +assert( fabs(ao_vgl[0][0][26][222] - ( 7.514816980753531e-09)) < 1.e-14 ); +assert( fabs(ao_vgl[1][0][26][222] - ( -4.025889138635182e-08)) < 1.e-14 ); +assert( fabs(ao_vgl[0][0][26][223] - ( -2.322049882502961e-09)) < 1.e-14 ); +assert( fabs(ao_vgl[1][0][26][223] - ( 1.243984441042288e-08)) < 1.e-14 ); +assert( fabs(ao_vgl[0][0][26][224] - ( 7.175045873560788e-10)) < 1.e-14 ); +assert( fabs(ao_vgl[1][0][26][224] - ( -3.843864637762753e-09)) < 1.e-14 ); +} + + #+end_src + * End of files :noexport: #+begin_src c :tangle (eval h_private_type) diff --git a/org/qmckl_tests.org b/org/qmckl_tests.org index 7d80c03..61f3151 100644 --- a/org/qmckl_tests.org +++ b/org/qmckl_tests.org @@ -528,7 +528,7 @@ F 1 #define chbrclf_prim_num 297 #define chbrclf_ao_num 263 -int64_t chbrclf_basis_nucleus_index[chbrclf_nucl_num] = {0, 14, 23, 27, 53}; +int64_t chbrclf_basis_nucleus_index[chbrclf_nucl_num] = {0, 14, 23, 37, 53}; int64_t chbrclf_basis_nucleus_shell_num[chbrclf_nucl_num] = {14, 9, 14, 16, 19}; diff --git a/tools/lib.org b/tools/lib.org index 01d86fb..d8e642a 100644 --- a/tools/lib.org +++ b/tools/lib.org @@ -96,7 +96,6 @@ def parse_table(table): return result #+END_SRC - *** Generates a C header #+NAME: generate_c_header @@ -129,7 +128,6 @@ return template #+END_SRC - *** Generates a C interface to the Fortran function #+NAME: generate_c_interface From cdf92e2464b47da0e9a4f0815dc8bdd1aac8be0d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 13 Jul 2021 09:54:43 +0200 Subject: [PATCH 90/92] Added AO_factor to AOs --- org/qmckl_ao.org | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index a01b18a..e9de5ec 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -3188,7 +3188,7 @@ end function test_qmckl_ao_polynomial_vgl * Combining radial and polynomial parts -*** TODO Get +*** Get #+begin_src c :comments org :tangle (eval h_func) :noweb yes qmckl_exit_code qmckl_get_ao_vgl(qmckl_context context, double* const ao_vgl); @@ -3230,7 +3230,7 @@ qmckl_exit_code qmckl_get_ao_vgl(qmckl_context context, double* const ao_vgl) { end interface #+end_src -*** TODO Provide +*** Provide #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context); @@ -3302,6 +3302,7 @@ qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context) ctx->ao_basis.nucleus_range, ctx->ao_basis.nucleus_max_ang_mom, ctx->ao_basis.shell_ang_mom, + ctx->ao_basis.ao_factor, ctx->ao_basis.shell_vgl, ctx->ao_basis.ao_vgl); if (rc != QMCKL_SUCCESS) { @@ -3315,7 +3316,7 @@ qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context) } #+end_src -*** TODO Compute +*** Compute :PROPERTIES: :Name: qmckl_compute_ao_vgl :CRetType: qmckl_exit_code @@ -3336,6 +3337,7 @@ qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context) | ~double~ | ~nucleus_range[nucl_num]~ | in | Range beyond which all is zero | | ~int32_t~ | ~nucleus_max_ang_mom[nucl_num]~ | in | Maximum angular momentum per nucleus | | ~int32_t~ | ~shell_ang_mom[shell_num]~ | in | Angular momentum of each shell | + | ~double~ | ~ao_factor[ao_num]~ | in | Normalization factor of the AOs | | ~double~ | ~shell_vgl[5][walk_num][elec_num][shell_num]~ | in | Value, gradients and Laplacian of the shells | | ~double~ | ~ao_vgl[5][walk_num][elec_num][ao_num]~ | out | Value, gradients and Laplacian of the AOs | @@ -3344,7 +3346,7 @@ integer function qmckl_compute_ao_vgl_f(context, & ao_num, shell_num, elec_num, nucl_num, walk_num, & elec_coord, nucl_coord, nucleus_index, nucleus_shell_num, & nucleus_range, nucleus_max_ang_mom, shell_ang_mom, & - shell_vgl, ao_vgl) & + ao_factor, shell_vgl, ao_vgl) & result(info) use qmckl implicit none @@ -3361,6 +3363,7 @@ integer function qmckl_compute_ao_vgl_f(context, & double precision , intent(in) :: nucleus_range(nucl_num) integer , intent(in) :: nucleus_max_ang_mom(nucl_num) integer , intent(in) :: shell_ang_mom(shell_num) + double precision , intent(in) :: ao_factor(ao_num) double precision , intent(in) :: shell_vgl(shell_num,elec_num,walk_num,5) double precision , intent(out) :: ao_vgl(ao_num,elec_num,walk_num,5) @@ -3422,32 +3425,36 @@ integer function qmckl_compute_ao_vgl_f(context, & do il = lstart(l), lstart(l+1)-1 ! Value ao_vgl(k,ielec,iwalk,1) = & - poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,1) + poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,1) * ao_factor(k) ! Grad_x - ao_vgl(k,ielec,iwalk,2) = & + ao_vgl(k,ielec,iwalk,2) = ( & poly_vgl(2,il) * shell_vgl(ishell,ielec,iwalk,1) + & - poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,2) + poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,2) & + ) * ao_factor(k) ! Grad_y - ao_vgl(k,ielec,iwalk,3) = & + ao_vgl(k,ielec,iwalk,3) = ( & poly_vgl(3,il) * shell_vgl(ishell,ielec,iwalk,1) + & - poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,3) + poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,3) & + ) * ao_factor(k) ! Grad_z - ao_vgl(k,ielec,iwalk,4) = & + ao_vgl(k,ielec,iwalk,4) = ( & poly_vgl(4,il) * shell_vgl(ishell,ielec,iwalk,1) + & - poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,4) + poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,4) & + ) * ao_factor(k) ! Lapl_z - ao_vgl(k,ielec,iwalk,5) = & + ao_vgl(k,ielec,iwalk,5) = ( & poly_vgl(5,il) * shell_vgl(ishell,ielec,iwalk,1) + & poly_vgl(1,il) * shell_vgl(ishell,ielec,iwalk,5) + & 2.d0 * ( & poly_vgl(2,il) * shell_vgl(ishell,ielec,iwalk,2) + & poly_vgl(3,il) * shell_vgl(ishell,ielec,iwalk,3) + & - poly_vgl(4,il) * shell_vgl(ishell,ielec,iwalk,4) ) - + poly_vgl(4,il) * shell_vgl(ishell,ielec,iwalk,4) ) & + ) * ao_factor(k) + k = k+1 end do end do @@ -3477,6 +3484,7 @@ end function qmckl_compute_ao_vgl_f const double* nucleus_range, const int32_t* nucleus_max_ang_mom, const int32_t* shell_ang_mom, + const double* ao_factor, const double* shell_vgl, double* const ao_vgl ); #+end_src @@ -3499,6 +3507,7 @@ end function qmckl_compute_ao_vgl_f nucleus_range, & nucleus_max_ang_mom, & shell_ang_mom, & + ao_factor, & shell_vgl, & ao_vgl) & bind(C) result(info) @@ -3519,6 +3528,7 @@ end function qmckl_compute_ao_vgl_f real (c_double ) , intent(in) :: nucleus_range(nucl_num) integer (c_int32_t) , intent(in) :: nucleus_max_ang_mom(nucl_num) integer (c_int32_t) , intent(in) :: shell_ang_mom(shell_num) + real (c_double ) , intent(in) :: ao_factor(ao_num) real (c_double ) , intent(in) :: shell_vgl(shell_num,elec_num,walk_num,5) real (c_double ) , intent(out) :: ao_vgl(ao_num,elec_num,walk_num,5) @@ -3537,6 +3547,7 @@ end function qmckl_compute_ao_vgl_f nucleus_range, & nucleus_max_ang_mom, & shell_ang_mom, & + ao_factor, & shell_vgl, & ao_vgl) @@ -3617,7 +3628,7 @@ print ( "[1][0][26][224] : %25.15e"%(df(a,x,y,1)* (x[2] - y[2]) * (x[2] - y[2])) [1][0][26][224] : -3.843880138733679e-09 #+end_example -*** TODO Test +*** Test #+begin_src c :tangle (eval c_test) :exports none { From c8cad599221da329e748b85efd1f55eff9d03fd5 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 19 Jul 2021 09:26:05 +0200 Subject: [PATCH 91/92] Added Fortran interfaces --- org/qmckl_ao.org | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index e9de5ec..647be4a 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -1388,6 +1388,36 @@ interface integer (c_int64_t) , intent(in) , value :: context real (c_double) , intent(in) :: prim_factor(*) end function +end interface +interface + integer(c_int32_t) function qmckl_set_ao_basis_ao_num(context, num) & + bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + integer (c_int64_t) , intent(in) , value :: context + 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) + use, intrinsic :: iso_c_binding + import + implicit none + integer (c_int64_t) , intent(in) , value :: context + logical (c_bool) , intent(in) , value :: cartesian + end function end interface #+end_src From e5806e676b5695f258b3972009caba5a414c5d0a Mon Sep 17 00:00:00 2001 From: Pablo de Oliveira Castro Date: Fri, 23 Jul 2021 09:02:25 +0200 Subject: [PATCH 92/92] Make sure qmckl.h can be imported from C++ (#26) When qmckl.h is included in a C++ file wrap the definitions in an extern "C" block to avoid mangling. --- tools/build_qmckl_h.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/build_qmckl_h.sh b/tools/build_qmckl_h.sh index 6365689..3ddeada 100755 --- a/tools/build_qmckl_h.sh +++ b/tools/build_qmckl_h.sh @@ -85,6 +85,10 @@ cat << EOF > ${OUTPUT} #ifndef __QMCKL_H__ #define __QMCKL_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -100,6 +104,9 @@ do done cat << EOF >> ${OUTPUT} +#ifdef __cplusplus +} +#endif #endif EOF