From dcc5f09724e0712f11eaf32c5e360729315292f8 Mon Sep 17 00:00:00 2001 From: v1j4y Date: Wed, 13 Oct 2021 17:56:33 +0200 Subject: [PATCH] Fixed provider for local_energy. #41 --- org/qmckl_determinant.org | 2 ++ org/qmckl_local_energy.org | 33 +++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/org/qmckl_determinant.org b/org/qmckl_determinant.org index 6c25591..bbd8a5c 100644 --- a/org/qmckl_determinant.org +++ b/org/qmckl_determinant.org @@ -1626,6 +1626,7 @@ integer function qmckl_compute_det_inv_matrix_alpha_f(context, & end do end do + deallocate(matA) end function qmckl_compute_det_inv_matrix_alpha_f #+end_src @@ -1756,6 +1757,7 @@ integer function qmckl_compute_det_inv_matrix_beta_f(context, & end do end do + deallocate(matA) end function qmckl_compute_det_inv_matrix_beta_f #+end_src diff --git a/org/qmckl_local_energy.org b/org/qmckl_local_energy.org index 33d2cbb..f2b9740 100644 --- a/org/qmckl_local_energy.org +++ b/org/qmckl_local_energy.org @@ -1035,7 +1035,7 @@ qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double * const loc assert (ctx != NULL); size_t sze = ctx->electron.walk_num * sizeof(double); - memcpy(local_energy, ctx->local_energy.e_kin, sze); + memcpy(local_energy, ctx->local_energy.e_local, sze); return QMCKL_SUCCESS; } @@ -1092,23 +1092,40 @@ qmckl_exit_code qmckl_provide_local_energy(qmckl_context context) { NULL); } + qmckl_exit_code rc; + rc = qmckl_provide_kinetic_energy(context); + if(rc != QMCKL_SUCCESS){ + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_kinetic_energy", + NULL); + } + + rc = qmckl_provide_potential_energy(context); + if(rc != QMCKL_SUCCESS){ + return qmckl_failwith( context, + QMCKL_NOT_PROVIDED, + "qmckl_potential_energy", + NULL); + } + /* Compute if necessary */ - if (ctx->electron.coord_new_date > ctx->local_energy.e_kin_date) { + if (ctx->electron.coord_new_date > ctx->local_energy.e_local_date) { /* Allocate array */ - if (ctx->local_energy.e_kin == NULL) { + if (ctx->local_energy.e_local == NULL) { qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; mem_info.size = ctx->electron.walk_num * sizeof(double); - double* e_kin = (double*) qmckl_malloc(context, mem_info); + double* local_energy = (double*) qmckl_malloc(context, mem_info); - if (e_kin == NULL) { + if (local_energy == NULL) { return qmckl_failwith( context, QMCKL_ALLOCATION_FAILED, - "qmckl_e_kin", + "qmckl_local_energy", NULL); } - ctx->local_energy.e_kin = e_kin; + ctx->local_energy.e_local = local_energy; } qmckl_exit_code rc; @@ -1128,7 +1145,7 @@ qmckl_exit_code qmckl_provide_local_energy(qmckl_context context) { return rc; } - ctx->local_energy.e_kin_date = ctx->date; + ctx->local_energy.e_local_date = ctx->date; } return QMCKL_SUCCESS;