mirror of
https://github.com/TREX-CoE/trexio.git
synced 2025-01-09 20:48:53 +01:00
Add index in files
This commit is contained in:
parent
84cc086228
commit
77f2858548
@ -56,7 +56,7 @@ AC_PROG_LN_S
|
|||||||
## ---------
|
## ---------
|
||||||
|
|
||||||
# Checks for basic header files.
|
# Checks for basic header files.
|
||||||
AC_CHECK_HEADERS([fcntl.h inttypes.h stdint.h stdlib.h string.h unistd.h])
|
AC_CHECK_HEADERS([fcntl.h inttypes.h stdint.h stdbool.h stdlib.h string.h unistd.h])
|
||||||
|
|
||||||
|
|
||||||
### HDF5
|
### HDF5
|
||||||
|
@ -49,11 +49,12 @@ typedef int32_t trexio_exit_code;
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "trexio.h"
|
#include "trexio.h"
|
||||||
#include "trexio_s.h"
|
|
||||||
#include "trexio_private.h"
|
#include "trexio_private.h"
|
||||||
|
#include "trexio_s.h"
|
||||||
#include "trexio_text.h"
|
#include "trexio_text.h"
|
||||||
#include "trexio_hdf5.h"
|
#include "trexio_hdf5.h"
|
||||||
/*
|
/*
|
||||||
@ -70,6 +71,7 @@ typedef int32_t trexio_exit_code;
|
|||||||
#include "trexio.h"
|
#include "trexio.h"
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* Coding conventions
|
* Coding conventions
|
||||||
@ -421,11 +423,12 @@ typedef struct trexio_s trexio_t;
|
|||||||
|
|
||||||
#+begin_src c :tangle prefix_s_front.h
|
#+begin_src c :tangle prefix_s_front.h
|
||||||
struct trexio_s {
|
struct trexio_s {
|
||||||
char* file_name;
|
char file_name[TREXIO_MAX_FILENAME_LENGTH];
|
||||||
pthread_mutex_t thread_lock;
|
pthread_mutex_t thread_lock;
|
||||||
back_end_t back_end;
|
back_end_t back_end;
|
||||||
char mode;
|
char mode;
|
||||||
char padding[7]; /* Ensures the proper alignment of back ends */
|
bool one_based;
|
||||||
|
char padding[6]; /* Ensures the proper alignment of back ends */
|
||||||
};
|
};
|
||||||
#+end_src
|
#+end_src
|
||||||
** Polymorphism of the file handle
|
** Polymorphism of the file handle
|
||||||
@ -458,11 +461,13 @@ struct trexio_back_end_s {
|
|||||||
output:
|
output:
|
||||||
~trexio_t~ file handle
|
~trexio_t~ file handle
|
||||||
|
|
||||||
Note: the ~file_name~ in TEXT back end actually corresponds to the name of the folder where ~.txt~
|
Note: the ~file_name~ in TEXT back end actually corresponds to the
|
||||||
data files are stored. The actual name of each ~.txt~ file corresponds to the group name provided in
|
name of the directory where ~.txt~ data files are stored. The
|
||||||
~trex.config~ (e.g. ~nucleus.txt~ for nuclei-related data).
|
actual name of each ~.txt~ file corresponds to the group name
|
||||||
These names are populated by the generator.py (i.e. they are hard-coded), which is why the user
|
provided in ~trex.config~ (e.g. ~nucleus.txt~ for nuclei-related
|
||||||
should tend to avoid renaming the ~.txt~ data files.
|
data). These names are populated by the generator.py (i.e. they
|
||||||
|
are hard-coded), which is why the user should tend to avoid
|
||||||
|
renaming the ~.txt~ data files.
|
||||||
|
|
||||||
#+begin_src c :tangle prefix_front.h :exports none
|
#+begin_src c :tangle prefix_front.h :exports none
|
||||||
trexio_t* trexio_open(const char* file_name, const char mode, const back_end_t back_end);
|
trexio_t* trexio_open(const char* file_name, const char mode, const back_end_t back_end);
|
||||||
@ -509,16 +514,15 @@ trexio_open(const char* file_name, const char mode,
|
|||||||
|
|
||||||
/* Data for the parent type */
|
/* Data for the parent type */
|
||||||
|
|
||||||
result->file_name = CALLOC(TREXIO_MAX_FILENAME_LENGTH, char);
|
|
||||||
strncpy(result->file_name, file_name, TREXIO_MAX_FILENAME_LENGTH);
|
strncpy(result->file_name, file_name, TREXIO_MAX_FILENAME_LENGTH);
|
||||||
if (result->file_name[TREXIO_MAX_FILENAME_LENGTH-1] != '\0') {
|
if (result->file_name[TREXIO_MAX_FILENAME_LENGTH-1] != '\0') {
|
||||||
free(result->file_name);
|
|
||||||
free(result);
|
free(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->back_end = back_end;
|
result->back_end = back_end;
|
||||||
result->mode = mode;
|
result->mode = mode;
|
||||||
|
result->one_based = false; // Need to be flipped in Fortran interface
|
||||||
int irc = pthread_mutex_init ( &(result->thread_lock), NULL);
|
int irc = pthread_mutex_init ( &(result->thread_lock), NULL);
|
||||||
assert (irc == 0);
|
assert (irc == 0);
|
||||||
|
|
||||||
@ -545,7 +549,6 @@ trexio_open(const char* file_name, const char mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rc != TREXIO_SUCCESS) {
|
if (rc != TREXIO_SUCCESS) {
|
||||||
free(result->file_name);
|
|
||||||
free(result);
|
free(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -571,7 +574,6 @@ trexio_open(const char* file_name, const char mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rc != TREXIO_SUCCESS) {
|
if (rc != TREXIO_SUCCESS) {
|
||||||
free(result->file_name);
|
|
||||||
free(result);
|
free(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -591,6 +593,25 @@ interface
|
|||||||
end interface
|
end interface
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
Because arrays are zero-based in Fortran, we need to set a flag to
|
||||||
|
know if we need to shift by 1 arrays of indices.
|
||||||
|
|
||||||
|
#+begin_src c :tangle prefix_front.h :exports none
|
||||||
|
trexio_exit_code trexio_set_one_based(trexio_t* file);
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src c :tangle prefix_front.c
|
||||||
|
trexio_exit_code trexio_set_one_based(trexio_t* file)
|
||||||
|
{
|
||||||
|
if (file == NULL)
|
||||||
|
return TREXIO_FILE_ERROR;
|
||||||
|
|
||||||
|
file->one_based = true;
|
||||||
|
|
||||||
|
return TREXIO_SUCCESS;
|
||||||
|
}
|
||||||
|
#+end_src
|
||||||
|
|
||||||
** File closing
|
** File closing
|
||||||
|
|
||||||
~trexio_close~ closes an existing ~trexio_t~ file.
|
~trexio_close~ closes an existing ~trexio_t~ file.
|
||||||
@ -634,7 +655,6 @@ trexio_close (trexio_t* file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rc != TREXIO_SUCCESS) {
|
if (rc != TREXIO_SUCCESS) {
|
||||||
FREE(file->file_name);
|
|
||||||
FREE(file);
|
FREE(file);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -661,8 +681,6 @@ trexio_close (trexio_t* file)
|
|||||||
|
|
||||||
/* Terminate front end */
|
/* Terminate front end */
|
||||||
|
|
||||||
FREE(file->file_name);
|
|
||||||
|
|
||||||
int irc = pthread_mutex_destroy( &(file->thread_lock) );
|
int irc = pthread_mutex_destroy( &(file->thread_lock) );
|
||||||
|
|
||||||
free(file);
|
free(file);
|
||||||
|
@ -39,11 +39,11 @@
|
|||||||
"basis": {
|
"basis": {
|
||||||
"type" : [ "str" , [] ]
|
"type" : [ "str" , [] ]
|
||||||
, "shell_num" : [ "int" , [] ]
|
, "shell_num" : [ "int" , [] ]
|
||||||
, "shell_center" : [ "int" , [ "basis.shell_num" ] ]
|
, "shell_center" : [ "index", [ "basis.shell_num" ] ]
|
||||||
, "shell_ang_mom" : [ "int" , [ "basis.shell_num" ] ]
|
, "shell_ang_mom" : [ "int" , [ "basis.shell_num" ] ]
|
||||||
, "shell_prim_num" : [ "int" , [ "basis.shell_num" ] ]
|
, "shell_prim_num" : [ "int" , [ "basis.shell_num" ] ]
|
||||||
, "shell_factor" : [ "float", [ "basis.shell_num" ] ]
|
, "shell_factor" : [ "float", [ "basis.shell_num" ] ]
|
||||||
, "prim_index" : [ "int" , [ "basis.shell_num" ] ]
|
, "prim_index" : [ "index", [ "basis.shell_num" ] ]
|
||||||
, "prim_num" : [ "int" , [] ]
|
, "prim_num" : [ "int" , [] ]
|
||||||
, "exponent" : [ "float", [ "basis.prim_num" ] ]
|
, "exponent" : [ "float", [ "basis.prim_num" ] ]
|
||||||
, "coefficient" : [ "float", [ "basis.prim_num" ] ]
|
, "coefficient" : [ "float", [ "basis.prim_num" ] ]
|
||||||
@ -53,7 +53,7 @@
|
|||||||
"ao": {
|
"ao": {
|
||||||
"cartesian" : [ "int" , [] ]
|
"cartesian" : [ "int" , [] ]
|
||||||
, "num" : [ "int" , [] ]
|
, "num" : [ "int" , [] ]
|
||||||
, "shell" : [ "int" , [ "ao.num" ] ]
|
, "shell" : [ "index", [ "ao.num" ] ]
|
||||||
, "normalization" : [ "float", [ "ao.num" ] ]
|
, "normalization" : [ "float", [ "ao.num" ] ]
|
||||||
} ,
|
} ,
|
||||||
|
|
||||||
|
19
trex.org
19
trex.org
@ -7,6 +7,10 @@ column-major order (as in Fortran), and the ordering of the dimensions
|
|||||||
is reversed in the produces JSON configuration file as the library is
|
is reversed in the produces JSON configuration file as the library is
|
||||||
written in C.
|
written in C.
|
||||||
|
|
||||||
|
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
|
#+end_src
|
||||||
@ -195,11 +199,11 @@ written in C.
|
|||||||
#+NAME: basis
|
#+NAME: basis
|
||||||
| ~type~ | ~str~ | | Type of basis set: "Gaussian" or "Slater" |
|
| ~type~ | ~str~ | | Type of basis set: "Gaussian" or "Slater" |
|
||||||
| ~shell_num~ | ~int~ | | Total Number of shells |
|
| ~shell_num~ | ~int~ | | Total Number of shells |
|
||||||
| ~shell_center~ | ~int~ | ~(basis.shell_num)~ | Nucleus on which the shell is centered ($A$) |
|
| ~shell_center~ | ~index~ | ~(basis.shell_num)~ | Nucleus on which the shell is centered ($A$) |
|
||||||
| ~shell_ang_mom~ | ~int~ | ~(basis.shell_num)~ | Angular momentum ~0:S, 1:P, 2:D, ...~ |
|
| ~shell_ang_mom~ | ~int~ | ~(basis.shell_num)~ | Angular momentum ~0:S, 1:P, 2:D, ...~ |
|
||||||
| ~shell_prim_num~ | ~int~ | ~(basis.shell_num)~ | Number of primitives in the shell ($N_{\text{prim}}$) |
|
| ~shell_prim_num~ | ~int~ | ~(basis.shell_num)~ | Number of primitives in the shell ($N_{\text{prim}}$) |
|
||||||
| ~shell_factor~ | ~float~ | ~(basis.shell_num)~ | Normalization factor of the shell ($\mathcal{N}_s$) |
|
| ~shell_factor~ | ~float~ | ~(basis.shell_num)~ | Normalization factor of the shell ($\mathcal{N}_s$) |
|
||||||
| ~prim_index~ | ~int~ | ~(basis.shell_num)~ | Index of the first primitive in the complete list |
|
| ~prim_index~ | ~index~ | ~(basis.shell_num)~ | Index of the first primitive in the complete list |
|
||||||
| ~prim_num~ | ~int~ | | Total number of primitives |
|
| ~prim_num~ | ~int~ | | Total number of primitives |
|
||||||
| ~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}$) |
|
| ~coefficient~ | ~float~ | ~(basis.prim_num)~ | Coefficients of the primitives ($a_{ks}$) |
|
||||||
@ -213,11 +217,11 @@ written in C.
|
|||||||
"basis": {
|
"basis": {
|
||||||
"type" : [ "str" , [] ]
|
"type" : [ "str" , [] ]
|
||||||
, "shell_num" : [ "int" , [] ]
|
, "shell_num" : [ "int" , [] ]
|
||||||
, "shell_center" : [ "int" , [ "basis.shell_num" ] ]
|
, "shell_center" : [ "index", [ "basis.shell_num" ] ]
|
||||||
, "shell_ang_mom" : [ "int" , [ "basis.shell_num" ] ]
|
, "shell_ang_mom" : [ "int" , [ "basis.shell_num" ] ]
|
||||||
, "shell_prim_num" : [ "int" , [ "basis.shell_num" ] ]
|
, "shell_prim_num" : [ "int" , [ "basis.shell_num" ] ]
|
||||||
, "shell_factor" : [ "float", [ "basis.shell_num" ] ]
|
, "shell_factor" : [ "float", [ "basis.shell_num" ] ]
|
||||||
, "prim_index" : [ "int" , [ "basis.shell_num" ] ]
|
, "prim_index" : [ "index", [ "basis.shell_num" ] ]
|
||||||
, "prim_num" : [ "int" , [] ]
|
, "prim_num" : [ "int" , [] ]
|
||||||
, "exponent" : [ "float", [ "basis.prim_num" ] ]
|
, "exponent" : [ "float", [ "basis.prim_num" ] ]
|
||||||
, "coefficient" : [ "float", [ "basis.prim_num" ] ]
|
, "coefficient" : [ "float", [ "basis.prim_num" ] ]
|
||||||
@ -250,8 +254,7 @@ written in C.
|
|||||||
\chi_i (\mathbf{r}) = \mathcal{N}_i\, P_{\eta(i)}(\mathbf{r})\, R_{\theta(i)} (\mathbf{r})
|
\chi_i (\mathbf{r}) = \mathcal{N}_i\, P_{\eta(i)}(\mathbf{r})\, R_{\theta(i)} (\mathbf{r})
|
||||||
\]
|
\]
|
||||||
|
|
||||||
where $i$ is the atomic orbital index,
|
where $i$ is the atomic orbital index, $P$ encodes for either the
|
||||||
$P$ encodes for either the
|
|
||||||
polynomials or the spherical harmonics, $\theta(i)$ returns the
|
polynomials or the spherical harmonics, $\theta(i)$ returns the
|
||||||
shell on which the AO is expanded, and $\eta(i)$ denotes which
|
shell on which the AO is expanded, and $\eta(i)$ denotes which
|
||||||
angular function is chosen.
|
angular function is chosen.
|
||||||
@ -273,7 +276,7 @@ written in C.
|
|||||||
#+NAME: ao
|
#+NAME: ao
|
||||||
| ~cartesian~ | ~int~ | | ~1~: true, ~0~: false |
|
| ~cartesian~ | ~int~ | | ~1~: true, ~0~: false |
|
||||||
| ~num~ | ~int~ | | Total number of atomic orbitals |
|
| ~num~ | ~int~ | | Total number of atomic orbitals |
|
||||||
| ~shell~ | ~int~ | ~(ao.num)~ | basis set shell for each AO |
|
| ~shell~ | ~index~ | ~(ao.num)~ | basis set shell for each AO |
|
||||||
| ~normalization~ | ~float~ | ~(ao.num)~ | Normalization factors |
|
| ~normalization~ | ~float~ | ~(ao.num)~ | Normalization factors |
|
||||||
|
|
||||||
#+CALL: json(data=ao, title="ao")
|
#+CALL: json(data=ao, title="ao")
|
||||||
@ -284,7 +287,7 @@ written in C.
|
|||||||
"ao": {
|
"ao": {
|
||||||
"cartesian" : [ "int" , [] ]
|
"cartesian" : [ "int" , [] ]
|
||||||
, "num" : [ "int" , [] ]
|
, "num" : [ "int" , [] ]
|
||||||
, "shell" : [ "int" , [ "ao.num" ] ]
|
, "shell" : [ "index", [ "ao.num" ] ]
|
||||||
, "normalization" : [ "float", [ "ao.num" ] ]
|
, "normalization" : [ "float", [ "ao.num" ] ]
|
||||||
} ,
|
} ,
|
||||||
#+end_src
|
#+end_src
|
||||||
|
Loading…
Reference in New Issue
Block a user