From 8b463dbc543f8501804e26f5c041b7b656e01d74 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 18 Oct 2021 16:23:07 +0200 Subject: [PATCH 01/20] FIX: more flexible ECP format --- trex.org | 56 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/trex.org b/trex.org index e36bf19..2b21f04 100644 --- a/trex.org +++ b/trex.org @@ -122,7 +122,7 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an \[ V_A^{\text{ECP}} = V_{A \ell_{\max}} + - \sum_{\ell=0}^{\ell_{\max} -1} + \sum_{\ell=0}^{\ell_{\max}-1} \sum_{m=-\ell}^{\ell} | Y_{\ell m} \rangle \left[ V_{A \ell} - V_{A \ell_{\max}} \right] \langle Y_{\ell m} | \] @@ -138,20 +138,24 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an See http://dx.doi.org/10.1063/1.4984046 for more info. #+NAME: ecp - | Variable | Type | Dimensions | Description | - |-----------------------+---------+------------------------------------------+----------------------------------------------------------------------------------------------| - | ~lmax_plus_1~ | ~int~ | ~(nucleus.num)~ | $\ell_{\max} + 1$, one higher than the maximum angular momentum in the removed core orbitals | - | ~z_core~ | ~float~ | ~(nucleus.num)~ | Charges to remove | - | ~local_n~ | ~int~ | ~(nucleus.num)~ | Number of local functions $N_{q \ell}$ | - | ~local_num_n_max~ | ~dim~ | | Maximum value of ~local_n~, used for dimensioning arrays | - | ~local_exponent~ | ~float~ | ~(ecp.local_num_n_max, nucleus.num)~ | $\alpha_{A q \ell_{\max}}$ | - | ~local_coef~ | ~float~ | ~(ecp.local_num_n_max, nucleus.num)~ | $\beta_{A q \ell_{\max}}$ | - | ~local_power~ | ~int~ | ~(ecp.local_num_n_max, nucleus.num)~ | $n_{A q \ell_{\max}}$ | - | ~non_local_n~ | ~int~ | ~(nucleus.num)~ | $N_{q \ell_{\max}}$ | - | ~non_local_num_n_max~ | ~dim~ | | Maximum value of ~non_local_n~, used for dimensioning arrays | - | ~non_local_exponent~ | ~float~ | ~(ecp.non_local_num_n_max, nucleus.num)~ | $\alpha_{A q \ell}$ | - | ~non_local_coef~ | ~float~ | ~(ecp.non_local_num_n_max, nucleus.num)~ | $\beta_{A q \ell}$ | - | ~non_local_power~ | ~int~ | ~(ecp.non_local_num_n_max, nucleus.num)~ | $n_{A q \ell}$ | + | Variable | Type | Dimensions | Description | + |---------------+---------+-----------------+-----------------------------------------------------------------------------| + | ~max_ang_mom~ | ~int~ | ~(nucleus.num)~ | $\ell_{\max}$ the maximum angular momentum in the removed core orbitals | + | ~z_core~ | ~float~ | ~(nucleus.num)~ | Charges to remove | + | ~num~ | ~dim~ | | Total number of ECP functions for all atoms and all values of $\ell$ | + | ~ang_mom~ | ~int~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the angular momentum $\ell$ | + | ~nucleus~ | ~index~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the atom index | + | ~exponent~ | ~float~ | ~(ecp.num)~ | $\alpha_{A q \ell}$ all ECP exponents | + | ~coefficient~ | ~float~ | ~(ecp.num)~ | $\beta_{A q \ell}$ all ECP coefficients | + | ~power~ | ~int~ | ~(ecp.num)~ | $n_{A q \ell}$ all ECP powers | + + +*Note for developers*: avoid having variables with similar prefix in their name. +HDF5 back end might cause issues due to the way `find_dataset` function works +in the H5LT module. For example, in the ECP group we use ~max_ang_mom~ and +~ang_mom_max~ due to this. +The latter causes issues when written before ~ang_mom~ in the TREXIO file. + #+CALL: json(data=ecp, title="ecp") @@ -159,22 +163,20 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an :RESULTS: #+begin_src python :tangle trex.json "ecp": { - "lmax_plus_1" : [ "int" , [ "nucleus.num" ] ] - , "z_core" : [ "float", [ "nucleus.num" ] ] - , "local_n" : [ "int" , [ "nucleus.num" ] ] - , "local_num_n_max" : [ "dim" , [] ] - , "local_exponent" : [ "float", [ "nucleus.num", "ecp.local_num_n_max" ] ] - , "local_coef" : [ "float", [ "nucleus.num", "ecp.local_num_n_max" ] ] - , "local_power" : [ "int" , [ "nucleus.num", "ecp.local_num_n_max" ] ] - , "non_local_n" : [ "int" , [ "nucleus.num" ] ] - , "non_local_num_n_max" : [ "dim" , [] ] - , "non_local_exponent" : [ "float", [ "nucleus.num", "ecp.non_local_num_n_max" ] ] - , "non_local_coef" : [ "float", [ "nucleus.num", "ecp.non_local_num_n_max" ] ] - , "non_local_power" : [ "int" , [ "nucleus.num", "ecp.non_local_num_n_max" ] ] + "max_ang_mom" : [ "int" , [ "nucleus.num" ] ] + , "z_core" : [ "float", [ "nucleus.num" ] ] + , "num" : [ "dim" , [] ] + , "ang_mom" : [ "int" , [ "ecp.num" ] ] + , "nucleus" : [ "index", [ "ecp.num" ] ] + , "exponent" : [ "float", [ "ecp.num" ] ] + , "coefficient" : [ "float", [ "ecp.num" ] ] + , "power" : [ "int" , [ "ecp.num" ] ] } , #+end_src :END: + + * Basis set (basis group) We consider here basis functions centered on nuclei. Hence, we enable From 6ab65d243298f0dc688f2b58780a47193040123d Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 18 Oct 2021 16:53:17 +0200 Subject: [PATCH 02/20] add an example for GAMESS format --- trex.org | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/trex.org b/trex.org index 2b21f04..e208b2b 100644 --- a/trex.org +++ b/trex.org @@ -175,7 +175,60 @@ The latter causes issues when written before ~ang_mom~ in the TREXIO file. #+end_src :END: +** Example + For example, consider H_2 molecule with the following + [[https://pseudopotentiallibrary.org/recipes/H/ccECP/H.ccECP.gamess][effective core potential]] + (in GAMESS input format for the H atom): + + #+BEGIN_EXAMPLE +H-ccECP GEN 0 1 +3 +1.00000000000000 1 21.24359508259891 +21.24359508259891 3 21.24359508259891 +-10.85192405303825 2 21.77696655044365 +1 +0.00000000000000 2 1.000000000000000 + #+END_EXAMPLE + + In TREXIO representation this would be: + + #+BEGIN_EXAMPLE +ecp_num = 8 + +# max angular momentum per atom +ecp_max_ang_mom = [ 1, 1 ] +# number of core electrons to remove per atom +ecp_zcore = [ 0, 0 ] + +# first 4 ECP elements correspond to the first H atom, same for the second H atom +ecp_nucleus = [ + 0, 0, 0, 0, + 1, 1, 1, 1 + ] + +# 3 first ECP elements correspond to l=1 of the first H atom, then 1 ECP for l=0; same for the second H atom +ecp_ang_mom = [ + 1, 1, 1, 0, + 1, 1, 1, 0 + ] + +# flat arrays with ECP quantities that can be parsed based on the aforementioned ecp_ang_mom and ecp_nucleus +ecp_coefficient = [ + 1.00000000000000, 21.24359508259891, -10.85192405303825, 0.00000000000000, + 1.00000000000000, 21.24359508259891, -10.85192405303825, 0.00000000000000 + ] + +ecp_exponent = [ + 21.24359508259891, 21.24359508259891, 21.77696655044365, 1.000000000000000, + 21.24359508259891, 21.24359508259891, 21.77696655044365, 1.000000000000000 + ] + +ecp_power = [ + -1, 1, 0, 0, + -1, 1, 0, 0 + ] + #+END_EXAMPLE * Basis set (basis group) From 9b12332211e1f46e91d3ded0729642cf83d51e26 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 18 Oct 2021 17:40:53 +0200 Subject: [PATCH 03/20] FIX: data format in the basis group consistent with ECP --- trex.org | 71 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/trex.org b/trex.org index e36bf19..4f39208 100644 --- a/trex.org +++ b/trex.org @@ -215,20 +215,17 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an All the basis set parameters are stored in one-dimensional arrays: #+NAME: basis - | Variable | Type | Dimensions | Description | - |---------------------+---------+--------------------+----------------------------------------------------------| - | ~type~ | ~str~ | | Type of basis set: "Gaussian" or "Slater" | - | ~num~ | ~dim~ | | Total Number of shells | - | ~prim_num~ | ~dim~ | | Total number of primitives | - | ~nucleus_index~ | ~index~ | ~(nucleus.num)~ | Index of the first shell of each nucleus ($A$) | - | ~nucleus_shell_num~ | ~int~ | ~(nucleus.num)~ | Number of shells for each nucleus | - | ~shell_ang_mom~ | ~int~ | ~(basis.num)~ | Angular momentum ~0:S, 1:P, 2:D, ...~ | - | ~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}$) | - | ~coefficient~ | ~float~ | ~(basis.prim_num)~ | Coefficients of the primitives ($a_{ks}$) | - | ~prim_factor~ | ~float~ | ~(basis.prim_num)~ | Normalization coefficients for the primitives ($f_{ks}$) | + | Variable | Type | Dimensions | Description | + |-----------------+---------+---------------+------------------------------------------------------------------| + | ~type~ | ~str~ | | Type of basis set: "Gaussian" or "Slater" | + | ~num~ | ~dim~ | | Total number of primitives | + | ~nucleus_index~ | ~index~ | ~(basis.num)~ | One-to-one correspondence between primitives and atomic indices | + | ~ang_mom~ | ~int~ | ~(basis.num)~ | One-to-one correspondence between primitives and angular momenta | + | ~shell_index~ | ~index~ | ~(basis.num)~ | One-to-one correspondence between primitives and atomic shells | + | ~shell_factor~ | ~float~ | ~(basis.num)~ | Normalization factor of the shell ($\mathcal{N}_s$) | + | ~exponent~ | ~float~ | ~(basis.num)~ | Exponents of the primitives ($\gamma_{ks}$) | + | ~coefficient~ | ~float~ | ~(basis.num)~ | Coefficients of the primitives ($a_{ks}$) | + | ~prim_factor~ | ~float~ | ~(basis.num)~ | Normalization coefficients for the primitives ($f_{ks}$) | #+CALL: json(data=basis, title="basis") @@ -252,6 +249,8 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an #+end_src :END: +** Example + For example, consider H_2 with the following basis set (in GAMESS format), where both the AOs and primitives are considered normalized: @@ -272,31 +271,43 @@ P 1 P 1 1 3.880000E-01 1.000000E+00 D 1 -1 1.057000E+00 1.0000000 +1 1.057000E+00 1.000000E+00 #+END_EXAMPLE - we have: + In TREXIO representaion we have: #+BEGIN_EXAMPLE -type = "Gaussian" -num = 12 -prim_num = 20 +type = "Gaussian" +num = 20 -nucleus_index = [0 , 6] -shell_ang_mom = [0 , 0 , 0 , 1 , 1 , 2 , 0 , 0 , 0 , 1 , 1 , 2 ] -shell_prim_num = [5 , 1 , 1 , 1 , 1 , 1 , 5 , 1 , 1 , 1 , 1 , 1 ] -shell_prim_index = [0 , 5 , 6 , 7 , 8 , 9 , 10, 15, 16, 17, 18, 19] -shell_factor = [1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.] +# 10 primitives per H atom +nucleus_index = +[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] +# 7 primitives for S (l=0), 2 primitives for P (l=1), 1 primitive for D (l=2) shells +ang_mom = +[ 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 2 ] + +# 5 primitives for first S shell and then 1 primitive per remaining shells +shell_index = +[ 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, + 0, 0, 0, 0, 0, 1, 2, 3, 4, 5 ] + +# no need to normalize shells +shell_factor = +[ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1. ] + +# parameters of the primitives exponent = -[ 33.87, 5.095, 1.159, 0.3258, 0.1027, 0.3258, 0.1027, 1.407, - 0.388, 1.057, 33.87, 5.095, 1.159, 0.3258, 0.1027, 0.3258, 0.1027, 1.407, - 0.388, 1.057] +[ 33.87, 5.095, 1.159, 0.3258, 0.1027, 0.3258, 0.1027, 1.407, 0.388, 1.057, + 33.87, 5.095, 1.159, 0.3258, 0.1027, 0.3258, 0.1027, 1.407, 0.388, 1.057 ] coefficient = -[ 0.006068, 0.045308, 0.202822, 0.503903, 0.383421, 1.0, 1.0, - 1.0, 1.0, 1.0, 0.006068, 0.045308, 0.202822, 0.503903, 0.383421, 1.0, 1.0, - 1.0, 1.0, 1.0] +[ 0.006068, 0.045308, 0.202822, 0.503903, 0.383421, 1.0, 1.0, 1.0, 1.0, 1.0, + 0.006068, 0.045308, 0.202822, 0.503903, 0.383421, 1.0, 1.0, 1.0, 1.0, 1.0 ] prim_factor = [ 1.0006253235944540e+01, 2.4169531573445120e+00, 7.9610924849766440e-01 From 31485e6f90e59eccb971c51cfbc7ae0697cbd28d Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 18 Oct 2021 17:43:53 +0200 Subject: [PATCH 04/20] nucleus_index instead of nucleus attribute in ECP --- trex.org | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/trex.org b/trex.org index e208b2b..d25747e 100644 --- a/trex.org +++ b/trex.org @@ -138,16 +138,16 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an See http://dx.doi.org/10.1063/1.4984046 for more info. #+NAME: ecp - | Variable | Type | Dimensions | Description | - |---------------+---------+-----------------+-----------------------------------------------------------------------------| - | ~max_ang_mom~ | ~int~ | ~(nucleus.num)~ | $\ell_{\max}$ the maximum angular momentum in the removed core orbitals | - | ~z_core~ | ~float~ | ~(nucleus.num)~ | Charges to remove | - | ~num~ | ~dim~ | | Total number of ECP functions for all atoms and all values of $\ell$ | - | ~ang_mom~ | ~int~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the angular momentum $\ell$ | - | ~nucleus~ | ~index~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the atom index | - | ~exponent~ | ~float~ | ~(ecp.num)~ | $\alpha_{A q \ell}$ all ECP exponents | - | ~coefficient~ | ~float~ | ~(ecp.num)~ | $\beta_{A q \ell}$ all ECP coefficients | - | ~power~ | ~int~ | ~(ecp.num)~ | $n_{A q \ell}$ all ECP powers | + | Variable | Type | Dimensions | Description | + |-----------------+---------+-----------------+-----------------------------------------------------------------------------| + | ~max_ang_mom~ | ~int~ | ~(nucleus.num)~ | $\ell_{\max}$ the maximum angular momentum in the removed core orbitals | + | ~z_core~ | ~float~ | ~(nucleus.num)~ | Charges to remove | + | ~num~ | ~dim~ | | Total number of ECP functions for all atoms and all values of $\ell$ | + | ~ang_mom~ | ~int~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the angular momentum $\ell$ | + | ~nucleus_index~ | ~index~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the atom index | + | ~exponent~ | ~float~ | ~(ecp.num)~ | $\alpha_{A q \ell}$ all ECP exponents | + | ~coefficient~ | ~float~ | ~(ecp.num)~ | $\beta_{A q \ell}$ all ECP coefficients | + | ~power~ | ~int~ | ~(ecp.num)~ | $n_{A q \ell}$ all ECP powers | *Note for developers*: avoid having variables with similar prefix in their name. @@ -163,14 +163,14 @@ The latter causes issues when written before ~ang_mom~ in the TREXIO file. :RESULTS: #+begin_src python :tangle trex.json "ecp": { - "max_ang_mom" : [ "int" , [ "nucleus.num" ] ] - , "z_core" : [ "float", [ "nucleus.num" ] ] - , "num" : [ "dim" , [] ] - , "ang_mom" : [ "int" , [ "ecp.num" ] ] - , "nucleus" : [ "index", [ "ecp.num" ] ] - , "exponent" : [ "float", [ "ecp.num" ] ] - , "coefficient" : [ "float", [ "ecp.num" ] ] - , "power" : [ "int" , [ "ecp.num" ] ] + "max_ang_mom" : [ "int" , [ "nucleus.num" ] ] + , "z_core" : [ "float", [ "nucleus.num" ] ] + , "num" : [ "dim" , [] ] + , "ang_mom" : [ "int" , [ "ecp.num" ] ] + , "nucleus_index" : [ "index", [ "ecp.num" ] ] + , "exponent" : [ "float", [ "ecp.num" ] ] + , "coefficient" : [ "float", [ "ecp.num" ] ] + , "power" : [ "int" , [ "ecp.num" ] ] } , #+end_src :END: @@ -194,37 +194,37 @@ H-ccECP GEN 0 1 In TREXIO representation this would be: #+BEGIN_EXAMPLE -ecp_num = 8 +num = 8 # max angular momentum per atom -ecp_max_ang_mom = [ 1, 1 ] +max_ang_mom = [ 1, 1 ] # number of core electrons to remove per atom -ecp_zcore = [ 0, 0 ] +zcore = [ 0, 0 ] # first 4 ECP elements correspond to the first H atom, same for the second H atom -ecp_nucleus = [ +nucleus_index = [ 0, 0, 0, 0, 1, 1, 1, 1 ] # 3 first ECP elements correspond to l=1 of the first H atom, then 1 ECP for l=0; same for the second H atom -ecp_ang_mom = [ +ang_mom = [ 1, 1, 1, 0, 1, 1, 1, 0 ] # flat arrays with ECP quantities that can be parsed based on the aforementioned ecp_ang_mom and ecp_nucleus -ecp_coefficient = [ +coefficient = [ 1.00000000000000, 21.24359508259891, -10.85192405303825, 0.00000000000000, 1.00000000000000, 21.24359508259891, -10.85192405303825, 0.00000000000000 ] -ecp_exponent = [ +exponent = [ 21.24359508259891, 21.24359508259891, 21.77696655044365, 1.000000000000000, 21.24359508259891, 21.24359508259891, 21.77696655044365, 1.000000000000000 ] -ecp_power = [ +power = [ -1, 1, 0, 0, -1, 1, 0, 0 ] From 2e04d5e610c1d78e45a330ed8999d4c9d7069fcd Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 19 Oct 2021 10:09:20 +0200 Subject: [PATCH 05/20] update tangled part of basis for trex.json --- trex.org | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/trex.org b/trex.org index 4f39208..54bc2b6 100644 --- a/trex.org +++ b/trex.org @@ -233,18 +233,15 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an :RESULTS: #+begin_src python :tangle trex.json "basis": { - "type" : [ "str" , [] ] - , "num" : [ "dim" , [] ] - , "prim_num" : [ "dim" , [] ] - , "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" ] ] - , "exponent" : [ "float", [ "basis.prim_num" ] ] - , "coefficient" : [ "float", [ "basis.prim_num" ] ] - , "prim_factor" : [ "float", [ "basis.prim_num" ] ] + "type" : [ "str" , [] ] + , "num" : [ "dim" , [] ] + , "nucleus_index" : [ "index", [ "basis.num" ] ] + , "ang_mom" : [ "int" , [ "basis.num" ] ] + , "shell_index" : [ "index", [ "basis.num" ] ] + , "shell_factor" : [ "float", [ "basis.num" ] ] + , "exponent" : [ "float", [ "basis.num" ] ] + , "coefficient" : [ "float", [ "basis.num" ] ] + , "prim_factor" : [ "float", [ "basis.num" ] ] } , #+end_src :END: @@ -295,12 +292,12 @@ shell_index = [ 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5 ] -# no need to normalize shells +# no need to renormalize shells shell_factor = [ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1. ] -# parameters of the primitives +# parameters of the primitives (10 per H atom) exponent = [ 33.87, 5.095, 1.159, 0.3258, 0.1027, 0.3258, 0.1027, 1.407, 0.388, 1.057, 33.87, 5.095, 1.159, 0.3258, 0.1027, 0.3258, 0.1027, 1.407, 0.388, 1.057 ] From db35b102ed3c3597fc3588a7d589dce7538800d2 Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 19 Oct 2021 10:22:08 +0200 Subject: [PATCH 06/20] fix tests broken due to new dimension of basis_nucleus_index --- tests/io_dset_int_hdf5.c | 4 ++-- tests/io_dset_int_text.c | 4 ++-- tests/test_f.f90 | 14 +++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/io_dset_int_hdf5.c b/tests/io_dset_int_hdf5.c index 49ff5bb..fa5703c 100644 --- a/tests/io_dset_int_hdf5.c +++ b/tests/io_dset_int_hdf5.c @@ -25,7 +25,7 @@ static int test_write_dset (const char* file_name, const back_end_t backend) { assert (file != NULL); // write numerical attribute in an empty file - rc = trexio_write_nucleus_num(file, num); + rc = trexio_write_basis_num(file, num); assert (rc == TREXIO_SUCCESS); // write numerical (integer) dataset in a file @@ -91,7 +91,7 @@ static int test_read_dset (const char* file_name, const back_end_t backend) { assert (file != NULL); // read numerical attribute from the file - rc = trexio_read_nucleus_num(file, &num); + rc = trexio_read_basis_num(file, &num); assert (rc == TREXIO_SUCCESS); assert (num == 12); diff --git a/tests/io_dset_int_text.c b/tests/io_dset_int_text.c index ca6ded2..6026afe 100644 --- a/tests/io_dset_int_text.c +++ b/tests/io_dset_int_text.c @@ -25,7 +25,7 @@ static int test_write_dset (const char* file_name, const back_end_t backend) { assert (file != NULL); // write numerical attribute in an empty file - rc = trexio_write_nucleus_num(file, num); + rc = trexio_write_basis_num(file, num); assert (rc == TREXIO_SUCCESS); // write numerical (integer) dataset in a file @@ -91,7 +91,7 @@ static int test_read_dset (const char* file_name, const back_end_t backend) { assert (file != NULL); // read numerical attribute from the file - rc = trexio_read_nucleus_num(file, &num); + rc = trexio_read_basis_num(file, &num); assert (rc == TREXIO_SUCCESS); assert (num == 12); diff --git a/tests/test_f.f90 b/tests/test_f.f90 index 0390756..59027b9 100644 --- a/tests/test_f.f90 +++ b/tests/test_f.f90 @@ -44,9 +44,9 @@ subroutine test_write(file_name, back_end) integer :: rc = 1 - integer :: num + integer :: num, basis_num - integer :: basis_nucleus_index(12) + integer :: basis_nucleus_index(24) double precision :: charge(12) double precision :: coord(3,12) @@ -70,7 +70,8 @@ subroutine test_write(file_name, back_end) 0.00000000d0, 2.47304151d0 , 0.00000000d0 /), & shape(coord) ) - basis_nucleus_index = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 /) + basis_num = 24 + basis_nucleus_index = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 /) label = [character(len=8) :: 'C', 'Na','C', 'C 66', 'C','C', 'H 99', 'Ru', 'H', 'H', 'H', 'H' ] @@ -104,6 +105,8 @@ subroutine test_write(file_name, back_end) deallocate(sym_str) call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS WRITE POINT GROUP') + rc = trexio_write_basis_num(trex_file, basis_num) + call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS WRITE BASIS NUM') rc = trexio_write_basis_nucleus_index(trex_file, basis_nucleus_index) call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS WRITE INDEX') @@ -137,9 +140,9 @@ subroutine test_read(file_name, back_end) integer :: i, j, k, ind, offset, flag integer :: rc = 1 - integer :: num, num_read + integer :: num, num_read, basis_num - integer :: basis_nucleus_index(12) + integer :: basis_nucleus_index(24) double precision :: charge(12) double precision :: coord(3,12) @@ -152,6 +155,7 @@ subroutine test_read(file_name, back_end) character*(128) :: str num = 12 + basis_num = 24 ! ================= START OF TEST ===================== ! From 5756b5df3319dc719f08b7f42e01d5ffd208f8a9 Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 19 Oct 2021 10:24:44 +0200 Subject: [PATCH 07/20] upgrade major versions due to changes in basis and ECP formats needed to indicate that the backward copatibility will be broken --- configure.ac | 2 +- python/pytrexio/_version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index fb9f626..55b705d 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) -AC_INIT([trexio], [1.1.0], [https://github.com/TREX-CoE/trexio/issues]) +AC_INIT([trexio], [2.0.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_PREREQ([2.2]) diff --git a/python/pytrexio/_version.py b/python/pytrexio/_version.py index 3dc1f76..5becc17 100644 --- a/python/pytrexio/_version.py +++ b/python/pytrexio/_version.py @@ -1 +1 @@ -__version__ = "0.1.0" +__version__ = "1.0.0" From 2d07db222fb5a6a38ceb4d5c413767c89d383121 Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 19 Oct 2021 10:26:35 +0200 Subject: [PATCH 08/20] upgrade major versions due to changes in the ECP format --- configure.ac | 2 +- python/pytrexio/_version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index fb9f626..55b705d 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) -AC_INIT([trexio], [1.1.0], [https://github.com/TREX-CoE/trexio/issues]) +AC_INIT([trexio], [2.0.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_PREREQ([2.2]) diff --git a/python/pytrexio/_version.py b/python/pytrexio/_version.py index 3dc1f76..5becc17 100644 --- a/python/pytrexio/_version.py +++ b/python/pytrexio/_version.py @@ -1 +1 @@ -__version__ = "0.1.0" +__version__ = "1.0.0" From 64b3e25da59b61de15a61058a6758d4531b1ed49 Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 19 Oct 2021 10:43:00 +0200 Subject: [PATCH 09/20] fix Python tests for basis_nucleus_index --- python/test/test_api.py | 18 +++++++++++------- python/test/test_pytrexio.py | 13 +++++++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/python/test/test_api.py b/python/test/test_api.py index f6b151d..7dd9e0a 100644 --- a/python/test/test_api.py +++ b/python/test/test_api.py @@ -71,11 +71,15 @@ charges_np = np.array(charges, dtype=np.int32) # from the size of the list/array by SWIG using typemaps from numpy.i trexio.write_nucleus_charge(test_file, charges_np) +basis_num = 24 # initialize arrays of nuclear indices as a list and convert it to numpy array -indices = [i for i in range(nucleus_num)] +indices = [i for i in range(basis_num)] # type cast is important here because by default numpy transforms a list of integers into int64 array indices_np = np.array(indices, dtype=np.int64) +# first write basis_num because it is needed to check dimensions of basis_nucleus_index in TREXIO >= 2.0.0 +trexio.write_basis_num(test_file, basis_num) + # function call below works with both lists and numpy arrays, dimension needed for memory-safety is derived # from the size of the list/array by SWIG using typemacs from numpy.i trexio.write_basis_nucleus_index(test_file, indices_np) @@ -160,20 +164,20 @@ except trexio.Error: print("Unsafe call to safe API: checked") # safe call to read array of int values (nuclear indices) -rindices_np_16 = trexio.read_basis_nucleus_index(test_file2, dim=nucleus_num, dtype=np.int16) +rindices_np_16 = trexio.read_basis_nucleus_index(test_file2, dim=basis_num, dtype=np.int16) assert rindices_np_16.dtype is np.dtype(np.int16) -for i in range(nucleus_num): +for i in range(basis_num): assert rindices_np_16[i]==indices_np[i] -rindices_np_32 = trexio.read_basis_nucleus_index(test_file2, dim=nucleus_num, dtype=np.int32) +rindices_np_32 = trexio.read_basis_nucleus_index(test_file2, dim=basis_num, dtype=np.int32) assert rindices_np_32.dtype is np.dtype(np.int32) -for i in range(nucleus_num): +for i in range(basis_num): assert rindices_np_32[i]==indices_np[i] rindices_np_64 = trexio.read_basis_nucleus_index(test_file2) assert rindices_np_64.dtype is np.dtype(np.int64) -assert rindices_np_64.size==nucleus_num -for i in range(nucleus_num): +assert rindices_np_64.size==basis_num +for i in range(basis_num): assert rindices_np_64[i]==indices_np[i] # read nuclear coordinates without providing optional argument dim diff --git a/python/test/test_pytrexio.py b/python/test/test_pytrexio.py index 04b1266..04cdd55 100644 --- a/python/test/test_pytrexio.py +++ b/python/test/test_pytrexio.py @@ -59,11 +59,16 @@ assert rc==0 # charges[i] = 1. #rc = trexio_write_nucleus_charge(test_file, charges) +basis_num = 24 # initialize arrays of nuclear indices as a list and convert it to numpy array -indices = [i for i in range(nucleus_num)] +indices = [i for i in range(basis_num)] # type cast is important here because by default numpy transforms a list of integers into int64 array indices_np = np.array(indices, dtype=np.int32) +# first write basis_num because it is needed to check dimensions of basis_nucleus_index in TREXIO >= 2.0.0 +rc = trexio_write_basis_num(test_file, basis_num) +assert rc==0 + # function call below works with both lists and numpy arrays, dimension needed for memory-safety is derived # from the size of the list/array by SWIG using typemacs from numpy.i rc = trexio_write_safe_basis_nucleus_index(test_file, indices_np) @@ -124,8 +129,12 @@ assert rc==23 #for i in range(nucleus_num): # assert charges2[i]==charges[i] +result_basis = trexio_read_basis_num(test_file2) +assert result[0]==0 +assert result[1]==basis_num + # safe call to read_safe array of int values -rc, rindices_np = trexio_read_safe_basis_nucleus_index(test_file2, nucleus_num) +rc, rindices_np = trexio_read_safe_basis_nucleus_index(test_file2, basis_num) assert rc==0 assert rindices_np.dtype is np.dtype(np.int32) for i in range(nucleus_num): From e9ca73efc0239c4b7b781f37520e0922de14732c Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 19 Oct 2021 12:01:17 +0200 Subject: [PATCH 10/20] change array name of lmax to lmax+1 for better dimensioning --- trex.org | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/trex.org b/trex.org index d25747e..f44b008 100644 --- a/trex.org +++ b/trex.org @@ -121,10 +121,10 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an core electrons of atom $A$ is expressed as \[ V_A^{\text{ECP}} = - V_{A \ell_{\max}} + - \sum_{\ell=0}^{\ell_{\max}-1} + V_{A \ell_{\max}+1} + + \sum_{\ell=0}^{\ell_{\max}} \sum_{m=-\ell}^{\ell} | Y_{\ell m} \rangle \left[ - V_{A \ell} - V_{A \ell_{\max}} \right] \langle Y_{\ell m} | + V_{A \ell} - V_{A \ell_{\max}+1} \right] \langle Y_{\ell m} | \] The functions $V_{A\ell}$ are parameterized as: @@ -138,16 +138,16 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an See http://dx.doi.org/10.1063/1.4984046 for more info. #+NAME: ecp - | Variable | Type | Dimensions | Description | - |-----------------+---------+-----------------+-----------------------------------------------------------------------------| - | ~max_ang_mom~ | ~int~ | ~(nucleus.num)~ | $\ell_{\max}$ the maximum angular momentum in the removed core orbitals | - | ~z_core~ | ~float~ | ~(nucleus.num)~ | Charges to remove | - | ~num~ | ~dim~ | | Total number of ECP functions for all atoms and all values of $\ell$ | - | ~ang_mom~ | ~int~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the angular momentum $\ell$ | - | ~nucleus_index~ | ~index~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the atom index | - | ~exponent~ | ~float~ | ~(ecp.num)~ | $\alpha_{A q \ell}$ all ECP exponents | - | ~coefficient~ | ~float~ | ~(ecp.num)~ | $\beta_{A q \ell}$ all ECP coefficients | - | ~power~ | ~int~ | ~(ecp.num)~ | $n_{A q \ell}$ all ECP powers | + | Variable | Type | Dimensions | Description | + |----------------------+---------+-----------------+----------------------------------------------------------------------------------------| + | ~max_ang_mom_plus_1~ | ~int~ | ~(nucleus.num)~ | $\ell_{\max}+1$, one higher than the max angular momentum in the removed core orbitals | + | ~z_core~ | ~float~ | ~(nucleus.num)~ | Charges to remove | + | ~num~ | ~dim~ | | Total number of ECP functions for all atoms and all values of $\ell$ | + | ~ang_mom~ | ~int~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the angular momentum $\ell$ | + | ~nucleus_index~ | ~index~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the atom index | + | ~exponent~ | ~float~ | ~(ecp.num)~ | $\alpha_{A q \ell}$ all ECP exponents | + | ~coefficient~ | ~float~ | ~(ecp.num)~ | $\beta_{A q \ell}$ all ECP coefficients | + | ~power~ | ~int~ | ~(ecp.num)~ | $n_{A q \ell}$ all ECP powers | *Note for developers*: avoid having variables with similar prefix in their name. @@ -163,14 +163,14 @@ The latter causes issues when written before ~ang_mom~ in the TREXIO file. :RESULTS: #+begin_src python :tangle trex.json "ecp": { - "max_ang_mom" : [ "int" , [ "nucleus.num" ] ] - , "z_core" : [ "float", [ "nucleus.num" ] ] - , "num" : [ "dim" , [] ] - , "ang_mom" : [ "int" , [ "ecp.num" ] ] - , "nucleus_index" : [ "index", [ "ecp.num" ] ] - , "exponent" : [ "float", [ "ecp.num" ] ] - , "coefficient" : [ "float", [ "ecp.num" ] ] - , "power" : [ "int" , [ "ecp.num" ] ] + "max_ang_mom_plus_1" : [ "int" , [ "nucleus.num" ] ] + , "z_core" : [ "float", [ "nucleus.num" ] ] + , "num" : [ "dim" , [] ] + , "ang_mom" : [ "int" , [ "ecp.num" ] ] + , "nucleus_index" : [ "index", [ "ecp.num" ] ] + , "exponent" : [ "float", [ "ecp.num" ] ] + , "coefficient" : [ "float", [ "ecp.num" ] ] + , "power" : [ "int" , [ "ecp.num" ] ] } , #+end_src :END: @@ -196,10 +196,11 @@ H-ccECP GEN 0 1 #+BEGIN_EXAMPLE num = 8 -# max angular momentum per atom -max_ang_mom = [ 1, 1 ] +# lmax+1 per atom +max_ang_mom_plus_1 = [ 2, 2 ] + # number of core electrons to remove per atom -zcore = [ 0, 0 ] +zcore = [ 0, 0 ] # first 4 ECP elements correspond to the first H atom, same for the second H atom nucleus_index = [ From 250b29a7bdf89bf0db06015bdc78e48ad8880180 Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 19 Oct 2021 13:31:48 +0200 Subject: [PATCH 11/20] fix typo in the example --- trex.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trex.org b/trex.org index f44b008..1841692 100644 --- a/trex.org +++ b/trex.org @@ -197,7 +197,7 @@ H-ccECP GEN 0 1 num = 8 # lmax+1 per atom -max_ang_mom_plus_1 = [ 2, 2 ] +max_ang_mom_plus_1 = [ 1, 1 ] # number of core electrons to remove per atom zcore = [ 0, 0 ] From 68cf38e8228a1d4ee5be1368dd733393323e9805 Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 19 Oct 2021 15:47:13 +0200 Subject: [PATCH 12/20] better documentation of th ECP block --- trex.org | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/trex.org b/trex.org index 1841692..9fc315d 100644 --- a/trex.org +++ b/trex.org @@ -118,7 +118,7 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an * Effective core potentials (ecp group) An effective core potential (ECP) $V_A^{\text{ECP}}$ replacing the - core electrons of atom $A$ is expressed as + core electrons of atom $A$ can be expressed as \[ V_A^{\text{ECP}} = V_{A \ell_{\max}+1} + @@ -127,6 +127,9 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an V_{A \ell} - V_{A \ell_{\max}+1} \right] \langle Y_{\ell m} | \] + The first term in the equation above is sometimes attributed to the local channel, + while the remaining terms correspond to the non-local channel projections. + The functions $V_{A\ell}$ are parameterized as: \[ V_{A \ell}(\mathbf{r}) = @@ -135,13 +138,13 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an e^{-\alpha_{A q \ell} |\mathbf{r}-\mathbf{R}_{A}|^2 } \] - See http://dx.doi.org/10.1063/1.4984046 for more info. + See http://dx.doi.org/10.1063/1.4984046 or https://doi.org/10.1063/1.5121006for more info. #+NAME: ecp | Variable | Type | Dimensions | Description | |----------------------+---------+-----------------+----------------------------------------------------------------------------------------| | ~max_ang_mom_plus_1~ | ~int~ | ~(nucleus.num)~ | $\ell_{\max}+1$, one higher than the max angular momentum in the removed core orbitals | - | ~z_core~ | ~float~ | ~(nucleus.num)~ | Charges to remove | + | ~z_core~ | ~float~ | ~(nucleus.num)~ | Number of core electrons to remove per atom | | ~num~ | ~dim~ | | Total number of ECP functions for all atoms and all values of $\ell$ | | ~ang_mom~ | ~int~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the angular momentum $\ell$ | | ~nucleus_index~ | ~index~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the atom index | @@ -150,10 +153,17 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an | ~power~ | ~int~ | ~(ecp.num)~ | $n_{A q \ell}$ all ECP powers | +There might be some confusion in the meaning of the $\ell_{\max}$. +It can be attributed to the maximum angular momentum occupied +in the core orbitals, which are removed by the ECP. +On the other hand, it can be attributed to the maximum angular momentum of the +ECP that replaces the core electrons. +*Note*, that the latter $\ell_{\max}$ is always higher by 1 than the former. + + *Note for developers*: avoid having variables with similar prefix in their name. -HDF5 back end might cause issues due to the way `find_dataset` function works -in the H5LT module. For example, in the ECP group we use ~max_ang_mom~ and -~ang_mom_max~ due to this. +HDF5 back end might cause issues due to the way `find_dataset` function works. +For example, in the ECP group we use ~max_ang_mom~ and not ~ang_mom_max~. The latter causes issues when written before ~ang_mom~ in the TREXIO file. @@ -202,19 +212,19 @@ max_ang_mom_plus_1 = [ 1, 1 ] # number of core electrons to remove per atom zcore = [ 0, 0 ] -# first 4 ECP elements correspond to the first H atom, same for the second H atom +# first 4 ECP elements correspond to the first H atom; the remaining 4 elements are for the second H atom nucleus_index = [ 0, 0, 0, 0, 1, 1, 1, 1 ] -# 3 first ECP elements correspond to l=1 of the first H atom, then 1 ECP for l=0; same for the second H atom +# 3 first ECP elements correspond to the P orbital (l=1), then 1 element for the S orbital (l=0) ; similar for the second H atom ang_mom = [ 1, 1, 1, 0, 1, 1, 1, 0 ] -# flat arrays with ECP quantities that can be parsed based on the aforementioned ecp_ang_mom and ecp_nucleus +# ECP quantities that can be attributed to atoms and/or angular momenta based on the aforementioned ecp_nucleus and ecp_ang_mom arrays coefficient = [ 1.00000000000000, 21.24359508259891, -10.85192405303825, 0.00000000000000, 1.00000000000000, 21.24359508259891, -10.85192405303825, 0.00000000000000 From 8fa8fc0c99a7c629e1fba0e02bfa54aefb173499 Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 19 Oct 2021 17:07:15 +0200 Subject: [PATCH 13/20] change ecp_z_core type from float to int --- trex.org | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/trex.org b/trex.org index 9fc315d..5ee11dd 100644 --- a/trex.org +++ b/trex.org @@ -144,7 +144,7 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an | Variable | Type | Dimensions | Description | |----------------------+---------+-----------------+----------------------------------------------------------------------------------------| | ~max_ang_mom_plus_1~ | ~int~ | ~(nucleus.num)~ | $\ell_{\max}+1$, one higher than the max angular momentum in the removed core orbitals | - | ~z_core~ | ~float~ | ~(nucleus.num)~ | Number of core electrons to remove per atom | + | ~z_core~ | ~int~ | ~(nucleus.num)~ | Number of core electrons to remove per atom | | ~num~ | ~dim~ | | Total number of ECP functions for all atoms and all values of $\ell$ | | ~ang_mom~ | ~int~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the angular momentum $\ell$ | | ~nucleus_index~ | ~index~ | ~(ecp.num)~ | One-to-one correspondence between ECP items and the atom index | @@ -174,7 +174,7 @@ The latter causes issues when written before ~ang_mom~ in the TREXIO file. #+begin_src python :tangle trex.json "ecp": { "max_ang_mom_plus_1" : [ "int" , [ "nucleus.num" ] ] - , "z_core" : [ "float", [ "nucleus.num" ] ] + , "z_core" : [ "int" , [ "nucleus.num" ] ] , "num" : [ "dim" , [] ] , "ang_mom" : [ "int" , [ "ecp.num" ] ] , "nucleus_index" : [ "index", [ "ecp.num" ] ] @@ -212,13 +212,13 @@ max_ang_mom_plus_1 = [ 1, 1 ] # number of core electrons to remove per atom zcore = [ 0, 0 ] -# first 4 ECP elements correspond to the first H atom; the remaining 4 elements are for the second H atom +# first 4 ECP elements correspond to the first H atom ; the remaining 4 elements are for the second H atom nucleus_index = [ 0, 0, 0, 0, 1, 1, 1, 1 ] -# 3 first ECP elements correspond to the P orbital (l=1), then 1 element for the S orbital (l=0) ; similar for the second H atom +# 3 first ECP elements correspond to potential of the P orbital (l=1), then 1 element for the S orbital (l=0) ; similar for the second H atom ang_mom = [ 1, 1, 1, 0, 1, 1, 1, 0 From 9321213a2128c20856626b7cae1fee26fc86b36d Mon Sep 17 00:00:00 2001 From: q-posev Date: Thu, 21 Oct 2021 15:51:21 +0200 Subject: [PATCH 14/20] split the basis format to depend on shell_num and prim_num --- trex.org | 71 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/trex.org b/trex.org index 54bc2b6..9a406f6 100644 --- a/trex.org +++ b/trex.org @@ -215,17 +215,18 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an All the basis set parameters are stored in one-dimensional arrays: #+NAME: basis - | Variable | Type | Dimensions | Description | - |-----------------+---------+---------------+------------------------------------------------------------------| - | ~type~ | ~str~ | | Type of basis set: "Gaussian" or "Slater" | - | ~num~ | ~dim~ | | Total number of primitives | - | ~nucleus_index~ | ~index~ | ~(basis.num)~ | One-to-one correspondence between primitives and atomic indices | - | ~ang_mom~ | ~int~ | ~(basis.num)~ | One-to-one correspondence between primitives and angular momenta | - | ~shell_index~ | ~index~ | ~(basis.num)~ | One-to-one correspondence between primitives and atomic shells | - | ~shell_factor~ | ~float~ | ~(basis.num)~ | Normalization factor of the shell ($\mathcal{N}_s$) | - | ~exponent~ | ~float~ | ~(basis.num)~ | Exponents of the primitives ($\gamma_{ks}$) | - | ~coefficient~ | ~float~ | ~(basis.num)~ | Coefficients of the primitives ($a_{ks}$) | - | ~prim_factor~ | ~float~ | ~(basis.num)~ | Normalization coefficients for the primitives ($f_{ks}$) | + | Variable | Type | Dimensions | Description | + |-----------------+---------+---------------------+--------------------------------------------------------------| + | ~type~ | ~str~ | | Type of basis set: "Gaussian" or "Slater" | + | ~prim_num~ | ~dim~ | | Total number of primitives | + | ~shell_num~ | ~dim~ | | Total number of shells | + | ~nucleus_index~ | ~index~ | ~(basis.shell_num)~ | One-to-one correspondence between shells and atomic indices | + | ~ang_mom~ | ~int~ | ~(basis.shell_num)~ | One-to-one correspondence between shells and angular momenta | + | ~shell_factor~ | ~float~ | ~(basis.shell_num)~ | Normalization factor of each shell ($\mathcal{N}_s$) | + | ~shell_index~ | ~index~ | ~(basis.prim_num)~ | One-to-one correspondence between primitives and shell index | + | ~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") @@ -233,15 +234,16 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an :RESULTS: #+begin_src python :tangle trex.json "basis": { - "type" : [ "str" , [] ] - , "num" : [ "dim" , [] ] - , "nucleus_index" : [ "index", [ "basis.num" ] ] - , "ang_mom" : [ "int" , [ "basis.num" ] ] - , "shell_index" : [ "index", [ "basis.num" ] ] - , "shell_factor" : [ "float", [ "basis.num" ] ] - , "exponent" : [ "float", [ "basis.num" ] ] - , "coefficient" : [ "float", [ "basis.num" ] ] - , "prim_factor" : [ "float", [ "basis.num" ] ] + "type" : [ "str" , [] ] + , "prim_num" : [ "dim" , [] ] + , "shell_num" : [ "dim" , [] ] + , "nucleus_index" : [ "index", [ "basis.shell_num" ] ] + , "ang_mom" : [ "int" , [ "basis.shell_num" ] ] + , "shell_factor" : [ "float", [ "basis.shell_num" ] ] + , "shell_index" : [ "index", [ "basis.prim_num" ] ] + , "exponent" : [ "float", [ "basis.prim_num" ] ] + , "coefficient" : [ "float", [ "basis.prim_num" ] ] + , "prim_factor" : [ "float", [ "basis.prim_num" ] ] } , #+end_src :END: @@ -275,27 +277,28 @@ D 1 #+BEGIN_EXAMPLE type = "Gaussian" -num = 20 +prim_num = 20 +shell_num = 12 -# 10 primitives per H atom +# 6 shells per H atom nucleus_index = -[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] +[ 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1 ] -# 7 primitives for S (l=0), 2 primitives for P (l=1), 1 primitive for D (l=2) shells +# 3 shells in S (l=0), 2 in P (l=1), 1 in D (l=2) ang_mom = -[ 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, - 0, 0, 0, 0, 0, 0, 0, 1, 1, 2 ] - -# 5 primitives for first S shell and then 1 primitive per remaining shells -shell_index = -[ 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, - 0, 0, 0, 0, 0, 1, 2, 3, 4, 5 ] +[ 0, 0, 0, 1, 1, 2, + 0, 0, 0, 1, 1, 2 ] # no need to renormalize shells shell_factor = -[ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., - 1., 1., 1., 1., 1., 1., 1., 1., 1., 1. ] +[ 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1. ] + +# 5 primitives for the first S shell and then 1 primitive per remaining shells in each H atom +shell_index = +[ 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, + 6, 6, 6, 6, 6, 7, 8, 9, 10, 11 ] # parameters of the primitives (10 per H atom) exponent = From 745958970140ff7845a5a1b882deeb6186eb8785 Mon Sep 17 00:00:00 2001 From: q-posev Date: Thu, 21 Oct 2021 15:52:12 +0200 Subject: [PATCH 15/20] adapt the tests to use basis_shell_num --- python/test/test_api.py | 20 ++++++++++---------- python/test/test_pytrexio.py | 4 ++-- tests/io_dset_int_hdf5.c | 4 ++-- tests/io_dset_int_text.c | 4 ++-- tests/test_f.f90 | 10 +++++----- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/python/test/test_api.py b/python/test/test_api.py index 7dd9e0a..543eb3d 100644 --- a/python/test/test_api.py +++ b/python/test/test_api.py @@ -71,14 +71,14 @@ charges_np = np.array(charges, dtype=np.int32) # from the size of the list/array by SWIG using typemaps from numpy.i trexio.write_nucleus_charge(test_file, charges_np) -basis_num = 24 +basis_shell_num = 24 # initialize arrays of nuclear indices as a list and convert it to numpy array -indices = [i for i in range(basis_num)] +indices = [i for i in range(basis_shell_num)] # type cast is important here because by default numpy transforms a list of integers into int64 array indices_np = np.array(indices, dtype=np.int64) -# first write basis_num because it is needed to check dimensions of basis_nucleus_index in TREXIO >= 2.0.0 -trexio.write_basis_num(test_file, basis_num) +# first write basis_shell_num because it is needed to check dimensions of basis_nucleus_index in TREXIO >= 2.0.0 +trexio.write_basis_shell_num(test_file, basis_shell_num) # function call below works with both lists and numpy arrays, dimension needed for memory-safety is derived # from the size of the list/array by SWIG using typemacs from numpy.i @@ -164,20 +164,20 @@ except trexio.Error: print("Unsafe call to safe API: checked") # safe call to read array of int values (nuclear indices) -rindices_np_16 = trexio.read_basis_nucleus_index(test_file2, dim=basis_num, dtype=np.int16) +rindices_np_16 = trexio.read_basis_nucleus_index(test_file2, dim=basis_shell_num, dtype=np.int16) assert rindices_np_16.dtype is np.dtype(np.int16) -for i in range(basis_num): +for i in range(basis_shell_num): assert rindices_np_16[i]==indices_np[i] -rindices_np_32 = trexio.read_basis_nucleus_index(test_file2, dim=basis_num, dtype=np.int32) +rindices_np_32 = trexio.read_basis_nucleus_index(test_file2, dim=basis_shell_num, dtype=np.int32) assert rindices_np_32.dtype is np.dtype(np.int32) -for i in range(basis_num): +for i in range(basis_shell_num): assert rindices_np_32[i]==indices_np[i] rindices_np_64 = trexio.read_basis_nucleus_index(test_file2) assert rindices_np_64.dtype is np.dtype(np.int64) -assert rindices_np_64.size==basis_num -for i in range(basis_num): +assert rindices_np_64.size==basis_shell_num +for i in range(basis_shell_num): assert rindices_np_64[i]==indices_np[i] # read nuclear coordinates without providing optional argument dim diff --git a/python/test/test_pytrexio.py b/python/test/test_pytrexio.py index 04cdd55..0636bc0 100644 --- a/python/test/test_pytrexio.py +++ b/python/test/test_pytrexio.py @@ -66,7 +66,7 @@ indices = [i for i in range(basis_num)] indices_np = np.array(indices, dtype=np.int32) # first write basis_num because it is needed to check dimensions of basis_nucleus_index in TREXIO >= 2.0.0 -rc = trexio_write_basis_num(test_file, basis_num) +rc = trexio_write_basis_shell_num(test_file, basis_num) assert rc==0 # function call below works with both lists and numpy arrays, dimension needed for memory-safety is derived @@ -129,7 +129,7 @@ assert rc==23 #for i in range(nucleus_num): # assert charges2[i]==charges[i] -result_basis = trexio_read_basis_num(test_file2) +result_basis = trexio_read_basis_shell_num(test_file2) assert result[0]==0 assert result[1]==basis_num diff --git a/tests/io_dset_int_hdf5.c b/tests/io_dset_int_hdf5.c index fa5703c..50a3988 100644 --- a/tests/io_dset_int_hdf5.c +++ b/tests/io_dset_int_hdf5.c @@ -25,7 +25,7 @@ static int test_write_dset (const char* file_name, const back_end_t backend) { assert (file != NULL); // write numerical attribute in an empty file - rc = trexio_write_basis_num(file, num); + rc = trexio_write_basis_shell_num(file, num); assert (rc == TREXIO_SUCCESS); // write numerical (integer) dataset in a file @@ -91,7 +91,7 @@ static int test_read_dset (const char* file_name, const back_end_t backend) { assert (file != NULL); // read numerical attribute from the file - rc = trexio_read_basis_num(file, &num); + rc = trexio_read_basis_shell_num(file, &num); assert (rc == TREXIO_SUCCESS); assert (num == 12); diff --git a/tests/io_dset_int_text.c b/tests/io_dset_int_text.c index 6026afe..456d206 100644 --- a/tests/io_dset_int_text.c +++ b/tests/io_dset_int_text.c @@ -25,7 +25,7 @@ static int test_write_dset (const char* file_name, const back_end_t backend) { assert (file != NULL); // write numerical attribute in an empty file - rc = trexio_write_basis_num(file, num); + rc = trexio_write_basis_shell_num(file, num); assert (rc == TREXIO_SUCCESS); // write numerical (integer) dataset in a file @@ -91,7 +91,7 @@ static int test_read_dset (const char* file_name, const back_end_t backend) { assert (file != NULL); // read numerical attribute from the file - rc = trexio_read_basis_num(file, &num); + rc = trexio_read_basis_shell_num(file, &num); assert (rc == TREXIO_SUCCESS); assert (num == 12); diff --git a/tests/test_f.f90 b/tests/test_f.f90 index 59027b9..7f1e945 100644 --- a/tests/test_f.f90 +++ b/tests/test_f.f90 @@ -44,7 +44,7 @@ subroutine test_write(file_name, back_end) integer :: rc = 1 - integer :: num, basis_num + integer :: num, basis_shell_num integer :: basis_nucleus_index(24) double precision :: charge(12) @@ -70,7 +70,7 @@ subroutine test_write(file_name, back_end) 0.00000000d0, 2.47304151d0 , 0.00000000d0 /), & shape(coord) ) - basis_num = 24 + basis_shell_num = 24 basis_nucleus_index = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 /) label = [character(len=8) :: 'C', 'Na','C', 'C 66', 'C','C', 'H 99', 'Ru', 'H', 'H', 'H', 'H' ] @@ -105,7 +105,7 @@ subroutine test_write(file_name, back_end) deallocate(sym_str) call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS WRITE POINT GROUP') - rc = trexio_write_basis_num(trex_file, basis_num) + rc = trexio_write_basis_shell_num(trex_file, basis_shell_num) call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS WRITE BASIS NUM') rc = trexio_write_basis_nucleus_index(trex_file, basis_nucleus_index) @@ -140,7 +140,7 @@ subroutine test_read(file_name, back_end) integer :: i, j, k, ind, offset, flag integer :: rc = 1 - integer :: num, num_read, basis_num + integer :: num, num_read, basis_shell_num integer :: basis_nucleus_index(24) double precision :: charge(12) @@ -155,7 +155,7 @@ subroutine test_read(file_name, back_end) character*(128) :: str num = 12 - basis_num = 24 + basis_shell_num = 24 ! ================= START OF TEST ===================== ! From b535ffc8b2e290e045d6700cb79104b09e8e113f Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 25 Oct 2021 11:40:07 +0200 Subject: [PATCH 16/20] adapt README and ChangeLog --- ChangeLog | 7 +++++++ README.md | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 564b818..c333145 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,13 @@ CHANGES ======= +2.0 +--- + +- Fixed data structure of the group in trex.org in order to simplify the +access to both local and non-local quantities +- Adapted data structure of the group to be consistent with the + 1.1 --- diff --git a/README.md b/README.md index 6562200..95037e7 100644 --- a/README.md +++ b/README.md @@ -50,9 +50,15 @@ TREX library for efficient I/O. The `make install` command takes care of installing the TREXIO shared library on the user machine. Once installed, add `-ltrexio` to the list of compiler options. + In some cases (e.g. when using custom `prefix` during configuration), the TREXIO library might end up installed in a directory, which is absent in the default `$LIBRARY_PATH`. -In order to link the program against TREXIO, the search paths in the current shell can be modified as follows: `export LIBRARY_PATH=$LIBRARY_PATH:/lib` (same holds for `$LD_LIBRARY_PATH`). Do not forget to change ``. -If your compilation relies on some build tools (like Autotools or CMake), feel free to use the built-in functions to locate and link external dependencies automatically. +In order to link the program against TREXIO, the search paths can be modified as follows: + +`export LIBRARY_PATH=$LIBRARY_PATH:/lib` + +(same holds for `$LD_LIBRARY_PATH`). The `` has to be replaced by the prefix used during the installation. + +If your compilation relies on some build tools (like Autotools or CMake), feel free to use the built-in solutions to locate and link external dependencies automatically. In Fortran applications, make sure that the `trexio_f.f90` module file is included in the source tree. You might have to manually copy it into your program source directory. From ca81d94be6c3ab81442d7b42d1fce90df33874df Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 25 Oct 2021 12:17:15 +0200 Subject: [PATCH 17/20] fix typos in the ECP --- trex.org | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trex.org b/trex.org index 5ed835d..e07267b 100644 --- a/trex.org +++ b/trex.org @@ -138,7 +138,7 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an e^{-\alpha_{A q \ell} |\mathbf{r}-\mathbf{R}_{A}|^2 } \] - See http://dx.doi.org/10.1063/1.4984046 or https://doi.org/10.1063/1.5121006for more info. + See http://dx.doi.org/10.1063/1.4984046 or https://doi.org/10.1063/1.5121006 for more info. #+NAME: ecp | Variable | Type | Dimensions | Description | @@ -162,7 +162,7 @@ ECP that replaces the core electrons. *Note for developers*: avoid having variables with similar prefix in their name. -HDF5 back end might cause issues due to the way `find_dataset` function works. +HDF5 back end might cause issues due to the way ~find_dataset~ function works. For example, in the ECP group we use ~max_ang_mom~ and not ~ang_mom_max~. The latter causes issues when written before ~ang_mom~ in the TREXIO file. @@ -287,7 +287,7 @@ power = [ | ~prim_num~ | ~dim~ | | Total number of primitives | | ~shell_num~ | ~dim~ | | Total number of shells | | ~nucleus_index~ | ~index~ | ~(basis.shell_num)~ | One-to-one correspondence between shells and atomic indices | - | ~ang_mom~ | ~int~ | ~(basis.shell_num)~ | One-to-one correspondence between shells and angular momenta | + | ~shell_ang_mom~ | ~int~ | ~(basis.shell_num)~ | One-to-one correspondence between shells and angular momenta | | ~shell_factor~ | ~float~ | ~(basis.shell_num)~ | Normalization factor of each shell ($\mathcal{N}_s$) | | ~shell_index~ | ~index~ | ~(basis.prim_num)~ | One-to-one correspondence between primitives and shell index | | ~exponent~ | ~float~ | ~(basis.prim_num)~ | Exponents of the primitives ($\gamma_{ks}$) | From 60380da0df829c0f460980f5e9aab752fd1cbad6 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 25 Oct 2021 13:28:18 +0200 Subject: [PATCH 18/20] update the tangled block and example --- trex.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trex.org b/trex.org index e07267b..8336c15 100644 --- a/trex.org +++ b/trex.org @@ -304,7 +304,7 @@ power = [ , "prim_num" : [ "dim" , [] ] , "shell_num" : [ "dim" , [] ] , "nucleus_index" : [ "index", [ "basis.shell_num" ] ] - , "ang_mom" : [ "int" , [ "basis.shell_num" ] ] + , "shell_ang_mom" : [ "int" , [ "basis.shell_num" ] ] , "shell_factor" : [ "float", [ "basis.shell_num" ] ] , "shell_index" : [ "index", [ "basis.prim_num" ] ] , "exponent" : [ "float", [ "basis.prim_num" ] ] @@ -352,7 +352,7 @@ nucleus_index = 1, 1, 1, 1, 1, 1 ] # 3 shells in S (l=0), 2 in P (l=1), 1 in D (l=2) -ang_mom = +shell_ang_mom = [ 0, 0, 0, 1, 1, 2, 0, 0, 0, 1, 1, 2 ] From 9e53671252be9dd72bef351f6f3d294a7cf70105 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 25 Oct 2021 16:59:50 +0200 Subject: [PATCH 19/20] fix error in the ECP example --- trex.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trex.org b/trex.org index 8336c15..fb3af60 100644 --- a/trex.org +++ b/trex.org @@ -206,8 +206,8 @@ H-ccECP GEN 0 1 #+BEGIN_EXAMPLE num = 8 -# lmax+1 per atom -max_ang_mom_plus_1 = [ 1, 1 ] +# lmax+1 per atom: 0 here because no core electrons to be removed +max_ang_mom_plus_1 = [ 0, 0 ] # number of core electrons to remove per atom zcore = [ 0, 0 ] From 33078eeee48c18e8e5fe44c66064a8aa4ad85d78 Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 26 Oct 2021 10:34:59 +0200 Subject: [PATCH 20/20] Revert "fix error in the ECP example" This reverts commit 9e53671252be9dd72bef351f6f3d294a7cf70105. --- trex.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trex.org b/trex.org index fb3af60..8336c15 100644 --- a/trex.org +++ b/trex.org @@ -206,8 +206,8 @@ H-ccECP GEN 0 1 #+BEGIN_EXAMPLE num = 8 -# lmax+1 per atom: 0 here because no core electrons to be removed -max_ang_mom_plus_1 = [ 0, 0 ] +# lmax+1 per atom +max_ang_mom_plus_1 = [ 1, 1 ] # number of core electrons to remove per atom zcore = [ 0, 0 ]