diff --git a/configure.ac b/configure.ac index ef4376b..d9ebc09 100644 --- a/configure.ac +++ b/configure.ac @@ -98,6 +98,31 @@ case $CC in ;; esac +# Check if `cp -r -n` works, otherwise use `cp -r` +AC_CHECK_PROGS(CP_PROG, [cp]) + +AC_MSG_CHECKING([for cp -r -n option]) +AC_RUN_IFELSE( + [AC_LANG_PROGRAM([ +#include +],[ +execl("/bin/sh", "sh", "-c", "mkdir tmpdir1 && \ +touch tmpdir1/test_file && \ +$CP_PROG -r -n tmpdir1 tmpdir2 && \ +exec ls tmpdir2/test_file", NULL); +])], +[ rm -rf tmpdir1 tmpdir2 + CP_COMMAND="\"$CP_PROG\", \"-r\", \"-n\"" + AC_MSG_RESULT([yes])], +[ rm -rf tmpdir1 tmpdir2 + CP_COMMAND="\"$CP_PROG\", \"-r\"" + AC_MSG_RESULT([no])], +[ rm -rf tmpdir1 tmpdir2 + CP_COMMAND="\"$CP_PROG\", \"-r\"" + AC_MSG_RESULT([no])] +) +AC_DEFINE_UNQUOTED([CP_COMMAND], [$CP_COMMAND], [Command used for trexio_cp]) + ## --------- ## Libraries @@ -175,6 +200,9 @@ AC_TYPE_INT64_T AC_TYPE_SIZE_T AC_TYPE_UINT32_T AC_TYPE_UINT64_T +AC_TYPE_PID_T +AC_C_CONST +AC_C_INLINE # Checks for library functions. # AC_FUNC_MALLOC diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index d4619c3..33975b6 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -1590,7 +1590,7 @@ def _inquire(file_name: str) -> bool: ** File copy - ~trexio_cp~ copies a TREXIO file using =/bin/cp=. + ~trexio_cp~ copies a TREXIO file using =cp=. **Input parameters:** 1) ~source_file_name~ - string containing the name of the source file @@ -1650,24 +1650,14 @@ trexio_cp(const char* source, const char* dest) /* Call cp */ +#ifndef CP_COMMAND +#define CP_COMMAND "cp", "-r" +#endif + + pid_t pid = fork(); if (pid == 0) { - switch (back_end_local) { - case TREXIO_TEXT: - execl("/bin/cp", "/bin/cp", "-r", "-n", source, dest, (char *)0); - case TREXIO_HDF5: -#ifdef HAVE_HDF5 - execl("/bin/cp", "/bin/cp", "-n", source, dest, (char *)0); -#else - return TREXIO_FILE_ERROR; -#endif -/* - case TREXIO_JSON: - execl("/bin/cp", "/bin/cp", source, dest, (char *)0); -,*/ - default: - return TREXIO_FILE_ERROR; - } + execlp("cp", CP_COMMAND, source, dest, (char *)0); } else if (pid < 0) { return TREXIO_FILE_ERROR; } else { diff --git a/trex.org b/trex.org index fe86f8e..0c23fab 100644 --- a/trex.org +++ b/trex.org @@ -1132,12 +1132,7 @@ power = [ The Jastrow factor is an $N$-electron function to which the CI expansion is multiplied: $\Psi = \Phi \times \exp(J)$, - where - \[ - J(\mathbf{r},\mathbf{R}) = J_{\text{eN}}(\mathbf{r},\mathbf{R}) + J_{\text{ee}}(\mathbf{r}) + J_{\text{eeN}}(\mathbf{r},\mathbf{R}) - \] - In the following, we use the notations $r_{ij} = |\mathbf{r}_i - \mathbf{r}_j|$ and $R_{i\alpha} = |\mathbf{r}_i - \mathbf{R}_\alpha|$, where indices $i$ and $j$ correspond to electrons and $\alpha$ to nuclei. @@ -1152,7 +1147,12 @@ power = [ *** CHAMP The first form of Jastrow factor is the one used in - the [[https://trex-coe.eu/trex-quantum-chemistry-codes/champ][CHAMP]] program. + the [[https://trex-coe.eu/trex-quantum-chemistry-codes/champ][CHAMP]] program: + + \[ + J(\mathbf{r},\mathbf{R}) = J_{\text{eN}}(\mathbf{r},\mathbf{R}) + J_{\text{ee}}(\mathbf{r}) + J_{\text{eeN}}(\mathbf{r},\mathbf{R}) + \] + $J_{\text{eN}}$ contains electron-nucleus terms: @@ -1197,25 +1197,71 @@ power = [ g_\alpha(r) = e^{-\kappa_\alpha\, r}. \] -*** mu +*** Mu - The "mu" Jastrow factor has only a single parameter $\mu$ for the - [[https://doi.org/10.1063/5.0044683][electron-electron term]]: + [[https://aip.scitation.org/doi/10.1063/5.0044683][Mu-Jastrow]] is based on a one-parameter correlation factor that has + been introduced in the context of transcorrelated methods. This + correlation factor imposes the electron-electron cusp and it is + built such that the leading order in $1/r_{12}$ of the effective + two-electron potential reproduces the long-range interaction of the + range-separated density functional theory. Its analytical + expression reads + + \[ + J(\mathbf{r}, \mathbf{R}) = J_{\text{eeN}}(\mathbf{r}, \mathbf{R}) + + J_{\text{eN}}(\mathbf{r}, \mathbf{R}) + \]. + + The electron-electron cusp is incorporated in the three-body term. + + \[ + J_\text{eeN} (\mathbf{r}, \mathbf{R}) = + \sum_{i=1}^{N_\text{elec}} \sum_{j=1}^{i-1} \, u\left(\mu, r_{ij}\right) \, + \Pi_{\alpha=1}^{N_{\text{nucl}}} \, E_\alpha({R}_{i\alpha}) \, E_\alpha({R}_{j\alpha}) + \] + + $u$ is an electron-electron function given by the symetric function + + \[ + u\left(\mu, r\right) = \frac{r}{2} \, \left[ 1 - \text{erf}(\mu\, r) \right] - \frac{1}{2 \, \mu \, \sqrt{\pi}} \exp \left[ -(\mu \, r)^2 \right]. + \] + + This electron-electron term is tuned by the parameter $\mu$ which + controls the depth and the range of the Coulomb hole between + electrons. + + An envelope function has been introduced to cancel out the Jastrow + effects between two-electrons when they are both close to a nucleus + (to perform a frozen-core calculation). The envelope function is + given by + + \[ + E_\alpha(R) = 1 - \exp\left( - \gamma_{\alpha} \, R^2 \right). + \] + + In particular, if the parameters $\gamma_\alpha$ tend to zero, the + Mu-Jastrow factor becomes a two-body Jastrow factor: \[ J_{\text{ee}}(\mathbf{r}) = - \sum_{i=1}^{N_\text{elec}} \sum_{j=1}^{i-1} r_{ij} - \left( 1 - \text{erf}(\mu\, r_{ij})\right) - \frac{1}{\mu\sqrt{\pi}} - e^{-(\mu\,r_{ij})^2} + \sum_{i=1}^{N_\text{elec}} \sum_{j=1}^{i-1} \, u\left(\mu, r_{ij}\right) \] -# It was then updated for frozen-core calculations by introducing a -# set of electron-electron-nucleus terms with one parameter per nucleus: + and for large $\gamma_\alpha$ it becomes zero. + + To increase the flexibility of the Jastrow and improve the + electron density the following electron-nucleus term is added -# \[ -# J_{\text{eeN}}(\mathbf{r}) = -# \] + \[ + J_{\text{eN}}(\mathbf{r},\mathbf{R}) = \sum_{i=1}^{N_\text{elec}} \sum_{\alpha=1}^{N_\text{nucl}} \, + \left[ \exp\left( a_{\alpha} R_{i \alpha}^2 \right) - 1\right]. + \] + + The parameter $\mu$ is stored in the ~ee~ array, the parameters + $\gamma_\alpha$ are stored in the ~een~ array, and the parameters + $a_\alpha$ are stored in the ~en~ array. + *** Table of values #+name: jastrow