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}