1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-07-18 08:53:47 +02:00

Fixed provider for local_energy. #41

This commit is contained in:
v1j4y 2021-10-13 17:56:33 +02:00
parent ca5c332d85
commit dcc5f09724
2 changed files with 27 additions and 8 deletions

View File

@ -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

View File

@ -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;