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

Merge branch 'master' into unit-testing

This commit is contained in:
q-posev 2021-06-22 14:46:39 +02:00
commit 411334e2ee
7 changed files with 81 additions and 54 deletions

View File

@ -55,13 +55,13 @@ lib_LTLIBRARIES = src/libtrexio.la
SOURCES = \
$(trexio_h) \
$(srcdir)/src/trexio.c \
$(srcdir)/src/trexio_private.h \
$(srcdir)/src/trexio_s.h \
$(srcdir)/src/trexio_hdf5.c \
$(srcdir)/src/trexio_hdf5.h \
$(srcdir)/src/trexio_text.c \
$(srcdir)/src/trexio_text.h
src/trexio.c \
src/trexio_private.h \
src/trexio_s.h \
src/trexio_hdf5.c \
src/trexio_hdf5.h \
src/trexio_text.c \
src/trexio_text.h
ORG_FILES = \
src/templates_front/templator_front.org \
@ -99,6 +99,7 @@ check_PROGRAMS = $(TESTS)
# specify common options for all tests
LDADD = src/libtrexio.la
# in principal, specifying -no-install (see example below) is not mandatory
# for the tests to compile and pass, but the compilations itself differs
tests_io_num_hdf5_LDFLAGS = -no-install
@ -124,18 +125,37 @@ tests_test_f_SOURCES = $(test_trexio_f) tests/test_f.f90
tests_test_f_LDFLAGS = -no-install
HTML_FILES = docs/trexio.css \
docs/index.html \
docs/Sparse.html \
docs/templator_hdf5.html \
docs/trex.html \
docs/README.html \
docs/templator_front.html \
docs/templator_text.html
htmldir = $(docdir)
dist_html_DATA = $(HTML_FILES)
$(HTML_FILES): docs/index.html
if TREXIO_DEVEL
CLEANFILES += $(SOURCES) $(trexio_f) $(trexio_h)
BUILT_SOURCES = $(SOURCES) $(trexio_f) $(test_trexio_f)
$(SOURCES): $(trexio_f)
src/trexio.c: $(trexio_h)
$(trexio_f): $(ORG_FILES)
cd $(srcdir)/tools && ./build_trexio.sh
docs/index.html: $(SOURCES) $(srcdir)/src/README.org
cd $(srcdir)/tools && ./build_doc.sh
cppcheck: cppcheck.out
cat cppcheck.out

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([trexio], [0.2.0], [https://github.com/TREX-CoE/trexio/issues])
AC_INIT([trexio], [0.3.0], [https://github.com/TREX-CoE/trexio/issues])
AM_INIT_AUTOMAKE([subdir-objects color-tests parallel-tests silent-rules 1.11])
AM_MAINTAINER_MODE()
LT_INIT
@ -72,7 +72,7 @@ AC_CHECK_HEADERS([fcntl.h inttypes.h stdint.h stdbool.h stdlib.h string.h unistd
PKG_HDF5=""
AX_LIB_HDF5([serial])
AX_LIB_HDF5()
if test "x${with_hdf5}" = xno; then
AC_MSG_WARN([

View File

@ -4,6 +4,7 @@
------------------
- [[./trex.html][Data stored with TREXIO]]
- [[./templator_front.html][Front end API]]
- [[./templator_hdf5.html][HDF5 back end]]
- [[./templator_text.html][TEXT back end]]

View File

@ -1643,6 +1643,7 @@ trexio_read_$group_dset$_low (trexio_t* const file, char* dset, const uint32_t m
,*/
}
return TREXIO_FAILURE;
}
trexio_exit_code
@ -1803,7 +1804,6 @@ trexio_write_$group_dset$ (trexio_t* const file, const char** dset, const uint32
FREE(str_compiled);
return rc;
}
#+end_src
@ -1831,6 +1831,7 @@ trexio_has_$group_dset$ (trexio_t* const file)
break;
,*/
}
return TREXIO_FAILURE;
}
#+end_src
@ -1968,6 +1969,7 @@ trexio_read_$group_str$ (trexio_t* const file, char* const str, const uint32_t m
,*/
}
return TREXIO_FAILURE;
}
#+end_src
@ -2000,6 +2002,7 @@ trexio_write_$group_str$ (trexio_t* const file, const char* str, const uint32_t
,*/
}
return TREXIO_FAILURE;
}
#+end_src

View File

@ -289,15 +289,6 @@ trexio_hdf5_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $
const trexio_hdf5_t* f = (const trexio_hdf5_t*) file;
herr_t status;
int rrank;
// get the rank of the dataset in a file
status = H5LTget_dataset_ndims (f->$group$_group, $GROUP_DSET$_NAME, &rrank);
if (status < 0) return TREXIO_FAILURE;
if (rrank != (int) rank) return TREXIO_INVALID_ARG_3;
// open the dataset to get its dimensions
hid_t dset_id = H5Dopen(f->$group$_group, $GROUP_DSET$_NAME, H5P_DEFAULT);
if (dset_id <= 0) return TREXIO_INVALID_ID;
@ -306,28 +297,37 @@ trexio_hdf5_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $
hsize_t* ddims = CALLOC( (int) rank, hsize_t);
if (ddims == NULL) return TREXIO_FAILURE;
// read dimensions from the existing dataset
status = H5LDget_dset_dims(dset_id, ddims);
// get the dataspace of the dataset
hid_t dspace_id = H5Dget_space(dset_id);
// get the rank and dimensions of the dataset
int rrank = H5Sget_simple_extent_dims(dspace_id, ddims, NULL);
H5Dclose(dset_id);
if (status < 0) {
// check that dimensions are consistent
if (rrank != (int) rank) {
FREE(ddims);
return TREXIO_FAILURE;
H5Sclose(dspace_id);
H5Dclose(dset_id);
return TREXIO_INVALID_ARG_3;
}
for (uint32_t i=0; i<rank; ++i){
if (ddims[i] != dims[i]) {
FREE(ddims);
H5Sclose(dspace_id);
H5Dclose(dset_id);
return TREXIO_INVALID_ARG_4;
}
}
FREE(ddims);
H5Sclose(dspace_id);
H5Dclose(dset_id);
/* High-level H5LT API. No need to deal with dataspaces and datatypes */
status = H5LTread_dataset(f->$group$_group,
$GROUP_DSET$_NAME,
H5T_$GROUP_DSET_H5_DTYPE$,
$group_dset$);
herr_t status = H5LTread_dataset(f->$group$_group,
$GROUP_DSET$_NAME,
H5T_$GROUP_DSET_H5_DTYPE$,
$group_dset$);
if (status < 0) return TREXIO_FAILURE;
return TREXIO_SUCCESS;

View File

@ -99,10 +99,11 @@ function main() {
# Create documentation
cd ${SRC}
for dir in ${SRC}/templates_*/
for dir in ${SRC}/templates_*/ ${TREXIO_ROOT}/
do
dir=${dir%*/}
echo ${dir}
OLDPWD=$PWD
cd ${dir}
for i in *.org
do
@ -110,7 +111,7 @@ function main() {
echo "======= ${i} ======="
extract_doc ${i} ${dir}
done
cd ..
cd $OLDPWD
done
echo

View File

@ -1,5 +1,7 @@
#+TITLE: TREX Configuration file
#+STARTUP: latexpreview
#+SETUPFILE: docs/theme.setup
All the quantities are saved in atomic units.
The dimensions of the arrays in the tables below are given in
@ -11,12 +13,12 @@ In Fortran, the arrays are 1-based and in most other languages the
arrays are 0-base. Hence, we introduce the ~index~ type which is an
1-based ~int~ in the Fortran interface and 0-based otherwise.
#+begin_src python :tangle trex.json
#+begin_src python :tangle trex.json
{
#+end_src
* Metadata
As we expect our files to be archived in open-data repositories, we
need to give the possibility to the users to store some metadata
inside the files. We propose to store the list of names of the codes
@ -175,7 +177,7 @@ arrays are 0-base. Hence, we introduce the ~index~ type which is an
R_s(\mathbf{r}) = \mathcal{N}_s \vert\mathbf{r}-\mathbf{R}_A\vert^{n_s}
\sum_{k=1}^{N_{\text{prim}}} a_{ks}\, f_{ks}(\gamma_{ks},p)\,
\exp \left( - \gamma_{ks}
\vert \mathbf{r}-\mathbf{R}_A \vert ^p \right).
\vert \mathbf{r}-\mathbf{R}_A \vert ^p \right).
\]
In the case of Gaussian functions, $n_s$ is always zero.
@ -190,7 +192,7 @@ arrays are 0-base. Hence, we introduce the ~index~ type which is an
combination of /normalized/ primitives. This implies that a normalization
constant for the primitive $ks$ needs to be computed and stored. If
this normalization factor is not required, $f_{ks}=1$.
Some codes assume that the basis function are normalized. This
implies the computation of an extra normalization factor, $\mathcal{N}_s$.
If the the basis function is not considered normalized, $\mathcal{N}_s=1$.
@ -208,10 +210,10 @@ arrays are 0-base. Hence, we introduce the ~index~ type which is an
| ~shell_prim_num~ | ~int~ | ~(basis.num)~ | Number of primitives in the shell ($N_{\text{prim}}$) |
| ~shell_factor~ | ~float~ | ~(basis.num)~ | Normalization factor of the shell ($\mathcal{N}_s$) |
| ~shell_prim_index~ | ~index~ | ~(basis.num)~ | Index of the first primitive in the complete list |
| ~exponent~ | ~float~ | ~(basis.prim_num)~ | Exponents of the primitives ($\gamma_{ks}) |
| ~exponent~ | ~float~ | ~(basis.prim_num)~ | Exponents of the primitives ($\gamma_{ks}$) |
| ~coefficient~ | ~float~ | ~(basis.prim_num)~ | Coefficients of the primitives ($a_{ks}$) |
| ~prim_factor~ | ~float~ | ~(basis.prim_num)~ | Normalization coefficients for the primitives ($f_{ks}$) |
#+CALL: json(data=basis, title="basis")
#+RESULTS:
@ -221,12 +223,12 @@ arrays are 0-base. Hence, we introduce the ~index~ type which is an
"type" : [ "str" , [] ]
, "num" : [ "int" , [] ]
, "prim_num" : [ "int" , [] ]
, "nucleus_index" : [ "index" , [ "nucleus.num" ] ]
, "nucleus_index" : [ "index", [ "nucleus.num" ] ]
, "nucleus_shell_num" : [ "int" , [ "nucleus.num" ] ]
, "shell_ang_mom" : [ "int" , [ "basis.num" ] ]
, "shell_prim_num" : [ "int" , [ "basis.num" ] ]
, "shell_factor" : [ "float", [ "basis.num" ] ]
, "shell_prim_index" : [ "index" , [ "basis.num" ] ]
, "shell_prim_index" : [ "index", [ "basis.num" ] ]
, "exponent" : [ "float", [ "basis.prim_num" ] ]
, "coefficient" : [ "float", [ "basis.prim_num" ] ]
, "prim_factor" : [ "float", [ "basis.prim_num" ] ]
@ -324,9 +326,9 @@ prim_factor =
shell, as in the GAMESS convention where
$\mathcal{N}_{x^2} \ne \mathcal{N}_{xy}$ because
\[ \left[ \iiint \left(x-X_A \right)^2 R_{\theta(i)}
(\mathbf{r}) dx\, dy\, dz \right]^{-1/2} \ne
(\mathbf{r}) dx\, dy\, dz \right]^{-1/2} \ne
\left[ \iiint \left( x-X_A \right) \left( y-Y_A \right) R_{\theta(i)}
(\mathbf{r}) dx\, dy\, dz \right]^{-1/2}. \]
(\mathbf{r}) dx\, dy\, dz \right]^{-1/2}. \]
In such a case, one should set the normalization of the shell (in
the [[Basis set][Basis set]] section) to $\mathcal{N}_{z^2}$, which is the
@ -353,7 +355,7 @@ prim_factor =
} ,
#+end_src
:end:
** One-electron integrals
:PROPERTIES:
:CUSTOM_ID: ao_one_e
@ -362,7 +364,7 @@ prim_factor =
- \[ \hat{V}_{\text{ne}} = \sum_{A=1}^{N_\text{nucl}}
\sum_{i=1}^{N_\text{elec}} \frac{-Z_A }{\vert \mathbf{R}_A -
\mathbf{r}_i \vert} \] : electron-nucleus attractive potential,
- \[ \hat{T}_{\text{e}} =
- \[ \hat{T}_{\text{e}} =
\sum_{i=1}^{N_\text{elec}} -\frac{1}{2}\hat{\Delta}_i \] : electronic kinetic energy
- $\hat{h} = \hat{T}_\text{e} + \hat{V}_\text{ne} +
\hat{V}_\text{ecp,l} + \hat{V}_\text{ecp,nl}$ : core electronic Hamiltonian
@ -375,8 +377,8 @@ prim_factor =
| ~overlap~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert q \rangle$ |
| ~kinetic~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{T}_e \vert q \rangle$ |
| ~potential_n_e~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{V}_{\text{ne}} \vert q \rangle$ |
| ~ecp_local~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{V}_{\text{ecp,l} \vert q \rangle$ |
| ~ecp_non_local~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{V}_{\text{ecp,nl} \vert q \rangle$ |
| ~ecp_local~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{V}_{\text{ecp,l}} \vert q \rangle$ |
| ~ecp_non_local~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{V}_{\text{ecp,nl}} \vert q \rangle$ |
| ~core_hamiltonian~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{h} \vert q \rangle$ |
#+CALL: json(data=ao_1e_int, title="ao_1e_int")
@ -409,7 +411,7 @@ prim_factor =
notation.
# TODO: Physicist / Chemist functions
- \[ \hat{W}_{\text{ee}} = \sum_{i=2}^{N_\text{elec}} \sum_{j=1}^{i-1} \frac{1}{\vert \mathbf{r}_i - \mathbf{r}_j \vert} \] : electron-electron repulsive potential operator.
- \[ \hat{W}^{lr}_{\text{ee}} = \sum_{i=2}^{N_\text{elec}}
\sum_{j=1}^{i-1} \frac{\text{erf}(\vert \mathbf{r}_i -
@ -460,15 +462,15 @@ prim_factor =
** One-electron integrals
The operators as the same as those defined in the
[[ao_one_e][AO one-electron integrals section]]. Here, the integrals are given in
[[#ao_one_e][AO one-electron integrals section]]. Here, the integrals are given in
the basis of molecular orbitals.
#+NAME: mo_1e_int
| ~overlap~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert j \rangle$ |
| ~kinetic~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{T}_e \vert j \rangle$ |
| ~potential_n_e~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{V}_{\text{ne}} \vert j \rangle$ |
| ~ecp_local~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{V}_{\text{ecp,l} \vert j \rangle$ |
| ~ecp_non_local~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{V}_{\text{ecp,nl} \vert j \rangle$ |
| ~ecp_local~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{V}_{\text{ecp,l}} \vert j \rangle$ |
| ~ecp_non_local~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{V}_{\text{ecp,nl}} \vert j \rangle$ |
| ~core_hamiltonian~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{h} \vert j \rangle$ |
#+CALL: json(data=mo_1e_int, title="mo_1e_int")
@ -490,7 +492,7 @@ prim_factor =
** Two-electron integrals
The operators as the same as those defined in the
[[ao_two_e][AO two-electron integrals section]]. Here, the integrals are given in
[[#ao_one_e][AO one-electron integrals section]]. Here, the integrals are given in
the basis of molecular orbitals.
#+NAME: mo_2e_int
@ -511,7 +513,7 @@ prim_factor =
* TODO Slater determinants
* TODO Reduced density matrices
#+NAME: rdm
| ~one_e~ | ~float~ | ~(mo.num, mo.num)~ |
| ~one_e_up~ | ~float~ | ~(mo.num, mo.num)~ |
@ -532,12 +534,12 @@ prim_factor =
#+end_src
:end:
* Appendix :noexport:
* Appendix
** Python script from table to json
#+NAME: json
#+begin_src python :var data=nucleus title="nucleus" last=0 :results output drawer
print("""#+begin_src python :tangle trex.json""")
#+begin_src python :var data=nucleus title="nucleus" last=0 :results output drawer
print("""#+begin_src python :tangle trex.json""")
print(""" "%s": {"""%(title))
indent = " "
f1 = 0 ; f2 = 0 ; f3 = 0