From faba6a0cdcfb7d80c2db5faa32dec7db0a2e3644 Mon Sep 17 00:00:00 2001 From: v1j4y Date: Mon, 11 Oct 2021 18:27:58 +0200 Subject: [PATCH] Bug fix for modims. --- org/qmckl_mo.org | 122 ++++++++++++++++++++++------------------------- 1 file changed, 57 insertions(+), 65 deletions(-) diff --git a/org/qmckl_mo.org b/org/qmckl_mo.org index f521b4d..94a8063 100644 --- a/org/qmckl_mo.org +++ b/org/qmckl_mo.org @@ -87,7 +87,7 @@ int main() { |---------------+-----------------------------------+----------------------------------------------------------------------------------------| |---------------+-----------------------------------+----------------------------------------------------------------------------------------| - | ~mo_vgl~ | ~[5][walk_num][elec_num][mo_num]~ | Value, gradients, Laplacian of the MOs at electron positions | + | ~mo_vgl~ | ~[5][elec_num][mo_num]~ | Value, gradients, Laplacian of the MOs at electron positions | | ~mo_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the MOs at electron positions | |---------------+-----------------------------------+----------------------------------------------------------------------------------------| @@ -319,7 +319,7 @@ qmckl_exit_code qmckl_get_mo_basis_vgl(qmckl_context context, double* const mo_v qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - size_t sze = 5 * ctx->electron.num * ctx->mo_basis.mo_num * ctx->electron.walk_num; + size_t sze = 5 * ctx->electron.num * ctx->mo_basis.mo_num; memcpy(mo_vgl, ctx->mo_basis.mo_vgl, sze * sizeof(double)); return QMCKL_SUCCESS; @@ -385,8 +385,7 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context) if (ctx->mo_basis.mo_vgl == NULL) { qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; - mem_info.size = 5 * ctx->electron.num * ctx->mo_basis.mo_num * - ctx->electron.walk_num * sizeof(double); + mem_info.size = 5 * ctx->electron.num * ctx->mo_basis.mo_num * sizeof(double); double* mo_vgl = (double*) qmckl_malloc(context, mem_info); if (mo_vgl == NULL) { @@ -404,7 +403,6 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context) ctx->ao_basis.ao_num, ctx->mo_basis.mo_num, ctx->electron.num, - ctx->electron.walk_num, ctx->mo_basis.coefficient, ctx->ao_basis.ao_vgl, ctx->mo_basis.mo_vgl); @@ -437,14 +435,13 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context) | ~int64_t~ | ~ao_num~ | in | Number of AOs | | ~int64_t~ | ~mo_num~ | in | Number of MOs | | ~int64_t~ | ~elec_num~ | in | Number of electrons | - | ~int64_t~ | ~walk_num~ | in | Number of walkers | | ~double~ | ~coef_normalized[mo_num][ao_num]~ | in | AO to MO transformation matrix | - | ~double~ | ~ao_vgl[5][walk_num][elec_num][ao_num]~ | in | Value, gradients and Laplacian of the AOs | - | ~double~ | ~mo_vgl[5][walk_num][elec_num][mo_num]~ | out | Value, gradients and Laplacian of the MOs | + | ~double~ | ~ao_vgl[5][elec_num][ao_num]~ | in | Value, gradients and Laplacian of the AOs | + | ~double~ | ~mo_vgl[5][elec_num][mo_num]~ | out | Value, gradients and Laplacian of the MOs | #+begin_src f90 :comments org :tangle (eval f) :noweb yes integer function qmckl_compute_mo_basis_gaussian_vgl_f(context, & - ao_num, mo_num, elec_num, walk_num, & + ao_num, mo_num, elec_num, & coef_normalized, ao_vgl, mo_vgl) & result(info) use qmckl @@ -452,10 +449,9 @@ integer function qmckl_compute_mo_basis_gaussian_vgl_f(context, & integer(qmckl_context), intent(in) :: context integer*8 , intent(in) :: ao_num, mo_num integer*8 , intent(in) :: elec_num - integer*8 , intent(in) :: walk_num - double precision , intent(in) :: ao_vgl(ao_num,elec_num,walk_num,5) + double precision , intent(in) :: ao_vgl(ao_num,elec_num,5) double precision , intent(in) :: coef_normalized(ao_num,mo_num) - double precision , intent(out) :: mo_vgl(mo_num,elec_num,walk_num,5) + double precision , intent(out) :: mo_vgl(mo_num,elec_num,5) logical*8 :: TransA, TransB double precision :: alpha, beta integer :: info_qmckl_dgemm_value @@ -489,39 +485,37 @@ integer function qmckl_compute_mo_basis_gaussian_vgl_f(context, & LDB = K LDC = M - do iwalk = 1, walk_num - do ielec = 1, elec_num - ! Value - info_qmckl_dgemm_value = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, & - ao_vgl(:, ielec, iwalk, 1), LDA, & - coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8, & - beta, & - mo_vgl(:,ielec,iwalk,1),LDC) - ! Grad_x - info_qmckl_dgemm_Gx = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, & - ao_vgl(:, ielec, iwalk, 2), LDA, & - coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8, & - beta, & - mo_vgl(:,ielec,iwalk,2),LDC) - ! Grad_y - info_qmckl_dgemm_Gy = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, & - ao_vgl(:, ielec, iwalk, 3), LDA, & - coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8, & - beta, & - mo_vgl(:,ielec,iwalk,3),LDC) - ! Grad_z - info_qmckl_dgemm_Gz = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, & - ao_vgl(:, ielec, iwalk, 4), LDA, & - coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8, & - beta, & - mo_vgl(:,ielec,iwalk,4),LDC) - ! Lapl_z - info_qmckl_dgemm_lap = qmckl_dgemm(context, TransA, TransB, M, N, K, alpha, & - ao_vgl(:, ielec, iwalk, 5), LDA, & - coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8, & - beta, & - mo_vgl(:,ielec,iwalk,5),LDC) - end do + do ielec = 1, elec_num + ! Value + info_qmckl_dgemm_value = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, & + ao_vgl(:, ielec, 1), LDA, & + coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8, & + beta, & + mo_vgl(:,ielec,1),LDC) + ! Grad_x + info_qmckl_dgemm_Gx = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, & + ao_vgl(:, ielec, 2), LDA, & + coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8, & + beta, & + mo_vgl(:,ielec,2),LDC) + ! Grad_y + info_qmckl_dgemm_Gy = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, & + ao_vgl(:, ielec, 3), LDA, & + coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8, & + beta, & + mo_vgl(:,ielec,3),LDC) + ! Grad_z + info_qmckl_dgemm_Gz = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, & + ao_vgl(:, ielec, 4), LDA, & + coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8, & + beta, & + mo_vgl(:,ielec,4),LDC) + ! Lapl_z + info_qmckl_dgemm_lap = qmckl_dgemm(context, TransA, TransB, M, N, K, alpha, & + ao_vgl(:, ielec, 5), LDA, & + coef_normalized(1:ao_num,1:mo_num),size(coef_normalized,1) * 1_8, & + beta, & + mo_vgl(:,ielec,5),LDC) end do if(info_qmckl_dgemm_value .eq. QMCKL_SUCCESS .and. & @@ -546,7 +540,6 @@ end function qmckl_compute_mo_basis_gaussian_vgl_f const int64_t ao_num, const int64_t mo_num, const int64_t elec_num, - const int64_t walk_num, const double* coef_normalized, const double* ao_vgl, double* const mo_vgl ); @@ -558,7 +551,7 @@ end function qmckl_compute_mo_basis_gaussian_vgl_f #+RESULTS: #+begin_src f90 :tangle (eval f) :comments org :exports none integer(c_int32_t) function qmckl_compute_mo_basis_gaussian_vgl & - (context, ao_num, mo_num, elec_num, walk_num, coef_normalized, ao_vgl, mo_vgl) & + (context, ao_num, mo_num, elec_num, coef_normalized, ao_vgl, mo_vgl) & bind(C) result(info) use, intrinsic :: iso_c_binding @@ -568,14 +561,13 @@ end function qmckl_compute_mo_basis_gaussian_vgl_f integer (c_int64_t) , intent(in) , value :: ao_num integer (c_int64_t) , intent(in) , value :: mo_num integer (c_int64_t) , intent(in) , value :: elec_num - integer (c_int64_t) , intent(in) , value :: walk_num real (c_double ) , intent(in) :: coef_normalized(ao_num,mo_num) - real (c_double ) , intent(in) :: ao_vgl(ao_num,elec_num,walk_num,5) - real (c_double ) , intent(out) :: mo_vgl(mo_num,elec_num,walk_num,5) + real (c_double ) , intent(in) :: ao_vgl(ao_num,elec_num,5) + real (c_double ) , intent(out) :: mo_vgl(mo_num,elec_num,5) integer(c_int32_t), external :: qmckl_compute_mo_basis_gaussian_vgl_f info = qmckl_compute_mo_basis_gaussian_vgl_f & - (context, ao_num, mo_num, elec_num, walk_num, coef_normalized, ao_vgl, mo_vgl) + (context, ao_num, mo_num, elec_num, coef_normalized, ao_vgl, mo_vgl) end function qmckl_compute_mo_basis_gaussian_vgl #+end_src @@ -773,8 +765,8 @@ assert (rc == QMCKL_SUCCESS); assert(qmckl_mo_basis_provided(context)); -double mo_vgl[5][walk_num][elec_num][chbrclf_mo_num]; -rc = qmckl_get_mo_basis_vgl(context, &(mo_vgl[0][0][0][0])); +double mo_vgl[5][elec_num][chbrclf_mo_num]; +rc = qmckl_get_mo_basis_vgl(context, &(mo_vgl[0][0][0])); assert (rc == QMCKL_SUCCESS); // Test overlap of MO @@ -818,18 +810,18 @@ assert (rc == QMCKL_SUCCESS); printf("\n"); -printf(" mo_vgl mo_vgl[0][0][26][219] %25.15e\n", mo_vgl[0][0][2][3]); -printf(" mo_vgl mo_vgl[1][0][26][219] %25.15e\n", mo_vgl[1][0][2][3]); -printf(" mo_vgl mo_vgl[0][0][26][220] %25.15e\n", mo_vgl[0][0][2][3]); -printf(" mo_vgl mo_vgl[1][0][26][220] %25.15e\n", mo_vgl[1][0][2][3]); -printf(" mo_vgl mo_vgl[0][0][26][221] %25.15e\n", mo_vgl[0][0][2][3]); -printf(" mo_vgl mo_vgl[1][0][26][221] %25.15e\n", mo_vgl[1][0][2][3]); -printf(" mo_vgl mo_vgl[0][0][26][222] %25.15e\n", mo_vgl[0][0][2][3]); -printf(" mo_vgl mo_vgl[1][0][26][222] %25.15e\n", mo_vgl[1][0][2][3]); -printf(" mo_vgl mo_vgl[0][0][26][223] %25.15e\n", mo_vgl[0][0][2][3]); -printf(" mo_vgl mo_vgl[1][0][26][223] %25.15e\n", mo_vgl[1][0][2][3]); -printf(" mo_vgl mo_vgl[0][0][26][224] %25.15e\n", mo_vgl[0][0][2][3]); -printf(" mo_vgl mo_vgl[1][0][26][224] %25.15e\n", mo_vgl[1][0][2][3]); +printf(" mo_vgl mo_vgl[0][26][219] %25.15e\n", mo_vgl[0][2][3]); +printf(" mo_vgl mo_vgl[1][26][219] %25.15e\n", mo_vgl[1][2][3]); +printf(" mo_vgl mo_vgl[0][26][220] %25.15e\n", mo_vgl[0][2][3]); +printf(" mo_vgl mo_vgl[1][26][220] %25.15e\n", mo_vgl[1][2][3]); +printf(" mo_vgl mo_vgl[0][26][221] %25.15e\n", mo_vgl[0][2][3]); +printf(" mo_vgl mo_vgl[1][26][221] %25.15e\n", mo_vgl[1][2][3]); +printf(" mo_vgl mo_vgl[0][26][222] %25.15e\n", mo_vgl[0][2][3]); +printf(" mo_vgl mo_vgl[1][26][222] %25.15e\n", mo_vgl[1][2][3]); +printf(" mo_vgl mo_vgl[0][26][223] %25.15e\n", mo_vgl[0][2][3]); +printf(" mo_vgl mo_vgl[1][26][223] %25.15e\n", mo_vgl[1][2][3]); +printf(" mo_vgl mo_vgl[0][26][224] %25.15e\n", mo_vgl[0][2][3]); +printf(" mo_vgl mo_vgl[1][26][224] %25.15e\n", mo_vgl[1][2][3]); printf("\n"); }