diff --git a/README.html b/README.html index f92690e..35d7e82 100644 --- a/README.html +++ b/README.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + QMCkl source code documentation @@ -316,6 +316,7 @@ for the JavaScript code in this tag.
  • Context
  • Memory management
  • Numerical precision
  • +
  • Nucleus
  • Electrons
  • Atomic Orbitals
  • Inter-particle distances
  • @@ -349,7 +350,7 @@ and bug reports should be submitted at

    Author: TREX CoE

    -

    Created: 2021-05-12 Wed 21:59

    +

    Created: 2021-05-15 Sat 23:32

    Validate

    diff --git a/qmckl.html b/qmckl.html index 2878bc5..455d367 100644 --- a/qmckl.html +++ b/qmckl.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Introduction @@ -333,30 +333,30 @@ for the JavaScript code in this tag.

    Table of Contents

    -
    -

    1 Using QMCkl

    +
    +

    1 Using QMCkl

    The qmckl.h header file installed in the ${prefix}/include directory @@ -385,12 +385,12 @@ Both files are located in the include/ directory.

    -
    -

    2 Developing in QMCkl

    +
    +

    2 Developing in QMCkl

    -
    -

    2.1 Literate programming

    +
    +

    2.1 Literate programming

    In a traditional source code, most of the lines of source files of a program @@ -435,8 +435,8 @@ interactively, in the same spirit as Jupyter notebooks.

    -
    -

    2.2 Source code editing

    +
    +

    2.2 Source code editing

    For a tutorial on literate programming with org-mode, follow this link. @@ -467,8 +467,8 @@ org-mode.

    -
    -

    2.3 Choice of the programming language

    +
    +

    2.3 Choice of the programming language

    Most of the codes of the TREX CoE are written in Fortran with some scripts in @@ -516,8 +516,8 @@ For more guidelines on using Fortran to generate a C interface, see

    -
    -

    2.4 Coding rules

    +
    +

    2.4 Coding rules

    The authors should follow the recommendations of the C99 @@ -535,8 +535,8 @@ Compliance can be checked with cppcheck as:

    -
    -

    2.5 Design of the library

    +
    +

    2.5 Design of the library

    The proposed API should allow the library to: deal with memory transfers @@ -547,8 +547,8 @@ functions (see below).

    -
    -

    2.6 Naming conventions

    +
    +

    2.6 Naming conventions

    To avoid namespace collisions, we use qmckl_ as a prefix for all exported @@ -573,8 +573,8 @@ form is allowed.

    -
    -

    2.7 Application programming interface

    +
    +

    2.7 Application programming interface

    In the C language, the number of bits used by the integer types can change @@ -606,15 +606,15 @@ bindings in other languages in other repositories.

    -
    -

    2.8 Global state

    +
    +

    2.8 Global state

    Global variables should be avoided in the library, because it is possible that one single program needs to use multiple instances of the library. To solve this problem we propose to use a pointer to a context variable, built by the library with the -qmckl_context_create function. The =context= contains the global +qmckl_context_create function. The =context= contains the global state of the library, and is used as the first argument of many QMCkl functions.

    @@ -628,8 +628,8 @@ the state is done by setters and getters, prefixed by
    -
    -

    2.9 Headers

    +
    +

    2.9 Headers

    A single qmckl.h header to be distributed by the library @@ -717,8 +717,8 @@ and the types definitions should be written in the *_f_type.f90 fil

    -
    -

    2.10 Low-level functions

    +
    +

    2.10 Low-level functions

    Low-level functions are very simple functions which are leaves of @@ -727,14 +727,14 @@ the function call tree (they don't call any other QMCkl function).

    These functions are pure, and unaware of the QMCkl -context. They are not allowed to allocate/deallocate memory, and +context. They are not allowed to allocate/deallocate memory, and if they need temporary memory it should be provided in input.

    -
    -

    2.11 High-level functions

    +
    +

    2.11 High-level functions

    High-level functions are at the top of the function call tree. @@ -747,27 +747,27 @@ temporary storage, to simplify the use of accelerators.

    The high-level functions should be pure, unless the introduction of non-purity is justified. All the side effects should be made in -the context variable. +the context variable.

    -
    -

    2.12 Numerical precision

    +
    +

    2.12 Numerical precision

    The number of bits of precision required for a function should be given as an input of low-level computational functions. This input will be used to define the values of the different thresholds that might be used to avoid computing unnecessary noise. High-level -functions will use the precision specified in the context +functions will use the precision specified in the context variable.

    -
    -

    2.13 Algorithms

    +
    +

    2.13 Algorithms

    Reducing the scaling of an algorithm usually implies also reducing @@ -783,7 +783,7 @@ implemented adapted to different problem sizes.

    Author: TREX CoE

    -

    Created: 2021-05-12 Wed 21:59

    +

    Created: 2021-05-15 Sat 23:32

    Validate

    diff --git a/qmckl_ao.html b/qmckl_ao.html index d145d75..d304181 100644 --- a/qmckl_ao.html +++ b/qmckl_ao.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Atomic Orbitals @@ -333,52 +333,52 @@ for the JavaScript code in this tag.

    Table of Contents

    -
    -

    1 Context

    +
    +

    1 Context

    The following arrays are stored in the context: @@ -503,8 +503,8 @@ coefficient = [ 0.006068, 0.045308, 0.202822, 0.503903, 0.383421,

    -
    -

    1.1 Data structure

    +
    +

    1.1 Data structure

    typedef struct qmckl_ao_basis_struct {
    @@ -533,8 +533,8 @@ struct is then initialized and provided == true.
     
    -
    -

    1.2 Access functions

    +
    +

    1.2 Access functions

    When all the data for the AOs have been provided, the following @@ -548,8 +548,8 @@ function returns true.

    -
    -

    1.3 Initialization functions

    +
    +

    1.3 Initialization functions

    To set the basis set, all the following functions need to be @@ -572,17 +572,17 @@ called. When

    -
    -

    1.4 TODO Fortran interfaces

    +
    +

    1.4 TODO Fortran interfaces

    -
    -

    2 Polynomial part

    +
    +

    2 Polynomial part

    -
    -

    2.1 Powers of \(x-X_i\)

    +
    +

    2.1 Powers of \(x-X_i\)

    The qmckl_ao_power function computes all the powers of the n @@ -594,7 +594,7 @@ the \(n\) points: \[ P_{ik} = X_i^k \]

    - +
    @@ -652,8 +652,8 @@ the \(n\) points:
    -
    -

    2.1.1 Requirements

    +
    +

    2.1.1 Requirements

    • context is not QMCKL_NULL_CONTEXT
    • @@ -666,8 +666,8 @@ the \(n\) points:
    -
    -

    2.1.2 C Header

    +
    +

    2.1.2 C Header

    qmckl_exit_code qmckl_ao_power (
    @@ -682,8 +682,8 @@ the \(n\) points:
     
    -
    -

    2.1.3 Source

    +
    +

    2.1.3 Source

    integer function qmckl_ao_power_f(context, n, X, LMAX, P, ldp) result(info)
    @@ -734,15 +734,15 @@ the \(n\) points:
     
    -
    -

    2.1.4 C interface

    +
    +

    2.1.4 C interface

    -
    -

    2.1.5 Fortran interface

    +
    +

    2.1.5 Fortran interface

    -
    -

    2.1.6 Test

    +
    +

    2.1.6 Test

    integer(c_int32_t) function test_qmckl_ao_power(context) bind(C)
    @@ -793,8 +793,8 @@ the \(n\) points:
     
    -
    -

    2.2 Value, Gradient and Laplacian of a polynomial

    +
    +

    2.2 Value, Gradient and Laplacian of a polynomial

    A polynomial is centered on a nucleus \(\mathbf{R}_i\) @@ -839,7 +839,7 @@ Laplacians at a given point in space, of all polynomials with an angular momentum up to lmax.

    - +
    @@ -918,8 +918,8 @@ angular momentum up to lmax.
    -
    -

    2.2.1 Requirements

    +
    +

    2.2.1 Requirements

    • context is not QMCKL_NULL_CONTEXT
    • @@ -944,8 +944,8 @@ For example, with a=0, b=2 and c=1 the string is "yyz"
    -
    -

    2.2.2 C Header

    +
    +

    2.2.2 C Header

    qmckl_exit_code qmckl_ao_polynomial_vgl (
    @@ -963,8 +963,8 @@ For example, with a=0, b=2 and c=1 the string is "yyz"
     
    -
    -

    2.2.3 Source

    +
    +

    2.2.3 Source

    integer function qmckl_ao_polynomial_vgl_f(context, X, R, lmax, n, L, ldl, VGL, ldv) result(info)
    @@ -1099,16 +1099,16 @@ For example, with a=0, b=2 and c=1 the string is "yyz"
     
    -
    -

    2.2.4 C interface

    +
    +

    2.2.4 C interface

    -
    -

    2.2.5 Fortran interface

    +
    +

    2.2.5 Fortran interface

    -
    -

    2.2.6 Test

    +
    +

    2.2.6 Test

    integer(c_int32_t) function test_qmckl_ao_polynomial_vgl(context) bind(C)
    @@ -1213,12 +1213,12 @@ assert(0 == test_qmckl_ao_polynomial_vgl(context));
     
    -
    -

    3 Radial part

    +
    +

    3 Radial part

    -
    -

    3.1 Gaussian basis functions

    +
    +

    3.1 Gaussian basis functions

    qmckl_ao_gaussian_vgl computes the values, gradients and @@ -1450,21 +1450,21 @@ Requirements

    -
    -

    3.2 TODO Slater basis functions

    +
    +

    3.2 TODO Slater basis functions

    -
    -

    3.3 TODO Radial functions on a grid

    +
    +

    3.3 TODO Radial functions on a grid

    -
    -

    4 Combining radial and polynomial parts

    +
    +

    4 Combining radial and polynomial parts

    Author: TREX CoE

    -

    Created: 2021-05-12 Wed 21:59

    +

    Created: 2021-05-15 Sat 23:32

    Validate

    diff --git a/qmckl_context.html b/qmckl_context.html index c35a2f6..ebdcadc 100644 --- a/qmckl_context.html +++ b/qmckl_context.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Context @@ -311,21 +311,21 @@ for the JavaScript code in this tag.

    Table of Contents

    -
    -

    1 Context handling

    +
    +

    1 Context handling

    The context variable is a handle for the state of the library, @@ -338,7 +338,7 @@ A value of QMCKL_NULL_CONTEXT for the context is equivalent to a

    -
    typedef int64_t qmckl_context ;
    +
    typedef int64_t qmckl_context ;
     #define QMCKL_NULL_CONTEXT (qmckl_context) 0
     
    @@ -356,8 +356,8 @@ and ctx is a qmckl_context_struct* pointer.

    -
    -

    1.1 Data structure

    +
    +

    1.1 Data structure

    The context keeps a ``date'' that allows to check which data needs @@ -367,7 +367,7 @@ coordinates are updated.

    When a new element is added to the context, the functions -qmcklcontextcreate, qmcklcontextdestroy and qmcklcontextcopy +qmcklcontextcreate, qmcklcontextdestroy and qmcklcontextcopy should be updated inorder to make deep copies.

    @@ -416,8 +416,8 @@ if the context is valid, QMCKL_NULL_CONTEXT otherwise.
    -
    -

    1.2 Creation

    +
    +

    1.2 Creation

    To create a new context, qmckl_context_create() should be used. @@ -468,6 +468,7 @@ To create a new context, qmckl_context_create() should be used. ctx->numprec.range = QMCKL_DEFAULT_RANGE; ctx->ao_basis.uninitialized = (1 << 10) - 1; + ctx->nucleus.uninitialized = (1 << 3) - 1; ctx->electron.uninitialized = (1 << 2) - 1; /* Allocate qmckl_memory_struct */ @@ -491,8 +492,8 @@ To create a new context, qmckl_context_create() should be used.

    -
    -

    1.3 Locking

    +
    +

    1.3 Locking

    For thread safety, the context may be locked/unlocked. The lock is @@ -537,8 +538,8 @@ number of times the thread has locked it is saved in the

    -
    -

    1.4 TODO Copy

    +
    +

    1.4 TODO Copy

    qmckl_context_copy makes a deep copy of a context. It returns @@ -586,8 +587,8 @@ number of times the thread has locked it is saved in the

    -
    -

    1.5 Destroy

    +
    +

    1.5 Destroy

    The context is destroyed with qmckl_context_destroy, leaving the ancestors untouched. @@ -641,7 +642,7 @@ It frees the context, and returns the previous context.

    Author: TREX CoE

    -

    Created: 2021-05-12 Wed 21:59

    +

    Created: 2021-05-15 Sat 23:32

    Validate

    diff --git a/qmckl_distance.html b/qmckl_distance.html index fed71d7..7bd54b4 100644 --- a/qmckl_distance.html +++ b/qmckl_distance.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Inter-particle distances @@ -333,26 +333,26 @@ for the JavaScript code in this tag.

    Table of Contents

    -
    -

    1 Squared distance

    +
    +

    1 Squared distance

    -
    -

    1.1 qmckl_distance_sq

    +
    +

    1.1 qmckl_distance_sq

    qmckl_distance_sq computes the matrix of the squared distances @@ -379,7 +379,7 @@ between all pairs of points in two sets, one point within each set: \]

    - +
    @@ -472,8 +472,8 @@ between all pairs of points in two sets, one point within each set:
    -
    -

    1.1.1 Requirements

    +
    +

    1.1.1 Requirements

    • context is not QMCKL_NULL_CONTEXT
    • @@ -491,8 +491,8 @@ between all pairs of points in two sets, one point within each set:
    -
    -

    1.1.2 C header

    +
    +

    1.1.2 C header

    qmckl_exit_code qmckl_distance (
    @@ -512,8 +512,8 @@ between all pairs of points in two sets, one point within each set:
     
    -
    -

    1.1.3 Source

    +
    +

    1.1.3 Source

    integer function qmckl_distance_sq_f(context, transa, transb, m, n, &
    @@ -648,8 +648,8 @@ between all pairs of points in two sets, one point within each set:
     
    -
    -

    1.1.4 Performance

    +
    +

    1.1.4 Performance

    This function might be more efficient when A and B are @@ -659,12 +659,12 @@ transposed.

    -
    -

    2 Distance

    +
    +

    2 Distance

    -
    -

    2.1 qmckl_distance

    +
    +

    2.1 qmckl_distance

    qmckl_distance computes the matrix of the distances between all @@ -677,7 +677,7 @@ pairs of points in two sets, one point within each set: \]

    - +
    @@ -770,8 +770,8 @@ pairs of points in two sets, one point within each set:
    -
    -

    2.1.1 Requirements

    +
    +

    2.1.1 Requirements

    • context is not QMCKL_NULL_CONTEXT
    • @@ -789,8 +789,8 @@ pairs of points in two sets, one point within each set:
    -
    -

    2.1.2 C header

    +
    +

    2.1.2 C header

    qmckl_exit_code qmckl_distance (
    @@ -810,8 +810,8 @@ pairs of points in two sets, one point within each set:
     
    -
    -

    2.1.3 Source

    +
    +

    2.1.3 Source

    integer function qmckl_distance_f(context, transa, transb, m, n, &
    @@ -950,8 +950,8 @@ pairs of points in two sets, one point within each set:
     
    -
    -

    2.1.4 Performance

    +
    +

    2.1.4 Performance

    This function might be more efficient when A and B are @@ -964,7 +964,7 @@ transposed.

    Author: TREX CoE

    -

    Created: 2021-05-12 Wed 21:59

    +

    Created: 2021-05-15 Sat 23:32

    Validate

    diff --git a/qmckl_electron.html b/qmckl_electron.html index 9b22c6c..8b440ff 100644 --- a/qmckl_electron.html +++ b/qmckl_electron.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Electrons @@ -311,21 +311,21 @@ for the JavaScript code in this tag.

    Table of Contents

    -
    -

    1 Context

    +
    +

    1 Context

    The following data stored in the context: @@ -421,8 +421,8 @@ The following data stored in the context:

    -
    -

    1.1 Data structure

    +
    +

    1.1 Data structure

    typedef struct qmckl_electron_struct {
    @@ -450,28 +450,39 @@ struct is then initialized and provided == true.
     
    -
    -

    1.2 Access functions

    +
    +

    1.2 TODO Access functions

    +

    +Access functions return QMCKL_SUCCESS when the data has been +successfully retrieved. It returnes QMCKL_INVALID_CONTEXT when +the context is not a valid context, and QMCKL_NOT_PROVIDED when +the data has not been provided. If the function returns +successfully, the variable pointed by the pointer given in argument +contains the requested data. Otherwise, this variable is untouched. +

    +

    When all the data relative to electrons have been set, the following function returns true.

    -
    bool      qmckl_electron_provided       (const qmckl_context context);
    +
    bool qmckl_electron_provided (const qmckl_context context);
     
    -
    -

    1.3 Initialization functions

    + +
    +

    1.3 Initialization functions

    To set the data relative to the electrons in the context, the following functions need to be called. When the data structure is -initialized, the coord_new and coord_old arrays are both allocated. +initialized, the internal coord_new and coord_old arrays are +both allocated.

    @@ -496,8 +507,8 @@ electrons have been set.
    -
    -

    1.4 Test

    +
    +

    1.4 Test

    /* Reference input data */
    @@ -525,25 +536,69 @@ electrons have been set.
     
     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, up_num, down_num);
     assert(rc == QMCKL_SUCCESS);
     assert(!qmckl_electron_provided(context));
     
    +rc = qmckl_get_electron_up_num (context, &n);
    +assert(rc == QMCKL_SUCCESS);
    +assert(n == up_num);
    +
    +rc = qmckl_get_electron_down_num (context, &n);
    +assert(rc == QMCKL_SUCCESS);
    +assert(n == down_num);
    +
    +rc = qmckl_get_electron_num (context, &n);
    +assert(rc == QMCKL_SUCCESS);
    +assert(n == num);
    +
    +
    +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, coord);
     assert(rc == QMCKL_SUCCESS);
     
    +/*
    +double coord2[walk_num*3*num];
    +
    +rc = qmckl_get_electron_coord_new (context, coord2);
    +assert(rc == QMCKL_SUCCESS);
    +for (size_t i=0 ; i<3*num ; ++i) {
    +  assert( coord[i] == coord2[i] );
    + }
    + */
    +
     
    -
    -

    2 Computation

    +
    +

    2 Computation

    The computed data is stored in the context so that it can be reused @@ -556,12 +611,12 @@ current date is stored.

    -
    -

    2.1 Electron-electron distances

    +
    +

    2.1 Electron-electron distances

    -
    -

    2.1.1 Get

    +
    +

    2.1.1 Get

    qmckl_exit_code qmckl_get_electron_ee_distance(qmckl_context context, double* distance);
    @@ -570,10 +625,10 @@ current date is stored.
     
    -
    -

    2.1.2 Compute

    +
    +

    2.1.2 Compute

    - +
    @@ -670,8 +725,8 @@ current date is stored. -
    -

    2.1.3 Test

    +
    +

    2.1.3 Test

    /* Reference input data */
    @@ -694,7 +749,7 @@ rc = qmckl_get_electron_ee_distance(context, distance);
     

    Author: TREX CoE

    -

    Created: 2021-05-12 Wed 21:59

    +

    Created: 2021-05-15 Sat 23:32

    Validate

    diff --git a/qmckl_error.html b/qmckl_error.html index a656cc5..bacd5ed 100644 --- a/qmckl_error.html +++ b/qmckl_error.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Error handling @@ -311,16 +311,16 @@ for the JavaScript code in this tag.

    Table of Contents

    -
    -

    1 Decoding errors

    +
    +

    1 Decoding errors

    To decode the error messages, qmckl_string_of_error converts an @@ -387,6 +387,9 @@ The text strings are extracted from the previous table. case QMCKL_DEALLOCATION_FAILED: return "De-allocation failed"; break; + case QMCKL_NOT_PROVIDED: + return "Not provided"; + break; case QMCKL_INVALID_EXIT_CODE: return "Invalid exit code"; break; @@ -414,8 +417,8 @@ The text strings are extracted from the previous table.

    -
    -

    2 Data structure in context

    +
    +

    2 Data structure in context

    The strings are declared with a maximum fixed size to avoid @@ -438,8 +441,8 @@ dynamic memory allocation.

    -
    -

    3 Updating errors in the context

    +
    +

    3 Updating errors in the context

    The error is updated in the context using qmckl_set_error. @@ -485,8 +488,8 @@ explaining the error. The exit code can't be QMCKL_SUCCESS.

    -
    -

    4 Failing

    +
    +

    4 Failing

    To make a function fail, the qmckl_failwith function should be @@ -549,7 +552,7 @@ For example, this function can be used as

    Author: TREX CoE

    -

    Created: 2021-05-12 Wed 21:59

    +

    Created: 2021-05-15 Sat 23:32

    Validate

    diff --git a/qmckl_memory.html b/qmckl_memory.html index 62f3f54..f46c608 100644 --- a/qmckl_memory.html +++ b/qmckl_memory.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Memory management @@ -311,15 +311,15 @@ for the JavaScript code in this tag.

    Table of Contents

    -
    -

    1 Memory data structure for the context

    +
    +

    1 Memory data structure for the context

    Every time a new block of memory is allocated, the information @@ -361,8 +361,8 @@ array, and the number of allocated blocks.

    -
    -

    2 Passing info to allocation routines

    +
    +

    2 Passing info to allocation routines

    Passing information to the allocation routine should be done by @@ -371,8 +371,8 @@ passing an instance of a qmckl_memory_info_struct.

    -
    -

    3 Allocation/deallocation functions

    +
    +

    3 Allocation/deallocation functions

    Memory allocation inside the library should be done with @@ -535,7 +535,7 @@ allocation and needs to be updated.

    Author: TREX CoE

    -

    Created: 2021-05-12 Wed 21:59

    +

    Created: 2021-05-15 Sat 23:32

    Validate

    diff --git a/qmckl_nucleus.html b/qmckl_nucleus.html new file mode 100644 index 0000000..a03cefc --- /dev/null +++ b/qmckl_nucleus.html @@ -0,0 +1,783 @@ + + + + + + + + + + + + + + + +
    + +

    +#i+TITLE: Nucleus +

    + +

    +A ll the data relative to the molecular geometry is described here. +

    + +
    +

    1 Context

    +
    +

    +The following data stored in the context: +

    + +
    + + +++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    uninitializedint32tKeeps bit set for uninitialized data
    numint64tTotal number of nuclei
    providedboolIf true, nucleus is valid
    chargedouble[num]Nuclear charges
    coorddouble[3][num]Nuclear coordinates
    nn_distancedouble[num][num]Nucleus-nucleus distances
    nn_distance_dateint64tDate when Nucleus-nucleus distances were computed
    repulsiondoubleNuclear repulsion energy
    repulsion_dateint64tDate when the nuclear repulsion energy was computed
    +
    + +
    +

    1.1 Data structure

    +
    +
    +
    typedef struct qmckl_nucleus_struct {
    +  int64_t   num;
    +  int64_t   repulsion_date;
    +  int64_t   nn_distance_date;
    +  double*   coord;
    +  double*   charge;
    +  double*   nn_distance;
    +  double    repulsion;
    +  int32_t   uninitialized;
    +  bool      provided;
    +} qmckl_nucleus_struct;
    +
    +
    + +

    +The uninitialized integer contains one bit set to one for each +initialization function which has not bee called. It becomes equal +to zero after all initialization functions have been called. The +struct is then initialized and provided == true. +

    +
    +
    + +
    +

    1.2 Access functions

    +
    +

    +When all the data relative to nuclei have been set, the following +function returns true. +

    + +
    +
    bool qmckl_nucleus_provided (const qmckl_context context);
    +
    +
    +
    +
    + +
    +

    1.3 Initialization functions

    +
    +

    +To set the data relative to the nuclei in the context, the +following functions need to be called. +

    + +
    +
    qmckl_exit_code  qmckl_set_nucleus_num    (qmckl_context context, const int64_t num);
    +qmckl_exit_code  qmckl_set_nucleus_charge (qmckl_context context, const double* charge);
    +qmckl_exit_code  qmckl_set_nucleus_coord  (qmckl_context context, const double* coord);
    +
    +
    + +

    +To set the number of nuclei, use +

    + +

    +The following function sets the nuclear charges of all the atoms. +

    + +

    +The following function sets the nuclear coordinates of all the +atoms. The coordinates should be given in atomic units. +

    +
    +
    + +
    +

    1.4 Test

    +
    +
    +
    /* Reference input data */
    +
    +#define num ((int64_t) 9)
    +
    +double charge[num] = { 6., 6., 6., 7., 7., 1., 1., 1., 1. };
    +
    +double coord[3*num] =
    +    { 4.166279566732572e-01,  -1.526183863767697e+00,   1.041604719335635e+00,
    +     -1.903457631371503e+00,   2.242154435363994e+00,   6.550163404813796e-01,
    +     -3.575005445908036e+00,  -3.063638942318878e+00,   2.086739409279095e+00,
    +      2.060062599100338e+00,  -1.623431626827498e+00,  -1.930074272670425e+00,
    +      9.491495662916423e-01,   3.808343139803397e-01,   4.077482772289367e+00,
    +      1.841031662652821e+00,  -2.945591662994877e+00,  -3.670011011125464e+00,
    +      0.000000000000000e+00,   0.000000000000000e+00,   0.000000000000000e+00,
    +      0.000000000000000e+00,   0.000000000000000e+00,   0.000000000000000e+00,
    +      0.000000000000000e+00,   0.000000000000000e+00,   0.000000000000000e+00};
    +
    +/* --- */
    +
    +qmckl_exit_code rc;
    +
    +assert(!qmckl_nucleus_provided(context));
    +
    +int64_t n;
    +rc = qmckl_get_nucleus_num (context, &n);
    +assert(rc == QMCKL_NOT_PROVIDED);
    +
    +
    +rc = qmckl_set_nucleus_num (context, num);
    +assert(rc == QMCKL_SUCCESS);
    +assert(!qmckl_nucleus_provided(context));
    +
    +rc = qmckl_get_nucleus_num (context, &n);
    +assert(rc == QMCKL_SUCCESS);
    +assert(n == num);
    +
    +double coord2[3*num];
    +
    +rc = qmckl_get_nucleus_coord (context, coord2);
    +assert(rc == QMCKL_NOT_PROVIDED);
    +
    +rc = qmckl_set_nucleus_coord (context, coord);
    +assert(rc == QMCKL_SUCCESS);
    +
    +rc = qmckl_get_nucleus_coord (context, coord2);
    +assert(rc == QMCKL_SUCCESS);
    +for (size_t i=0 ; i<3*num ; ++i) {
    +  assert( coord[i] == coord2[i] );
    + }
    +
    +assert(!qmckl_nucleus_provided(context));
    +
    +double charge2[num];
    +
    +rc = qmckl_get_nucleus_charge(context, charge2);
    +assert(rc == QMCKL_NOT_PROVIDED);
    +
    +rc = qmckl_set_nucleus_charge(context, charge);
    +assert(rc == QMCKL_SUCCESS);
    +
    +rc = qmckl_get_nucleus_charge(context, charge2);
    +assert(rc == QMCKL_SUCCESS);
    +for (size_t i=0 ; i<num ; ++i) {
    +  assert( charge[i] == charge2[i] );
    + }
    +assert(qmckl_nucleus_provided(context));
    +
    +
    +
    +
    +
    + +
    +

    2 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. +

    +
    + +
    +

    2.1 Nucleus-nucleus distances

    +
    +
    +
    +

    2.1.1 Get

    +
    +
    +
    qmckl_exit_code qmckl_get_nucleus_nn_distance(qmckl_context context, double* distance);
    +
    +
    +
    +
    + +
    +

    2.1.2 Compute

    +
    + + + +++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    qmcklcontextcontextinGlobal state
    int64tnuclnuminNumber of nuclei
    doublecoord[3][nuclnum]inNuclear coordinates (au)
    doublenndistance[nuclnum][nuclnum]outNucleus-nucleus distances (au)
    + +
    +
    integer function qmckl_compute_nn_distance_f(context, nucl_num, coord, nn_distance) &
    +     result(info)
    +  use qmckl
    +  implicit none
    +  integer(qmckl_context), intent(in)  :: context
    +  integer*8             , intent(in)  :: nucl_num
    +  double precision      , intent(in)  :: coord(nucl_num,3)
    +  double precision      , intent(out) :: nn_distance(nucl_num,nucl_num)
    +
    +  integer*8 :: k
    +
    +  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
    +
    +  info = qmckl_distance(context, 'T', 'T', nucl_num, nucl_num, &
    +          coord, nucl_num, &
    +          coord, nucl_num, &
    +          nn_distance, nucl_num)
    +
    +end function qmckl_compute_nn_distance_f
    +
    +
    +
    +
    + +
    +

    2.1.3 Test

    +
    +
    +
    /* Reference input data */
    +
    +assert(qmckl_nucleus_provided(context));
    +
    +double distance[num*num];
    +rc = qmckl_get_nucleus_nn_distance(context, distance);
    +rc = qmckl_get_nucleus_nn_distance(context, distance);
    +assert(distance[0] == 0.);
    +assert(distance[1] == distance[num]);
    +assert(abs(distance[1]-4.164450441785663) < 1.e-12);
    +
    +
    +
    +
    +
    +
    + +
    +

    2.2 Nuclear repulsion energy

    +
    +

    +\[ + V_{NN} = \sum_{A=1}^{N-1} \sum_{B>A}^N \frac{Q_A Q_B}{R_{AB}} + \] +

    +
    + +
    +

    2.2.1 Get

    +
    +
    +
    qmckl_exit_code qmckl_get_nucleus_repulsion(qmckl_context context, double* energy);
    +
    +
    +
    +
    + +
    +

    2.2.2 Compute

    +
    + + + +++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    qmcklcontextcontextinGlobal state
    int64tnuclnuminNumber of nuclei
    doublecharge[nuclnum]inNuclear charges (au)
    doublenndistance[nuclnum][nuclnum]inNucleus-nucleus distances (au)
    doubleenergyoutNuclear repulsion energy
    + +
    +
    integer function qmckl_compute_nucleus_repulsion_f(context, nucl_num, charge, nn_distance, energy) &
    +     result(info)
    +  use qmckl
    +  implicit none
    +  integer(qmckl_context), intent(in)  :: context
    +  integer*8             , intent(in)  :: nucl_num
    +  double precision      , intent(in)  :: charge(nucl_num)
    +  double precision      , intent(in)  :: nn_distance(nucl_num,nucl_num)
    +  double precision      , intent(out) :: energy
    +
    +  integer*8 :: i, j
    +
    +  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
    +
    +  energy = 0.d0
    +  do j=2, nucl_num
    +     do i=1, j-1
    +        energy = energy + charge(i) * charge(j) / nn_distance(i,j) 
    +     end do
    +  end do
    +  print *, energy
    +
    +end function qmckl_compute_nucleus_repulsion_f
    +
    +
    +
    +
    + +
    +

    2.2.3 Test

    +
    +
    +
    /* Reference input data */
    +
    +assert(qmckl_nucleus_provided(context));
    +
    +double rep;
    +rc = qmckl_get_nucleus_repulsion(context, &rep);
    +assert(rep - 163.50434957121263 < 1.e-10);
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Created: 2021-05-15 Sat 23:32

    +

    Validate

    +
    + + diff --git a/qmckl_numprec.html b/qmckl_numprec.html index 0cbbf76..c9b8675 100644 --- a/qmckl_numprec.html +++ b/qmckl_numprec.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Numerical precision @@ -333,16 +333,16 @@ for the JavaScript code in this tag.

    Table of Contents

    -
    -

    1 Control of the numerical precision

    +
    +

    1 Control of the numerical precision

    Controlling numerical precision enables optimizations. Here, the @@ -353,7 +353,7 @@ Arithmetic (IEEE 754), refers to the number of exponent bits.

    - +
    @@ -397,8 +397,8 @@ integer. The update functions return QMCKL_SUCCESS or -
    -

    2 Precision

    +
    +

    2 Precision

    qmckl_context_set_numprec_precision modifies the parameter for the @@ -485,8 +485,8 @@ numerical precision in the context.

    -
    -

    3 Range

    +
    +

    3 Range

    qmckl_set_numprec_range modifies the parameter for the numerical @@ -561,8 +561,8 @@ range in a given context.

    -
    -

    4 Helper functions

    +
    +

    4 Helper functions

    qmckl_get_numprec_epsilon returns \(\epsilon = 2^{1-n}\) where n is the precision. @@ -581,7 +581,7 @@ We need to remove the sign bit from the precision.

    Author: TREX CoE

    -

    Created: 2021-05-12 Wed 21:59

    +

    Created: 2021-05-15 Sat 23:32

    Validate