1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-12-22 20:36:01 +01:00

Basis read from trexio

This commit is contained in:
Anthony Scemama 2021-10-11 23:26:12 +02:00
parent ecfe58a966
commit e620e78938

View File

@ -414,7 +414,7 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
}
#+end_src
*** Nucleus_shell_num array
*** Number of shells per nucleus
#+begin_src c :tangle (eval c)
{
@ -450,6 +450,259 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
}
#+end_src
*** Angular momentum
#+begin_src c :tangle (eval c)
{
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = shell_num * sizeof(int32_t);
int32_t* shell_ang_mom = (int32_t*) qmckl_malloc(context, mem_info);
if (shell_ang_mom == NULL) {
return qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
"qmckl_trexio_read_basis_shell_ang_mom_X",
NULL);
}
assert (shell_ang_mom != NULL);
rcio = trexio_read_basis_shell_ang_mom_32(file, shell_ang_mom);
if (rcio != TREXIO_SUCCESS) {
return qmckl_failwith( context,
QMCKL_FAILURE,
"trexio_read_basis_shell_ang_mom",
trexio_string_of_error(rcio));
}
rc = qmckl_set_ao_basis_shell_ang_mom(context, shell_ang_mom);
qmckl_free(context, shell_ang_mom);
shell_ang_mom = NULL;
if (rc != QMCKL_SUCCESS)
return rc;
}
#+end_src
*** Number of primitives per shell
#+begin_src c :tangle (eval c)
{
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = shell_num * sizeof(int64_t);
int64_t* shell_prim_num = (int64_t*) qmckl_malloc(context, mem_info);
if (shell_prim_num == NULL) {
return qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
"qmckl_trexio_read_basis_shell_prim_num_X",
NULL);
}
assert (shell_prim_num != NULL);
rcio = trexio_read_basis_shell_prim_num_64(file, shell_prim_num);
if (rcio != TREXIO_SUCCESS) {
return qmckl_failwith( context,
QMCKL_FAILURE,
"trexio_read_basis_shell_prim_num",
trexio_string_of_error(rcio));
}
rc = qmckl_set_ao_basis_shell_prim_num(context, shell_prim_num);
qmckl_free(context, shell_prim_num);
shell_prim_num = NULL;
if (rc != QMCKL_SUCCESS)
return rc;
}
#+end_src
*** Indices of the primitives
#+begin_src c :tangle (eval c)
{
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = shell_num * sizeof(int64_t);
int64_t* shell_prim_index = (int64_t*) qmckl_malloc(context, mem_info);
if (shell_prim_index == NULL) {
return qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
"qmckl_trexio_read_basis_shell_prim_index_X",
NULL);
}
assert (shell_prim_index != NULL);
rcio = trexio_read_basis_shell_prim_index_64(file, shell_prim_index);
if (rcio != TREXIO_SUCCESS) {
return qmckl_failwith( context,
QMCKL_FAILURE,
"trexio_read_basis_shell_prim_index",
trexio_string_of_error(rcio));
}
rc = qmckl_set_ao_basis_shell_prim_index(context, shell_prim_index);
qmckl_free(context, shell_prim_index);
shell_prim_index = NULL;
if (rc != QMCKL_SUCCESS)
return rc;
}
#+end_src
*** Normalization of the shells
#+begin_src c :tangle (eval c)
{
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = shell_num * sizeof(double);
double* shell_factor = (double*) qmckl_malloc(context, mem_info);
if (shell_factor == NULL) {
return qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
"qmckl_trexio_read_basis_shell_factor_X",
NULL);
}
assert (shell_factor != NULL);
rcio = trexio_read_basis_shell_factor_64(file, shell_factor);
if (rcio != TREXIO_SUCCESS) {
return qmckl_failwith( context,
QMCKL_FAILURE,
"trexio_read_basis_shell_factor",
trexio_string_of_error(rcio));
}
rc = qmckl_set_ao_basis_shell_factor(context, shell_factor);
qmckl_free(context, shell_factor);
shell_factor = NULL;
if (rc != QMCKL_SUCCESS)
return rc;
}
#+end_src
*** Exponents
#+begin_src c :tangle (eval c)
{
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = prim_num * sizeof(double);
double* exponent = (double*) qmckl_malloc(context, mem_info);
if (exponent == NULL) {
return qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
"qmckl_trexio_read_basis_exponent_X",
NULL);
}
assert (exponent != NULL);
rcio = trexio_read_basis_exponent_64(file, exponent);
if (rcio != TREXIO_SUCCESS) {
return qmckl_failwith( context,
QMCKL_FAILURE,
"trexio_read_basis_exponent",
trexio_string_of_error(rcio));
}
rc = qmckl_set_ao_basis_exponent(context, exponent);
qmckl_free(context, exponent);
exponent = NULL;
if (rc != QMCKL_SUCCESS)
return rc;
}
#+end_src
*** Coefficients
#+begin_src c :tangle (eval c)
{
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = prim_num * sizeof(double);
double* coefficient = (double*) qmckl_malloc(context, mem_info);
if (coefficient == NULL) {
return qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
"qmckl_trexio_read_basis_coefficient_X",
NULL);
}
assert (coefficient != NULL);
rcio = trexio_read_basis_coefficient_64(file, coefficient);
if (rcio != TREXIO_SUCCESS) {
return qmckl_failwith( context,
QMCKL_FAILURE,
"trexio_read_basis_coefficient",
trexio_string_of_error(rcio));
}
rc = qmckl_set_ao_basis_coefficient(context, coefficient);
qmckl_free(context, coefficient);
coefficient = NULL;
if (rc != QMCKL_SUCCESS)
return rc;
}
#+end_src
*** Normalization of the primitivies
#+begin_src c :tangle (eval c)
{
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = prim_num * sizeof(double);
double* prim_factor = (double*) qmckl_malloc(context, mem_info);
if (prim_factor == NULL) {
return qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
"qmckl_trexio_read_basis_prim_factor_X",
NULL);
}
assert (prim_factor != NULL);
rcio = trexio_read_basis_prim_factor_64(file, prim_factor);
if (rcio != TREXIO_SUCCESS) {
return qmckl_failwith( context,
QMCKL_FAILURE,
"trexio_read_basis_prim_factor",
trexio_string_of_error(rcio));
}
rc = qmckl_set_ao_basis_prim_factor(context, prim_factor);
qmckl_free(context, prim_factor);
prim_factor = NULL;
if (rc != QMCKL_SUCCESS)
return rc;
}
#+end_src
*** End
#+begin_src c :tangle (eval c)
@ -600,7 +853,7 @@ coord = NULL;
#+end_src
*** Atomic basis
#+begin_src c :tangle (eval c_test)
printf("Atomic basis\n");
@ -626,6 +879,8 @@ assert (rc == QMCKL_SUCCESS);
for (int i=0 ; i<nucl_num ; i++) {
assert (nucleus_index[i] == chbrclf_basis_nucleus_index[i]);
}
free(nucleus_index);
nucleus_index = NULL;
int64_t* nucleus_shell_num = (int64_t*) malloc (nucl_num * sizeof(int64_t));
rc = qmckl_get_ao_basis_nucleus_shell_num(context, nucleus_shell_num, nucl_num);
@ -633,10 +888,72 @@ assert (rc == QMCKL_SUCCESS);
for (int i=0 ; i<nucl_num ; i++) {
assert (nucleus_shell_num[i] == chbrclf_basis_nucleus_shell_num[i]);
}
free(nucleus_shell_num);
nucleus_shell_num = NULL;
int32_t* shell_ang_mom = (int32_t*) malloc (shell_num * sizeof(int32_t));
rc = qmckl_get_ao_basis_shell_ang_mom(context, shell_ang_mom, shell_num);
assert (rc == QMCKL_SUCCESS);
for (int i=0 ; i<shell_num ; i++) {
assert (shell_ang_mom[i] == chbrclf_basis_shell_ang_mom[i]);
}
free(shell_ang_mom);
shell_ang_mom = NULL;
int64_t* shell_prim_num = (int64_t*) malloc (shell_num * sizeof(int64_t));
rc = qmckl_get_ao_basis_shell_prim_num(context, shell_prim_num, shell_num);
assert (rc == QMCKL_SUCCESS);
for (int i=0 ; i<shell_num ; i++) {
assert (shell_prim_num[i] == chbrclf_basis_shell_prim_num[i]);
}
free(shell_prim_num);
shell_prim_num = NULL;
int64_t* shell_prim_index = (int64_t*) malloc (shell_num * sizeof(int64_t));
rc = qmckl_get_ao_basis_shell_prim_index(context, shell_prim_index, shell_num);
assert (rc == QMCKL_SUCCESS);
for (int i=0 ; i<shell_num ; i++) {
assert (shell_prim_index[i] == chbrclf_basis_shell_prim_index[i]);
}
free(shell_prim_index);
shell_prim_index = NULL;
double* shell_factor = (double*) malloc (shell_num * sizeof(double));
rc = qmckl_get_ao_basis_shell_factor(context, shell_factor, shell_num);
assert (rc == QMCKL_SUCCESS);
for (int i=0 ; i<shell_num ; i++) {
assert (fabs(shell_factor[i] - chbrclf_basis_shell_factor[i]) < 1.e-6);
}
free(shell_factor);
shell_factor = NULL;
double* exponent = (double*) malloc (prim_num * sizeof(double));
rc = qmckl_get_ao_basis_exponent(context, exponent, prim_num);
assert (rc == QMCKL_SUCCESS);
for (int i=0 ; i<prim_num ; i++) {
assert (fabs((exponent[i] - chbrclf_basis_exponent[i])/chbrclf_basis_exponent[i]) < 1.e-7);
}
free(exponent);
exponent = NULL;
double* coefficient = (double*) malloc (prim_num * sizeof(double));
rc = qmckl_get_ao_basis_coefficient(context, coefficient, prim_num);
assert (rc == QMCKL_SUCCESS);
for (int i=0 ; i<prim_num ; i++) {
assert (fabs((coefficient[i] - chbrclf_basis_coefficient[i])/chbrclf_basis_coefficient[i]) < 1.e-7);
}
free(coefficient);
coefficient = NULL;
double* prim_factor = (double*) malloc (prim_num * sizeof(double));
rc = qmckl_get_ao_basis_prim_factor(context, prim_factor, prim_num);
assert (rc == QMCKL_SUCCESS);
for (int i=0 ; i<prim_num ; i++) {
assert (fabs((prim_factor[i] - chbrclf_basis_prim_factor[i])/chbrclf_basis_prim_factor[i]) < 1.e-7);
}
free(prim_factor);
prim_factor = NULL;
free(charge);
charge = NULL;
#endif
#+end_src