Reading MOs from TREXIO. Modified MOs API

This commit is contained in:
Anthony Scemama 2021-10-12 00:10:01 +02:00
parent e620e78938
commit f43a4ebff8
3 changed files with 286 additions and 134 deletions

View File

@ -238,7 +238,10 @@ qmckl_exit_code qmckl_init_ao_basis(qmckl_context context);
qmckl_exit_code qmckl_init_ao_basis(qmckl_context context) {
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return false;
return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_init_ao_basis",
NULL);
}
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
@ -955,7 +958,7 @@ qmckl_exit_code qmckl_get_ao_basis_ao_factor (const qmckl_context context,
function returns ~true~.
#+begin_src c :comments org :tangle (eval h_func)
bool qmckl_ao_basis_provided (const qmckl_context context);
bool qmckl_ao_basis_provided (const qmckl_context context);
#+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
@ -998,7 +1001,10 @@ qmckl_exit_code qmckl_set_ao_basis_cartesian (qmckl_context context, con
#+NAME:pre2
#+begin_src c :exports none
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return QMCKL_NULL_CONTEXT;
return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_get_ao_basis_*",
NULL);
}
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
@ -1590,7 +1596,10 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context);
qmckl_exit_code qmckl_finalize_basis(qmckl_context context) {
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return QMCKL_INVALID_CONTEXT;
return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_finalize_basis",
NULL);
}
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
@ -2302,7 +2311,10 @@ qmckl_exit_code qmckl_get_ao_basis_primitive_vgl(qmckl_context context, double*
qmckl_exit_code qmckl_get_ao_basis_primitive_vgl(qmckl_context context, double* const primitive_vgl) {
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return QMCKL_NULL_CONTEXT;
return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_get_ao_basis_primitive_vgl",
NULL);
}
qmckl_exit_code rc;
@ -2331,7 +2343,10 @@ qmckl_exit_code qmckl_provide_ao_basis_primitive_vgl(qmckl_context context)
{
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return QMCKL_NULL_CONTEXT;
return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_provide_get_ao_basis_primitive_vgl",
NULL);
}
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
@ -2647,7 +2662,10 @@ qmckl_exit_code qmckl_get_ao_basis_shell_vgl(qmckl_context context, double* cons
qmckl_exit_code qmckl_get_ao_basis_shell_vgl(qmckl_context context, double* const shell_vgl) {
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return QMCKL_NULL_CONTEXT;
return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_get_ao_basis_shell_vgl",
NULL);
}
qmckl_exit_code rc;
@ -2690,7 +2708,10 @@ qmckl_exit_code qmckl_provide_ao_basis_shell_vgl(qmckl_context context)
{
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return QMCKL_NULL_CONTEXT;
return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_provide_ao_basis_shell_vgl",
NULL);
}
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
@ -2699,7 +2720,7 @@ qmckl_exit_code qmckl_provide_ao_basis_shell_vgl(qmckl_context context)
if (!ctx->ao_basis.provided) {
return qmckl_failwith( context,
QMCKL_NOT_PROVIDED,
"qmckl_ao_basis_shell_vgl",
"qmckl_provide_ao_basis_shell_vgl",
NULL);
}
@ -3652,7 +3673,10 @@ qmckl_exit_code qmckl_get_ao_vgl(qmckl_context context, double* const ao_vgl);
qmckl_exit_code qmckl_get_ao_vgl(qmckl_context context, double* const ao_vgl) {
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return QMCKL_NULL_CONTEXT;
return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_get_ao_vgl",
NULL);
}
qmckl_exit_code rc;
@ -3695,7 +3719,10 @@ qmckl_exit_code qmckl_provide_ao_vgl(qmckl_context context)
{
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return QMCKL_NULL_CONTEXT;
return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_provide_ao_vgl",
NULL);
}
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;

View File

@ -78,18 +78,17 @@ int main() {
The following arrays are stored in the context:
|---------------------+--------------------+--------------------------------------------------------------|
| ~type~ | | Gaussian (~'G'~) or Slater (~'S'~) |
| ~mo_num~ | | Number of MOs |
| ~coefficient~ | ~[mo_num, ao_num]~ | Orbital coefficients |
|---------------+--------------------+----------------------|
| ~mo_num~ | | Number of MOs |
| ~coefficient~ | ~[mo_num][ao_num]~ | Orbital coefficients |
Computed data:
|---------------+-----------------------------------+----------------------------------------------------------------------------------------|
|---------------+-----------------------------------+----------------------------------------------------------------------------------------|
|---------------+-------------------------+----------------------------------------------------------------------------------------|
|---------------+-------------------------+----------------------------------------------------------------------------------------|
| ~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 |
|---------------+-----------------------------------+----------------------------------------------------------------------------------------|
| ~mo_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the MOs at electron positions |
|---------------+-------------------------+----------------------------------------------------------------------------------------|
** Data structure
@ -103,7 +102,6 @@ typedef struct qmckl_mo_basis_struct {
int32_t uninitialized;
bool provided;
char type;
} qmckl_mo_basis_struct;
#+end_src
@ -115,51 +113,24 @@ typedef struct qmckl_mo_basis_struct {
this mechanism.
** Access functions
#+begin_src c :comments org :tangle (eval h_private_func) :exports none
char qmckl_get_mo_basis_type (const qmckl_context context);
int64_t qmckl_get_mo_basis_mo_num (const qmckl_context context);
double* qmckl_get_mo_basis_coefficient (const qmckl_context context);
#+begin_src c :comments org :tangle (eval h_func) :exports none
qmckl_exit_code
qmckl_get_mo_basis_mo_num (const qmckl_context context,
int64_t* mo_num);
#+end_src
When all the data for the AOs have been provided, the following
function returns ~true~.
#+begin_src c :comments org :tangle (eval h_func)
bool qmckl_mo_basis_provided (const qmckl_context context);
#+end_src
#+NAME:post
#+begin_src c :exports none
if ( (ctx->mo_basis.uninitialized & mask) != 0) {
return NULL;
}
#+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
char qmckl_get_mo_basis_type (const qmckl_context context) {
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return (char) 0;
}
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
assert (ctx != NULL);
int32_t mask = 1;
if ( (ctx->mo_basis.uninitialized & mask) != 0) {
return (char) 0;
}
assert (ctx->mo_basis.type != (char) 0);
return ctx->mo_basis.type;
}
int64_t qmckl_get_mo_basis_mo_num (const qmckl_context context) {
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return (int64_t) 0;
qmckl_exit_code
qmckl_get_mo_basis_mo_num (const qmckl_context context,
int64_t* mo_num)
{
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_get_mo_basis_mo_num",
NULL);
return (int64_t) 0;
}
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
@ -168,13 +139,81 @@ int64_t qmckl_get_mo_basis_mo_num (const qmckl_context context) {
int32_t mask = 1 << 1;
if ( (ctx->mo_basis.uninitialized & mask) != 0) {
return (int64_t) 0;
return qmckl_failwith( context,
QMCKL_NOT_PROVIDED,
"qmckl_get_mo_basis_mo_num",
NULL);
}
assert (ctx->mo_basis.mo_num > (int64_t) 0);
return ctx->mo_basis.mo_num;
,*mo_num = ctx->mo_basis.mo_num;
return QMCKL_SUCCESS;
}
#+end_src
#+begin_src c :comments org :tangle (eval h_func) :exports none
qmckl_exit_code
qmckl_get_mo_basis_coefficient (const qmckl_context context,
double* const coefficient,
const int64_t size_max);
#+end_src
#+begin_src c :comments org :tangle (eval c) :exports none
qmckl_exit_code
qmckl_get_mo_basis_coefficient (const qmckl_context context,
double* const coefficient,
const int64_t size_max)
{
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return qmckl_failwith( context,
QMCKL_INVALID_CONTEXT,
"qmckl_get_mo_basis_coefficient",
NULL);
}
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
assert (ctx != NULL);
int32_t mask = 1 << 2;
if ( (ctx->ao_basis.uninitialized & mask) != 0) {
return qmckl_failwith( context,
QMCKL_NOT_PROVIDED,
"qmckl_get_mo_basis_coefficient",
NULL);
}
if (coefficient == NULL) {
return qmckl_failwith( context,
QMCKL_INVALID_ARG_2,
"qmckl_get_mo_basis_coefficient",
"NULL pointer");
}
if (size_max < ctx->ao_basis.ao_num * ctx->mo_basis.mo_num) {
return qmckl_failwith( context,
QMCKL_INVALID_ARG_3,
"qmckl_get_mo_basis_coefficient",
"Array too small. Expected mo_num * ao_num");
}
assert (ctx->mo_basis.coefficient != NULL);
memcpy(coefficient, ctx->mo_basis.coefficient,
ctx->ao_basis.ao_num * ctx->mo_basis.mo_num * sizeof(int64_t));
return QMCKL_SUCCESS;
}
#+end_src
When all the data for the AOs have been provided, the following
function returns ~true~.
#+begin_src c :comments org :tangle (eval h_func)
bool qmckl_mo_basis_provided (const qmckl_context context);
#+end_src
#+begin_src c :comments org :tangle (eval c) :exports none
bool qmckl_mo_basis_provided(const qmckl_context context) {
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
@ -196,12 +235,11 @@ bool qmckl_mo_basis_provided(const qmckl_context context) {
called.
#+begin_src c :comments org :tangle (eval h_func)
qmckl_exit_code qmckl_set_mo_basis_type (qmckl_context context, const char t);
qmckl_exit_code qmckl_set_mo_basis_mo_num (qmckl_context context, const int64_t mo_num);
qmckl_exit_code qmckl_set_mo_basis_coefficient (qmckl_context context, const double * coefficient);
#+end_src
#+NAME:pre2
#+NAME:pre
#+begin_src c :exports none
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return QMCKL_NULL_CONTEXT;
@ -210,7 +248,7 @@ if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
#+end_src
#+NAME:post2
#+NAME:post
#+begin_src c :exports none
ctx->mo_basis.uninitialized &= ~mask;
ctx->mo_basis.provided = (ctx->mo_basis.uninitialized == 0);
@ -223,24 +261,8 @@ return QMCKL_SUCCESS;
#+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
qmckl_exit_code qmckl_set_mo_basis_type(qmckl_context context, const char t) {
<<pre2>>
if (t != 'G' && t != 'S') {
return qmckl_failwith( context,
QMCKL_INVALID_ARG_2,
"qmckl_set_mo_basis_type",
NULL);
}
int32_t mask = 1;
ctx->mo_basis.type = t;
<<post2>>
}
qmckl_exit_code qmckl_set_mo_basis_mo_num(qmckl_context context, const int64_t mo_num) {
<<pre2>>
<<pre>>
if (mo_num <= 0) {
return qmckl_failwith( context,
@ -252,11 +274,11 @@ qmckl_exit_code qmckl_set_mo_basis_mo_num(qmckl_context context, const int64_t m
int32_t mask = 1 << 1;
ctx->mo_basis.mo_num = mo_num;
<<post2>>
<<post>>
}
qmckl_exit_code qmckl_set_mo_basis_coefficient(qmckl_context context, const double* coefficient) {
<<pre2>>
<<pre>>
int32_t mask = 1 << 2;
@ -283,7 +305,7 @@ qmckl_exit_code qmckl_set_mo_basis_coefficient(qmckl_context context, const dou
ctx->mo_basis.coefficient = new_array;
<<post2>>
<<post>>
}
#+end_src
@ -398,20 +420,13 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context)
}
qmckl_exit_code rc;
if (ctx->mo_basis.type == 'G') {
rc = qmckl_compute_mo_basis_gaussian_vgl(context,
ctx->ao_basis.ao_num,
ctx->mo_basis.mo_num,
ctx->electron.num,
ctx->mo_basis.coefficient,
ctx->ao_basis.ao_vgl,
ctx->mo_basis.mo_vgl);
} else {
return qmckl_failwith( context,
QMCKL_FAILURE,
"compute_mo_basis_vgl",
"Not yet implemented");
}
rc = qmckl_compute_mo_basis_vgl(context,
ctx->ao_basis.ao_num,
ctx->mo_basis.mo_num,
ctx->electron.num,
ctx->mo_basis.coefficient,
ctx->ao_basis.ao_vgl,
ctx->mo_basis.mo_vgl);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -425,22 +440,22 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context)
*** Compute
:PROPERTIES:
:Name: qmckl_compute_mo_basis_gaussian_vgl
:Name: qmckl_compute_mo_basis_vgl
:CRetType: qmckl_exit_code
:FRetType: qmckl_exit_code
:END:
#+NAME: qmckl_mo_basis_gaussian_vgl_args
| ~qmckl_context~ | ~context~ | in | Global state |
| ~int64_t~ | ~ao_num~ | in | Number of AOs |
| ~int64_t~ | ~mo_num~ | in | Number of MOs |
| ~int64_t~ | ~elec_num~ | in | Number of electrons |
| ~double~ | ~coef_normalized[mo_num][ao_num]~ | in | AO to MO transformation matrix |
| ~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 |
| ~qmckl_context~ | ~context~ | in | Global state |
| ~int64_t~ | ~ao_num~ | in | Number of AOs |
| ~int64_t~ | ~mo_num~ | in | Number of MOs |
| ~int64_t~ | ~elec_num~ | in | Number of electrons |
| ~double~ | ~coef_normalized[mo_num][ao_num]~ | in | AO to MO transformation matrix |
| ~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, &
integer function qmckl_compute_mo_basis_vgl_f(context, &
ao_num, mo_num, elec_num, &
coef_normalized, ao_vgl, mo_vgl) &
result(info)
@ -528,14 +543,14 @@ integer function qmckl_compute_mo_basis_gaussian_vgl_f(context, &
info = QMCKL_FAILURE
end if
end function qmckl_compute_mo_basis_gaussian_vgl_f
end function qmckl_compute_mo_basis_vgl_f
#+end_src
#+CALL: generate_c_header(table=qmckl_mo_basis_gaussian_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_mo_basis_gaussian_vgl"))
#+CALL: generate_c_header(table=qmckl_mo_basis_gaussian_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_mo_basis_vgl"))
#+RESULTS:
#+begin_src c :tangle (eval h_func) :comments org
qmckl_exit_code qmckl_compute_mo_basis_gaussian_vgl (
qmckl_exit_code qmckl_compute_mo_basis_vgl (
const qmckl_context context,
const int64_t ao_num,
const int64_t mo_num,
@ -546,11 +561,11 @@ end function qmckl_compute_mo_basis_gaussian_vgl_f
#+end_src
#+CALL: generate_c_interface(table=qmckl_mo_basis_gaussian_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_mo_basis_gaussian_vgl"))
#+CALL: generate_c_interface(table=qmckl_mo_basis_gaussian_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_mo_basis_vgl"))
#+RESULTS:
#+begin_src f90 :tangle (eval f) :comments org :exports none
integer(c_int32_t) function qmckl_compute_mo_basis_gaussian_vgl &
integer(c_int32_t) function qmckl_compute_mo_basis_vgl &
(context, ao_num, mo_num, elec_num, coef_normalized, ao_vgl, mo_vgl) &
bind(C) result(info)
@ -565,15 +580,13 @@ end function qmckl_compute_mo_basis_gaussian_vgl_f
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 &
integer(c_int32_t), external :: qmckl_compute_mo_basis_vgl_f
info = qmckl_compute_mo_basis_vgl_f &
(context, ao_num, mo_num, elec_num, coef_normalized, ao_vgl, mo_vgl)
end function qmckl_compute_mo_basis_gaussian_vgl
end function qmckl_compute_mo_basis_vgl
#+end_src
*** Test
#+begin_src python :results output :exports none
@ -751,9 +764,6 @@ rc = qmckl_get_ao_vgl(context, &(ao_vgl[0][0][0][0]));
assert (rc == QMCKL_SUCCESS);
/* Set up MO data */
rc = qmckl_set_mo_basis_type(context, typ);
assert (rc == QMCKL_SUCCESS);
const int64_t mo_num = chbrclf_mo_num;
rc = qmckl_set_mo_basis_mo_num(context, mo_num);
assert (rc == QMCKL_SUCCESS);
@ -827,7 +837,6 @@ printf("\n");
#+end_src
* End of files :noexport:
#+begin_src c :tangle (eval h_private_type)

View File

@ -113,8 +113,8 @@ qmckl_trexio_read_electron_X(qmckl_context context, trexio_t* const file)
int rcio = 0;
int64_t up_num = 0;
int64_t dn_num = 0;
int64_t up_num = 0L;
int64_t dn_num = 0L;
rcio = trexio_read_electron_up_num_64(file, &up_num);
if (rcio != TREXIO_SUCCESS) {
@ -124,7 +124,7 @@ qmckl_trexio_read_electron_X(qmckl_context context, trexio_t* const file)
trexio_string_of_error(rcio));
}
assert (up_num >= 0);
assert (up_num >= 0L);
rcio = trexio_read_electron_dn_num_64(file, &dn_num);
if (rcio != TREXIO_SUCCESS) {
@ -134,7 +134,7 @@ qmckl_trexio_read_electron_X(qmckl_context context, trexio_t* const file)
trexio_string_of_error(rcio));
}
assert (dn_num >= 0);
assert (dn_num >= 0L);
qmckl_exit_code rc;
@ -163,7 +163,7 @@ qmckl_trexio_read_nucleus_X(qmckl_context context, trexio_t* const file)
*** Number of nuclei
#+begin_src c :tangle (eval c)
int64_t nucleus_num = 0;
int64_t nucleus_num = 0L;
rcio = trexio_read_nucleus_num_64(file, &nucleus_num);
if (rcio != TREXIO_SUCCESS) {
@ -279,7 +279,7 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
qmckl_exit_code rc;
int rcio = 0;
int64_t nucleus_num = 0;
int64_t nucleus_num = 0L;
rc = qmckl_get_nucleus_num(context, &nucleus_num);
if (rc != QMCKL_SUCCESS)
@ -318,7 +318,7 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
*** Number of shells
#+begin_src c :tangle (eval c)
int64_t shell_num = 0;
int64_t shell_num = 0L;
rcio = trexio_read_basis_num_64(file, &shell_num);
if (rcio != TREXIO_SUCCESS) {
@ -339,7 +339,7 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
*** Number of primitives
#+begin_src c :tangle (eval c)
int64_t prim_num = 0;
int64_t prim_num = 0L;
rcio = trexio_read_basis_prim_num_64(file, &prim_num);
if (rcio != TREXIO_SUCCESS) {
@ -360,7 +360,7 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
*** Number of atomic orbitals
#+begin_src c :tangle (eval c)
int64_t ao_num = 0;
int64_t ao_num = 0LL;
rcio = trexio_read_ao_num_64(file, &ao_num);
if (rcio != TREXIO_SUCCESS) {
@ -702,7 +702,92 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
}
#+end_src
*** End
#+begin_src c :tangle (eval c)
return QMCKL_SUCCESS;
}
#endif
#+end_src
** Molecular orbitals
In this section we read the MO coefficients.
#+begin_src c :tangle (eval c)
#ifdef HAVE_TREXIO
qmckl_exit_code
qmckl_trexio_read_mo_X(qmckl_context context, trexio_t* const file)
{
assert (context != (qmckl_context) 0);
assert (file != NULL);
qmckl_exit_code rc;
int rcio = 0;
int64_t ao_num = 0L;
rc = qmckl_get_ao_basis_ao_num(context, &ao_num);
if (rc != QMCKL_SUCCESS)
return rc;
#+end_src
*** Number of MOs
#+begin_src c :tangle (eval c)
int64_t mo_num = 0L;
rcio = trexio_read_mo_num_64(file, &mo_num);
if (rcio != TREXIO_SUCCESS) {
return qmckl_failwith( context,
QMCKL_FAILURE,
"trexio_read_mo_num",
trexio_string_of_error(rcio));
}
assert (mo_num > 0);
rc = qmckl_set_mo_basis_mo_num(context, mo_num);
if (rc != QMCKL_SUCCESS)
return rc;
#+end_src
*** MO coefficients
#+begin_src c :tangle (eval c)
{
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = ao_num * mo_num * sizeof(double);
double* mo_coef = (double*) qmckl_malloc(context, mem_info);
if (mo_coef == NULL) {
return qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
"qmckl_trexio_read_mo_X",
NULL);
}
assert (mo_coef != NULL);
rcio = trexio_read_mo_coefficient_64(file, mo_coef);
if (rcio != TREXIO_SUCCESS) {
return qmckl_failwith( context,
QMCKL_FAILURE,
"trexio_read_mo_coefficient",
trexio_string_of_error(rcio));
}
rc = qmckl_set_mo_basis_coefficient(context, mo_coef);
qmckl_free(context, mo_coef);
mo_coef = NULL;
if (rc != QMCKL_SUCCESS)
return rc;
}
#+end_src
#+begin_src c :tangle (eval c)
@ -767,6 +852,15 @@ qmckl_trexio_read(const qmckl_context context, const char* file_name)
"Error reading AOs");
}
rc = qmckl_trexio_read_mo_X(context, file);
if (rc != QMCKL_SUCCESS) {
trexio_close(file);
return qmckl_failwith( context,
QMCKL_FAILURE,
"qmckl_trexio_read",
"Error reading MOs");
}
trexio_close(file);
file = NULL;
#else
@ -957,6 +1051,28 @@ prim_factor = NULL;
#endif
#+end_src
*** MO Basis
#+begin_src c :tangle (eval c_test)
printf("MOs\n");
int64_t mo_num;
rc = qmckl_get_mo_basis_mo_num(context, &mo_num);
assert (rc == QMCKL_SUCCESS);
assert (mo_num == chbrclf_mo_num);
printf("MO coefs\n");
double * mo_coef = (double*) malloc (ao_num * mo_num * sizeof(double));
rc = qmckl_get_mo_basis_coefficient(context, mo_coef, mo_num*ao_num);
assert (rc == QMCKL_SUCCESS);
for (int i=0 ; i<ao_num * mo_num ; i++) {
assert (mo_coef[i] == chbrclf_mo_coef[i]);
}
free(mo_coef);
charge = NULL;
#+end_src
* End of files :noexport:
*** Test