Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jastrow mu #108

Merged
merged 7 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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 <unistd.h>
],[
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
Expand Down Expand Up @@ -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
Expand Down
24 changes: 7 additions & 17 deletions src/templates_front/templator_front.org
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1650,24 +1650,14 @@ trexio_cp(const char* source, const char* dest)

/* Call cp */

#ifndef CP_COMMAND
#define CP_COMMAND "cp", "-r"
scemama marked this conversation as resolved.
Show resolved Hide resolved
#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 {
Expand Down
80 changes: 63 additions & 17 deletions trex.org
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:

Expand Down Expand Up @@ -1197,25 +1197,71 @@ power = [
g_\alpha(r) = e^{-\kappa_\alpha\, r}.
\]

*** mu
*** Mu

[[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 is 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.

The "mu" Jastrow factor has only a single parameter $\mu$ for the
[[https://doi.org/10.1063/5.0044683][electron-electron term]]:
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{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].
\]

# \[
# J_{\text{eeN}}(\mathbf{r}) =
# \]

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
Expand Down