mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-08-16 18:38:28 +02:00
Documentation in MOs
This commit is contained in:
parent
5512c1b41c
commit
d5289057cd
309
org/qmckl_mo.org
309
org/qmckl_mo.org
@ -3,16 +3,16 @@
|
||||
#+INCLUDE: ../tools/lib.org
|
||||
|
||||
The molecular orbitals (MOs) are defined in the basis of AOs along with a AO to MO
|
||||
coefficient matrix \[C\]. Using these coefficients (e.g. from Hartree Fock SCF method)
|
||||
coefficient matrix $C$. Using these coefficients (e.g. from Hartree Fock method)
|
||||
the MOs are defined as follows:
|
||||
|
||||
\[
|
||||
\phi_i(\mathbf{r}) = C_i * \chi_i (\mathbf{r})
|
||||
\]
|
||||
|
||||
|
||||
In this section we demonstrate how to use the QMCkl specific DGEMM
|
||||
function to calculate the MOs.
|
||||
By default, all the MOs are computed. A subset of MOs can be selected
|
||||
for computation, for example to remove computation of the useless
|
||||
virtual MOs present in a MO coefficient matrix.
|
||||
|
||||
|
||||
* Headers :noexport:
|
||||
@ -84,11 +84,11 @@ int main() {
|
||||
The following arrays are stored in the context:
|
||||
|
||||
|
||||
|-----------------+--------------------+----------------------------------------|
|
||||
| ~mo_num~ | | Number of MOs |
|
||||
| ~coefficient~ | ~[mo_num][ao_num]~ | Orbital coefficients |
|
||||
| ~coefficient_t~ | ~[ao_num][mo_num]~ | Transposed of the Orbital coefficients |
|
||||
|-----------------+--------------------+----------------------------------------|
|
||||
|-------------------+--------------------+----------------------------------------|
|
||||
| ~mo_num~ | | Number of MOs |
|
||||
| ~coefficient~ | ~[mo_num][ao_num]~ | MO coefficients |
|
||||
| ~coefficient_t~ | ~[ao_num][mo_num]~ | Transposed of the Orbital coefficients |
|
||||
|-------------------+--------------------+----------------------------------------|
|
||||
|
||||
Computed data:
|
||||
|
||||
@ -103,7 +103,7 @@ int main() {
|
||||
|
||||
#+begin_src c :comments org :tangle (eval h_private_type)
|
||||
typedef struct qmckl_mo_basis_struct {
|
||||
int64_t mo_num;
|
||||
int64_t mo_num;
|
||||
double * restrict coefficient;
|
||||
double * restrict coefficient_t;
|
||||
|
||||
@ -144,150 +144,6 @@ qmckl_exit_code qmckl_init_mo_basis(qmckl_context context) {
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** Access functions
|
||||
|
||||
#+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
|
||||
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
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);
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
int32_t mask = 1;
|
||||
|
||||
if ( (ctx->mo_basis.uninitialized & mask) != 0) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_NOT_PROVIDED,
|
||||
"qmckl_get_mo_basis_mo_num",
|
||||
NULL);
|
||||
}
|
||||
|
||||
assert (ctx->mo_basis.mo_num > (int64_t) 0);
|
||||
,*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*) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
int32_t mask = 1 << 1;
|
||||
|
||||
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(double));
|
||||
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
return ctx->mo_basis.provided;
|
||||
}
|
||||
|
||||
|
||||
#+end_src
|
||||
|
||||
*** Fortran interfaces
|
||||
|
||||
#+begin_src f90 :tangle (eval fh_func) :comments org :exports none
|
||||
interface
|
||||
integer(c_int32_t) function qmckl_get_mo_basis_mo_num (context, &
|
||||
mo_num) bind(C)
|
||||
use, intrinsic :: iso_c_binding
|
||||
import
|
||||
implicit none
|
||||
integer (c_int64_t) , intent(in) , value :: context
|
||||
integer (c_int64_t) , intent(out) :: mo_num
|
||||
end function qmckl_get_mo_basis_mo_num
|
||||
end interface
|
||||
|
||||
interface
|
||||
integer(c_int32_t) function qmckl_get_mo_basis_coefficient(context, &
|
||||
coefficient, size_max) bind(C)
|
||||
use, intrinsic :: iso_c_binding
|
||||
import
|
||||
implicit none
|
||||
integer (c_int64_t) , intent(in) , value :: context
|
||||
double precision, intent(out) :: coefficient(*)
|
||||
integer (c_int64_t) , intent(in), value :: size_max
|
||||
end function qmckl_get_mo_basis_coefficient
|
||||
end interface
|
||||
|
||||
#+end_src
|
||||
|
||||
** Initialization functions
|
||||
|
||||
To set the basis set, all the following functions need to be
|
||||
@ -431,6 +287,151 @@ qmckl_exit_code qmckl_finalize_mo_basis(qmckl_context context) {
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** Access functions
|
||||
|
||||
#+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
|
||||
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
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);
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
int32_t mask = 1;
|
||||
|
||||
if ( (ctx->mo_basis.uninitialized & mask) != 0) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_NOT_PROVIDED,
|
||||
"qmckl_get_mo_basis_mo_num",
|
||||
NULL);
|
||||
}
|
||||
|
||||
assert (ctx->mo_basis.mo_num > (int64_t) 0);
|
||||
,*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*) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
int32_t mask = 1 << 1;
|
||||
|
||||
if ( (ctx->mo_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(double));
|
||||
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
return ctx->mo_basis.provided;
|
||||
}
|
||||
|
||||
|
||||
#+end_src
|
||||
|
||||
|
||||
*** Fortran interfaces
|
||||
|
||||
#+begin_src f90 :tangle (eval fh_func) :comments org :exports none
|
||||
interface
|
||||
integer(c_int32_t) function qmckl_get_mo_basis_mo_num (context, &
|
||||
mo_num) bind(C)
|
||||
use, intrinsic :: iso_c_binding
|
||||
import
|
||||
implicit none
|
||||
integer (c_int64_t) , intent(in) , value :: context
|
||||
integer (c_int64_t) , intent(out) :: mo_num
|
||||
end function qmckl_get_mo_basis_mo_num
|
||||
end interface
|
||||
|
||||
interface
|
||||
integer(c_int32_t) function qmckl_get_mo_basis_coefficient(context, &
|
||||
coefficient, size_max) bind(C)
|
||||
use, intrinsic :: iso_c_binding
|
||||
import
|
||||
implicit none
|
||||
integer (c_int64_t) , intent(in) , value :: context
|
||||
double precision, intent(out) :: coefficient(*)
|
||||
integer (c_int64_t) , intent(in), value :: size_max
|
||||
end function qmckl_get_mo_basis_coefficient
|
||||
end interface
|
||||
|
||||
#+end_src
|
||||
|
||||
* Computation
|
||||
|
||||
** Computation of MOs: values only
|
||||
|
Loading…
Reference in New Issue
Block a user