1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-06-01 02:45:43 +02:00
qmckl/qmckl_jastrow_champ.html

8066 lines
438 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2024-04-10 Wed 14:39 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>CHAMP Jastrow Factor</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="TREX CoE" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<link rel="stylesheet" title="Standard" href="qmckl.css" type="text/css" />
<script type="text/javascript" src="org-info.js">
/**
*
* @source: org-info.js
*
* @licstart The following is the entire license notice for the
* JavaScript code in org-info.js.
*
* Copyright (C) 2012-2020 Free Software Foundation, Inc.
*
*
* The JavaScript code in this tag is free software: you can
* redistribute it and/or modify it under the terms of the GNU
* General Public License (GNU GPL) as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version. The code is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
*
* As additional permission under GNU GPL version 3 section 7, you
* may distribute non-source (e.g., minimized or compacted) forms of
* that code without the copy of the GNU GPL normally required by
* section 4, provided you include this license notice and a URL
* through which recipients can access the Corresponding Source.
*
* @licend The above is the entire license notice
* for the JavaScript code in org-info.js.
*
*/
</script>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2020 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
org_html_manager.set("TOC_DEPTH", "4");
org_html_manager.set("LINK_HOME", "index.html");
org_html_manager.set("LINK_UP", "");
org_html_manager.set("LOCAL_TOC", "1");
org_html_manager.set("VIEW_BUTTONS", "0");
org_html_manager.set("MOUSE_HINT", "underline");
org_html_manager.set("FIXED_TOC", "0");
org_html_manager.set("TOC", "1");
org_html_manager.set("VIEW", "info");
org_html_manager.setup(); // activate after the parameters are set
/*]]>*///-->
</script>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2020 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
displayAlign: "center",
displayIndent: "0em",
"HTML-CSS": { scale: 100,
linebreaks: { automatic: "false" },
webFont: "TeX"
},
SVG: {scale: 100,
linebreaks: { automatic: "false" },
font: "TeX"},
NativeMML: {scale: 100},
TeX: { equationNumbers: {autoNumber: "AMS"},
MultLineWidth: "85%",
TagSide: "right",
TagIndent: ".8em"
}
});
</script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body>
<div id="org-div-home-and-up">
<a accesskey="h" href=""> UP </a>
|
<a accesskey="H" href="index.html"> HOME </a>
</div><div id="content">
<h1 class="title">CHAMP Jastrow Factor</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org25a502e">1. Introduction</a></li>
<li><a href="#orgebcef65">2. Context</a>
<ul>
<li><a href="#org8a25884">2.1. Data structure</a></li>
<li><a href="#org29331db">2.2. Initialization functions</a>
<ul>
<li>
<ul>
<li><a href="#orgbb0b671">2.2.0.1. Fortran interface</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org24b9107">2.3. Access functions</a>
<ul>
<li>
<ul>
<li><a href="#orga6b9e90">2.3.0.1. Fortran interface</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#orgf6608a3">2.4. Test</a></li>
</ul>
</li>
<li><a href="#org5f2ac44">3. Computation</a>
<ul>
<li><a href="#org1cc8426">3.1. Electron-electron component</a>
<ul>
<li><a href="#org2dc1809">3.1.1. Asymptotic component</a>
<ul>
<li><a href="#org712c41f">3.1.1.1. Get</a></li>
<li><a href="#org2eaae3d">3.1.1.2. Compute</a></li>
<li><a href="#org9a5a34a">3.1.1.3. Test</a></li>
</ul>
</li>
<li><a href="#org9d19898">3.1.2. Electron-electron component</a>
<ul>
<li><a href="#org587897c">3.1.2.1. Get</a></li>
<li><a href="#orgc180bd1">3.1.2.2. Compute</a></li>
<li><a href="#orgafc8cc8">3.1.2.3. Test</a></li>
</ul>
</li>
<li><a href="#org42ced79">3.1.3. Derivative</a>
<ul>
<li><a href="#org6a9af69">3.1.3.1. Get</a></li>
<li><a href="#org35bf5ea">3.1.3.2. Compute</a></li>
<li><a href="#org1f30636">3.1.3.3. Test</a></li>
</ul>
</li>
<li><a href="#org13de2cb">3.1.4. Electron-electron rescaled distances</a>
<ul>
<li><a href="#orga5c3e31">3.1.4.1. Get</a></li>
<li><a href="#org398c519">3.1.4.2. Compute</a></li>
<li><a href="#org563d91e">3.1.4.3. Test</a></li>
</ul>
</li>
<li><a href="#orgcbdc228">3.1.5. Electron-electron rescaled distance gradients and Laplacian with respect to electron coordinates</a>
<ul>
<li><a href="#orge900bfa">3.1.5.1. Get</a></li>
<li><a href="#org02b6cf8">3.1.5.2. Compute</a></li>
<li><a href="#org451145b">3.1.5.3. Test</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org1430509">3.2. Electron-nucleus component</a>
<ul>
<li><a href="#org8e99884">3.2.1. Asymptotic component for</a>
<ul>
<li><a href="#org2197ccf">3.2.1.1. Get</a></li>
<li><a href="#org733e257">3.2.1.2. Compute</a></li>
<li><a href="#org530618d">3.2.1.3. Test</a></li>
</ul>
</li>
<li><a href="#orgf7e87f9">3.2.2. Electron-nucleus component</a>
<ul>
<li><a href="#org737a5c3">3.2.2.1. Get</a></li>
<li><a href="#org2cc199b">3.2.2.2. Compute</a></li>
<li><a href="#org45d9746">3.2.2.3. Test</a></li>
</ul>
</li>
<li><a href="#orgb30c985">3.2.3. Derivative</a>
<ul>
<li><a href="#orgdd86b74">3.2.3.1. Get</a></li>
<li><a href="#org2c112fa">3.2.3.2. Compute</a></li>
<li><a href="#org2eab6a4">3.2.3.3. Test</a></li>
</ul>
</li>
<li><a href="#orgf840b91">3.2.4. Electron-nucleus rescaled distances</a>
<ul>
<li><a href="#orga4cc5db">3.2.4.1. Get</a></li>
<li><a href="#org772d350">3.2.4.2. Compute</a></li>
<li><a href="#org7eb0b3d">3.2.4.3. Test</a></li>
</ul>
</li>
<li><a href="#orgdd07176">3.2.5. Electron-electron rescaled distance gradients and Laplacian with respect to electron coordinates</a>
<ul>
<li><a href="#org3dab799">3.2.5.1. Get</a></li>
<li><a href="#org93b1e07">3.2.5.2. Compute</a></li>
<li><a href="#org68b06a3">3.2.5.3. Test</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#orgdd03967">3.3. Electron-electron-nucleus component</a>
<ul>
<li><a href="#orgc1b2757">3.3.1. Electron-electron rescaled distances in \(J_\text{eeN}\)</a>
<ul>
<li><a href="#org4ca33bc">3.3.1.1. Get</a></li>
<li><a href="#org88bc232">3.3.1.2. Compute</a></li>
<li><a href="#org36da75a">3.3.1.3. Test</a></li>
</ul>
</li>
<li><a href="#org3c44fff">3.3.2. Electron-electron rescaled distances derivatives in \(J_\text{eeN}\)</a>
<ul>
<li><a href="#org6283b2e">3.3.2.1. Get</a></li>
<li><a href="#orga0b439b">3.3.2.2. Compute</a></li>
<li><a href="#org20aec8a">3.3.2.3. Test</a></li>
</ul>
</li>
<li><a href="#orgd06bacb">3.3.3. Electron-nucleus rescaled distances in \(J_\text{eeN}\)</a>
<ul>
<li><a href="#orgbbf476e">3.3.3.1. Get</a></li>
<li><a href="#org6dc9ed2">3.3.3.2. Compute</a></li>
<li><a href="#org0b64998">3.3.3.3. Test</a></li>
</ul>
</li>
<li><a href="#orgd785a7d">3.3.4. Electron-nucleus rescaled distances derivatives in \(J_\text{eeN}\)</a>
<ul>
<li><a href="#org20d9153">3.3.4.1. Get</a></li>
<li><a href="#orgbc6216b">3.3.4.2. Compute</a></li>
<li><a href="#org0ac4264">3.3.4.3. Test</a></li>
</ul>
</li>
<li><a href="#orgbf2ce39">3.3.5. Temporary arrays for electron-electron-nucleus Jastrow \(f_{een}\)</a>
<ul>
<li><a href="#orgf388bb9">3.3.5.1. Compute dim<sub>c</sub><sub>vector</sub></a></li>
<li><a href="#orga4fbf71">3.3.5.2. Get</a></li>
<li><a href="#org1821673">3.3.5.3. Compute c<sub>vector</sub><sub>full</sub></a></li>
<li><a href="#orgaace9f3">3.3.5.4. Compute lkpm<sub>combined</sub><sub>index</sub></a></li>
<li><a href="#org0568c87">3.3.5.5. Compute tmp<sub>c</sub></a></li>
<li><a href="#org4e804a3">3.3.5.6. Compute dtmp<sub>c</sub></a></li>
<li><a href="#orgf1e9aac">3.3.5.7. Test</a></li>
</ul>
</li>
<li><a href="#org418b4f4">3.3.6. Electron-electron-nucleus Jastrow \(f_{een}\)</a>
<ul>
<li><a href="#org09fdec0">3.3.6.1. Get</a></li>
<li><a href="#orgea21787">3.3.6.2. Compute naive</a></li>
<li><a href="#org8c9bae6">3.3.6.3. Compute</a></li>
<li><a href="#org41d0527">3.3.6.4. Test</a></li>
</ul>
</li>
<li><a href="#orgb5b0459">3.3.7. Electron-electron-nucleus Jastrow \(f_{een}\) derivative</a>
<ul>
<li><a href="#org218988d">3.3.7.1. Get</a></li>
<li><a href="#orgc1a7cbc">3.3.7.2. Compute Naive</a></li>
<li><a href="#orgaa84f73">3.3.7.3. Compute</a></li>
<li><a href="#orgc167f66">3.3.7.4. Test</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#orgecb8240">3.4. Total Jastrow</a>
<ul>
<li><a href="#org5c76e07">3.4.1. Value</a>
<ul>
<li><a href="#org367ad74">3.4.1.1. Get</a></li>
<li><a href="#orgbec2a58">3.4.1.2. Compute</a></li>
<li><a href="#org29cd2a7">3.4.1.3. Test</a></li>
</ul>
</li>
<li><a href="#org4debb3f">3.4.2. Derivatives</a>
<ul>
<li><a href="#org5416142">3.4.2.1. Get</a></li>
<li><a href="#orgfb20810">3.4.2.2. Compute</a></li>
<li><a href="#orgcb4645f">3.4.2.3. Test</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org25a502e" class="outline-2">
<h2 id="org25a502e"><span class="section-number-2">1</span> Introduction</h2>
<div class="outline-text-2" id="text-1">
<p>
The Jastrow factor depends on the electronic (\(\mathbf{r}\)) and
nuclear (\(\mathbf{R}\)) coordinates. Its defined as \(\exp(J(\mathbf{r},\mathbf{R}))\), where
</p>
<p>
\[
J(\mathbf{r},\mathbf{R}) = J_{\text{eN}}(\mathbf{r},\mathbf{R}) + J_{\text{ee}}(\mathbf{r}) + J_{\text{eeN}}(\mathbf{r},\mathbf{R})
\]
</p>
<p>
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|\).
</p>
<p>
\(J_{\text{eN}}\) contains electron-nucleus terms:
</p>
<p>
\[
J_{\text{eN}}(\mathbf{r},\mathbf{R}) =
\sum_{\alpha=1}^{N_\text{nucl}} \sum_{i=1}^{N_\text{elec}}
\frac{a_{1\,\alpha}\, f_\alpha(R_{i\alpha})}{1+a_{2\,\alpha}\, f_\alpha(R_{i\alpha})} +
\sum_{p=2}^{N_\text{ord}^a} a_{p+1\,\alpha}\, [f_\alpha(R_{i\alpha})]^p - J_{\text{eN}}^{\infty \alpha}
\]
</p>
<p>
\(J_{\text{ee}}\) contains electron-electron terms:
\[
J_{\text{ee}}(\mathbf{r}) =
\sum_{i=1}^{N_\text{elec}} \sum_{j=1}^{i-1}
\frac{\frac{1}{2}(1+\delta^{\uparrow\downarrow}_{ij}) b_1\, f_{\text{ee}}(r_{ij})}{1+b_2\, f_{\text{ee}}(r_{ij})} +
\sum_{p=2}^{N_\text{ord}^b} b_{p+1}\, [f_{\text{ee}}(r_{ij})]^p - J_{ee}^\infty
\]
</p>
<p>
and \(J_{\text{eeN}}\) contains electron-electron-Nucleus terms:
</p>
<p>
\[
J_{\text{eeN}}(\mathbf{r},\mathbf{R}) =
\sum_{\alpha=1}^{N_{\text{nucl}}}
\sum_{i=1}^{N_{\text{elec}}}
\sum_{j=1}^{i-1}
\sum_{p=2}^{N_{\text{ord}}}
\sum_{k=0}^{p-1}
\sum_{l=0}^{p-k-2\delta_{k,0}}
c_{lkp\alpha} \left[ g_\text{e}({r}_{ij}) \right]^k
\left[ \left[ g_\alpha({R}_{i\alpha}) \right]^l + \left[ g_\alpha({R}_{j\alpha}) \right]^l \right]
\left[ g_\alpha({R}_{i\,\alpha}) \, g_\alpha({R}_{j\alpha}) \right]^{(p-k-l)/2}
\]
</p>
<p>
\(c_{lkp\alpha}\) are non-zero only when \(p-k-l\) is even.
</p>
<p>
\(f\) and \(g\) are scaling function defined as
</p>
<p>
\[
f_\alpha(r) = \frac{1-e^{-\kappa_\alpha\, r}}{\kappa_\alpha} \text{ and }
g_\alpha(r) = e^{-\kappa_\alpha\, r} = 1-\kappa_\alpha f_\alpha(r).
\]
</p>
<p>
The terms \(J_{\text{ee}}^\infty\) and \(J_{\text{eN}}^\infty\) are shifts to ensure that
\(J_{\text{ee}}\) and \(J_{\text{eN}}\) have an asymptotic value of zero.
</p>
<p>
The eN and eeN parameters are the same of all identical nuclei.
Warning: The types of nuclei use zero-based indexing.
</p>
</div>
</div>
<div id="outline-container-orgebcef65" class="outline-2">
<h2 id="orgebcef65"><span class="section-number-2">2</span> Context</h2>
<div class="outline-text-2" id="text-2">
<p>
The following data stored in the context:
</p>
<table id="org1a3e451" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>uninitialized</code></td>
<td class="org-left"><code>int32_t</code></td>
<td class="org-left">Keeps bits set for uninitialized data</td>
</tr>
<tr>
<td class="org-left"><code>rescale_factor_ee</code></td>
<td class="org-left"><code>double</code></td>
<td class="org-left">The distance scaling factor</td>
</tr>
<tr>
<td class="org-left"><code>rescale_factor_en</code></td>
<td class="org-left"><code>double[type_nucl_num]</code></td>
<td class="org-left">The distance scaling factor</td>
</tr>
<tr>
<td class="org-left"><code>aord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">The number of a coeffecients</td>
</tr>
<tr>
<td class="org-left"><code>bord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">The number of b coeffecients</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">The number of c coeffecients</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">Number of Nuclei types</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_vector</code></td>
<td class="org-left"><code>int64_t[nucl_num]</code></td>
<td class="org-left">IDs of types of Nuclei. These use 0-based indexing as in C.</td>
</tr>
<tr>
<td class="org-left"><code>a_vector</code></td>
<td class="org-left"><code>double[aord_num + 1][type_nucl_num]</code></td>
<td class="org-left">a polynomial coefficients</td>
</tr>
<tr>
<td class="org-left"><code>b_vector</code></td>
<td class="org-left"><code>double[bord_num + 1]</code></td>
<td class="org-left">b polynomial coefficients</td>
</tr>
<tr>
<td class="org-left"><code>c_vector</code></td>
<td class="org-left"><code>double[dim_c_vector][type_nucl_num]</code></td>
<td class="org-left">c polynomial coefficients</td>
</tr>
<tr>
<td class="org-left"><code>c_vector</code></td>
<td class="org-left"><code>double[dim_c_vector][type_nucl_num]</code></td>
<td class="org-left">c polynomial coefficients</td>
</tr>
<tr>
<td class="org-left"><code>spin_independent</code></td>
<td class="org-left"><code>int32_t</code></td>
<td class="org-left">If 1, use same parameters for parallel and anti-parallel spins. Otherwise, 0.</td>
</tr>
</tbody>
</table>
<p>
Computed data:
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>dim_c_vector</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">Number of unique C coefficients</td>
</tr>
<tr>
<td class="org-left"><code>dim_c_vector_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Number of unique C coefficients</td>
</tr>
<tr>
<td class="org-left"><code>asymp_jasa</code></td>
<td class="org-left"><code>double[type_nucl_num]</code></td>
<td class="org-left">Asymptotic component</td>
</tr>
<tr>
<td class="org-left"><code>asymp_jasa_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Ladt modification of the asymptotic component</td>
</tr>
<tr>
<td class="org-left"><code>asymp_jasb</code></td>
<td class="org-left"><code>double[2]</code></td>
<td class="org-left">Asymptotic component (up- or down-spin)</td>
</tr>
<tr>
<td class="org-left"><code>asymp_jasb_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Ladt modification of the asymptotic component</td>
</tr>
<tr>
<td class="org-left"><code>c_vector_full</code></td>
<td class="org-left"><code>double[dim_c_vector][nucl_num]</code></td>
<td class="org-left">vector of non-zero coefficients</td>
</tr>
<tr>
<td class="org-left"><code>c_vector_full_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Keep track of changes here</td>
</tr>
<tr>
<td class="org-left"><code>lkpm_combined_index</code></td>
<td class="org-left"><code>int64_t[4][dim_c_vector]</code></td>
<td class="org-left">Transform l,k,p, and m into consecutive indices</td>
</tr>
<tr>
<td class="org-left"><code>lkpm_combined_index_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Transform l,k,p, and m into consecutive indices</td>
</tr>
<tr>
<td class="org-left"><code>tmp_c</code></td>
<td class="org-left"><code>double[walk_num][cord_num][cord_num+1][nucl_num][elec_num]</code></td>
<td class="org-left">vector of non-zero coefficients</td>
</tr>
<tr>
<td class="org-left"><code>dtmp_c</code></td>
<td class="org-left"><code>double[walk_num][elec_num][4][nucl_num][cord_num+1][cord_num]</code></td>
<td class="org-left">vector of non-zero coefficients</td>
</tr>
<tr>
<td class="org-left"><code>ee_distance_rescaled</code></td>
<td class="org-left"><code>double[walk_num][num][num]</code></td>
<td class="org-left">Electron-electron rescaled distances</td>
</tr>
<tr>
<td class="org-left"><code>ee_distance_rescaled_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Last modification date of the electron-electron distances</td>
</tr>
<tr>
<td class="org-left"><code>ee_distance_rescaled_gl</code></td>
<td class="org-left"><code>double[walk_num][num][num][4]</code></td>
<td class="org-left">Electron-electron rescaled distances derivatives</td>
</tr>
<tr>
<td class="org-left"><code>ee_distance_rescaled_gl_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Last modification date of the electron-electron distance derivatives</td>
</tr>
<tr>
<td class="org-left"><code>en_distance_rescaled</code></td>
<td class="org-left"><code>double[walk_num][nucl_num][num]</code></td>
<td class="org-left">Electron-nucleus distances</td>
</tr>
<tr>
<td class="org-left"><code>en_distance_rescaled_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Last modification date of the electron-electron distances</td>
</tr>
<tr>
<td class="org-left"><code>en_distance_rescaled_gl</code></td>
<td class="org-left"><code>double[walk_num][nucl_num][num][4]</code></td>
<td class="org-left">Electron-electron rescaled distances derivatives</td>
</tr>
<tr>
<td class="org-left"><code>en_distance_rescaled_gl_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Last modification date of the electron-electron distance derivatives</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n</code></td>
<td class="org-left"><code>double[walk_num][cord_num+1][nucl_num][elec_num]</code></td>
<td class="org-left">The electron-electron rescaled distances raised to the powers defined by cord</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Keep track of the date of creation</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_e_gl</code></td>
<td class="org-left"><code>double[walk_num][cord_num+1][elec_num][4][elec_num]</code></td>
<td class="org-left">The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_e_gl_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Keep track of the date of creation</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n_gl</code></td>
<td class="org-left"><code>double[walk_num][cord_num+1][nucl_num][4][elec_num]</code></td>
<td class="org-left">The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n_gl_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Keep track of the date of creation</td>
</tr>
<tr>
<td class="org-left"><code>factor_ee</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">Jastrow factor: electron-electron part</td>
</tr>
<tr>
<td class="org-left"><code>factor_ee_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Jastrow factor: electron-electron part</td>
</tr>
<tr>
<td class="org-left"><code>factor_en</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">Jastrow factor: electron-nucleus part</td>
</tr>
<tr>
<td class="org-left"><code>factor_en_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Jastrow factor: electron-nucleus part</td>
</tr>
<tr>
<td class="org-left"><code>factor_een</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">Jastrow factor: electron-electron-nucleus part</td>
</tr>
<tr>
<td class="org-left"><code>factor_een_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Jastrow factor: electron-electron-nucleus part</td>
</tr>
<tr>
<td class="org-left"><code>factor_ee_gl</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num]</code></td>
<td class="org-left">Derivative of the Jastrow factor: electron-electron-nucleus part</td>
</tr>
<tr>
<td class="org-left"><code>factor_ee_gl_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Keep track of the date for the derivative</td>
</tr>
<tr>
<td class="org-left"><code>factor_en_gl</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num]</code></td>
<td class="org-left">Derivative of the Jastrow factor: electron-electron-nucleus part</td>
</tr>
<tr>
<td class="org-left"><code>factor_en_gl_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Keep track of the date for the en derivative</td>
</tr>
<tr>
<td class="org-left"><code>factor_een_gl</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num]</code></td>
<td class="org-left">Derivative of the Jastrow factor: electron-electron-nucleus part</td>
</tr>
<tr>
<td class="org-left"><code>factor_een_gl_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Keep track of the date for the een derivative</td>
</tr>
<tr>
<td class="org-left"><code>value</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">Value of the Jastrow factor</td>
</tr>
<tr>
<td class="org-left"><code>value_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Keep track of the date</td>
</tr>
<tr>
<td class="org-left"><code>gl</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num]</code></td>
<td class="org-left">Gradient and Laplacian of the Jastrow factor</td>
</tr>
<tr>
<td class="org-left"><code>value_date</code></td>
<td class="org-left"><code>uint64_t</code></td>
<td class="org-left">Keep track of the date</td>
</tr>
</tbody>
</table>
</div>
<div id="outline-container-org8a25884" class="outline-3">
<h3 id="org8a25884"><span class="section-number-3">2.1</span> Data structure</h3>
<div class="outline-text-3" id="text-2-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #a020f0;">typedef</span> <span style="color: #a020f0;">struct</span> <span style="color: #228b22;">qmckl_jastrow_champ_struct</span>{
<span style="color: #228b22;">int64_t</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">lkpm_combined_index</span>;
<span style="color: #228b22;">int64_t</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">type_nucl_vector</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">asymp_jasa</span>;
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">asymp_jasb</span>[2];
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">a_vector</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">b_vector</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">c_vector</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">c_vector_full</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">dtmp_c</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">ee_distance_rescaled</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">ee_distance_rescaled_gl</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">een_rescaled_e</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">een_rescaled_e_gl</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">een_rescaled_n</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">een_rescaled_n_gl</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">en_distance_rescaled</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">en_distance_rescaled_gl</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">factor_ee</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">factor_ee_gl</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">factor_een</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">factor_een_gl</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">factor_en</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">factor_en_gl</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">rescale_factor_en</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">tmp_c</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">value</span>;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">gl</span>;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">aord_num</span>;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">bord_num</span>;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">type_nucl_num</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">asymp_jasa_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">asymp_jasb_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">c_vector_full_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">dim_c_vector_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">dtmp_c_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">ee_distance_rescaled_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">ee_distance_rescaled_gl_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">een_rescaled_e_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">een_rescaled_e_gl_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">een_rescaled_n_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">een_rescaled_n_gl_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">en_distance_rescaled_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">en_distance_rescaled_gl_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">factor_ee_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">factor_ee_gl_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">factor_een_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">factor_een_gl_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">factor_en_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">factor_en_gl_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">lkpm_combined_index_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">tmp_c_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">value_date</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">gl_date</span>;
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">rescale_factor_ee</span>;
<span style="color: #228b22;">int32_t</span> <span style="color: #a0522d;">uninitialized</span>;
<span style="color: #228b22;">int32_t</span> <span style="color: #a0522d;">spin_independent</span>;
<span style="color: #228b22;">bool</span> <span style="color: #a0522d;">provided</span>;
} <span style="color: #228b22;">qmckl_jastrow_champ_struct</span>;
</pre>
</div>
<p>
The <code>uninitialized</code> integer contains one bit set to one for each
initialization function which has not been called. It becomes equal
to zero after all initialization functions have been called. The
struct is then initialized and <code>provided == true</code>.
Some values are initialized by default, and are not concerned by
this mechanism.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_init_jastrow_champ</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_init_jastrow_champ</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>) {
<span style="color: #a020f0;">if</span> (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
<span style="color: #a020f0;">return</span> <span style="color: #008b8b;">false</span>;
}
<span style="color: #228b22;">qmckl_context_struct</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">ctx</span> = (<span style="color: #228b22;">qmckl_context_struct</span>*) context;
assert (ctx != <span style="color: #008b8b;">NULL</span>);
ctx-&gt;jastrow_champ.uninitialized = (1 &lt;&lt; 11) - 1;
/* <span style="color: #b22222;">Default values</span> */
ctx-&gt;jastrow_champ.aord_num = -1;
ctx-&gt;jastrow_champ.bord_num = -1;
ctx-&gt;jastrow_champ.cord_num = -1;
ctx-&gt;jastrow_champ.dim_c_vector = -1;
ctx-&gt;jastrow_champ.type_nucl_num = -1;
ctx-&gt;jastrow_champ.spin_independent = -1;
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org29331db" class="outline-3">
<h3 id="org29331db"><span class="section-number-3">2.2</span> Initialization functions</h3>
<div class="outline-text-3" id="text-2-2">
<p>
To prepare for the Jastrow and its derivative, all the following functions need to be
called.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_rescale_factor_ee</span> (<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">kappa_ee</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_rescale_factor_en</span> (<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">kappa_en</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_aord_num</span> (<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">aord_num</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_bord_num</span> (<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">bord_num</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_cord_num</span> (<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_type_nucl_num</span> (<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">type_nucl_num</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_type_nucl_vector</span> (<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">type_nucl_vector</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_a_vector</span> (<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> * <span style="color: #a0522d;">a_vector</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_b_vector</span> (<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> * <span style="color: #a0522d;">b_vector</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_c_vector</span> (<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> * <span style="color: #a0522d;">c_vector</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_spin_independent</span> (<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">int32_t</span> <span style="color: #a0522d;">spin_independent</span>);
</pre>
</div>
<p>
When the required information is completely entered, other data structures are
computed to accelerate the calculations. The intermediates factors
are precontracted using BLAS LEVEL 3 operations.
</p>
</div>
<div id="outline-container-orgbb0b671" class="outline-5">
<h5 id="orgbb0b671"><span class="section-number-5">2.2.0.1</span> Fortran interface</h5>
<div class="outline-text-5" id="text-2-2-0-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">interface</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_set_jastrow_champ_rescale_factor_ee (context, </span><span style="color: #a020f0;">&amp;</span>
kappa_ee) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> kappa_ee</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_rescale_factor_ee</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_set_jastrow_champ_rescale_factor_en (context, </span><span style="color: #a020f0;">&amp;</span>
kappa_en, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> kappa_en(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_rescale_factor_en</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_set_jastrow_champ_aord_num (context, </span><span style="color: #a020f0;">&amp;</span>
aord_num) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> aord_num</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_aord_num</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_set_jastrow_champ_bord_num (context, </span><span style="color: #a020f0;">&amp;</span>
bord_num) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> bord_num</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_bord_num</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_set_jastrow_champ_cord_num (context, </span><span style="color: #a020f0;">&amp;</span>
cord_num) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> cord_num</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_cord_num</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_set_jastrow_champ_type_nucl_num (context, </span><span style="color: #a020f0;">&amp;</span>
type_nucl_num) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> type_nucl_num</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_type_nucl_num</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_set_jastrow_champ_type_nucl_vector (context, </span><span style="color: #a020f0;">&amp;</span>
type_nucl_vector, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_vector(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_type_nucl_vector</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_set_jastrow_champ_a_vector(context, </span><span style="color: #a020f0;">&amp;</span>
a_vector, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> a_vector(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_a_vector</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_set_jastrow_champ_b_vector(context, </span><span style="color: #a020f0;">&amp;</span>
b_vector, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> b_vector(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_b_vector</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_set_jastrow_champ_c_vector(context, </span><span style="color: #a020f0;">&amp;</span>
c_vector, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> c_vector(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_c_vector</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_set_jastrow_champ_spin_independent(context, </span><span style="color: #a020f0;">&amp;</span>
spin_independent) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int32_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> spin_independent</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_set_jastrow_champ_spin_independent</span>
<span style="color: #a020f0;">end interface</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org24b9107" class="outline-3">
<h3 id="org24b9107"><span class="section-number-3">2.3</span> Access functions</h3>
<div class="outline-text-3" id="text-2-3">
<p>
Along with these core functions, calculation of the jastrow factor
requires the following additional information to be set:
</p>
<p>
When all the data for the AOs have been provided, the following
function returns <code>true</code>.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">bool</span> <span style="color: #0000ff;">qmckl_jastrow_champ_provided</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>);
</pre>
</div>
</div>
<div id="outline-container-orga6b9e90" class="outline-5">
<h5 id="orga6b9e90"><span class="section-number-5">2.3.0.1</span> Fortran interface</h5>
<div class="outline-text-5" id="text-2-3-0-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">interface</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_rescale_factor_ee (context, </span><span style="color: #a020f0;">&amp;</span>
kappa_ee) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> kappa_ee</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_rescale_factor_ee</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_rescale_factor_en (context, </span><span style="color: #a020f0;">&amp;</span>
kappa_en, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> kappa_en(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_rescale_factor_en</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_aord_num (context, </span><span style="color: #a020f0;">&amp;</span>
aord_num) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> aord_num</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_aord_num</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_bord_num (context, </span><span style="color: #a020f0;">&amp;</span>
bord_num) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> bord_num</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_bord_num</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_cord_num (context, </span><span style="color: #a020f0;">&amp;</span>
cord_num) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> cord_num</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_cord_num</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_type_nucl_num (context, </span><span style="color: #a020f0;">&amp;</span>
type_nucl_num) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> type_nucl_num</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_type_nucl_num</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_type_nucl_vector (context, </span><span style="color: #a020f0;">&amp;</span>
type_nucl_vector, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> type_nucl_vector(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_type_nucl_vector</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_a_vector(context, </span><span style="color: #a020f0;">&amp;</span>
a_vector, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> a_vector(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_a_vector</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_b_vector(context, </span><span style="color: #a020f0;">&amp;</span>
b_vector, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> b_vector(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_b_vector</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_c_vector(context, </span><span style="color: #a020f0;">&amp;</span>
c_vector, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> c_vector(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_c_vector</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_spin_independent(context, </span><span style="color: #a020f0;">&amp;</span>
spin_independent) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int32_t</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> spin_independent</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_spin_independent</span>
<span style="color: #a020f0;">end interface</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgf6608a3" class="outline-3">
<h3 id="orgf6608a3"><span class="section-number-3">2.4</span> Test</h3>
<div class="outline-text-3" id="text-2-4">
<div class="org-src-container">
<pre class="src src-c">/* <span style="color: #b22222;">Reference input data</span> */
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span> = n2_walk_num;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span> = n2_elec_num;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_up_num</span> = n2_elec_up_num;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_dn_num</span> = n2_elec_dn_num;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span> = n2_nucl_num;
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">rescale_factor_ee</span> = 0.6;
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">rescale_factor_en</span>[2] = { 0.6, 0.6 };
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">elec_coord</span> = &amp;(n2_elec_coord[0][0][0]);
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">nucl_charge</span> = n2_charge;
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">nucl_coord</span> = &amp;(n2_nucl_coord[0][0]);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>;
/* <span style="color: #b22222;">Provide Electron data</span> */
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #a0522d;">rc</span>;
assert(!qmckl_electron_provided(context));
rc = qmckl_check(context,
qmckl_set_electron_num (context, elec_up_num, elec_dn_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_electron_provided</span>(<span style="color: #a0522d;">context</span>));
rc = qmckl_check(context,
qmckl_set_electron_coord (context, <span style="color: #8b2252;">'N'</span>, walk_num, elec_coord, walk_num*3*elec_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">elec_coord2</span>[walk_num*3*elec_num];
rc = qmckl_check(context,
qmckl_get_electron_coord (context, <span style="color: #8b2252;">'N'</span>, elec_coord2, walk_num*3*elec_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;3*elec_num ; ++i) {
assert( elec_coord[i] == elec_coord2[i] );
}
/* <span style="color: #b22222;">Provide Nucleus data</span> */
assert(!qmckl_nucleus_provided(context));
rc = qmckl_check(context,
qmckl_set_nucleus_num (context, nucl_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
assert(!qmckl_nucleus_provided(context));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">nucl_coord2</span>[3*nucl_num];
rc = qmckl_get_nucleus_coord (context, <span style="color: #8b2252;">'T'</span>, nucl_coord2, 3*nucl_num);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_NOT_PROVIDED);
rc = qmckl_check(context,
qmckl_set_nucleus_coord (context, <span style="color: #8b2252;">'T'</span>, &amp;(nucl_coord[0]), 3*nucl_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
assert(!qmckl_nucleus_provided(context));
rc = qmckl_check(context,
qmckl_get_nucleus_coord (context, <span style="color: #8b2252;">'N'</span>, nucl_coord2, nucl_num*3)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">k</span>=0 ; k&lt;3 ; ++k) {
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;nucl_num ; ++i) {
assert( nucl_coord[nucl_num*k+i] == nucl_coord2[3*i+k] );
}
}
rc = qmckl_check(context,
qmckl_get_nucleus_coord (context, <span style="color: #8b2252;">'T'</span>, nucl_coord2, nucl_num*3)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;3*nucl_num ; ++i) {
assert( nucl_coord[i] == nucl_coord2[i] );
}
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">nucl_charge2</span>[nucl_num];
rc = qmckl_get_nucleus_charge(context, nucl_charge2, nucl_num);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_NOT_PROVIDED);
rc = qmckl_check(context,
qmckl_set_nucleus_charge(context, nucl_charge, nucl_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_get_nucleus_charge(context, nucl_charge2, nucl_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;nucl_num ; ++i) {
assert( nucl_charge[i] == nucl_charge2[i] );
}
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_nucleus_provided</span>(<span style="color: #a0522d;">context</span>));
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org5f2ac44" class="outline-2">
<h2 id="org5f2ac44"><span class="section-number-2">3</span> Computation</h2>
<div class="outline-text-2" id="text-3">
<p>
The computed data is stored in the context so that it can be reused
by different kernels. To ensure that the data is valid, for each
computed data the date of the context is stored when it is computed.
To know if some data needs to be recomputed, we check if the date of
the dependencies are more recent than the date of the data to
compute. If it is the case, then the data is recomputed and the
current date is stored.
</p>
</div>
<div id="outline-container-org1cc8426" class="outline-3">
<h3 id="org1cc8426"><span class="section-number-3">3.1</span> Electron-electron component</h3>
<div class="outline-text-3" id="text-3-1">
</div>
<div id="outline-container-org2dc1809" class="outline-4">
<h4 id="org2dc1809"><span class="section-number-4">3.1.1</span> Asymptotic component</h4>
<div class="outline-text-4" id="text-3-1-1">
<p>
Calculate the asymptotic component <code>asymp_jasb</code> to be subtracted from the
electron-electron jastrow factor \(J_{\text{ee}}\). Two values are
computed. The first one is for parallel spin pairs, and the
second one for antiparallel spin pairs.
If the <code>spin_independent</code> variable is set to <code>1</code>, then
\(\delta^{\uparrow \downarrow}\) is always equal to one.
</p>
<p>
\[
J_{\text{ee}}^{\infty} = \frac{\frac{1}{2}(1+\delta^{\uparrow \downarrow})\,b_1 \kappa_\text{ee}^{-1}}{1 + b_2\,
\kappa_\text{ee}^{-1}} + \sum_{p=2}^{N_\text{ord}^b} b_{p+1}\, \kappa_\text{ee}^{-p}
\]
</p>
</div>
<div id="outline-container-org712c41f" class="outline-5">
<h5 id="org712c41f"><span class="section-number-5">3.1.1.1</span> Get</h5>
<div class="outline-text-5" id="text-3-1-1-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_asymp_jasb</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">asymp_jasb</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
<ol class="org-ol">
<li><a id="org7896b98"></a>Fortran interface<br />
<div class="outline-text-6" id="text-3-1-1-1-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">interface</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_asymp_jasb(context, </span><span style="color: #a020f0;">&amp;</span>
asymp_jasb, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> asymp_jasb(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_asymp_jasb</span>
<span style="color: #a020f0;">end interface</span>
</pre>
</div>
</div>
</li>
</ol>
</div>
<div id="outline-container-org2eaae3d" class="outline-5">
<h5 id="org2eaae3d"><span class="section-number-5">3.1.1.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-1-1-2">
<table id="org89d8ed0" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>bord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Order of the polynomial</td>
</tr>
<tr>
<td class="org-left"><code>b_vector</code></td>
<td class="org-left"><code>double[bord_num+1]</code></td>
<td class="org-left">in</td>
<td class="org-left">Values of b</td>
</tr>
<tr>
<td class="org-left"><code>rescale_factor_ee</code></td>
<td class="org-left"><code>double</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron coordinates</td>
</tr>
<tr>
<td class="org-left"><code>spin_independent</code></td>
<td class="org-left"><code>int32_t</code></td>
<td class="org-left">in</td>
<td class="org-left">If 1, same parameters for parallel and anti-parallel pairs</td>
</tr>
<tr>
<td class="org-left"><code>asymp_jasb</code></td>
<td class="org-left"><code>double[2]</code></td>
<td class="org-left">out</td>
<td class="org-left">Asymptotic value</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_asymp_jasb_doc</span>(context, <span style="color: #a020f0;">&amp;</span>
bord_num, b_vector, rescale_factor_ee, spin_independent, asymp_jasb) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">bind</span>(C) <span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> bord_num</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> b_vector(bord_num+1)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> rescale_factor_ee</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int32_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> spin_independent</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> asymp_jasb(2)</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code) ::<span style="color: #a0522d;"> info</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, p</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> kappa_inv, x, asym_one</span>
kappa_inv = 1.0d0 / rescale_factor_ee
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (bord_num &lt; 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
asym_one = b_vector(1) * kappa_inv / (1.0d0 + b_vector(2) * kappa_inv)
<span style="color: #a020f0;">if</span> (spin_independent == 1) <span style="color: #a020f0;">then</span>
asymp_jasb(:) = (/asym_one, asym_one/)
<span style="color: #a020f0;">else</span>
asymp_jasb(:) = (/0.5d0*asym_one, asym_one/)
<span style="color: #a020f0;">end if</span>
x = kappa_inv
<span style="color: #a020f0;">do</span> p = 2, bord_num
x = x * kappa_inv
<span style="color: #a020f0;">do</span> i = 1, 2
asymp_jasb(i) = asymp_jasb(i) + b_vector(p + 1) * x
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_asymp_jasb_doc</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_compute_jastrow_champ_asymp_jasb_hpc</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">bord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">b_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">rescale_factor_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int32_t</span> <span style="color: #a0522d;">spin_independent</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">asymp_jasb</span> )
{
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) {
<span style="color: #a020f0;">return</span> QMCKL_INVALID_CONTEXT;
}
<span style="color: #a020f0;">if</span> (bord_num &lt; 0) {
<span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_2;
}
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">kappa_inv</span> = 1.0 / rescale_factor_ee;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">asym_one</span> = b_vector[0] * kappa_inv / (1.0 + b_vector[1] * kappa_inv);
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">f</span> = 0.;
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">x</span> = kappa_inv;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span> = 2; k &lt;= bord_num; ++k) {
x *= kappa_inv;
f = f + b_vector[k]*x;
}
asymp_jasb[0] = spin_independent == 1 ? asym_one + f : 0.5 * asym_one + f;
asymp_jasb[1] = asym_one + f;
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_asymp_jasb</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">bord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">b_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">rescale_factor_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int32_t</span> <span style="color: #a0522d;">spin_independent</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">asymp_jasb</span> )
{
<span style="color: #483d8b;">#ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_asymp_jasb_hpc
<span style="color: #483d8b;">#else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_asymp_jasb_doc
<span style="color: #483d8b;">#endif</span>
(context, bord_num, b_vector, rescale_factor_ee, spin_independent, asymp_jasb);
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org9a5a34a" class="outline-5">
<h5 id="org9a5a34a"><span class="section-number-5">3.1.1.3</span> Test</h5>
<div class="outline-text-5" id="text-3-1-1-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_electron_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">type_nucl_num</span> = n2_type_nucl_num;
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">type_nucl_vector</span> = &amp;(n2_type_nucl_vector[0]);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">aord_num</span> = n2_aord_num;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">bord_num</span> = n2_bord_num;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span> = n2_cord_num;
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">a_vector</span> = &amp;(n2_a_vector[0][0]);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">b_vector</span> = &amp;(n2_b_vector[0]);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">c_vector</span> = &amp;(n2_c_vector[0][0]);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>=0;
assert(!qmckl_jastrow_champ_provided(context));
/* <span style="color: #b22222;">Set the data</span> */
rc = qmckl_check(context,
qmckl_set_jastrow_champ_spin_independent(context, 0)
);
rc = qmckl_check(context,
qmckl_set_jastrow_champ_aord_num(context, aord_num)
);
rc = qmckl_check(context,
qmckl_set_jastrow_champ_bord_num(context, bord_num)
);
rc = qmckl_check(context,
qmckl_set_jastrow_champ_cord_num(context, cord_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_set_jastrow_champ_type_nucl_num(context, type_nucl_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_set_jastrow_champ_type_nucl_vector(context, type_nucl_vector, nucl_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_set_jastrow_champ_a_vector(context, a_vector,(aord_num+1)*type_nucl_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_set_jastrow_champ_b_vector(context, b_vector,(bord_num+1))
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_get_jastrow_champ_dim_c_vector(context, &amp;dim_c_vector)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_set_jastrow_champ_c_vector(context, c_vector, dim_c_vector*type_nucl_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">k_ee</span> = 0.;
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">k_en</span>[2] = { 0., 0. };
rc = qmckl_check(context,
qmckl_set_jastrow_champ_rescale_factor_en(context, rescale_factor_en, type_nucl_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_set_jastrow_champ_rescale_factor_ee(context, rescale_factor_ee)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_get_jastrow_champ_rescale_factor_ee (context, &amp;k_ee)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #0000ff;">assert</span>(k_ee == rescale_factor_ee);
rc = qmckl_check(context,
qmckl_get_jastrow_champ_rescale_factor_en (context, &amp;(k_en[0]), type_nucl_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;type_nucl_num ; ++i) {
assert(k_en[i] == rescale_factor_en[i]);
}
/* <span style="color: #b22222;">Check if Jastrow is properly initialized</span> */
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_jastrow_champ_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">asymp_jasb</span>[2];
rc = qmckl_check(context,
qmckl_get_jastrow_champ_asymp_jasb(context, asymp_jasb,2)
);
// <span style="color: #b22222;">calculate asymp_jasb</span>
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">asymp_jasb</span>[0]-0.7115733522582638) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">asymp_jasb</span>[1]-1.043287918508297 ) &lt; 1.e-12);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org9d19898" class="outline-4">
<h4 id="org9d19898"><span class="section-number-4">3.1.2</span> Electron-electron component</h4>
<div class="outline-text-4" id="text-3-1-2">
<p>
Calculate the electron-electron jastrow component <code>factor_ee</code> using the <code>asymp_jasb</code>
component and the electron-electron rescaled distances <code>ee_distance_rescaled</code>.
If the <code>spin_independent</code> variable is set to <code>1</code>, then
\(\delta^{\uparrow \downarrow}\) is always equal to one.
</p>
<p>
\[
f_\text{ee} = \sum_{i,j<i} \left[
\frac{\delta_{ij}^{\uparrow\downarrow} B_0\, C_{ij}}{1 + B_1\,
C_{ij}} + \sum_{k=2}^{n_\text{ord}} B_k\, C_{ij}^k - {J_{\text{ee}}^{\infty}}_{ij} \right]
\]
</p>
<p>
\(\delta\) is the spin factor, \(B\) is the vector of \(b\) parameters,
\(C\) is the array of rescaled distances.
</p>
<p>
\(f_{\text{ee}}\) can be rewritten as:
</p>
<p>
\[
f_\text{ee} = \frac{1}{2} \left[ \sum_{i,j} \frac{\delta_{ij}^{\uparrow\downarrow} B_0\, C_{ij}}{1 + B_1\, C_{ij}} + \sum_{i,j} \sum_{k=2}^{n_\text{ord}} B_k\, C_{ij}^k \right] - \left[ \frac{n_\uparrow (n_\uparrow-1) + n_\downarrow (n_\downarrow-1)}{2}\, J_{\text{ee}}^{\infty}}_{\uparrow \uparrow} + n_\uparrow\,n_\downarrow\, J_{\text{ee}}^{\infty}}_{\uparrow \downarrow} \right]
\]
</p>
</div>
<div id="outline-container-org587897c" class="outline-5">
<h5 id="org587897c"><span class="section-number-5">3.1.2.1</span> Get</h5>
<div class="outline-text-5" id="text-3-1-2-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_factor_ee</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
<ol class="org-ol">
<li><a id="orge5f9ff9"></a>Fortran interface<br />
<div class="outline-text-6" id="text-3-1-2-1-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">interface</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_factor_ee (context, </span><span style="color: #a020f0;">&amp;</span>
factor_ee, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_ee(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_factor_ee</span>
<span style="color: #a020f0;">end interface</span>
</pre>
</div>
</div>
</li>
</ol>
</div>
<div id="outline-container-orgc180bd1" class="outline-5">
<h5 id="orgc180bd1"><span class="section-number-5">3.1.2.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-1-2-2">
<table id="org5519a98" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>up_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of alpha electrons</td>
</tr>
<tr>
<td class="org-left"><code>bord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of coefficients</td>
</tr>
<tr>
<td class="org-left"><code>b_vector</code></td>
<td class="org-left"><code>double[bord_num+1]</code></td>
<td class="org-left">in</td>
<td class="org-left">List of coefficients</td>
</tr>
<tr>
<td class="org-left"><code>ee_distance_rescaled</code></td>
<td class="org-left"><code>double[walk_num][elec_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-electron distances</td>
</tr>
<tr>
<td class="org-left"><code>asymp_jasb</code></td>
<td class="org-left"><code>double[2]</code></td>
<td class="org-left">in</td>
<td class="org-left">Asymptotic value of the Jastrow</td>
</tr>
<tr>
<td class="org-left"><code>factor_ee</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">\(f_{ee}\)</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_ee_doc</span>(context, <span style="color: #a020f0;">&amp;</span>
walk_num, elec_num, up_num, bord_num, b_vector, <span style="color: #a020f0;">&amp;</span>
ee_distance_rescaled, asymp_jasb, spin_independent, factor_ee) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">bind</span>(C) <span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> up_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> bord_num</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> b_vector(bord_num+1)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> ee_distance_rescaled(elec_num,elec_num,walk_num)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> asymp_jasb(2)</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int32_t</span>) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> spin_independent</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_ee(walk_num)</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code) ::<span style="color: #a0522d;"> info</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, j, k, nw</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x, xk</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (bord_num &lt; 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> nw =1, walk_num
factor_ee(nw) = 0.0d0
<span style="color: #a020f0;">do</span> j=1,elec_num
<span style="color: #a020f0;">do</span> i=1,j-1
x = ee_distance_rescaled(i,j,nw)
<span style="color: #a020f0;">if</span> (spin_independent == 1) <span style="color: #a020f0;">then</span>
factor_ee(nw) = factor_ee(nw) + b_vector(1) * x / (1.d0 + b_vector(2) * x) - asymp_jasb(2)
<span style="color: #a020f0;">else</span>
<span style="color: #a020f0;">if</span> ( (j &lt;= up_num)<span style="color: #a020f0;">.or.</span>(i &gt; up_num) ) <span style="color: #a020f0;">then</span>
factor_ee(nw) = factor_ee(nw) + 0.5d0 * b_vector(1) * x / (1.d0 + b_vector(2) * x) - asymp_jasb(1)
<span style="color: #a020f0;">else</span>
factor_ee(nw) = factor_ee(nw) + b_vector(1) * x / (1.d0 + b_vector(2) * x) - asymp_jasb(2)
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">endif</span>
xk = x
<span style="color: #a020f0;">do</span> k=2,bord_num
xk = xk * x
factor_ee(nw) = factor_ee(nw) + b_vector(k+1)* xk
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_ee_doc</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_ee_hpc</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">up_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">bord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">b_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance_rescaled</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">asymp_jasb</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int32_t</span> <span style="color: #a0522d;">spin_independent</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_ee</span> )
{
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) {
<span style="color: #a020f0;">return</span> QMCKL_INVALID_CONTEXT;
}
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) {
<span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_2;
}
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) {
<span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_3;
}
<span style="color: #a020f0;">if</span> (bord_num &lt; 0) {
<span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_4;
}
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dn_num</span> = elec_num - up_num;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">fshift</span> = 0.5 * (<span style="color: #228b22;">double</span>) ((dn_num-1)*dn_num + (up_num-1)*up_num) * asymp_jasb[0] +
(<span style="color: #228b22;">float</span>) (up_num*dn_num) * asymp_jasb[1];
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;"> #pragma</span> omp parallel
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">nw</span> = 0; nw &lt; walk_num; ++nw) {
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">result</span> = 0.;
<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">ishift</span> = nw * elec_num * elec_num;
<span style="color: #a020f0;">if</span> (spin_independent == 1) {
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">j</span> = 0; j &lt; elec_num; ++j ) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">xj</span> = &amp;(ee_distance_rescaled[j * elec_num + ishift]);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span> = 0; i &lt; j ; ++i) {
result = result + b_vector[0]*xj[i] / (1. + b_vector[1]*xj[i]);
}
}
} <span style="color: #a020f0;">else</span> {
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">j</span> = 0; j &lt; up_num; ++j ) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">xj</span> = &amp;(ee_distance_rescaled[j * elec_num + ishift]);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span> = 0; i &lt; j ; ++i) {
result = result + 0.5 * b_vector[0]*xj[i] / (1. + b_vector[1]*xj[i]);
}
}
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">j</span> = up_num ; j &lt; elec_num; ++j ) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">xj</span> = &amp;(ee_distance_rescaled[j * elec_num + ishift]);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span> = 0; i &lt; up_num; ++i) {
result = result + b_vector[0]*xj[i] / (1. + b_vector[1]*xj[i]);
}
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span> = up_num ; i &lt; j ; ++i) {
result = result + 0.5 * b_vector[0]*xj[i] / (1. + b_vector[1]*xj[i]);
}
}
}
result = result - fshift;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">j</span>=0; j &lt; elec_num; ++j ) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">xj</span> = &amp;(ee_distance_rescaled[j * elec_num + ishift]);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0; i &lt; j ; ++i) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">x</span> = xj[i];
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">xk</span> = x;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span> = 2; k &lt;= bord_num; ++k) {
xk *= x;
result = result + b_vector[k] * xk;
}
}
}
factor_ee[nw] = result;
}
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_ee</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">up_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">bord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">b_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance_rescaled</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">asymp_jasb</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int32_t</span> <span style="color: #a0522d;">spin_independent</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_ee</span> )
{
<span style="color: #483d8b;">#ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_factor_ee_hpc
<span style="color: #483d8b;">#else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_factor_ee_doc
<span style="color: #483d8b;">#endif</span>
(context, walk_num, elec_num, up_num, bord_num, b_vector,
ee_distance_rescaled, asymp_jasb, spin_independent, factor_ee);
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgafc8cc8" class="outline-5">
<h5 id="orgafc8cc8"><span class="section-number-5">3.1.2.3</span> Test</h5>
<div class="outline-text-5" id="text-3-1-2-3">
<div class="org-src-container">
<pre class="src src-c">/* <span style="color: #b22222;">Check if Jastrow is properly initialized</span> */
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_jastrow_champ_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">factor_ee</span>[walk_num];
rc = qmckl_check(context,
qmckl_get_jastrow_champ_factor_ee(context, factor_ee, walk_num)
);
// <span style="color: #b22222;">calculate factor_ee</span>
printf(<span style="color: #8b2252;">"%e\n%e\n\n"</span>,factor_ee[0],-16.83886184243964);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">factor_ee</span>[0]+16.83886184243964) &lt; 1.e-12);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org42ced79" class="outline-4">
<h4 id="org42ced79"><span class="section-number-4">3.1.3</span> Derivative</h4>
<div class="outline-text-4" id="text-3-1-3">
<p>
The derivative of <code>factor_ee</code> is computed using the <code>ee_distance_rescaled</code> and
the electron-electron rescaled distances derivatives
<code>ee_distance_rescaled_gl</code>.
There are four components, the gradient which has 3 components in the \(x, y, z\)
directions and the laplacian as the last component.
</p>
<p>
\[ \nabla_i f_\text{ee} = \sum_{j\ne i}
\left[\frac{\delta_{ij}^{\uparrow\downarrow} B_0\, \nabla_i
C_{ij}}{(1 + B_1\, C_{ij})^2} + \sum^{n_\text{ord}}_{k=2}
B_k\, k\, C_{ij}^{k-1} \nabla C_{ij} \right] \]
</p>
<p>
\[ \Delta_i f_\text{ee} = \sum_{j \ne i}
\left[ \delta_{ij}^{\uparrow\downarrow} B_0
\left(\frac{ \Delta_i C_{ij}}{(1 + B_1\, C_{ij})^2} -\frac{2\,B_1
\left(\nabla_i C_{ij}\right)^2 }{(1 + B_1\, C_{ij})^3} \right) + \sum^{n_\text{ord}}_{k=2}
B_k\, k\, \left((k-1)\, C_{ij}^{k-2} \left(\nabla_i C_{ij}\right)^2 + C_{ij}^{k-1} \Delta_i C_{ij} \right) \right] \]
</p>
</div>
<div id="outline-container-org6a9af69" class="outline-5">
<h5 id="org6a9af69"><span class="section-number-5">3.1.3.1</span> Get</h5>
<div class="outline-text-5" id="text-3-1-3-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_factor_ee_gl</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_ee_gl</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
<ol class="org-ol">
<li><a id="org2e06e4f"></a>Fortran interface<br />
<div class="outline-text-6" id="text-3-1-3-1-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">interface</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_factor_ee_gl (context, </span><span style="color: #a020f0;">&amp;</span>
factor_ee_gl, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_ee_gl(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_factor_ee_gl</span>
<span style="color: #a020f0;">end interface</span>
</pre>
</div>
</div>
</li>
</ol>
</div>
<div id="outline-container-org35bf5ea" class="outline-5">
<h5 id="org35bf5ea"><span class="section-number-5">3.1.3.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-1-3-2">
<table id="orgc9de9bd" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>up_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of alpha electrons</td>
</tr>
<tr>
<td class="org-left"><code>bord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of coefficients</td>
</tr>
<tr>
<td class="org-left"><code>b_vector</code></td>
<td class="org-left"><code>double[bord_num+1]</code></td>
<td class="org-left">in</td>
<td class="org-left">List of coefficients</td>
</tr>
<tr>
<td class="org-left"><code>ee_distance_rescaled</code></td>
<td class="org-left"><code>double[walk_num][elec_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-electron distances</td>
</tr>
<tr>
<td class="org-left"><code>ee_distance_rescaled_gl</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-electron distances</td>
</tr>
<tr>
<td class="org-left"><code>spin_independent</code></td>
<td class="org-left"><code>int32_t</code></td>
<td class="org-left">in</td>
<td class="org-left">If 1, same parameters for parallel and antiparallel spins</td>
</tr>
<tr>
<td class="org-left"><code>factor_ee_gl</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-electron distances</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_ee_gl_doc</span>( <span style="color: #a020f0;">&amp;</span>
context, walk_num, elec_num, up_num, bord_num, <span style="color: #a020f0;">&amp;</span>
b_vector, ee_distance_rescaled, ee_distance_rescaled_gl, <span style="color: #a020f0;">&amp;</span>
spin_independent, factor_ee_gl) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">bind</span>(C) <span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> up_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> bord_num</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> b_vector(bord_num+1)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> ee_distance_rescaled(elec_num,elec_num,walk_num)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> ee_distance_rescaled_gl(4,elec_num,elec_num,walk_num)</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int32_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> spin_independent</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_ee_gl(elec_num,4,walk_num)</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code) ::<span style="color: #a0522d;"> info</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, j, k, nw, ii</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x, x1, kf</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> denom, invdenom, invdenom2, f</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> grad_c2</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> dx(4)</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (bord_num &lt; 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> ((spin_independent &lt; 0)<span style="color: #a020f0;">.or.</span>(spin_independent &gt; 1)) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_8
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> nw =1, walk_num
factor_ee_gl(:,:,nw) = 0.0d0
<span style="color: #a020f0;">do</span> j = 1, elec_num
<span style="color: #a020f0;">do</span> i = 1, elec_num
<span style="color: #a020f0;">if</span> (i == j) <span style="color: #a020f0;">cycle</span>
x = ee_distance_rescaled(i,j,nw)
denom = 1.0d0 + b_vector(2) * x
invdenom = 1.0d0 / denom
invdenom2 = invdenom * invdenom
dx(1) = ee_distance_rescaled_gl(1, i, j, nw)
dx(2) = ee_distance_rescaled_gl(2, i, j, nw)
dx(3) = ee_distance_rescaled_gl(3, i, j, nw)
dx(4) = ee_distance_rescaled_gl(4, i, j, nw)
grad_c2 = dx(1)*dx(1) + dx(2)*dx(2) + dx(3)*dx(3)
<span style="color: #a020f0;">if</span> (spin_independent == 1) <span style="color: #a020f0;">then</span>
f = b_vector(1) * invdenom2
<span style="color: #a020f0;">else</span>
<span style="color: #a020f0;">if</span>((i &lt;= up_num <span style="color: #a020f0;">.and.</span> j &lt;= up_num ) <span style="color: #a020f0;">.or.</span> (i &gt; up_num <span style="color: #a020f0;">.and.</span> j &gt; up_num)) <span style="color: #a020f0;">then</span>
f = 0.5d0 * b_vector(1) * invdenom2
<span style="color: #a020f0;">else</span>
f = b_vector(1) * invdenom2
<span style="color: #a020f0;">end if</span>
<span style="color: #a020f0;">end if</span>
factor_ee_gl(i,1,nw) = factor_ee_gl(i,1,nw) + f * dx(1)
factor_ee_gl(i,2,nw) = factor_ee_gl(i,2,nw) + f * dx(2)
factor_ee_gl(i,3,nw) = factor_ee_gl(i,3,nw) + f * dx(3)
factor_ee_gl(i,4,nw) = factor_ee_gl(i,4,nw) <span style="color: #a020f0;">&amp;</span>
+ f * (dx(4) - 2.d0 * b_vector(2) * grad_c2 * invdenom)
kf = 2.d0
x1 = x
x = 1.d0
<span style="color: #a020f0;">do</span> k=2, bord_num
f = b_vector(k+1) * kf * x
factor_ee_gl(i,1,nw) = factor_ee_gl(i,1,nw) + f * x1 * dx(1)
factor_ee_gl(i,2,nw) = factor_ee_gl(i,2,nw) + f * x1 * dx(2)
factor_ee_gl(i,3,nw) = factor_ee_gl(i,3,nw) + f * x1 * dx(3)
factor_ee_gl(i,4,nw) = factor_ee_gl(i,4,nw) <span style="color: #a020f0;">&amp;</span>
+ f * (x1 * dx(4) + (kf-1.d0) * grad_c2)
x = x*x1
kf = kf + 1.d0
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_ee_gl_doc</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_ee_gl_hpc</span>(<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">up_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">bord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">b_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance_rescaled</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance_rescaled_gl</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int32_t</span> <span style="color: #a0522d;">spin_independent</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_ee_gl</span> )
{
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">return</span> QMCKL_INVALID_CONTEXT;
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_2;
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_3;
<span style="color: #a020f0;">if</span> (up_num &lt;= 0) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_4;
<span style="color: #a020f0;">if</span> (bord_num &lt; 0) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_5;
<span style="color: #a020f0;">if</span> (b_vector == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_6;
<span style="color: #a020f0;">if</span> (ee_distance_rescaled == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_7;
<span style="color: #a020f0;">if</span> (ee_distance_rescaled_gl == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_8;
<span style="color: #a020f0;">if</span> (spin_independent &amp; (<span style="color: #228b22;">int32_t</span>) (-2)) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_8;
<span style="color: #a020f0;">if</span> (factor_ee_gl == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_9;
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">kf</span>[bord_num+1];
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span>=0 ; k&lt;=bord_num ; ++k) {
kf[k] = (<span style="color: #228b22;">double</span>) k;
}
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp parallel <span style="color: #a020f0;">for</span>
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">nw</span> = 0; nw &lt; walk_num; ++nw) {
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">xk</span>[bord_num+1];
<span style="color: #228b22;">bool</span> <span style="color: #a0522d;">touched</span> = <span style="color: #008b8b;">false</span>;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">j</span> = 0; j &lt; elec_num; ++j) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">dxj</span> = &amp;ee_distance_rescaled_gl[4*elec_num*(j+nw*elec_num)];
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">xj</span> = &amp;ee_distance_rescaled [ elec_num*(j+nw*elec_num)];
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">factor_ee_gl_0</span> = &amp;(factor_ee_gl[nw*elec_num*4]);
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">factor_ee_gl_1</span> = factor_ee_gl_0 + elec_num;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">factor_ee_gl_2</span> = factor_ee_gl_1 + elec_num;
<span style="color: #228b22;">double</span> * <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">factor_ee_gl_3</span> = factor_ee_gl_2 + elec_num;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span> = 0; i &lt; elec_num; ++i) {
<span style="color: #a020f0;">if</span> (j == i) <span style="color: #a020f0;">continue</span>;
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">x</span> = xj[i];
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">denom</span> = 1.0 + b_vector[1]*x;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">invdenom</span> = 1.0 / denom;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">invdenom2</span> = invdenom * invdenom;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">dx</span> = dxj + 4*i;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">grad_c2</span> = dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2];
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">f</span> = b_vector[0] * invdenom2;
<span style="color: #a020f0;">if</span> ((spin_independent == 0) &amp;&amp; (
((i &lt; up_num) &amp;&amp; (j &lt; up_num)) ||
((i &gt;= up_num) &amp;&amp; (j &gt;= up_num))) ) {
f *= 0.5;
}
<span style="color: #a020f0;">if</span> (touched) {
factor_ee_gl_0[i] = factor_ee_gl_0[i] + f*dx[0];
factor_ee_gl_1[i] = factor_ee_gl_1[i] + f*dx[1];
factor_ee_gl_2[i] = factor_ee_gl_2[i] + f*dx[2];
factor_ee_gl_3[i] = factor_ee_gl_3[i] + f*dx[3];
} <span style="color: #a020f0;">else</span> {
touched = <span style="color: #008b8b;">true</span>;
factor_ee_gl_0[i] = f*dx[0];
factor_ee_gl_1[i] = f*dx[1];
factor_ee_gl_2[i] = f*dx[2];
factor_ee_gl_3[i] = f*dx[3];
}
factor_ee_gl_3[i] = factor_ee_gl_3[i] - f*grad_c2*invdenom*2.0 * b_vector[1];
xk[0] = 1.0;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span>=1 ; k&lt;= bord_num ; ++k) {
xk[k] = xk[k-1]*x;
}
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span>=2 ; k&lt;= bord_num ; ++k) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">f1</span> = b_vector[k] * kf[k] * xk[k-2];
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">f2</span> = f1*xk[1];
factor_ee_gl_0[i] = factor_ee_gl_0[i] + f2*dx[0];
factor_ee_gl_1[i] = factor_ee_gl_1[i] + f2*dx[1];
factor_ee_gl_2[i] = factor_ee_gl_2[i] + f2*dx[2];
factor_ee_gl_3[i] = factor_ee_gl_3[i] + f2*dx[3];
factor_ee_gl_3[i] = factor_ee_gl_3[i] + f1*kf[k-1]*grad_c2;
}
}
}
<span style="color: #a020f0;">if</span> (!touched) {
memset(&amp;(factor_ee_gl[nw*4*elec_num]), 0, elec_num*4*<span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
}
}
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_ee_gl_hpc</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">up_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">bord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">b_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance_rescaled</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance_rescaled_gl</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int32_t</span> <span style="color: #a0522d;">spin_independent</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_ee_gl</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_ee_gl_doc</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">up_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">bord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">b_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance_rescaled</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance_rescaled_gl</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int32_t</span> <span style="color: #a0522d;">spin_independent</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_ee_gl</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_ee_gl</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">up_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">bord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">b_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance_rescaled</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance_rescaled_gl</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int32_t</span> <span style="color: #a0522d;">spin_independent</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_ee_gl</span> )
{
<span style="color: #483d8b;">#ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_factor_ee_gl_hpc
<span style="color: #483d8b;">#else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_factor_ee_gl_doc
<span style="color: #483d8b;">#endif</span>
(context, walk_num, elec_num, up_num, bord_num, b_vector,
ee_distance_rescaled, ee_distance_rescaled_gl, spin_independent, factor_ee_gl );
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org1f30636" class="outline-5">
<h5 id="org1f30636"><span class="section-number-5">3.1.3.3</span> Test</h5>
<div class="outline-text-5" id="text-3-1-3-3">
<div class="org-src-container">
<pre class="src src-c">/* <span style="color: #b22222;">Check if Jastrow is properly initialized</span> */
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_jastrow_champ_provided</span>(<span style="color: #a0522d;">context</span>));
// <span style="color: #b22222;">calculate factor_ee_gl</span>
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">factor_ee_gl</span>[walk_num][4][elec_num];
rc = qmckl_get_jastrow_champ_factor_ee_gl(context, &amp;(factor_ee_gl[0][0][0]),walk_num*4*elec_num);
// <span style="color: #b22222;">check factor_ee_gl</span>
printf(<span style="color: #8b2252;">"%f %f\n"</span>, factor_ee_gl[0][0][0], -0.39319353942687446);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">factor_ee_gl</span>[0][0][0]+0.39319353942687446) &lt; 1.e-12);
printf(<span style="color: #8b2252;">"%f %f\n"</span>, factor_ee_gl[0][1][0], 1.0535615450668214);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">factor_ee_gl</span>[0][1][0]-1.0535615450668214) &lt; 1.e-12);
printf(<span style="color: #8b2252;">"%f %f\n"</span>, factor_ee_gl[0][2][0],-0.39098406960784515);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">factor_ee_gl</span>[0][2][0]+0.39098406960784515) &lt; 1.e-12);
printf(<span style="color: #8b2252;">"%f %f\n"</span>, factor_ee_gl[0][3][0],2.8650469630854483);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">factor_ee_gl</span>[0][3][0]-2.8650469630854483) &lt; 1.e-12);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org13de2cb" class="outline-4">
<h4 id="org13de2cb"><span class="section-number-4">3.1.4</span> Electron-electron rescaled distances</h4>
<div class="outline-text-4" id="text-3-1-4">
<p>
<code>ee_distance_rescaled</code> stores the matrix of the rescaled distances between all
pairs of electrons:
</p>
<p>
\[
C_{ij} = \frac{ 1 - e^{-\kappa r_{ij}}}{\kappa}
\]
</p>
<p>
where \(r_{ij}\) is the matrix of electron-electron distances.
</p>
</div>
<div id="outline-container-orga5c3e31" class="outline-5">
<h5 id="orga5c3e31"><span class="section-number-5">3.1.4.1</span> Get</h5>
<div class="outline-text-5" id="text-3-1-4-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_ee_distance_rescaled</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">distance_rescaled</span>);
</pre>
</div>
</div>
</div>
<div id="outline-container-org398c519" class="outline-5">
<h5 id="org398c519"><span class="section-number-5">3.1.4.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-1-4-2">
<table id="org79a82fa" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>rescale_factor_ee</code></td>
<td class="org-left"><code>double</code></td>
<td class="org-left">in</td>
<td class="org-left">Factor to rescale ee distances</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>coord</code></td>
<td class="org-left"><code>double[3][walk_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron coordinates</td>
</tr>
<tr>
<td class="org-left"><code>ee_distance</code></td>
<td class="org-left"><code>double[walk_num][elec_num][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-electron rescaled distances</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">function</span> <span style="color: #0000ff;">qmckl_compute_ee_distance_rescaled_doc</span>(context, <span style="color: #a020f0;">&amp;</span>
elec_num, rescale_factor_ee, walk_num, <span style="color: #a020f0;">&amp;</span>
coord, ee_distance_rescaled) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">bind</span>(C) <span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> rescale_factor_ee</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> coord(elec_num,walk_num,3)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> ee_distance_rescaled(elec_num,elec_num,walk_num)</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code) ::<span style="color: #a0522d;"> info</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> k</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> k=1,walk_num
info = qmckl_distance_rescaled(context, <span style="color: #8b2252;">'T'</span>, <span style="color: #8b2252;">'T'</span>, elec_num, elec_num, <span style="color: #a020f0;">&amp;</span>
coord(1,k,1), elec_num * walk_num, <span style="color: #a020f0;">&amp;</span>
coord(1,k,1), elec_num * walk_num, <span style="color: #a020f0;">&amp;</span>
ee_distance_rescaled(1,1,k), elec_num, rescale_factor_ee)
<span style="color: #a020f0;">if</span> (info /= QMCKL_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">exit</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_ee_distance_rescaled_doc</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org563d91e" class="outline-5">
<h5 id="org563d91e"><span class="section-number-5">3.1.4.3</span> Test</h5>
<div class="outline-text-5" id="text-3-1-4-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_electron_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">ee_distance_rescaled</span>[walk_num * elec_num * elec_num];
rc = qmckl_get_jastrow_champ_ee_distance_rescaled(context, ee_distance_rescaled);
// <span style="color: #b22222;">(e1,e2,w)</span>
// <span style="color: #b22222;">(0,0,0) == 0.</span>
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">ee_distance_rescaled</span>[0] == 0.);
// <span style="color: #b22222;">(1,0,0) == (0,1,0)</span>
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">ee_distance_rescaled</span>[1] == ee_distance_rescaled[elec_num]);
// <span style="color: #b22222;">value of (1,0,0)</span>
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">ee_distance_rescaled</span>[1]-0.6347507420688708) &lt; 1.e-12);
// <span style="color: #b22222;">(0,0,1) == 0.</span>
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">ee_distance_rescaled</span>[5*elec_num + 5] == 0.);
// <span style="color: #b22222;">(1,0,1) == (0,1,1)</span>
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">ee_distance_rescaled</span>[5*elec_num+6] == ee_distance_rescaled[6*elec_num+5]);
// <span style="color: #b22222;">value of (1,0,1)</span>
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">ee_distance_rescaled</span>[5*elec_num+6]-0.3941735387855409) &lt; 1.e-12);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgcbdc228" class="outline-4">
<h4 id="orgcbdc228"><span class="section-number-4">3.1.5</span> Electron-electron rescaled distance gradients and Laplacian with respect to electron coordinates</h4>
<div class="outline-text-4" id="text-3-1-5">
<p>
The rescaled distances, represented by \(C_{ij} = (1 - e^{-\kappa_\text{e} r_{ij}})/\kappa_\text{e}\)
are differentiated with respect to the electron coordinates.
This information is stored in the tensor
<code>ee_distance_rescaled_gl</code>. The initial three sequential
elements of this three-dimensional tensor provide the \(x\), \(y\), and \(z\)
direction derivatives, while the fourth index corresponds to the Laplacian.
</p>
</div>
<div id="outline-container-orge900bfa" class="outline-5">
<h5 id="orge900bfa"><span class="section-number-5">3.1.5.1</span> Get</h5>
<div class="outline-text-5" id="text-3-1-5-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_ee_distance_rescaled_gl</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">distance_rescaled_gl</span>);
</pre>
</div>
</div>
</div>
<div id="outline-container-org02b6cf8" class="outline-5">
<h5 id="org02b6cf8"><span class="section-number-5">3.1.5.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-1-5-2">
<table id="orgacf407b" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>rescale_factor_ee</code></td>
<td class="org-left"><code>double</code></td>
<td class="org-left">in</td>
<td class="org-left">Factor to rescale ee distances</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>coord</code></td>
<td class="org-left"><code>double[3][walk_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron coordinates</td>
</tr>
<tr>
<td class="org-left"><code>ee_distance_rescaled_gl</code></td>
<td class="org-left"><code>double[walk_num][elec_num][elec_num][4]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-electron rescaled distance derivatives</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">function</span> <span style="color: #0000ff;">qmckl_compute_ee_distance_rescaled_gl_doc</span>(context, <span style="color: #a020f0;">&amp;</span>
elec_num, rescale_factor_ee, walk_num, coord, ee_distance_rescaled_gl) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">bind</span>(C) <span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> rescale_factor_ee</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> coord(elec_num,walk_num,3)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> ee_distance_rescaled_gl(4,elec_num,elec_num,walk_num)</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code) ::<span style="color: #a0522d;"> info</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> k</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> k=1,walk_num
info = qmckl_distance_rescaled_gl(context, <span style="color: #8b2252;">'T'</span>, <span style="color: #8b2252;">'T'</span>, elec_num, elec_num, <span style="color: #a020f0;">&amp;</span>
coord(1,k,1), elec_num*walk_num, <span style="color: #a020f0;">&amp;</span>
coord(1,k,1), elec_num*walk_num, <span style="color: #a020f0;">&amp;</span>
ee_distance_rescaled_gl(1,1,1,k), elec_num, rescale_factor_ee)
<span style="color: #a020f0;">if</span> (info /= QMCKL_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">exit</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_ee_distance_rescaled_gl_doc</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org451145b" class="outline-5">
<h5 id="org451145b"><span class="section-number-5">3.1.5.3</span> Test</h5>
<div class="outline-text-5" id="text-3-1-5-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_electron_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">ee_distance_rescaled_gl</span>[4 * walk_num * elec_num * elec_num];
rc = qmckl_get_jastrow_champ_ee_distance_rescaled_gl(context, ee_distance_rescaled_gl);
// <span style="color: #b22222;">TODO: Get exact values</span>
//// <span style="color: #b22222;">(e1,e2,w)</span>
//// <span style="color: #b22222;">(0,0,0) == 0.</span>
//<span style="color: #b22222;">assert(ee_distance[0] == 0.);</span>
//
//// <span style="color: #b22222;">(1,0,0) == (0,1,0)</span>
//<span style="color: #b22222;">assert(ee_distance[1] == ee_distance[elec_num]);</span>
//
//// <span style="color: #b22222;">value of (1,0,0)</span>
//<span style="color: #b22222;">assert(fabs(ee_distance[1]-7.152322512964209) &lt; 1.e-12);</span>
//
//// <span style="color: #b22222;">(0,0,1) == 0.</span>
//<span style="color: #b22222;">assert(ee_distance[elec_num*elec_num] == 0.);</span>
//
//// <span style="color: #b22222;">(1,0,1) == (0,1,1)</span>
//<span style="color: #b22222;">assert(ee_distance[elec_num*elec_num+1] == ee_distance[elec_num*elec_num+elec_num]);</span>
//
//// <span style="color: #b22222;">value of (1,0,1)</span>
//<span style="color: #b22222;">assert(fabs(ee_distance[elec_num*elec_num+1]-6.5517646321055665) &lt; 1.e-12);</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="outline-container-org1430509" class="outline-3">
<h3 id="org1430509"><span class="section-number-3">3.2</span> Electron-nucleus component</h3>
<div class="outline-text-3" id="text-3-2">
</div>
<div id="outline-container-org8e99884" class="outline-4">
<h4 id="org8e99884"><span class="section-number-4">3.2.1</span> Asymptotic component for</h4>
<div class="outline-text-4" id="text-3-2-1">
<p>
Calculate the asymptotic component <code>asymp_jasa</code> to be subtracted from the final
electron-nucleus jastrow factor \(J_{\text{eN}}\). The asymptotic component is calculated
via the <code>a_vector</code> and the electron-nucleus rescale factors <code>rescale_factor_en</code>.
</p>
<p>
\[
J_{\text{en}}^{\infty \alpha} = -\frac{a_1 \kappa_\alpha^{-1}}{1 + a_2 \kappa_\alpha^{-1}}
\]
</p>
</div>
<div id="outline-container-org2197ccf" class="outline-5">
<h5 id="org2197ccf"><span class="section-number-5">3.2.1.1</span> Get</h5>
<div class="outline-text-5" id="text-3-2-1-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_asymp_jasa</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">asymp_jasa</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
<ol class="org-ol">
<li><a id="org5decf1c"></a>Fortran interface<br />
<div class="outline-text-6" id="text-3-2-1-1-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">interface</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_asymp_jasa(context, </span><span style="color: #a020f0;">&amp;</span>
asymp_jasa, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> asymp_jasa(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_asymp_jasa</span>
<span style="color: #a020f0;">end interface</span>
</pre>
</div>
</div>
</li>
</ol>
</div>
<div id="outline-container-org733e257" class="outline-5">
<h5 id="org733e257"><span class="section-number-5">3.2.1.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-2-1-2">
<table id="org3488463" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>aord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Order of the polynomial</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of nucleus types</td>
</tr>
<tr>
<td class="org-left"><code>a_vector</code></td>
<td class="org-left"><code>double[type_nucl_num][aord_num+1]</code></td>
<td class="org-left">in</td>
<td class="org-left">Values of a</td>
</tr>
<tr>
<td class="org-left"><code>rescale_factor_en</code></td>
<td class="org-left"><code>double[type_nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron nucleus distances</td>
</tr>
<tr>
<td class="org-left"><code>asymp_jasa</code></td>
<td class="org-left"><code>double[type_nucl_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Asymptotic value</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_jastrow_champ_asymp_jasa_f(context, aord_num, type_nucl_num, a_vector, </span><span style="color: #a020f0;">&amp;</span>
rescale_factor_en, asymp_jasa) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> aord_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_num</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> a_vector(aord_num + 1, type_nucl_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> rescale_factor_en(type_nucl_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> asymp_jasa(type_nucl_num)</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, j, p</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> kappa_inv, x, asym_one</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (aord_num &lt; 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> i=1,type_nucl_num
kappa_inv = 1.0d0 / rescale_factor_en(i)
asymp_jasa(i) = a_vector(1,i) * kappa_inv / (1.0d0 + a_vector(2,i) * kappa_inv)
x = kappa_inv
<span style="color: #a020f0;">do</span> p = 2, aord_num
x = x * kappa_inv
asymp_jasa(i) = asymp_jasa(i) + a_vector(p+1, i) * x
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_asymp_jasa_f</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_asymp_jasa</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">aord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">type_nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">a_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">rescale_factor_en</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">asymp_jasa</span> );
</pre>
</div>
</div>
</div>
<div id="outline-container-org530618d" class="outline-5">
<h5 id="org530618d"><span class="section-number-5">3.2.1.3</span> Test</h5>
<div class="outline-text-5" id="text-3-2-1-3">
<p>
double asymp<sub>jasa</sub>[2];
rc = qmckl<sub>get</sub><sub>jastrow</sub><sub>champ</sub><sub>asymp</sub><sub>jasa</sub>(context, asymp<sub>jasa</sub>, type<sub>nucl</sub><sub>num</sub>);
</p>
<p>
// calculate asymp<sub>jasb</sub>
printf("%e %e\n", asymp<sub>jasa</sub>[0], -1.75529774);
assert(fabs(-1.75529774 - asymp<sub>jasa</sub>[0]) &lt; 1.e-8);
</p>
<p>
#+end<sub>src</sub>
</p>
</div>
</div>
</div>
<div id="outline-container-orgf7e87f9" class="outline-4">
<h4 id="orgf7e87f9"><span class="section-number-4">3.2.2</span> Electron-nucleus component</h4>
<div class="outline-text-4" id="text-3-2-2">
<p>
Calculate the electron-electron jastrow component <code>factor_en</code> using the <code>a_vector</code>
coeffecients and the electron-nucleus rescaled distances <code>en_distance_rescaled</code>.
</p>
<p>
\[
f_{\alpha}(R_{i\alpha}) = - \sum_{i,j<i} \left[ \frac{ A_0 C_{ij}}{1 - A_1 C_{ij}} + \sum^{N^\alpha_{\text{ord}}}_{k}A_k C_{ij}^k \right]
\]
</p>
</div>
<div id="outline-container-org737a5c3" class="outline-5">
<h5 id="org737a5c3"><span class="section-number-5">3.2.2.1</span> Get</h5>
<div class="outline-text-5" id="text-3-2-2-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_factor_en</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_en</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
<ol class="org-ol">
<li><a id="orga1df156"></a>Fortran interface<br />
<div class="outline-text-6" id="text-3-2-2-1-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">interface</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_factor_en (context, </span><span style="color: #a020f0;">&amp;</span>
factor_en, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_en(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_factor_en</span>
<span style="color: #a020f0;">end interface</span>
</pre>
</div>
</div>
</li>
</ol>
</div>
<div id="outline-container-org2cc199b" class="outline-5">
<h5 id="org2cc199b"><span class="section-number-5">3.2.2.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-2-2-2">
<table id="orgebbbbdc" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of unique nuclei</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_vector</code></td>
<td class="org-left"><code>int64_t[nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">IDs of unique nuclei</td>
</tr>
<tr>
<td class="org-left"><code>aord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of coefficients</td>
</tr>
<tr>
<td class="org-left"><code>a_vector</code></td>
<td class="org-left"><code>double[type_nucl_num][aord_num+1]</code></td>
<td class="org-left">in</td>
<td class="org-left">List of coefficients</td>
</tr>
<tr>
<td class="org-left"><code>en_distance_rescaled</code></td>
<td class="org-left"><code>double[walk_num][nucl_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus distances</td>
</tr>
<tr>
<td class="org-left"><code>asymp_jasa</code></td>
<td class="org-left"><code>double[type_nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Type of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>factor_en</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-nucleus jastrow</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_en_doc</span>( <span style="color: #a020f0;">&amp;</span>
context, walk_num, elec_num, nucl_num, type_nucl_num, <span style="color: #a020f0;">&amp;</span>
type_nucl_vector, aord_num, a_vector, <span style="color: #a020f0;">&amp;</span>
en_distance_rescaled, asymp_jasa, factor_en) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">bind</span>(C) <span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> nucl_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> type_nucl_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_vector(nucl_num)</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> aord_num</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> a_vector(aord_num+1,type_nucl_num)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> en_distance_rescaled(elec_num,nucl_num,walk_num)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> asymp_jasa(type_nucl_num)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_en(walk_num)</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code) ::<span style="color: #a0522d;"> info</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, a, p, nw</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x, power_ser</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (type_nucl_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (aord_num &lt; 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_7
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> nw =1, walk_num
factor_en(nw) = 0.0d0
<span style="color: #a020f0;">do</span> a = 1, nucl_num
<span style="color: #a020f0;">do</span> i = 1, elec_num
x = en_distance_rescaled(i, a, nw)
factor_en(nw) = factor_en(nw) + a_vector(1, type_nucl_vector(a)+1) * x / <span style="color: #a020f0;">&amp;</span>
(1.0d0 + a_vector(2, type_nucl_vector(a)+1) * x) - asymp_jasa(type_nucl_vector(a)+1)
<span style="color: #a020f0;">do</span> p = 2, aord_num
x = x * en_distance_rescaled(i, a, nw)
factor_en(nw) = factor_en(nw) + a_vector(p + 1, type_nucl_vector(a)+1) * x
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_en_doc</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_en_doc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">type_nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">type_nucl_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">aord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">a_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">en_distance_rescaled</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">asymp_jasa</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_en</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_en</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">type_nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">type_nucl_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">aord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">a_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">en_distance_rescaled</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">asymp_jasa</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_en</span> )
{
<span style="color: #483d8b;">#ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_factor_en_hpc
<span style="color: #483d8b;">#else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_factor_en_doc
<span style="color: #483d8b;">#endif</span>
(context, walk_num, elec_num, nucl_num, type_nucl_num,
type_nucl_vector, aord_num, a_vector, en_distance_rescaled,
asymp_jasa, factor_en );
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org45d9746" class="outline-5">
<h5 id="org45d9746"><span class="section-number-5">3.2.2.3</span> Test</h5>
<div class="outline-text-5" id="text-3-2-2-3">
<div class="org-src-container">
<pre class="src src-c">/* <span style="color: #b22222;">Check if Jastrow is properly initialized</span> */
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_jastrow_champ_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">factor_en</span>[walk_num];
rc = qmckl_get_jastrow_champ_factor_en(context, factor_en,walk_num);
// <span style="color: #b22222;">calculate factor_en</span>
printf(<span style="color: #8b2252;">"%f %f\n"</span>, factor_en[0], 22.781375792083587);
<span style="color: #0000ff;">assert</span>(fabs(22.781375792083587 - factor_en[0]) &lt; 1.e-12);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgb30c985" class="outline-4">
<h4 id="orgb30c985"><span class="section-number-4">3.2.3</span> Derivative</h4>
<div class="outline-text-4" id="text-3-2-3">
<p>
Calculate the electron-electron jastrow component <code>factor_en_gl</code> derivative
with respect to the electron coordinates using the <code>en_distance_rescaled</code> and
<code>en_distance_rescaled_gl</code> which are already calculated previously.
</p>
<p>
TODO: write equations.
</p>
</div>
<div id="outline-container-orgdd86b74" class="outline-5">
<h5 id="orgdd86b74"><span class="section-number-5">3.2.3.1</span> Get</h5>
<div class="outline-text-5" id="text-3-2-3-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_factor_en_gl</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_en_gl</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
<ol class="org-ol">
<li><a id="org71217e1"></a>Fortran interface<br />
<div class="outline-text-6" id="text-3-2-3-1-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">interface</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_factor_en_gl (context, </span><span style="color: #a020f0;">&amp;</span>
factor_en_gl, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_en_gl(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_factor_en_gl</span>
<span style="color: #a020f0;">end interface</span>
</pre>
</div>
</div>
</li>
</ol>
</div>
<div id="outline-container-org2c112fa" class="outline-5">
<h5 id="org2c112fa"><span class="section-number-5">3.2.3.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-2-3-2">
<table id="org3cc4900" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of unique nuclei</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_vector</code></td>
<td class="org-left"><code>int64_t[nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">IDs of unique nuclei</td>
</tr>
<tr>
<td class="org-left"><code>aord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of coefficients</td>
</tr>
<tr>
<td class="org-left"><code>a_vector</code></td>
<td class="org-left"><code>double[type_nucl_num][aord_num+1]</code></td>
<td class="org-left">in</td>
<td class="org-left">List of coefficients</td>
</tr>
<tr>
<td class="org-left"><code>en_distance_rescaled</code></td>
<td class="org-left"><code>double[walk_num][nucl_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus distances</td>
</tr>
<tr>
<td class="org-left"><code>en_distance_rescaled_gl</code></td>
<td class="org-left"><code>double[walk_num][nucl_num][elec_num][4]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus distance derivatives</td>
</tr>
<tr>
<td class="org-left"><code>factor_en_gl</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-nucleus jastrow</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_en_gl_doc</span>( <span style="color: #a020f0;">&amp;</span>
context, walk_num, elec_num, nucl_num, type_nucl_num, <span style="color: #a020f0;">&amp;</span>
type_nucl_vector, aord_num, a_vector, <span style="color: #a020f0;">&amp;</span>
en_distance_rescaled, en_distance_rescaled_gl, factor_en_gl) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">bind</span>(C) <span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> nucl_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> type_nucl_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_vector(nucl_num)</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> aord_num</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> a_vector(aord_num+1,type_nucl_num)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> en_distance_rescaled(elec_num,nucl_num,walk_num)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> en_distance_rescaled_gl(4, elec_num,nucl_num,walk_num)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_en_gl(elec_num,4,walk_num)</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code) ::<span style="color: #a0522d;"> info</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, a, k, nw, ii</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x, x1, kf</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> denom, invdenom, invdenom2, f</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> grad_c2</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> dx(4)</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (aord_num &lt; 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_7
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> nw =1, walk_num
factor_en_gl(:,:,nw) = 0.0d0
<span style="color: #a020f0;">do</span> a = 1, nucl_num
<span style="color: #a020f0;">do</span> i = 1, elec_num
x = en_distance_rescaled(i,a,nw)
<span style="color: #a020f0;">if</span>(<span style="color: #a020f0;">abs</span>(x) &lt; 1.d-12) <span style="color: #a020f0;">continue</span>
denom = 1.0d0 + a_vector(2, type_nucl_vector(a)+1) * x
invdenom = 1.0d0 / denom
invdenom2 = invdenom*invdenom
dx(1) = en_distance_rescaled_gl(1,i,a,nw)
dx(2) = en_distance_rescaled_gl(2,i,a,nw)
dx(3) = en_distance_rescaled_gl(3,i,a,nw)
dx(4) = en_distance_rescaled_gl(4,i,a,nw)
f = a_vector(1, type_nucl_vector(a)+1) * invdenom2
grad_c2 = dx(1)*dx(1) + dx(2)*dx(2) + dx(3)*dx(3)
factor_en_gl(i,1,nw) = factor_en_gl(i,1,nw) + f * dx(1)
factor_en_gl(i,2,nw) = factor_en_gl(i,2,nw) + f * dx(2)
factor_en_gl(i,3,nw) = factor_en_gl(i,3,nw) + f * dx(3)
factor_en_gl(i,4,nw) = factor_en_gl(i,4,nw) <span style="color: #a020f0;">&amp;</span>
+ f * (dx(4) - 2.d0 * a_vector(2, type_nucl_vector(a)+1) * grad_c2 * invdenom)
kf = 2.d0
x1 = x
x = 1.d0
<span style="color: #a020f0;">do</span> k=2, aord_num
f = a_vector(k+1,type_nucl_vector(a)+1) * kf * x
factor_en_gl(i,1,nw) = factor_en_gl(i,1,nw) + f * x1 * dx(1)
factor_en_gl(i,2,nw) = factor_en_gl(i,2,nw) + f * x1 * dx(2)
factor_en_gl(i,3,nw) = factor_en_gl(i,3,nw) + f * x1 * dx(3)
factor_en_gl(i,4,nw) = factor_en_gl(i,4,nw) <span style="color: #a020f0;">&amp;</span>
+ f * (x1 * dx(4) + (kf-1.d0) * grad_c2)
x = x*x1
kf = kf + 1.d0
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_en_gl_doc</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org2eab6a4" class="outline-5">
<h5 id="org2eab6a4"><span class="section-number-5">3.2.3.3</span> Test</h5>
<div class="outline-text-5" id="text-3-2-3-3">
<div class="org-src-container">
<pre class="src src-c">/* <span style="color: #b22222;">Check if Jastrow is properly initialized</span> */
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_jastrow_champ_provided</span>(<span style="color: #a0522d;">context</span>));
// <span style="color: #b22222;">calculate factor_en_gl</span>
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">factor_en_gl</span>[walk_num][4][elec_num];
rc = qmckl_get_jastrow_champ_factor_en_gl(context, &amp;(factor_en_gl[0][0][0]),walk_num*4*elec_num);
// <span style="color: #b22222;">check factor_en_gl</span>
<span style="color: #0000ff;">assert</span>(fabs( 0.19656663796630847 - factor_en_gl[0][0][0]) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs( -0.3945140890522283 - factor_en_gl[0][1][0]) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs( 0.5082964671286118 - factor_en_gl[0][2][0]) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs( -1.8409460670666289 - factor_en_gl[0][3][0]) &lt; 1.e-12);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgf840b91" class="outline-4">
<h4 id="orgf840b91"><span class="section-number-4">3.2.4</span> Electron-nucleus rescaled distances</h4>
<div class="outline-text-4" id="text-3-2-4">
<p>
<code>en_distance_rescaled</code> stores the matrix of the rescaled distances between
electrons and nuclei.
</p>
<p>
\[
C_{i\alpha} = \frac{ 1 - e^{-\kappa_\alpha R_{i\alpha}}}{\kappa_\alpha}
\]
</p>
<p>
where \(R_{i\alpha}\) is the matrix of electron-nucleus distances.
</p>
</div>
<div id="outline-container-orga4cc5db" class="outline-5">
<h5 id="orga4cc5db"><span class="section-number-5">3.2.4.1</span> Get</h5>
<div class="outline-text-5" id="text-3-2-4-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_get_electron_en_distance_rescaled</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">distance_rescaled</span>);
</pre>
</div>
</div>
</div>
<div id="outline-container-org772d350" class="outline-5">
<h5 id="org772d350"><span class="section-number-5">3.2.4.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-2-4-2">
<table id="orgdb18af0" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of types of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_vector</code></td>
<td class="org-left"><code>int64_t[nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of types of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>rescale_factor_en</code></td>
<td class="org-left"><code>double[type_nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">The factor for rescaled distances</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_coord</code></td>
<td class="org-left"><code>double[3][walk_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron coordinates</td>
</tr>
<tr>
<td class="org-left"><code>nucl_coord</code></td>
<td class="org-left"><code>double[3][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Nuclear coordinates</td>
</tr>
<tr>
<td class="org-left"><code>en_distance_rescaled</code></td>
<td class="org-left"><code>double[walk_num][nucl_num][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-nucleus distances</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">function</span> <span style="color: #0000ff;">qmckl_compute_en_distance_rescaled_doc</span>(context, <span style="color: #a020f0;">&amp;</span>
elec_num, nucl_num, type_nucl_num, <span style="color: #a020f0;">&amp;</span>
type_nucl_vector, rescale_factor_en, walk_num, elec_coord, <span style="color: #a020f0;">&amp;</span>
nucl_coord, en_distance_rescaled) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">bind</span>(C) <span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> nucl_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> type_nucl_num</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_vector(nucl_num)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> rescale_factor_en(type_nucl_num)</span>
<span style="color: #228b22;">integer</span> (<span style="color: #008b8b;">c_int64_t</span>) , <span style="color: #a020f0;">intent</span>(in) , <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> elec_coord(elec_num,walk_num,3)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> nucl_coord(nucl_num,3)</span>
<span style="color: #228b22;">real</span> (<span style="color: #008b8b;">c_double</span> ) , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> en_distance_rescaled(elec_num,nucl_num,walk_num)</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code) ::<span style="color: #a0522d;"> info</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, k</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> coord(3)</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_5
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> i=1, nucl_num
coord(1:3) = nucl_coord(i,1:3)
<span style="color: #a020f0;">do</span> k=1,walk_num
info = qmckl_distance_rescaled(context, <span style="color: #8b2252;">'T'</span>, <span style="color: #8b2252;">'N'</span>, elec_num, 1_8, <span style="color: #a020f0;">&amp;</span>
elec_coord(1,k,1), elec_num*walk_num, coord, 3_8, <span style="color: #a020f0;">&amp;</span>
en_distance_rescaled(1,i,k), elec_num, rescale_factor_en(type_nucl_vector(i)+1))
<span style="color: #a020f0;">if</span> (info /= QMCKL_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_en_distance_rescaled_doc</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org7eb0b3d" class="outline-5">
<h5 id="org7eb0b3d"><span class="section-number-5">3.2.4.3</span> Test</h5>
<div class="outline-text-5" id="text-3-2-4-3">
<div class="org-src-container">
<pre class="src src-c">
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_electron_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_nucleus_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">en_distance_rescaled</span>[walk_num][nucl_num][elec_num];
rc = qmckl_check(context,
qmckl_get_electron_en_distance_rescaled(context, &amp;(en_distance_rescaled[0][0][0]))
);
<span style="color: #0000ff;">assert</span> (rc == QMCKL_SUCCESS);
// <span style="color: #b22222;">(e,n,w) in Fortran notation</span>
// <span style="color: #b22222;">(1,1,1)</span>
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">en_distance_rescaled</span>[0][0][0] - 0.4942158656729477) &lt; 1.e-12);
// <span style="color: #b22222;">(1,2,1)</span>
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">en_distance_rescaled</span>[0][1][0] - 1.2464137498005765) &lt; 1.e-12);
// <span style="color: #b22222;">(2,1,1)</span>
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">en_distance_rescaled</span>[0][0][1] - 0.5248654474756858) &lt; 1.e-12);
// <span style="color: #b22222;">(1,1,2)</span>
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">en_distance_rescaled</span>[0][0][5] - 0.19529459944794733) &lt; 1.e-12);
// <span style="color: #b22222;">(1,2,2)</span>
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">en_distance_rescaled</span>[0][1][5] - 1.2091967687767369) &lt; 1.e-12);
// <span style="color: #b22222;">(2,1,2)</span>
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">en_distance_rescaled</span>[0][0][6] - 0.4726452953409436) &lt; 1.e-12);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgdd07176" class="outline-4">
<h4 id="orgdd07176"><span class="section-number-4">3.2.5</span> Electron-electron rescaled distance gradients and Laplacian with respect to electron coordinates</h4>
<div class="outline-text-4" id="text-3-2-5">
<p>
The rescaled distances, represented by \(C_{i\alpha} = (1 - e^{-\kappa_\alpha R_{i\alpha}})/\kappa\)
are differentiated with respect to the electron coordinates.
This information is stored in the tensor
<code>en_distance_rescaled_gl</code>. The initial three sequential
elements of this three-index tensor provide the \(x\), \(y\), and \(z\)
direction derivatives, while the fourth index corresponds to the Laplacian.
</p>
</div>
<div id="outline-container-org3dab799" class="outline-5">
<h5 id="org3dab799"><span class="section-number-5">3.2.5.1</span> Get</h5>
<div class="outline-text-5" id="text-3-2-5-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_get_electron_en_distance_rescaled_gl</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">distance_rescaled_gl</span>);
</pre>
</div>
</div>
</div>
<div id="outline-container-org93b1e07" class="outline-5">
<h5 id="org93b1e07"><span class="section-number-5">3.2.5.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-2-5-2">
<table id="org5be23e8" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of nucleus types</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_vector</code></td>
<td class="org-left"><code>int64_t[nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Array of nucleus types</td>
</tr>
<tr>
<td class="org-left"><code>rescale_factor_en</code></td>
<td class="org-left"><code>double[nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">The factors for rescaled distances</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_coord</code></td>
<td class="org-left"><code>double[3][walk_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron coordinates</td>
</tr>
<tr>
<td class="org-left"><code>nucl_coord</code></td>
<td class="org-left"><code>double[3][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Nuclear coordinates</td>
</tr>
<tr>
<td class="org-left"><code>en_distance_rescaled_gl</code></td>
<td class="org-left"><code>double[walk_num][nucl_num][elec_num][4]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-nucleus distance derivatives</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_en_distance_rescaled_gl_doc_f(context, elec_num, nucl_num, </span><span style="color: #a020f0;">&amp;</span>
type_nucl_num, type_nucl_vector, rescale_factor_en, walk_num, elec_coord, <span style="color: #a020f0;">&amp;</span>
nucl_coord, en_distance_rescaled_gl) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> nucl_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_vector(nucl_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> rescale_factor_en(nucl_num)</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> elec_coord(elec_num,walk_num,3)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> nucl_coord(nucl_num,3)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> en_distance_rescaled_gl(4,elec_num,nucl_num,walk_num)</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, k</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> coord(3)</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_5
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> i=1, nucl_num
coord(1:3) = nucl_coord(i,1:3)
<span style="color: #a020f0;">do</span> k=1,walk_num
info = qmckl_distance_rescaled_gl(context, <span style="color: #8b2252;">'T'</span>, <span style="color: #8b2252;">'T'</span>, elec_num, 1_8, <span style="color: #a020f0;">&amp;</span>
elec_coord(1,k,1), elec_num*walk_num, coord, 1_8, <span style="color: #a020f0;">&amp;</span>
en_distance_rescaled_gl(1,1,i,k), elec_num, rescale_factor_en(type_nucl_vector(i)+1))
<span style="color: #a020f0;">if</span> (info /= QMCKL_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_en_distance_rescaled_gl_doc_f</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org68b06a3" class="outline-5">
<h5 id="org68b06a3"><span class="section-number-5">3.2.5.3</span> Test</h5>
<div class="outline-text-5" id="text-3-2-5-3">
<div class="org-src-container">
<pre class="src src-c">
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_electron_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_nucleus_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">en_distance_rescaled_gl</span>[walk_num][4][nucl_num][elec_num];
rc = qmckl_check(context,
qmckl_get_electron_en_distance_rescaled_gl(context, &amp;(en_distance_rescaled_gl[0][0][0][0]))
);
<span style="color: #0000ff;">assert</span> (rc == QMCKL_SUCCESS);
// <span style="color: #b22222;">TODO: check exact values</span>
//// <span style="color: #b22222;">(e,n,w) in Fortran notation</span>
//// <span style="color: #b22222;">(1,1,1)</span>
//<span style="color: #b22222;">assert(fabs(en_distance_rescaled[0][0][0] - 7.546738741619978) &lt; 1.e-12);</span>
//
//// <span style="color: #b22222;">(1,2,1)</span>
//<span style="color: #b22222;">assert(fabs(en_distance_rescaled[0][1][0] - 8.77102435246984) &lt; 1.e-12);</span>
//
//// <span style="color: #b22222;">(2,1,1)</span>
//<span style="color: #b22222;">assert(fabs(en_distance_rescaled[0][0][1] - 3.698922010513608) &lt; 1.e-12);</span>
//
//// <span style="color: #b22222;">(1,1,2)</span>
//<span style="color: #b22222;">assert(fabs(en_distance_rescaled[1][0][0] - 5.824059436060509) &lt; 1.e-12);</span>
//
//// <span style="color: #b22222;">(1,2,2)</span>
//<span style="color: #b22222;">assert(fabs(en_distance_rescaled[1][1][0] - 7.080482110317645) &lt; 1.e-12);</span>
//
//// <span style="color: #b22222;">(2,1,2)</span>
//<span style="color: #b22222;">assert(fabs(en_distance_rescaled[1][0][1] - 3.1804527583077356) &lt; 1.e-12);</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="outline-container-orgdd03967" class="outline-3">
<h3 id="orgdd03967"><span class="section-number-3">3.3</span> Electron-electron-nucleus component</h3>
<div class="outline-text-3" id="text-3-3">
</div>
<div id="outline-container-orgc1b2757" class="outline-4">
<h4 id="orgc1b2757"><span class="section-number-4">3.3.1</span> Electron-electron rescaled distances in \(J_\text{eeN}\)</h4>
<div class="outline-text-4" id="text-3-3-1">
<p>
<code>een_rescaled_e</code> stores the table of the rescaled distances between all
pairs of electrons and raised to the power \(p\) defined by <code>cord_num</code>:
</p>
<p>
\[
C_{ij,p} = \left[ \exp\left(-\kappa_\text{e}\, r_{ij}\right) \right]^p
\]
</p>
<p>
where \(r_{ij}\) is the matrix of electron-electron distances.
</p>
</div>
<div id="outline-container-org4ca33bc" class="outline-5">
<h5 id="org4ca33bc"><span class="section-number-5">3.3.1.1</span> Get</h5>
<div class="outline-text-5" id="text-3-3-1-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_een_rescaled_e</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">distance_rescaled</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
</div>
<div id="outline-container-org88bc232" class="outline-5">
<h5 id="org88bc232"><span class="section-number-5">3.3.1.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-3-1-2">
<table id="orgfbd4ea4" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Order of polynomials</td>
</tr>
<tr>
<td class="org-left"><code>rescale_factor_ee</code></td>
<td class="org-left"><code>double</code></td>
<td class="org-left">in</td>
<td class="org-left">Factor to rescale ee distances</td>
</tr>
<tr>
<td class="org-left"><code>ee_distance</code></td>
<td class="org-left"><code>double[walk_num][elec_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-electron distances for each walker</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_e</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][elec_num][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-electron rescaled distances for each walker</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_een_rescaled_e_doc_f( </span><span style="color: #a020f0;">&amp;</span>
context, walk_num, elec_num, cord_num, rescale_factor_ee, <span style="color: #a020f0;">&amp;</span>
ee_distance, een_rescaled_e) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> cord_num</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> rescale_factor_ee</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> ee_distance(elec_num,elec_num,walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> een_rescaled_e(elec_num,elec_num,0:cord_num,walk_num)</span>
<span style="color: #228b22;">double precision</span>,<span style="color: #a020f0;">dimension</span>(:,:),<span style="color: #a020f0;">allocatable</span> ::<span style="color: #a0522d;"> een_rescaled_e_ij</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, j, k, l, nw</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">allocate</span>(een_rescaled_e_ij(elec_num * (elec_num - 1) / 2, cord_num + 1))
! <span style="color: #b22222;">Prepare table of exponentiated distances raised to appropriate power</span>
<span style="color: #a020f0;">do</span> nw = 1, walk_num
een_rescaled_e_ij(:, 1) = 1.0d0
k = 0
<span style="color: #a020f0;">do</span> j = 1, elec_num
<span style="color: #a020f0;">do</span> i = 1, j - 1
k = k + 1
een_rescaled_e_ij(k, 2) = dexp(-rescale_factor_ee * ee_distance(i, j, nw))
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">do</span> l = 2, cord_num
<span style="color: #a020f0;">do</span> k = 1, elec_num * (elec_num - 1)/2
een_rescaled_e_ij(k, l + 1) = een_rescaled_e_ij(k, l) * een_rescaled_e_ij(k, 2)
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
! <span style="color: #b22222;">prepare the actual een table</span>
een_rescaled_e(:, :, 0, nw) = 1.0d0
<span style="color: #a020f0;">do</span> l = 1, cord_num
k = 0
<span style="color: #a020f0;">do</span> j = 1, elec_num
<span style="color: #a020f0;">do</span> i = 1, j - 1
k = k + 1
x = een_rescaled_e_ij(k, l + 1)
een_rescaled_e(i, j, l, nw) = x
een_rescaled_e(j, i, l, nw) = x
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">do</span> l = 0, cord_num
<span style="color: #a020f0;">do</span> j = 1, elec_num
een_rescaled_e(j, j, l, nw) = 0.0d0
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_een_rescaled_e_doc_f</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_een_rescaled_e_hpc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">rescale_factor_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">een_rescaled_e</span> ) {
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) {
<span style="color: #a020f0;">return</span> QMCKL_INVALID_CONTEXT;
}
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) {
<span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_2;
}
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) {
<span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_3;
}
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) {
<span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_4;
}
// <span style="color: #b22222;">Prepare table of exponentiated distances raised to appropriate power</span>
// <span style="color: #b22222;">init</span>
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">elec_pairs</span> = (<span style="color: #228b22;">size_t</span>) (elec_num * (elec_num - 1)) / 2;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">len_een_ij</span> = (<span style="color: #228b22;">size_t</span>) elec_pairs * (cord_num + 1);
// <span style="color: #b22222;">number of elements for the een_rescaled_e_ij[N_e*(N_e-1)/2][cord+1]</span>
// <span style="color: #b22222;">probably in C is better [cord+1, Ne*(Ne-1)/2]</span>
// <span style="color: #b22222;">elec_pairs = (elec_num * (elec_num - 1)) / 2;</span>
// <span style="color: #b22222;">len_een_ij = elec_pairs * (cord_num + 1);</span>
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">e2</span> = elec_num*elec_num;
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp parallel
<span style="color: #483d8b;">#endif</span>
{
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">een_rescaled_e_ij</span> = calloc(len_een_ij,<span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">kk</span> = 0; kk &lt; elec_pairs ; ++kk) {
een_rescaled_e_ij[kk]= 1.0;
}
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp <span style="color: #a020f0;">for</span>
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">nw</span> = 0; nw &lt; (<span style="color: #228b22;">size_t</span>) walk_num; ++nw) {
<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">kk</span> = 0;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">i</span> = 0; i &lt; (<span style="color: #228b22;">size_t</span>) elec_num; ++i) {
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">ee1</span> = &amp;een_rescaled_e_ij[kk + elec_pairs];
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">ee2</span> = &amp;ee_distance[i*elec_num + nw*e2];
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp simd
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">j</span> = 0; j &lt; i; ++j) {
// <span style="color: #b22222;">een_rescaled_e_ij[j + kk + elec_pairs] = -rescale_factor_ee * ee_distance[j + i*elec_num + nw*e2];</span>
ee1[j] = -rescale_factor_ee * ee2[j];
}
kk += i;
}
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp simd
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">k</span> = elec_pairs; k &lt; 2*elec_pairs; ++k) {
een_rescaled_e_ij[k] = exp(een_rescaled_e_ij[k]);
}
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">ee3</span> = &amp;een_rescaled_e_ij[elec_pairs];
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">l</span> = 2; l &lt; (<span style="color: #228b22;">size_t</span>) (cord_num+1); ++l) {
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">ee1</span> = &amp;een_rescaled_e_ij[l*elec_pairs];
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">ee2</span> = &amp;een_rescaled_e_ij[(l-1)*elec_pairs];
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp simd
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">k</span> = 0; k &lt; elec_pairs; ++k) {
// <span style="color: #b22222;">een_rescaled_e_ij(k, l + 1) = een_rescaled_e_ij(k, l + 1 - 1) * een_rescaled_e_ij(k, 2)</span>
// <span style="color: #b22222;">een_rescaled_e_ij[k+l*elec_pairs] = een_rescaled_e_ij[k + (l - 1)*elec_pairs] *</span>
// <span style="color: #b22222;">een_rescaled_e_ij[k + elec_pairs];</span>
ee1[k] = ee2[k] * ee3[k];
}
}
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">een_rescaled_e_</span> = &amp;(een_rescaled_e[nw*(cord_num+1)*e2]);
// <span style="color: #b22222;">prepare the actual een table</span>
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp simd
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">i</span> = 0; i &lt; e2; ++i){
een_rescaled_e_[i] = 1.0;
}
<span style="color: #a020f0;">for</span> ( <span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">l</span> = 1; l &lt; (<span style="color: #228b22;">size_t</span>) (cord_num+1); ++l) {
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">x</span> = een_rescaled_e_ij + l*elec_pairs;
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">een_rescaled_e__</span> = &amp;(een_rescaled_e_[l*e2]);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_e_i</span> = een_rescaled_e__;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">i</span> = 0; i &lt; (<span style="color: #228b22;">size_t</span>) elec_num; ++i) {
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">j</span> = 0; j &lt; i; ++j) {
een_rescaled_e_i[j] = *x;
een_rescaled_e__[i + j*elec_num] = *x;
x += 1;
}
een_rescaled_e_i += elec_num;
}
}
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">x0</span> = &amp;(een_rescaled_e[nw*e2*(cord_num+1)]);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">l</span> = 0; l &lt; (<span style="color: #228b22;">size_t</span>) (cord_num + 1); ++l) {
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">x1</span> = &amp;(x0[l*e2]);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">j</span> = 0; j &lt; (<span style="color: #228b22;">size_t</span>) elec_num; ++j) {
*x1 = 0.0;
x1 += 1+elec_num;
}
}
}
free(een_rescaled_e_ij);
} // <span style="color: #b22222;">OpenMP</span>
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_een_rescaled_e_doc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">rescale_factor_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">een_rescaled_e</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_een_rescaled_e_hpc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">rescale_factor_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">een_rescaled_e</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"> <span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_een_rescaled_e</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">rescale_factor_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">een_rescaled_e</span> ) {
<span style="color: #483d8b;">#ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_een_rescaled_e_hpc
<span style="color: #483d8b;">#else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_een_rescaled_e_doc
<span style="color: #483d8b;">#endif</span>
(context, walk_num, elec_num, cord_num, rescale_factor_ee, ee_distance, een_rescaled_e);
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org36da75a" class="outline-5">
<h5 id="org36da75a"><span class="section-number-5">3.3.1.3</span> Test</h5>
<div class="outline-text-5" id="text-3-3-1-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_electron_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">een_rescaled_e</span>[walk_num][(cord_num + 1)][elec_num][elec_num];
rc = qmckl_get_jastrow_champ_een_rescaled_e(context, &amp;(een_rescaled_e[0][0][0][0]),elec_num*elec_num*(cord_num+1)*walk_num);
// <span style="color: #b22222;">value of (0,2,1)</span>
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_e</span>[0][1][0][2]- 0.2211015082992776 ) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_e</span>[0][1][0][3]- 0.2611178387068169 ) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_e</span>[0][1][0][4]- 0.0884012350763747 ) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_e</span>[0][2][1][3]- 0.1016685507354656 ) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_e</span>[0][2][1][4]- 0.0113118073246869 ) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_e</span>[0][2][1][5]- 0.5257156022077619 ) &lt; 1.e-12);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org3c44fff" class="outline-4">
<h4 id="org3c44fff"><span class="section-number-4">3.3.2</span> Electron-electron rescaled distances derivatives in \(J_\text{eeN}\)</h4>
<div class="outline-text-4" id="text-3-3-2">
<p>
<code>een_rescaled_e_gl</code> stores the table of the derivatives of the
rescaled distances between all pairs of electrons and raised to the
power \(p\) defined by <code>cord_num</code>. Here we take its derivatives
required for the een jastrow<sub>champ</sub>.
</p>
<p>
\[ \frac{\partial}{\partial x} \left[ {g_\text{e}(r)}\right]^p =
-\frac{x}{r} \kappa_\text{e}\, p\,\left[ {g_\text{e}(r)}\right]^p \]
\[ \Delta \left[ {g_\text{e}(r)}\right]^p = \frac{2}{r} \kappa_\text{e}\, p\,\left[ {g_\text{e}(r)}\right]^p \right] + \left(\frac{\partial}{\partial x}\left[ {g_\text{e}(r)}\right]^p \right)^2 + \left(\frac{\partial}{\partial y}\left[ {g_\text{e}(r)}\right]^p \right)^2 + \left(\frac{\partial}{\partial z}\left[ {g_\text{e}(r)}\right]^p \right)^2 \]
</p>
</div>
<div id="outline-container-org6283b2e" class="outline-5">
<h5 id="org6283b2e"><span class="section-number-5">3.3.2.1</span> Get</h5>
<div class="outline-text-5" id="text-3-3-2-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_een_rescaled_e_gl</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">distance_rescaled</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
</div>
<div id="outline-container-orga0b439b" class="outline-5">
<h5 id="orga0b439b"><span class="section-number-5">3.3.2.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-3-2-2">
<table id="orgb84bc3e" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Order of polynomials</td>
</tr>
<tr>
<td class="org-left"><code>rescale_factor_ee</code></td>
<td class="org-left"><code>double</code></td>
<td class="org-left">in</td>
<td class="org-left">Factor to rescale ee distances</td>
</tr>
<tr>
<td class="org-left"><code>coord_ee</code></td>
<td class="org-left"><code>double[walk_num][3][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron coordinates</td>
</tr>
<tr>
<td class="org-left"><code>ee_distance</code></td>
<td class="org-left"><code>double[walk_num][elec_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-electron distances</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_e</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][elec_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-electron distances</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_e_gl</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][elec_num][4][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-electron rescaled distances</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_jastrow_champ_factor_een_rescaled_e_gl_f( </span><span style="color: #a020f0;">&amp;</span>
context, walk_num, elec_num, cord_num, rescale_factor_ee, <span style="color: #a020f0;">&amp;</span>
coord_ee, ee_distance, een_rescaled_e, een_rescaled_e_gl) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> cord_num</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> rescale_factor_ee</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> coord_ee(elec_num,3,walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> ee_distance(elec_num,elec_num,walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_e(elec_num,elec_num,0:cord_num,walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> een_rescaled_e_gl(elec_num,4,elec_num,0:cord_num,walk_num)</span>
<span style="color: #228b22;">double precision</span>,<span style="color: #a020f0;">dimension</span>(:,:,:),<span style="color: #a020f0;">allocatable</span> ::<span style="color: #a0522d;"> elec_dist_gl</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x, rij_inv, kappa_l</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, j, k, l, nw, ii</span>
<span style="color: #a020f0;">allocate</span>(elec_dist_gl(elec_num, 4, elec_num))
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
! <span style="color: #b22222;">Prepare table of exponentiated distances raised to appropriate power</span>
<span style="color: #a020f0;">do</span> nw = 1, walk_num
<span style="color: #a020f0;">do</span> j = 1, elec_num
<span style="color: #a020f0;">do</span> i = 1, j-1
rij_inv = 1.0d0 / ee_distance(i, j, nw)
<span style="color: #a020f0;">do</span> ii = 1, 3
elec_dist_gl(i, ii, j) = (coord_ee(i, ii, nw) - coord_ee(j, ii, nw)) * rij_inv
<span style="color: #a020f0;">end do</span>
elec_dist_gl(i, 4, j) = 2.0d0 * rij_inv
<span style="color: #a020f0;">end do</span>
elec_dist_gl(j, :, j) = 0.0d0
<span style="color: #a020f0;">do</span> i = j+1, elec_num
rij_inv = 1.0d0 / ee_distance(i, j, nw)
<span style="color: #a020f0;">do</span> ii = 1, 3
elec_dist_gl(i, ii, j) = (coord_ee(i, ii, nw) - coord_ee(j, ii, nw)) * rij_inv
<span style="color: #a020f0;">end do</span>
elec_dist_gl(i, 4, j) = 2.0d0 * rij_inv
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
! <span style="color: #b22222;">Not necessary: should be set to zero by qmckl_malloc</span>
! <span style="color: #b22222;">een_rescaled_e_gl(:,:,:,0,nw) = 0.d0</span>
<span style="color: #a020f0;">do</span> l = 1, cord_num
kappa_l = - <span style="color: #a020f0;">dble</span>(l) * rescale_factor_ee
<span style="color: #a020f0;">do</span> j = 1, elec_num
<span style="color: #a020f0;">do</span> i = 1, elec_num
een_rescaled_e_gl(i, 1, j, l, nw) = kappa_l * elec_dist_gl(i, 1, j)
een_rescaled_e_gl(i, 2, j, l, nw) = kappa_l * elec_dist_gl(i, 2, j)
een_rescaled_e_gl(i, 3, j, l, nw) = kappa_l * elec_dist_gl(i, 3, j)
een_rescaled_e_gl(i, 4, j, l, nw) = kappa_l * elec_dist_gl(i, 4, j)
een_rescaled_e_gl(i, 4, j, l, nw) = een_rescaled_e_gl(i, 4, j, l, nw) <span style="color: #a020f0;">&amp;</span>
+ een_rescaled_e_gl(i, 1, j, l, nw) * een_rescaled_e_gl(i, 1, j, l, nw) <span style="color: #a020f0;">&amp;</span>
+ een_rescaled_e_gl(i, 2, j, l, nw) * een_rescaled_e_gl(i, 2, j, l, nw) <span style="color: #a020f0;">&amp;</span>
+ een_rescaled_e_gl(i, 3, j, l, nw) * een_rescaled_e_gl(i, 3, j, l, nw)
een_rescaled_e_gl(i,1,j,l,nw) = een_rescaled_e_gl(i,1,j,l,nw) * een_rescaled_e(i,j,l,nw)
een_rescaled_e_gl(i,2,j,l,nw) = een_rescaled_e_gl(i,2,j,l,nw) * een_rescaled_e(i,j,l,nw)
een_rescaled_e_gl(i,3,j,l,nw) = een_rescaled_e_gl(i,3,j,l,nw) * een_rescaled_e(i,j,l,nw)
een_rescaled_e_gl(i,4,j,l,nw) = een_rescaled_e_gl(i,4,j,l,nw) * een_rescaled_e(i,j,l,nw)
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_een_rescaled_e_gl_f</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_een_rescaled_e_gl_hpc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">rescale_factor_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">coord_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_e</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">een_rescaled_e_gl</span> )
{
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">return</span> QMCKL_INVALID_CONTEXT;
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_2;
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_3;
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_4;
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">elec_dist_gl0</span> = (<span style="color: #228b22;">double</span>*) calloc(elec_num * elec_num, <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">elec_dist_gl1</span> = (<span style="color: #228b22;">double</span>*) calloc(elec_num * elec_num, <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">elec_dist_gl2</span> = (<span style="color: #228b22;">double</span>*) calloc(elec_num * elec_num, <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">elec_dist_gl3</span> = (<span style="color: #228b22;">double</span>*) calloc(elec_num * elec_num, <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
assert (elec_dist_gl0 != <span style="color: #008b8b;">NULL</span>);
assert (elec_dist_gl1 != <span style="color: #008b8b;">NULL</span>);
assert (elec_dist_gl2 != <span style="color: #008b8b;">NULL</span>);
assert (elec_dist_gl3 != <span style="color: #008b8b;">NULL</span>);
<span style="color: #483d8b;"> #pragma</span> omp parallel <span style="color: #a020f0;">for</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nw</span> = 0; nw &lt; walk_num; ++nw) {
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">rij_inv</span>[elec_num];
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">j</span> = 0; j &lt; elec_num; ++j) {
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp simd
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span> = 0; i &lt; elec_num ; ++i) {
rij_inv[i] = ee_distance[i + j * elec_num + nw * elec_num * elec_num] + 1.e-30;
}
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp simd
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span> = 0; i &lt; elec_num ; ++i) {
rij_inv[i] = 1.0/rij_inv[i];
}
rij_inv[j] = 0.;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">xj</span> = coord_ee[j + nw * elec_num * 3];
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">yj</span> = coord_ee[j + elec_num + nw * elec_num * 3];
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">zj</span> = coord_ee[j + 2 * elec_num + nw * elec_num * 3];
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp simd
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span> = 0; i &lt; elec_num ; ++i) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">xi</span> = coord_ee[i + nw * elec_num * 3];
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">yi</span> = coord_ee[i + elec_num + nw * elec_num * 3];
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">zi</span> = coord_ee[i + 2 * elec_num + nw * elec_num * 3];
elec_dist_gl0[i + j * elec_num] = rij_inv[i] * (xi-xj);
elec_dist_gl1[i + j * elec_num] = rij_inv[i] * (yi-yj);
elec_dist_gl2[i + j * elec_num] = rij_inv[i] * (zi-zj);
elec_dist_gl3[i + j * elec_num] = rij_inv[i] + rij_inv[i];
}
}
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">j</span> = 0; j &lt; elec_num; ++j) {
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">eegl</span> = &amp;een_rescaled_e_gl[ elec_num * 4 * (j + elec_num * (cord_num + 1) * nw)];
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp simd
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span> = 0; i &lt; 4*elec_num; ++i) {
eegl[i] = 0.0;
}
}
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">l</span> = 1; l &lt;= cord_num; ++l) {
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">kappa_l</span> = - (<span style="color: #228b22;">double</span>)<span style="color: #228b22;">l</span> * <span style="color: #a0522d;">rescale_factor_ee</span>;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">j</span> = 0; j &lt; elec_num; ++j) {
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">eegl</span> = &amp;een_rescaled_e_gl[ elec_num * 4 * (j + elec_num * (l + (cord_num + 1) * nw))];
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a020f0;">restrict</span> <span style="color: #a0522d;">ee</span> = &amp;een_rescaled_e [ elec_num * (j + elec_num * (l + (cord_num + 1) * nw))];
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp simd
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span> = 0; i &lt; elec_num; ++i) {
eegl[i ] = kappa_l * elec_dist_gl0[i + j * elec_num];
eegl[i + elec_num ] = kappa_l * elec_dist_gl1[i + j * elec_num];
eegl[i + elec_num * 2] = kappa_l * elec_dist_gl2[i + j * elec_num];
eegl[i + elec_num * 3] = kappa_l * elec_dist_gl3[i + j * elec_num];
}
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp simd
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span> = 0; i &lt; elec_num; ++i) {
eegl[i + elec_num*3] = eegl[i + elec_num*3] +
eegl[i] * eegl[i] +
eegl[i + elec_num*1] * eegl[i + elec_num*1] +
eegl[i + elec_num*2] * eegl[i + elec_num*2];
}
<span style="color: #483d8b;">#ifdef</span> HAVE_OPENMP
<span style="color: #483d8b;">#pragma</span> omp simd
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span> = 0; i &lt; elec_num; ++i) {
eegl[i ] *= ee[i];
eegl[i + elec_num * 1] *= ee[i];
eegl[i + elec_num * 2] *= ee[i];
eegl[i + elec_num * 3] *= ee[i];
}
}
}
}
free(elec_dist_gl0);
free(elec_dist_gl1);
free(elec_dist_gl2);
free(elec_dist_gl3);
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_een_rescaled_e_gl</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> <span style="color: #a0522d;">rescale_factor_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">coord_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ee_distance</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_e</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">een_rescaled_e_gl</span> )
{
<span style="color: #483d8b;">#ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_factor_een_rescaled_e_gl_hpc
<span style="color: #483d8b;">#else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_factor_een_rescaled_e_gl_doc
<span style="color: #483d8b;">#endif</span>
(context, walk_num, elec_num, cord_num, rescale_factor_ee,
coord_ee, ee_distance, een_rescaled_e, een_rescaled_e_gl );
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org20aec8a" class="outline-5">
<h5 id="org20aec8a"><span class="section-number-5">3.3.2.3</span> Test</h5>
<div class="outline-text-5" id="text-3-3-2-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">double</span> <span style="color: #a0522d;">een_rescaled_e_gl</span>[walk_num][(cord_num + 1)][elec_num][4][elec_num];
size_max=walk_num*(cord_num + 1)*elec_num*4*elec_num;
rc = qmckl_get_jastrow_champ_een_rescaled_e_gl(context,
&amp;(een_rescaled_e_gl[0][0][0][0][0]),size_max);
// <span style="color: #b22222;">value of (0,0,0,2,1)</span>
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_e_gl</span>[0][1][0][0][2] + 0.09831391870751387 ) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_e_gl</span>[0][1][0][0][3] + 0.017204157459682526 ) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_e_gl</span>[0][1][0][0][4] + 0.013345768421098641 ) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_e_gl</span>[0][2][1][0][3] + 0.03733086358273962 ) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_e_gl</span>[0][2][1][0][4] + 0.004922634822943517 ) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_e_gl</span>[0][2][1][0][5] + 0.5416751547830984 ) &lt; 1.e-12);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgd06bacb" class="outline-4">
<h4 id="orgd06bacb"><span class="section-number-4">3.3.3</span> Electron-nucleus rescaled distances in \(J_\text{eeN}\)</h4>
<div class="outline-text-4" id="text-3-3-3">
<p>
<code>een_rescaled_n</code> stores the table of the rescaled distances between
electrons and nuclei raised to the power \(p\) defined by <code>cord_num</code>:
</p>
<p>
\[
C_{i\alpha,p} = \left[ \exp\left(-\kappa_\alpha\, R_{i\alpha}\right) \right]^p
\]
</p>
<p>
where \(R_{i\alpha}\) is the matrix of electron-nucleus distances.
</p>
</div>
<div id="outline-container-orgbbf476e" class="outline-5">
<h5 id="orgbbf476e"><span class="section-number-5">3.3.3.1</span> Get</h5>
<div class="outline-text-5" id="text-3-3-3-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_een_rescaled_n</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">distance_rescaled</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
</div>
<div id="outline-container-org6dc9ed2" class="outline-5">
<h5 id="org6dc9ed2"><span class="section-number-5">3.3.3.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-3-3-2">
<table id="org7239a20" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of atoms</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of atom types</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_vector</code></td>
<td class="org-left"><code>int64_t[nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Types of atoms</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Order of polynomials</td>
</tr>
<tr>
<td class="org-left"><code>rescale_factor_en</code></td>
<td class="org-left"><code>double[nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Factor to rescale ee distances</td>
</tr>
<tr>
<td class="org-left"><code>en_distance</code></td>
<td class="org-left"><code>double[walk_num][elec_num][nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus distances</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][nucl_num][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-nucleus rescaled distances</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_een_rescaled_n_f( </span><span style="color: #a020f0;">&amp;</span>
context, walk_num, elec_num, nucl_num, <span style="color: #a020f0;">&amp;</span>
type_nucl_num, type_nucl_vector, cord_num, rescale_factor_en, <span style="color: #a020f0;">&amp;</span>
en_distance, een_rescaled_n) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> nucl_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_vector(nucl_num)</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> cord_num</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> rescale_factor_en(type_nucl_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> en_distance(nucl_num,elec_num,walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, a, k, l, nw</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_5
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> nw = 1, walk_num
! <span style="color: #b22222;">prepare the actual een table</span>
een_rescaled_n(:, :, 0, nw) = 1.0d0
<span style="color: #a020f0;">do</span> a = 1, nucl_num
<span style="color: #a020f0;">do</span> i = 1, elec_num
een_rescaled_n(i, a, 1, nw) = dexp(-rescale_factor_en(type_nucl_vector(a)+1) * en_distance(a, i, nw))
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">do</span> l = 2, cord_num
<span style="color: #a020f0;">do</span> a = 1, nucl_num
<span style="color: #a020f0;">do</span> i = 1, elec_num
een_rescaled_n(i, a, l, nw) = een_rescaled_n(i, a, l - 1, nw) * een_rescaled_n(i, a, 1, nw)
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_een_rescaled_n_f</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c">/*
<span style="color: #b22222;">qmckl_exit_code qmckl_compute_een_rescaled_n (</span>
<span style="color: #b22222;"> const qmckl_context context,</span>
<span style="color: #b22222;"> const int64_t walk_num,</span>
<span style="color: #b22222;"> const int64_t elec_num,</span>
<span style="color: #b22222;"> const int64_t nucl_num,</span>
<span style="color: #b22222;"> const int64_t type_nucl_num,</span>
<span style="color: #b22222;"> int64_t* const type_nucl_vector,</span>
<span style="color: #b22222;"> const int64_t cord_num,</span>
<span style="color: #b22222;"> const double* rescale_factor_en,</span>
<span style="color: #b22222;"> const double* en_distance,</span>
<span style="color: #b22222;"> double* const een_rescaled_n ) {</span>
<span style="color: #b22222;"> if (context == QMCKL_NULL_CONTEXT) {</span>
<span style="color: #b22222;"> return QMCKL_INVALID_CONTEXT;</span>
<span style="color: #b22222;"> }</span>
<span style="color: #b22222;"> if (walk_num &lt;= 0) {</span>
<span style="color: #b22222;"> return QMCKL_INVALID_ARG_2;</span>
<span style="color: #b22222;"> }</span>
<span style="color: #b22222;"> if (elec_num &lt;= 0) {</span>
<span style="color: #b22222;"> return QMCKL_INVALID_ARG_3;</span>
<span style="color: #b22222;"> }</span>
<span style="color: #b22222;"> if (nucl_num &lt;= 0) {</span>
<span style="color: #b22222;"> return QMCKL_INVALID_ARG_4;</span>
<span style="color: #b22222;"> }</span>
<span style="color: #b22222;"> if (cord_num &lt; 0) {</span>
<span style="color: #b22222;"> return QMCKL_INVALID_ARG_5;</span>
<span style="color: #b22222;"> }</span>
<span style="color: #b22222;"> // Prepare table of exponentiated distances raised to appropriate power</span>
<span style="color: #b22222;"> for (int i = 0; i &lt; (walk_num*(cord_num+1)*nucl_num*elec_num); ++i) {</span>
<span style="color: #b22222;"> een_rescaled_n[i] = 1.0;</span>
<span style="color: #b22222;"> }</span>
<span style="color: #b22222;"> for (int nw = 0; nw &lt; walk_num; ++nw) {</span>
<span style="color: #b22222;"> for (int a = 0; a &lt; nucl_num; ++a) {</span>
<span style="color: #b22222;"> for (int i = 0; i &lt; elec_num; ++i) {</span>
<span style="color: #b22222;"> een_rescaled_n[i + a*elec_num + nw * elec_num*nucl_num*(cord_num+1)] = 1.0;</span>
<span style="color: #b22222;"> een_rescaled_n[i + a*elec_num + elec_num*nucl_num + nw*elec_num*nucl_num*(cord_num+1)] =</span>
<span style="color: #b22222;"> exp(-rescale_factor_en[type_nucl_vector[a]] * en_distance[a + i*nucl_num + nw*elec_num*nucl_num]);</span>
<span style="color: #b22222;"> }</span>
<span style="color: #b22222;"> }</span>
<span style="color: #b22222;"> for (int l = 2; l &lt; (cord_num+1); ++l){</span>
<span style="color: #b22222;"> for (int a = 0; a &lt; nucl_num; ++a) {</span>
<span style="color: #b22222;"> for (int i = 0; i &lt; elec_num; ++i) {</span>
<span style="color: #b22222;"> een_rescaled_n[i + a*elec_num + l*elec_num*nucl_num + nw*elec_num*nucl_num*(cord_num+1)] =</span>
<span style="color: #b22222;"> een_rescaled_n[i + a*elec_num + (l-1)*elec_num*nucl_num + nw*elec_num*nucl_num*(cord_num+1)] *</span>
<span style="color: #b22222;"> een_rescaled_n[i + a*elec_num + elec_num*nucl_num + nw*elec_num*nucl_num*(cord_num+1)];</span>
<span style="color: #b22222;"> }</span>
<span style="color: #b22222;"> }</span>
<span style="color: #b22222;"> }</span>
<span style="color: #b22222;"> }</span>
<span style="color: #b22222;"> return QMCKL_SUCCESS;</span>
<span style="color: #b22222;">}</span>
*/
</pre>
</div>
</div>
</div>
<div id="outline-container-org0b64998" class="outline-5">
<h5 id="org0b64998"><span class="section-number-5">3.3.3.3</span> Test</h5>
<div class="outline-text-5" id="text-3-3-3-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_electron_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">een_rescaled_n</span>[walk_num][(cord_num + 1)][nucl_num][elec_num];
size_max=walk_num*(cord_num + 1)*nucl_num*elec_num;
rc = qmckl_get_jastrow_champ_een_rescaled_n(context, &amp;(een_rescaled_n[0][0][0][0]),size_max);
// <span style="color: #b22222;">value of (0,2,1)</span>
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_n</span>[0][1][0][2]-0.2603169838750542 )&lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_n</span>[0][1][0][3]-0.3016180139679065 )&lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_n</span>[0][1][0][4]-0.10506023826192266)&lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_n</span>[0][2][1][3]-0.9267719759374164 )&lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_n</span>[0][2][1][4]-0.11497585238132658)&lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">een_rescaled_n</span>[0][2][1][5]-0.07534033469115217)&lt; 1.e-12);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgd785a7d" class="outline-4">
<h4 id="orgd785a7d"><span class="section-number-4">3.3.4</span> Electron-nucleus rescaled distances derivatives in \(J_\text{eeN}\)</h4>
<div class="outline-text-4" id="text-3-3-4">
<p>
<code>een_rescaled_n_gl</code> stores the table of the derivatives of the
rescaled distances between all electron-nucleus pairs and raised to the
power \(p\) defined by <code>cord_num</code>. Here we take its derivatives
required for the een jastrow<sub>champ</sub>.
</p>
<p>
\[ \frac{\partial}{\partial x} \left[ {g_\alpha(R_{i\alpha})}\right]^p =
-\frac{x}{R_{i\alpha}} \kappa_\alpha\, p\,\left[ {g_\alpha(R_{i\alpha})}\right]^p \]
\[ \Delta \left[ {g_\alpha(R_{i\alpha})}\right]^p = \frac{2}{R_{i\alpha}}
\kappa_\alpha\, p\,\left[ {g_\alpha(R_{i\alpha})}\right]^p \right] +
\left(\frac{\partial}{\partial x}\left[ {g_\alpha(R_{i\alpha})}\right]^p
\right)^2 + \left(\frac{\partial}{\partial y}\left[
{g_\alpha(R_{i\alpha})}\right]^p \right)^2 + \left(\frac{\partial}{\partial
z}\left[ {g_\alpha(R_{i\alpha})}\right]^p \right)^2 \]
</p>
</div>
<div id="outline-container-org20d9153" class="outline-5">
<h5 id="org20d9153"><span class="section-number-5">3.3.4.1</span> Get</h5>
<div class="outline-text-5" id="text-3-3-4-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_een_rescaled_n_gl</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">distance_rescaled</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
</div>
<div id="outline-container-orgbc6216b" class="outline-5">
<h5 id="orgbc6216b"><span class="section-number-5">3.3.4.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-3-4-2">
<table id="org75c0f9d" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of atoms</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of atom types</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_vector</code></td>
<td class="org-left"><code>int64_t[nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Types of atoms</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Order of polynomials</td>
</tr>
<tr>
<td class="org-left"><code>rescale_factor_en</code></td>
<td class="org-left"><code>double[nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Factor to rescale ee distances</td>
</tr>
<tr>
<td class="org-left"><code>coord_ee</code></td>
<td class="org-left"><code>double[walk_num][3][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron coordinates</td>
</tr>
<tr>
<td class="org-left"><code>coord_n</code></td>
<td class="org-left"><code>double[3][nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Nuclear coordinates</td>
</tr>
<tr>
<td class="org-left"><code>en_distance</code></td>
<td class="org-left"><code>double[walk_num][elec_num][nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus distances</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][nucl_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus distances</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n_gl</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][nucl_num][4][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-nucleus rescaled distances</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_jastrow_champ_factor_een_rescaled_n_gl_f( </span><span style="color: #a020f0;">&amp;</span>
context, walk_num, elec_num, nucl_num, type_nucl_num, type_nucl_vector, <span style="color: #a020f0;">&amp;</span>
cord_num, rescale_factor_en, <span style="color: #a020f0;">&amp;</span>
coord_ee, coord_n, en_distance, een_rescaled_n, een_rescaled_n_gl) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> nucl_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_vector(nucl_num)</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> cord_num</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> rescale_factor_en(type_nucl_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> coord_ee(elec_num,3,walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> coord_n(nucl_num,3)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> en_distance(nucl_num,elec_num,walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> een_rescaled_n_gl(elec_num,4,nucl_num,0:cord_num,walk_num)</span>
<span style="color: #228b22;">double precision</span>,<span style="color: #a020f0;">dimension</span>(:,:,:),<span style="color: #a020f0;">allocatable</span> ::<span style="color: #a0522d;"> elnuc_dist_gl</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x, ria_inv, kappa_l</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, a, k, l, nw, ii</span>
<span style="color: #a020f0;">allocate</span>(elnuc_dist_gl(elec_num, 4, nucl_num))
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_5
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
! <span style="color: #b22222;">Prepare table of exponentiated distances raised to appropriate power</span>
een_rescaled_n_gl = 0.0d0
<span style="color: #a020f0;">do</span> nw = 1, walk_num
! <span style="color: #b22222;">prepare the actual een table</span>
<span style="color: #a020f0;">do</span> a = 1, nucl_num
<span style="color: #a020f0;">do</span> i = 1, elec_num
ria_inv = 1.0d0 / en_distance(a, i, nw)
<span style="color: #a020f0;">do</span> ii = 1, 3
elnuc_dist_gl(i, ii, a) = (coord_ee(i, ii, nw) - coord_n(a, ii)) * ria_inv
<span style="color: #a020f0;">end do</span>
elnuc_dist_gl(i, 4, a) = 2.0d0 * ria_inv
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">do</span> l = 0, cord_num
<span style="color: #a020f0;">do</span> a = 1, nucl_num
kappa_l = - <span style="color: #a020f0;">dble</span>(l) * rescale_factor_en(type_nucl_vector(a)+1)
<span style="color: #a020f0;">do</span> i = 1, elec_num
een_rescaled_n_gl(i, 1, a, l, nw) = kappa_l * elnuc_dist_gl(i, 1, a)
een_rescaled_n_gl(i, 2, a, l, nw) = kappa_l * elnuc_dist_gl(i, 2, a)
een_rescaled_n_gl(i, 3, a, l, nw) = kappa_l * elnuc_dist_gl(i, 3, a)
een_rescaled_n_gl(i, 4, a, l, nw) = kappa_l * elnuc_dist_gl(i, 4, a)
een_rescaled_n_gl(i, 4, a, l, nw) = een_rescaled_n_gl(i, 4, a, l, nw) <span style="color: #a020f0;">&amp;</span>
+ een_rescaled_n_gl(i, 1, a, l, nw) * een_rescaled_n_gl(i, 1, a, l, nw) <span style="color: #a020f0;">&amp;</span>
+ een_rescaled_n_gl(i, 2, a, l, nw) * een_rescaled_n_gl(i, 2, a, l, nw) <span style="color: #a020f0;">&amp;</span>
+ een_rescaled_n_gl(i, 3, a, l, nw) * een_rescaled_n_gl(i, 3, a, l, nw)
een_rescaled_n_gl(i, 1, a, l, nw) = een_rescaled_n_gl(i, 1, a, l, nw) * <span style="color: #a020f0;">&amp;</span>
een_rescaled_n(i, a, l, nw)
een_rescaled_n_gl(i, 2, a, l, nw) = een_rescaled_n_gl(i, 2, a, l, nw) * <span style="color: #a020f0;">&amp;</span>
een_rescaled_n(i, a, l, nw)
een_rescaled_n_gl(i, 3, a, l, nw) = een_rescaled_n_gl(i, 3, a, l, nw) * <span style="color: #a020f0;">&amp;</span>
een_rescaled_n(i, a, l, nw)
een_rescaled_n_gl(i, 4, a, l, nw) = een_rescaled_n_gl(i, 4, a, l, nw) * <span style="color: #a020f0;">&amp;</span>
een_rescaled_n(i, a, l, nw)
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_een_rescaled_n_gl_f</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org0ac4264" class="outline-5">
<h5 id="org0ac4264"><span class="section-number-5">3.3.4.3</span> Test</h5>
<div class="outline-text-5" id="text-3-3-4-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_electron_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">een_rescaled_n_gl</span>[walk_num][(cord_num + 1)][nucl_num][4][elec_num];
size_max=walk_num*(cord_num + 1)*nucl_num*4*elec_num;
rc = qmckl_get_jastrow_champ_een_rescaled_n_gl(context, &amp;(een_rescaled_n_gl[0][0][0][0][0]),size_max);
// <span style="color: #b22222;">value of (0,2,1)</span>
<span style="color: #0000ff;">assert</span>(fabs( -0.11234061209936878 - een_rescaled_n_gl[0][1][0][0][2]) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs( 0.0004440109367151707 - een_rescaled_n_gl[0][1][0][0][3]) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs( -0.012868642597346566 - een_rescaled_n_gl[0][1][0][0][4]) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs( 0.08601122289922644 - een_rescaled_n_gl[0][2][1][0][3]) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs( -0.058681563677207206 - een_rescaled_n_gl[0][2][1][0][4]) &lt; 1.e-12);
<span style="color: #0000ff;">assert</span>(fabs( 0.005359281880312882 - een_rescaled_n_gl[0][2][1][0][5]) &lt; 1.e-12);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgbf2ce39" class="outline-4">
<h4 id="orgbf2ce39"><span class="section-number-4">3.3.5</span> Temporary arrays for electron-electron-nucleus Jastrow \(f_{een}\)</h4>
<div class="outline-text-4" id="text-3-3-5">
<p>
Prepare <code>c_vector_full</code> and <code>lkpm_combined_index</code> tables required for the
calculation of the three-body jastrow <code>factor_een</code> and its derivative
<code>factor_een_gl</code>.
</p>
</div>
<div id="outline-container-orgf388bb9" class="outline-5">
<h5 id="orgf388bb9"><span class="section-number-5">3.3.5.1</span> Compute dim<sub>c</sub><sub>vector</sub></h5>
<div class="outline-text-5" id="text-3-3-5-1">
<p>
Computes the dimension of the vector of parameters.
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-right" />
<col class="org-right" />
</colgroup>
<tbody>
<tr>
<td class="org-right">\(N_{ord}\)</td>
<td class="org-right">Number of parameters</td>
</tr>
<tr>
<td class="org-right">&#xa0;</td>
<td class="org-right">&#xa0;</td>
</tr>
<tr>
<td class="org-right">1</td>
<td class="org-right">0</td>
</tr>
<tr>
<td class="org-right">2</td>
<td class="org-right">2</td>
</tr>
<tr>
<td class="org-right">3</td>
<td class="org-right">6</td>
</tr>
<tr>
<td class="org-right">4</td>
<td class="org-right">13</td>
</tr>
<tr>
<td class="org-right">5</td>
<td class="org-right">23</td>
</tr>
<tr>
<td class="org-right">6</td>
<td class="org-right">37</td>
</tr>
<tr>
<td class="org-right">7</td>
<td class="org-right">55</td>
</tr>
<tr>
<td class="org-right">8</td>
<td class="org-right">78</td>
</tr>
<tr>
<td class="org-right">9</td>
<td class="org-right">106</td>
</tr>
<tr>
<td class="org-right">10</td>
<td class="org-right">140</td>
</tr>
</tbody>
</table>
<table id="org7cb34a4" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Order of polynomials</td>
</tr>
<tr>
<td class="org-left"><code>dim_c_vector</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">out</td>
<td class="org-left">Number of parameters per atom type</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_dim_c_vector_f( </span><span style="color: #a020f0;">&amp;</span>
context, cord_num, dim_c_vector) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> cord_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> dim_c_vector</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, a, k, l, p, lmax</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
dim_c_vector = 0
<span style="color: #a020f0;">do</span> p = 2, cord_num
<span style="color: #a020f0;">do</span> k = p - 1, 0, -1
<span style="color: #a020f0;">if</span> (k <span style="color: #a020f0;">.ne.</span> 0) <span style="color: #a020f0;">then</span>
lmax = p - k
<span style="color: #a020f0;">else</span>
lmax = p - k - 2
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> l = lmax, 0, -1
<span style="color: #a020f0;">if</span> (<span style="color: #a020f0;">iand</span>(p - k - l, 1_8) == 1) <span style="color: #a020f0;">cycle</span>
dim_c_vector = dim_c_vector + 1
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_dim_c_vector_f</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orga4fbf71" class="outline-5">
<h5 id="orga4fbf71"><span class="section-number-5">3.3.5.2</span> Get</h5>
<div class="outline-text-5" id="text-3-3-5-2">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_tmp_c</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">tmp_c</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_dtmp_c</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">dtmp_c</span>);
</pre>
</div>
</div>
</div>
<div id="outline-container-org1821673" class="outline-5">
<h5 id="org1821673"><span class="section-number-5">3.3.5.3</span> Compute c<sub>vector</sub><sub>full</sub></h5>
<div class="outline-text-5" id="text-3-3-5-3">
<table id="org7fd3d97" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of atoms</td>
</tr>
<tr>
<td class="org-left"><code>dim_c_vector</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">dimension of cord full table</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">dimension of cord full table</td>
</tr>
<tr>
<td class="org-left"><code>type_nucl_vector</code></td>
<td class="org-left"><code>int64_t[nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">dimension of cord full table</td>
</tr>
<tr>
<td class="org-left"><code>c_vector</code></td>
<td class="org-left"><code>double[dim_c_vector][type_nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">dimension of cord full table</td>
</tr>
<tr>
<td class="org-left"><code>c_vector_full</code></td>
<td class="org-left"><code>double[nucl_num][dim_c_vector]</code></td>
<td class="org-left">out</td>
<td class="org-left">Full list of coefficients</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_c_vector_full_doc_f( </span><span style="color: #a020f0;">&amp;</span>
context, nucl_num, dim_c_vector, type_nucl_num, <span style="color: #a020f0;">&amp;</span>
type_nucl_vector, c_vector, c_vector_full) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> nucl_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> dim_c_vector</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> type_nucl_vector(nucl_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> c_vector(dim_c_vector, type_nucl_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> c_vector_full(nucl_num, dim_c_vector)</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, a, k, l, nw</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">if</span> (dim_c_vector &lt; 0) info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">if</span> (type_nucl_num &lt;= 0) info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">if</span> (info /= QMCKL_SUCCESS) <span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">do</span> a = 1, nucl_num
c_vector_full(a,1:dim_c_vector) = c_vector(1:dim_c_vector, type_nucl_vector(a)+1)
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_c_vector_full_doc_f</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_c_vector_full_hpc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">type_nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">type_nucl_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">c_vector</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">c_vector_full</span> ) {
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">return</span> QMCKL_INVALID_CONTEXT;
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_2;
<span style="color: #a020f0;">if</span> (dim_c_vector &lt; 0) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_3;
<span style="color: #a020f0;">if</span> (type_nucl_num &lt;= 0) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_4;
<span style="color: #a020f0;">if</span> (type_nucl_vector == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_5;
<span style="color: #a020f0;">if</span> (c_vector == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_6;
<span style="color: #a020f0;">if</span> (c_vector_full == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_7;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0; i &lt; dim_c_vector; ++i) {
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">a</span>=0; a &lt; nucl_num; ++a){
c_vector_full[a + i*nucl_num] = c_vector[i + type_nucl_vector[a]*dim_c_vector];
}
}
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_c_vector_full_doc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">type_nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">type_nucl_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">c_vector</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">c_vector_full</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_c_vector_full_hpc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">type_nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">type_nucl_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">c_vector</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">c_vector_full</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_c_vector_full</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">type_nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">type_nucl_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">c_vector</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">c_vector_full</span> ) {
<span style="color: #483d8b;">#ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_c_vector_full_hpc
<span style="color: #483d8b;">#else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_c_vector_full_doc
<span style="color: #483d8b;">#endif</span>
(context, nucl_num, dim_c_vector, type_nucl_num, type_nucl_vector, c_vector, c_vector_full);
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgaace9f3" class="outline-5">
<h5 id="orgaace9f3"><span class="section-number-5">3.3.5.4</span> Compute lkpm<sub>combined</sub><sub>index</sub></h5>
<div class="outline-text-5" id="text-3-3-5-4">
<table id="org1838daf" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Order of polynomials</td>
</tr>
<tr>
<td class="org-left"><code>dim_c_vector</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">dimension of cord full table</td>
</tr>
<tr>
<td class="org-left"><code>lkpm_combined_index</code></td>
<td class="org-left"><code>int64_t[4][dim_c_vector]</code></td>
<td class="org-left">out</td>
<td class="org-left">Full list of combined indices</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_lkpm_combined_index_doc_f( </span><span style="color: #a020f0;">&amp;</span>
context, cord_num, dim_c_vector, lkpm_combined_index) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> cord_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> dim_c_vector</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> lkpm_combined_index(dim_c_vector, 4)</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, a, k, l, kk, p, lmax, m</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">if</span> (dim_c_vector &lt; 0) info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">if</span> (info /= QMCKL_SUCCESS) <span style="color: #a020f0;">return</span>
kk = 0
<span style="color: #a020f0;">do</span> p = 2, cord_num
<span style="color: #a020f0;">do</span> k = p - 1, 0, -1
<span style="color: #a020f0;">if</span> (k /= 0) <span style="color: #a020f0;">then</span>
lmax = p - k
<span style="color: #a020f0;">else</span>
lmax = p - k - 2
<span style="color: #a020f0;">end if</span>
<span style="color: #a020f0;">do</span> l = lmax, 0, -1
<span style="color: #a020f0;">if</span> (<span style="color: #a020f0;">iand</span>(p - k - l, 1_8) <span style="color: #a020f0;">.eq.</span> 1_8) <span style="color: #a020f0;">cycle</span>
m = (p - k - l)/2
kk = kk + 1
lkpm_combined_index(kk, 1) = l
lkpm_combined_index(kk, 2) = k
lkpm_combined_index(kk, 3) = p
lkpm_combined_index(kk, 4) = m
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_lkpm_combined_index_doc_f</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_lkpm_combined_index_hpc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">lkpm_combined_index</span> ) {
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">kk</span>, <span style="color: #a0522d;">lmax</span>, <span style="color: #a0522d;">m</span>;
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">return</span> QMCKL_INVALID_CONTEXT;
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_2;
<span style="color: #a020f0;">if</span> (dim_c_vector &lt; 0) <span style="color: #a020f0;">return</span> QMCKL_INVALID_ARG_3;
kk = 0;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">p</span> = 2; p &lt;= cord_num; ++p) {
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span>=(p-1); k &gt;= 0; --k) {
<span style="color: #a020f0;">if</span> (k != 0) {
lmax = p - k;
} <span style="color: #a020f0;">else</span> {
lmax = p - k - 2;
}
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">l</span>=lmax; l &gt;= 0; --l) {
<span style="color: #a020f0;">if</span> (((p - k - l) &amp; 1) == 1) <span style="color: #a020f0;">continue</span>;
m = (p - k - l)/2;
lkpm_combined_index[kk ] = l;
lkpm_combined_index[kk + dim_c_vector] = k;
lkpm_combined_index[kk + 2*dim_c_vector] = p;
lkpm_combined_index[kk + 3*dim_c_vector] = m;
kk = kk + 1;
}
}
}
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_lkpm_combined_index</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">lkpm_combined_index</span> ) {
<span style="color: #483d8b;"> #ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_lkpm_combined_index_hpc
<span style="color: #483d8b;"> #else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_lkpm_combined_index_doc
<span style="color: #483d8b;"> #endif</span>
(context, cord_num, dim_c_vector, lkpm_combined_index);
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_lkpm_combined_index</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">lkpm_combined_index</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_lkpm_combined_index_doc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">lkpm_combined_index</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_lkpm_combined_index_hpc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">lkpm_combined_index</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_lkpm_combined_index</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">lkpm_combined_index</span> );
</pre>
</div>
</div>
</div>
<div id="outline-container-org0568c87" class="outline-5">
<h5 id="org0568c87"><span class="section-number-5">3.3.5.5</span> Compute tmp<sub>c</sub></h5>
<div class="outline-text-5" id="text-3-3-5-5">
<table id="orgfcbb6bb" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Order of polynomials</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_e</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][elec_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-electron rescaled factor</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][nucl_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus rescaled factor</td>
</tr>
<tr>
<td class="org-left"><code>tmp_c</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">vector of non-zero coefficients</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_tmp_c</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_e</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_n</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">tmp_c</span> )
{
<span style="color: #483d8b;">#ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_tmp_c_hpc
<span style="color: #483d8b;">#else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_tmp_c_doc
<span style="color: #483d8b;">#endif</span>
(context, cord_num, elec_num, nucl_num, walk_num,
een_rescaled_e, een_rescaled_n, tmp_c);
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_tmp_c_doc_f( </span><span style="color: #a020f0;">&amp;</span>
context, cord_num, elec_num, nucl_num, <span style="color: #a020f0;">&amp;</span>
walk_num, een_rescaled_e, een_rescaled_n, tmp_c) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> cord_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> nucl_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_e(elec_num, elec_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_n(elec_num, nucl_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> tmp_c(elec_num, nucl_num,0:cord_num, 0:cord_num-1, walk_num)</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, j, a, l, kk, p, lmax, nw</span>
<span style="color: #228b22;">character</span> ::<span style="color: #a0522d;"> TransA, TransB</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> alpha, beta</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> M, N, K, LDA, LDB, LDC</span>
TransA = <span style="color: #8b2252;">'N'</span>
TransB = <span style="color: #8b2252;">'N'</span>
alpha = 1.0d0
beta = 0.0d0
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) info = QMCKL_INVALID_ARG_5
<span style="color: #a020f0;">if</span> (info /= QMCKL_SUCCESS) <span style="color: #a020f0;">return</span>
M = elec_num
N = nucl_num*(cord_num + 1)
K = elec_num
LDA = <span style="color: #a020f0;">size</span>(een_rescaled_e,1)
LDB = <span style="color: #a020f0;">size</span>(een_rescaled_n,1)
LDC = <span style="color: #a020f0;">size</span>(tmp_c,1)
<span style="color: #a020f0;">do</span> nw=1, walk_num
<span style="color: #a020f0;">do</span> i=0, cord_num-1
info = qmckl_dgemm(context, TransA, TransB, M, N, K, alpha, <span style="color: #a020f0;">&amp;</span>
een_rescaled_e(1,1,i,nw),LDA*1_8, <span style="color: #a020f0;">&amp;</span>
een_rescaled_n(1,1,0,nw),LDB*1_8, <span style="color: #a020f0;">&amp;</span>
beta, <span style="color: #a020f0;">&amp;</span>
tmp_c(1,1,0,i,nw),LDC)
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_tmp_c_doc_f</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_tmp_c_doc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_e</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_n</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">tmp_c</span> );
</pre>
</div>
</div>
</div>
<div id="outline-container-org4e804a3" class="outline-5">
<h5 id="org4e804a3"><span class="section-number-5">3.3.5.6</span> Compute dtmp<sub>c</sub></h5>
<div class="outline-text-5" id="text-3-3-5-6">
<table id="org02c252e" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Order of polynomials</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_e_gl</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][elec_num][4][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-electron rescaled factor derivatives</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][nucl_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus rescaled factor</td>
</tr>
<tr>
<td class="org-left"><code>dtmp_c</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">vector of non-zero coefficients</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_compute_dtmp_c</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_e_gl</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_n</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">dtmp_c</span> )
{
<span style="color: #483d8b;">#ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_dtmp_c_hpc
<span style="color: #483d8b;">#else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_dtmp_c_doc
<span style="color: #483d8b;">#endif</span>
(context, cord_num, elec_num, nucl_num, walk_num, een_rescaled_e_gl,
een_rescaled_n, dtmp_c );
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_dtmp_c_doc_f( </span><span style="color: #a020f0;">&amp;</span>
context, cord_num, elec_num, nucl_num, <span style="color: #a020f0;">&amp;</span>
walk_num, een_rescaled_e_gl, een_rescaled_n, dtmp_c) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> cord_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> elec_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> nucl_num</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_e_gl(elec_num, 4, elec_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_n(elec_num, nucl_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> dtmp_c(elec_num, 4, nucl_num,0:cord_num, 0:cord_num-1, walk_num)</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> x</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, j, a, l, kk, p, lmax, nw, ii</span>
<span style="color: #228b22;">character</span> ::<span style="color: #a0522d;"> TransA, TransB</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> alpha, beta</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> M, N, K, LDA, LDB, LDC</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) info = QMCKL_INVALID_ARG_5
<span style="color: #a020f0;">if</span> (info /= QMCKL_SUCCESS) <span style="color: #a020f0;">return</span>
TransA = <span style="color: #8b2252;">'N'</span>
TransB = <span style="color: #8b2252;">'N'</span>
alpha = 1.0d0
beta = 0.0d0
M = 4*elec_num
N = nucl_num*(cord_num + 1)
K = elec_num
LDA = 4*<span style="color: #a020f0;">size</span>(een_rescaled_e_gl,1)
LDB = <span style="color: #a020f0;">size</span>(een_rescaled_n,1)
LDC = 4*<span style="color: #a020f0;">size</span>(dtmp_c,1)
<span style="color: #a020f0;">do</span> nw=1, walk_num
<span style="color: #a020f0;">do</span> i=0, cord_num-1
info = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, <span style="color: #a020f0;">&amp;</span>
een_rescaled_e_gl(1,1,1,i,nw),LDA*1_8, <span style="color: #a020f0;">&amp;</span>
een_rescaled_n(1,1,0,nw),LDB*1_8, <span style="color: #a020f0;">&amp;</span>
beta, <span style="color: #a020f0;">&amp;</span>
dtmp_c(1,1,1,0,i,nw),LDC)
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_dtmp_c_doc_f</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgf1e9aac" class="outline-5">
<h5 id="orgf1e9aac"><span class="section-number-5">3.3.5.7</span> Test</h5>
<div class="outline-text-5" id="text-3-3-5-7">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_electron_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">tmp_c</span>[walk_num][cord_num][cord_num+1][nucl_num][elec_num];
rc = qmckl_get_jastrow_champ_tmp_c(context, &amp;(tmp_c[0][0][0][0][0]));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">dtmp_c</span>[walk_num][cord_num][cord_num+1][nucl_num][4][elec_num];
rc = qmckl_get_jastrow_champ_dtmp_c(context, &amp;(dtmp_c[0][0][0][0][0][0]));
printf(<span style="color: #8b2252;">"%e\n%e\n"</span>, tmp_c[0][0][1][0][0], 3.954384);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">tmp_c</span>[0][0][1][0][0] - 3.954384) &lt; 1e-6);
printf(<span style="color: #8b2252;">"%e\n%e\n"</span>, dtmp_c[0][1][0][0][0][0],3.278657e-01);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">dtmp_c</span>[0][1][0][0][0][0] - 3.278657e-01 ) &lt; 1e-6);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org418b4f4" class="outline-4">
<h4 id="org418b4f4"><span class="section-number-4">3.3.6</span> Electron-electron-nucleus Jastrow \(f_{een}\)</h4>
<div class="outline-text-4" id="text-3-3-6">
<p>
Calculate the electron-electron-nuclear three-body jastrow component <code>factor_een</code>
using the above prepared tables.
</p>
<p>
TODO: write equations.
</p>
</div>
<div id="outline-container-org09fdec0" class="outline-5">
<h5 id="org09fdec0"><span class="section-number-5">3.3.6.1</span> Get</h5>
<div class="outline-text-5" id="text-3-3-6-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_factor_een</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_een</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
<ol class="org-ol">
<li><a id="orgedbd3aa"></a>Fortran interface<br />
<div class="outline-text-6" id="text-3-3-6-1-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">interface</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_factor_een (context, </span><span style="color: #a020f0;">&amp;</span>
factor_een, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_een(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_factor_een</span>
<span style="color: #a020f0;">end interface</span>
</pre>
</div>
</div>
</li>
</ol>
</div>
<div id="outline-container-orgea21787" class="outline-5">
<h5 id="orgea21787"><span class="section-number-5">3.3.6.2</span> Compute naive</h5>
<div class="outline-text-5" id="text-3-3-6-2">
<table id="orgbcfeda6" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">order of polynomials</td>
</tr>
<tr>
<td class="org-left"><code>dim_c_vector</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">dimension of full coefficient vector</td>
</tr>
<tr>
<td class="org-left"><code>c_vector_full</code></td>
<td class="org-left"><code>double[dim_c_vector][nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">full coefficient vector</td>
</tr>
<tr>
<td class="org-left"><code>lkpm_combined_index</code></td>
<td class="org-left"><code>int64_t[4][dim_c_vector]</code></td>
<td class="org-left">in</td>
<td class="org-left">combined indices</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_e</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][elec_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus rescaled</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][nucl_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus rescaled factor</td>
</tr>
<tr>
<td class="org-left"><code>factor_een</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-nucleus jastrow</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_jastrow_champ_factor_een_naive_f( </span><span style="color: #a020f0;">&amp;</span>
context, walk_num, elec_num, nucl_num, cord_num,<span style="color: #a020f0;">&amp;</span>
dim_c_vector, c_vector_full, lkpm_combined_index, <span style="color: #a020f0;">&amp;</span>
een_rescaled_e, een_rescaled_n, factor_een) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num, elec_num, cord_num, nucl_num, dim_c_vector</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> lkpm_combined_index(dim_c_vector,4)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> c_vector_full(nucl_num, dim_c_vector)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_e(elec_num, elec_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_n(elec_num, nucl_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_een(walk_num)</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, a, j, l, k, p, m, n, nw</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> accu, accu2, cn</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) info = QMCKL_INVALID_ARG_5
<span style="color: #a020f0;">if</span> (info /= QMCKL_SUCCESS) <span style="color: #a020f0;">return</span>
! <span style="color: #b22222;">do nw =1, walk_num</span>
! <span style="color: #b22222;">factor_een(nw) = 0.0d0</span>
! <span style="color: #b22222;">do n = 1, dim_c_vector</span>
! <span style="color: #b22222;">l = lkpm_combined_index(n, 1)</span>
! <span style="color: #b22222;">k = lkpm_combined_index(n, 2)</span>
! <span style="color: #b22222;">p = lkpm_combined_index(n, 3)</span>
! <span style="color: #b22222;">m = lkpm_combined_index(n, 4)</span>
! <span style="color: #b22222;">do a = 1, nucl_num</span>
! <span style="color: #b22222;">accu2 = 0.0d0</span>
! <span style="color: #b22222;">cn = c_vector_full(a, n)</span>
! <span style="color: #b22222;">do j = 1, elec_num</span>
! <span style="color: #b22222;">accu = 0.0d0</span>
! <span style="color: #b22222;">do i = 1, elec_num</span>
! <span style="color: #b22222;">accu = accu + een_rescaled_e(i,j,k,nw) * &amp;</span>
! <span style="color: #b22222;">een_rescaled_n(i,a,m,nw)</span>
! <span style="color: #b22222;">end do</span>
! <span style="color: #b22222;">accu2 = accu2 + accu * een_rescaled_n(j,a,m + l,nw)</span>
! <span style="color: #b22222;">end do</span>
! <span style="color: #b22222;">factor_een(nw) = factor_een(nw) + accu2 * cn</span>
! <span style="color: #b22222;">end do</span>
! <span style="color: #b22222;">end do</span>
! <span style="color: #b22222;">end do</span>
<span style="color: #a020f0;">do</span> nw =1, walk_num
factor_een(nw) = 0.d0
<span style="color: #a020f0;">do</span> n = 1, dim_c_vector
l = lkpm_combined_index(n, 1)
k = lkpm_combined_index(n, 2)
p = lkpm_combined_index(n, 3)
m = lkpm_combined_index(n, 4)
<span style="color: #a020f0;">do</span> a = 1, nucl_num
accu2 = 0.0d0
cn = c_vector_full(a, n)
<span style="color: #a020f0;">print</span> *, a, l, k, p, cn
<span style="color: #a020f0;">do</span> j = 1, elec_num
accu = 0.0d0
<span style="color: #a020f0;">do</span> i = 1, j-1
accu = accu + een_rescaled_e(i,j,k,nw) * <span style="color: #a020f0;">&amp;</span>
(een_rescaled_n(i,a,l,nw) + een_rescaled_n(j,a,l,nw)) * <span style="color: #a020f0;">&amp;</span>
(een_rescaled_n(i,a,m,nw) * een_rescaled_n(j,a,m,nw))
<span style="color: #a020f0;">end do</span>
accu2 = accu2 + accu
<span style="color: #a020f0;">end do</span>
factor_een(nw) = factor_een(nw) + accu2 * cn
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_een_naive_f</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org8c9bae6" class="outline-5">
<h5 id="org8c9bae6"><span class="section-number-5">3.3.6.3</span> Compute</h5>
<div class="outline-text-5" id="text-3-3-6-3">
<table id="orgfa26119" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">order of polynomials</td>
</tr>
<tr>
<td class="org-left"><code>dim_c_vector</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">dimension of full coefficient vector</td>
</tr>
<tr>
<td class="org-left"><code>c_vector_full</code></td>
<td class="org-left"><code>double[dim_c_vector][nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">full coefficient vector</td>
</tr>
<tr>
<td class="org-left"><code>lkpm_combined_index</code></td>
<td class="org-left"><code>int64_t[4][dim_c_vector]</code></td>
<td class="org-left">in</td>
<td class="org-left">combined indices</td>
</tr>
<tr>
<td class="org-left"><code>tmp_c</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">vector of non-zero coefficients</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][nucl_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus rescaled distances</td>
</tr>
<tr>
<td class="org-left"><code>factor_een</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-nucleus jastrow</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_jastrow_champ_factor_een_doc_f( </span><span style="color: #a020f0;">&amp;</span>
context, walk_num, elec_num, nucl_num, cord_num, <span style="color: #a020f0;">&amp;</span>
dim_c_vector, c_vector_full, lkpm_combined_index, <span style="color: #a020f0;">&amp;</span>
tmp_c, een_rescaled_n, factor_een) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num, elec_num, cord_num, nucl_num, dim_c_vector</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> lkpm_combined_index(dim_c_vector,4)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> c_vector_full(nucl_num, dim_c_vector)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> tmp_c(elec_num, nucl_num,0:cord_num, 0:cord_num-1, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_n(elec_num, nucl_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_een(walk_num)</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, a, j, l, k, p, m, n, nw</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> accu, accu2, cn</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) info = QMCKL_INVALID_ARG_5
<span style="color: #a020f0;">if</span> (info /= QMCKL_SUCCESS) <span style="color: #a020f0;">return</span>
factor_een = 0.0d0
<span style="color: #a020f0;">if</span> (cord_num == 0) <span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">do</span> nw =1, walk_num
<span style="color: #a020f0;">do</span> n = 1, dim_c_vector
l = lkpm_combined_index(n, 1)
k = lkpm_combined_index(n, 2)
p = lkpm_combined_index(n, 3)
m = lkpm_combined_index(n, 4)
<span style="color: #a020f0;">do</span> a = 1, nucl_num
cn = c_vector_full(a, n)
<span style="color: #a020f0;">if</span>(cn == 0.d0) <span style="color: #a020f0;">cycle</span>
accu = 0.0d0
<span style="color: #a020f0;">do</span> j = 1, elec_num
accu = accu + een_rescaled_n(j,a,m,nw) * tmp_c(j,a,m+l,k,nw)
<span style="color: #a020f0;">end do</span>
factor_een(nw) = factor_een(nw) + accu * cn
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_een_doc_f</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org41d0527" class="outline-5">
<h5 id="org41d0527"><span class="section-number-5">3.3.6.4</span> Test</h5>
<div class="outline-text-5" id="text-3-3-6-4">
<div class="org-src-container">
<pre class="src src-c">/* <span style="color: #b22222;">Check if Jastrow is properly initialized</span> */
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_jastrow_champ_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">factor_een</span>[walk_num];
rc = qmckl_get_jastrow_champ_factor_een(context, &amp;(factor_een[0]),walk_num);
<span style="color: #0000ff;">assert</span>(fabs(<span style="color: #228b22;">factor_een</span>[0] + 0.382580260174321) &lt; 1e-12);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgb5b0459" class="outline-4">
<h4 id="orgb5b0459"><span class="section-number-4">3.3.7</span> Electron-electron-nucleus Jastrow \(f_{een}\) derivative</h4>
<div class="outline-text-4" id="text-3-3-7">
<p>
Calculate the electron-electron-nuclear three-body jastrow component <code>factor_een_gl</code>
using the above prepared tables.
</p>
<p>
TODO: write equations.
</p>
</div>
<div id="outline-container-org218988d" class="outline-5">
<h5 id="org218988d"><span class="section-number-5">3.3.7.1</span> Get</h5>
<div class="outline-text-5" id="text-3-3-7-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_factor_een_gl</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_een_gl</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
<ol class="org-ol">
<li><a id="orgf6abb9e"></a>Fortran interface<br />
<div class="outline-text-6" id="text-3-3-7-1-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">interface</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_factor_een_gl (context, </span><span style="color: #a020f0;">&amp;</span>
factor_een_gl, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_een_gl(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_factor_een_gl</span>
<span style="color: #a020f0;">end interface</span>
</pre>
</div>
</div>
</li>
</ol>
</div>
<div id="outline-container-orgc1a7cbc" class="outline-5">
<h5 id="orgc1a7cbc"><span class="section-number-5">3.3.7.2</span> Compute Naive</h5>
<div class="outline-text-5" id="text-3-3-7-2">
<table id="org79d95c8" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">order of polynomials</td>
</tr>
<tr>
<td class="org-left"><code>dim_c_vector</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">dimension of full coefficient vector</td>
</tr>
<tr>
<td class="org-left"><code>c_vector_full</code></td>
<td class="org-left"><code>double[dim_c_vector][nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">full coefficient vector</td>
</tr>
<tr>
<td class="org-left"><code>lkpm_combined_index</code></td>
<td class="org-left"><code>int64_t[4][dim_c_vector]</code></td>
<td class="org-left">in</td>
<td class="org-left">combined indices</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_e</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][elec_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus rescaled</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][nucl_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus rescaled factor</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_e_gl</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][elec_num][4][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus rescaled</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n_gl</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][nucl_num][4][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus rescaled factor</td>
</tr>
<tr>
<td class="org-left"><code>factor_een_gl</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Electron-nucleus jastrow</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_jastrow_champ_factor_een_gl_naive_f( </span><span style="color: #a020f0;">&amp;</span>
context, walk_num, elec_num, nucl_num, cord_num, dim_c_vector, <span style="color: #a020f0;">&amp;</span>
c_vector_full, lkpm_combined_index, een_rescaled_e, een_rescaled_n, <span style="color: #a020f0;">&amp;</span>
een_rescaled_e_gl, een_rescaled_n_gl, factor_een_gl)<span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num, elec_num, cord_num, nucl_num, dim_c_vector</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> lkpm_combined_index(dim_c_vector, 4)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> c_vector_full(nucl_num, dim_c_vector)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_e(elec_num, elec_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_n(elec_num, nucl_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_e_gl(elec_num, 4, elec_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_n_gl(elec_num, 4, nucl_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_een_gl(elec_num, 4, walk_num)</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, a, j, l, k, p, m, n, nw</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> accu, accu2, cn</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> daccu(1:4), daccu2(1:4)</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) info = QMCKL_INVALID_ARG_5
<span style="color: #a020f0;">if</span> (info /= QMCKL_SUCCESS) <span style="color: #a020f0;">return</span>
factor_een_gl = 0.0d0
<span style="color: #a020f0;">do</span> nw =1, walk_num
<span style="color: #a020f0;">do</span> n = 1, dim_c_vector
l = lkpm_combined_index(n, 1)
k = lkpm_combined_index(n, 2)
p = lkpm_combined_index(n, 3)
m = lkpm_combined_index(n, 4)
<span style="color: #a020f0;">do</span> a = 1, nucl_num
cn = c_vector_full(a, n)
<span style="color: #a020f0;">do</span> j = 1, elec_num
accu = 0.0d0
accu2 = 0.0d0
daccu = 0.0d0
daccu2 = 0.0d0
<span style="color: #a020f0;">do</span> i = 1, elec_num
accu = accu + een_rescaled_e(i, j, k, nw) * een_rescaled_n(i, a, m, nw)
accu2 = accu2 + een_rescaled_e(i, j, k, nw) * een_rescaled_n(i, a, m + l, nw)
daccu(1:4) = daccu(1:4) + een_rescaled_e_gl(j, 1:4, i, k, nw) * <span style="color: #a020f0;">&amp;</span>
een_rescaled_n(i, a, m, nw)
daccu2(1:4) = daccu2(1:4) + een_rescaled_e_gl(j, 1:4, i, k, nw) * <span style="color: #a020f0;">&amp;</span>
een_rescaled_n(i, a, m + l, nw)
<span style="color: #a020f0;">end do</span>
factor_een_gl(j, 1:4, nw) = factor_een_gl(j, 1:4, nw) + <span style="color: #a020f0;">&amp;</span>
(accu * een_rescaled_n_gl(j, 1:4, a, m + l, nw) <span style="color: #a020f0;">&amp;</span>
+ daccu(1:4) * een_rescaled_n(j, a, m + l, nw) <span style="color: #a020f0;">&amp;</span>
+ daccu2(1:4) * een_rescaled_n(j, a, m, nw) <span style="color: #a020f0;">&amp;</span>
+ accu2 * een_rescaled_n_gl(j, 1:4, a, m, nw)) * cn
factor_een_gl(j, 4, nw) = factor_een_gl(j, 4, nw) + 2.0d0 * ( <span style="color: #a020f0;">&amp;</span>
daccu (1) * een_rescaled_n_gl(j, 1, a, m + l, nw) + <span style="color: #a020f0;">&amp;</span>
daccu (2) * een_rescaled_n_gl(j, 2, a, m + l, nw) + <span style="color: #a020f0;">&amp;</span>
daccu (3) * een_rescaled_n_gl(j, 3, a, m + l, nw) + <span style="color: #a020f0;">&amp;</span>
daccu2(1) * een_rescaled_n_gl(j, 1, a, m, nw ) + <span style="color: #a020f0;">&amp;</span>
daccu2(2) * een_rescaled_n_gl(j, 2, a, m, nw ) + <span style="color: #a020f0;">&amp;</span>
daccu2(3) * een_rescaled_n_gl(j, 3, a, m, nw ) ) * cn
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_een_gl_naive_f</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgaa84f73" class="outline-5">
<h5 id="orgaa84f73"><span class="section-number-5">3.3.7.3</span> Compute</h5>
<div class="outline-text-5" id="text-3-3-7-3">
<table id="orgf983866" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>nucl_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of nuclei</td>
</tr>
<tr>
<td class="org-left"><code>cord_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">order of polynomials</td>
</tr>
<tr>
<td class="org-left"><code>dim_c_vector</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">dimension of full coefficient vector</td>
</tr>
<tr>
<td class="org-left"><code>c_vector_full</code></td>
<td class="org-left"><code>double[dim_c_vector][nucl_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">full coefficient vector</td>
</tr>
<tr>
<td class="org-left"><code>lkpm_combined_index</code></td>
<td class="org-left"><code>int64_t[4][dim_c_vector]</code></td>
<td class="org-left">in</td>
<td class="org-left">combined indices</td>
</tr>
<tr>
<td class="org-left"><code>tmp_c</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Temporary intermediate tensor</td>
</tr>
<tr>
<td class="org-left"><code>dtmp_c</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num-1][0:cord_num][nucl_num][4][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">vector of non-zero coefficients</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][nucl_num][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Electron-nucleus rescaled factor</td>
</tr>
<tr>
<td class="org-left"><code>een_rescaled_n_gl</code></td>
<td class="org-left"><code>double[walk_num][0:cord_num][nucl_num][4][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Derivative of Electron-nucleus rescaled factor</td>
</tr>
<tr>
<td class="org-left"><code>factor_een_gl</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Derivative of Electron-nucleus jastrow</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_jastrow_champ_factor_een_gl_doc_f( </span><span style="color: #a020f0;">&amp;</span>
context, walk_num, elec_num, nucl_num, <span style="color: #a020f0;">&amp;</span>
cord_num, dim_c_vector, c_vector_full, lkpm_combined_index, <span style="color: #a020f0;">&amp;</span>
tmp_c, dtmp_c, een_rescaled_n, een_rescaled_n_gl, factor_een_gl)<span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num, elec_num, cord_num, nucl_num, dim_c_vector</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> lkpm_combined_index(dim_c_vector,4)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> c_vector_full(nucl_num, dim_c_vector)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> tmp_c(elec_num, nucl_num,0:cord_num, 0:cord_num-1, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> dtmp_c(elec_num, 4, nucl_num,0:cord_num, 0:cord_num-1, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_n(elec_num, nucl_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> een_rescaled_n_gl(elec_num, 4, nucl_num, 0:cord_num, walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> factor_een_gl(elec_num,4,walk_num)</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, a, j, l, k, m, n, nw, ii</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> accu, accu2, cn</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">if</span> (elec_num &lt;= 0) info = QMCKL_INVALID_ARG_3
<span style="color: #a020f0;">if</span> (nucl_num &lt;= 0) info = QMCKL_INVALID_ARG_4
<span style="color: #a020f0;">if</span> (cord_num &lt; 0) info = QMCKL_INVALID_ARG_5
<span style="color: #a020f0;">if</span> (info /= QMCKL_SUCCESS) <span style="color: #a020f0;">return</span>
factor_een_gl = 0.0d0
<span style="color: #a020f0;">if</span> (cord_num == 0) <span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">do</span> nw =1, walk_num
<span style="color: #a020f0;">do</span> n = 1, dim_c_vector
l = lkpm_combined_index(n, 1)
k = lkpm_combined_index(n, 2)
m = lkpm_combined_index(n, 4)
<span style="color: #a020f0;">do</span> a = 1, nucl_num
cn = c_vector_full(a, n)
<span style="color: #a020f0;">if</span>(cn == 0.d0) <span style="color: #a020f0;">cycle</span>
<span style="color: #a020f0;">do</span> ii = 1, 4
<span style="color: #a020f0;">do</span> j = 1, elec_num
factor_een_gl(j,ii,nw) = factor_een_gl(j,ii,nw) + ( <span style="color: #a020f0;">&amp;</span>
tmp_c(j,a,m,k,nw) * een_rescaled_n_gl(j,ii,a,m+l,nw) + <span style="color: #a020f0;">&amp;</span>
(dtmp_c(j,ii,a,m,k,nw)) * een_rescaled_n(j,a,m+l,nw) + <span style="color: #a020f0;">&amp;</span>
(dtmp_c(j,ii,a,m+l,k,nw)) * een_rescaled_n(j,a,m ,nw) + <span style="color: #a020f0;">&amp;</span>
tmp_c(j,a,m+l,k,nw) * een_rescaled_n_gl(j,ii,a,m,nw) <span style="color: #a020f0;">&amp;</span>
) * cn
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
cn = cn + cn
<span style="color: #a020f0;">do</span> j = 1, elec_num
factor_een_gl(j,4,nw) = factor_een_gl(j,4,nw) + ( <span style="color: #a020f0;">&amp;</span>
(dtmp_c(j,1,a,m ,k,nw)) * een_rescaled_n_gl(j,1,a,m+l,nw) + <span style="color: #a020f0;">&amp;</span>
(dtmp_c(j,2,a,m ,k,nw)) * een_rescaled_n_gl(j,2,a,m+l,nw) + <span style="color: #a020f0;">&amp;</span>
(dtmp_c(j,3,a,m ,k,nw)) * een_rescaled_n_gl(j,3,a,m+l,nw) + <span style="color: #a020f0;">&amp;</span>
(dtmp_c(j,1,a,m+l,k,nw)) * een_rescaled_n_gl(j,1,a,m ,nw) + <span style="color: #a020f0;">&amp;</span>
(dtmp_c(j,2,a,m+l,k,nw)) * een_rescaled_n_gl(j,2,a,m ,nw) + <span style="color: #a020f0;">&amp;</span>
(dtmp_c(j,3,a,m+l,k,nw)) * een_rescaled_n_gl(j,3,a,m ,nw) <span style="color: #a020f0;">&amp;</span>
) * cn
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_een_gl_doc_f</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_een_gl_doc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">c_vector_full</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">lkpm_combined_index</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">tmp_c</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">dtmp_c</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_n</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_n_gl</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_een_gl</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_een_gl</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">c_vector_full</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">lkpm_combined_index</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">tmp_c</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">dtmp_c</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_n</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">een_rescaled_n_gl</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_een_gl</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_compute_jastrow_champ_factor_een_gl</span>(<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">cord_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dim_c_vector</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> *<span style="color: #a0522d;">c_vector_full</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> *<span style="color: #a0522d;">lkpm_combined_index</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> *<span style="color: #a0522d;">tmp_c</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> *<span style="color: #a0522d;">dtmp_c</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> *<span style="color: #a0522d;">een_rescaled_n</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span> *<span style="color: #a0522d;">een_rescaled_n_gl</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">factor_een_gl</span>)
{
<span style="color: #483d8b;">#ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_factor_een_gl_hpc
<span style="color: #483d8b;">#else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_factor_een_gl_doc
<span style="color: #483d8b;">#endif</span>
(context, walk_num, elec_num, nucl_num,
cord_num, dim_c_vector, c_vector_full,
lkpm_combined_index, tmp_c, dtmp_c,
een_rescaled_n, een_rescaled_n_gl,
factor_een_gl);
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgc167f66" class="outline-5">
<h5 id="orgc167f66"><span class="section-number-5">3.3.7.4</span> Test</h5>
<div class="outline-text-5" id="text-3-3-7-4">
<div class="org-src-container">
<pre class="src src-c">/* <span style="color: #b22222;">Check if Jastrow is properly initialized</span> */
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_jastrow_champ_provided</span>(<span style="color: #a0522d;">context</span>));
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">factor_een_gl</span>[4][walk_num][elec_num];
rc = qmckl_get_jastrow_champ_factor_een_gl(context, &amp;(factor_een_gl[0][0][0]),4*walk_num*elec_num);
printf(<span style="color: #8b2252;">"%20.15e\n"</span>, factor_een_gl[0][0][0]);
<span style="color: #0000ff;">assert</span>(fabs(8.967809309100624e-02 - factor_een_gl[0][0][0]) &lt; 1e-12);
printf(<span style="color: #8b2252;">"%20.15e\n"</span>, factor_een_gl[1][0][1]);
<span style="color: #0000ff;">assert</span>(fabs(3.543090132452453e-02 - factor_een_gl[1][0][1]) &lt; 1e-12);
printf(<span style="color: #8b2252;">"%20.15e\n"</span>, factor_een_gl[2][0][2]);
<span style="color: #0000ff;">assert</span>(fabs(8.996044894431991e-04 - factor_een_gl[2][0][2]) &lt; 1e-12);
printf(<span style="color: #8b2252;">"%20.15e\n"</span>, factor_een_gl[3][0][3]);
<span style="color: #0000ff;">assert</span>(fabs(-1.175028308456619e+00 - factor_een_gl[3][0][3]) &lt; 1e-12);
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="outline-container-orgecb8240" class="outline-3">
<h3 id="orgecb8240"><span class="section-number-3">3.4</span> Total Jastrow</h3>
<div class="outline-text-3" id="text-3-4">
</div>
<div id="outline-container-org5c76e07" class="outline-4">
<h4 id="org5c76e07"><span class="section-number-4">3.4.1</span> Value</h4>
<div class="outline-text-4" id="text-3-4-1">
<p>
Value of the total Jastrow factor: \(\exp(J)\)
</p>
</div>
<div id="outline-container-org367ad74" class="outline-5">
<h5 id="org367ad74"><span class="section-number-5">3.4.1.1</span> Get</h5>
<div class="outline-text-5" id="text-3-4-1-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_value</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">value</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
<ol class="org-ol">
<li><a id="org2df5c5a"></a>Fortran interface<br />
<div class="outline-text-6" id="text-3-4-1-1-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">interface</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_value (context, </span><span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">value</span>, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> value(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_value</span>
<span style="color: #a020f0;">end interface</span>
</pre>
</div>
</div>
</li>
</ol>
</div>
<div id="outline-container-orgbec2a58" class="outline-5">
<h5 id="orgbec2a58"><span class="section-number-5">3.4.1.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-4-1-2">
<table id="org5fe2caf" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>f_ee</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">ee component</td>
</tr>
<tr>
<td class="org-left"><code>f_en</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">eN component</td>
</tr>
<tr>
<td class="org-left"><code>f_een</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">eeN component</td>
</tr>
<tr>
<td class="org-left"><code>value</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Total Jastrow factor</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_jastrow_champ_value_doc_f(context, </span><span style="color: #a020f0;">&amp;</span>
walk_num, f_ee, f_en, f_een, <span style="color: #a020f0;">value</span>) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> f_ee(walk_num), f_en(walk_num), f_een(walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> value(walk_num)</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> i = 1, walk_num
<span style="color: #a020f0;">value</span>(i) = f_ee(i) + f_en(i) + f_een(i)
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">do</span> i = 1, walk_num
! <span style="color: #b22222;">Flush to zero to avoid floating-point exception</span>
<span style="color: #a020f0;">if</span> (<span style="color: #a020f0;">value</span>(i) &lt; -100.d0) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">value</span>(i) = 0.d0
<span style="color: #a020f0;">else</span>
<span style="color: #a020f0;">value</span>(i) = dexp(<span style="color: #a020f0;">value</span>(i))
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_value_doc_f</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_value</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">f_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">f_en</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">f_een</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">value</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_value_doc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">f_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">f_en</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">f_een</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">value</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_value_hpc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">f_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">f_en</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">f_een</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">value</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_value</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">factor_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">factor_en</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">factor_een</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">value</span>)
{
<span style="color: #483d8b;">#ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_value_hpc
<span style="color: #483d8b;">#else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_value_doc
<span style="color: #483d8b;">#endif</span>
(context, walk_num, factor_ee, factor_en, factor_een, value);
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org29cd2a7" class="outline-5">
<h5 id="org29cd2a7"><span class="section-number-5">3.4.1.3</span> Test</h5>
<div class="outline-text-5" id="text-3-4-1-3">
<div class="org-src-container">
<pre class="src src-c">printf(<span style="color: #8b2252;">"Total Jastrow value\n"</span>);
/* <span style="color: #b22222;">Check if Jastrow is properly initialized</span> */
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_jastrow_champ_provided</span>(<span style="color: #a0522d;">context</span>));
rc = qmckl_check(context,
qmckl_get_jastrow_champ_factor_ee(context, &amp;(factor_ee[0]), walk_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_get_jastrow_champ_factor_en(context, &amp;(factor_en[0]), walk_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_get_jastrow_champ_factor_een(context, &amp;(factor_een[0]), walk_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">total_j</span>[walk_num];
rc = qmckl_check(context,
qmckl_get_jastrow_champ_value(context, &amp;(total_j[0]), walk_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt; walk_num ; ++i) {
assert (total_j[i] - exp(factor_ee[i] + factor_en[i] + factor_een[i]) &lt; 1.e-12);
}
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org4debb3f" class="outline-4">
<h4 id="org4debb3f"><span class="section-number-4">3.4.2</span> Derivatives</h4>
<div class="outline-text-4" id="text-3-4-2">
<p>
Gradients and Laplacian of the total Jastrow factor:
\[
\nabla \left[ e^{J(\mathbf{r})} \right] = e^{J(\mathbf{r})} \nabla J(\mathbf{r})
\]
\[
\Delta \left[ e^{J(\mathbf{r})} \right] = e^{J(\mathbf{r})}
\left[ \Delta J(\mathbf{r}) + \nabla J(\mathbf{r}) \cdot \nabla J(\mathbf{r}) \right]
\]
</p>
</div>
<div id="outline-container-org5416142" class="outline-5">
<h5 id="org5416142"><span class="section-number-5">3.4.2.1</span> Get</h5>
<div class="outline-text-5" id="text-3-4-2-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_get_jastrow_champ_gl</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">gl</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
</div>
<ol class="org-ol">
<li><a id="org0daadb7"></a>Fortran interface<br />
<div class="outline-text-6" id="text-3-4-2-1-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">interface</span>
<span style="color: #228b22;">integer</span>(qmckl_exit_code)<span style="color: #a0522d;"> function qmckl_get_jastrow_champ_gl (context, </span><span style="color: #a020f0;">&amp;</span>
gl, size_max) <span style="color: #a020f0;">bind</span>(C)
<span style="color: #a020f0;">use</span>, <span style="color: #a020f0;">intrinsic</span> :: <span style="color: #0000ff;">iso_c_binding</span>
<span style="color: #a020f0;">import</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span> (qmckl_context) , <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>(<span style="color: #008b8b;">c_int64_t</span>), <span style="color: #a020f0;">intent</span>(in), <span style="color: #a020f0;">value</span> ::<span style="color: #a0522d;"> size_max</span>
<span style="color: #228b22;">real</span>(<span style="color: #008b8b;">c_double</span>), <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> gl(size_max)</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_get_jastrow_champ_gl</span>
<span style="color: #a020f0;">end interface</span>
</pre>
</div>
</div>
</li>
</ol>
</div>
<div id="outline-container-orgfb20810" class="outline-5">
<h5 id="orgfb20810"><span class="section-number-5">3.4.2.2</span> Compute</h5>
<div class="outline-text-5" id="text-3-4-2-2">
<table id="org74e23f7" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Variable</th>
<th scope="col" class="org-left">Type</th>
<th scope="col" class="org-left">In/Out</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>context</code></td>
<td class="org-left"><code>qmckl_context</code></td>
<td class="org-left">in</td>
<td class="org-left">Global state</td>
</tr>
<tr>
<td class="org-left"><code>walk_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of walkers</td>
</tr>
<tr>
<td class="org-left"><code>elec_num</code></td>
<td class="org-left"><code>int64_t</code></td>
<td class="org-left">in</td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>value</code></td>
<td class="org-left"><code>double[walk_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">Total Jastrow</td>
</tr>
<tr>
<td class="org-left"><code>gl_ee</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">ee component</td>
</tr>
<tr>
<td class="org-left"><code>gl_en</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">eN component</td>
</tr>
<tr>
<td class="org-left"><code>gl_een</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num]</code></td>
<td class="org-left">in</td>
<td class="org-left">eeN component</td>
</tr>
<tr>
<td class="org-left"><code>gl</code></td>
<td class="org-left"><code>double[walk_num][4][elec_num]</code></td>
<td class="org-left">out</td>
<td class="org-left">Total Jastrow factor</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span><span style="color: #a0522d;"> function qmckl_compute_jastrow_champ_gl_doc_f(context, </span><span style="color: #a020f0;">&amp;</span>
walk_num, elec_num, <span style="color: #a020f0;">value</span>, gl_ee, gl_en, gl_een, gl) <span style="color: #a020f0;">&amp;</span>
<span style="color: #a020f0;">result</span>(info)
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">qmckl</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">integer</span>(qmckl_context), <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> context</span>
<span style="color: #228b22;">integer</span>*8 , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> walk_num, elec_num</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> value (walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> gl_ee (elec_num,4,walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> gl_en (elec_num,4,walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(in) ::<span style="color: #a0522d;"> gl_een(elec_num,4,walk_num)</span>
<span style="color: #228b22;">double precision</span> , <span style="color: #a020f0;">intent</span>(out) ::<span style="color: #a0522d;"> gl (elec_num,4,walk_num)</span>
<span style="color: #228b22;">integer</span>*8 ::<span style="color: #a0522d;"> i, j, k</span>
info = QMCKL_SUCCESS
<span style="color: #a020f0;">if</span> (context == QMCKL_NULL_CONTEXT) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_CONTEXT
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">if</span> (walk_num &lt;= 0) <span style="color: #a020f0;">then</span>
info = QMCKL_INVALID_ARG_2
<span style="color: #a020f0;">return</span>
<span style="color: #a020f0;">endif</span>
<span style="color: #a020f0;">do</span> k = 1, walk_num
<span style="color: #a020f0;">do</span> j=1,4
<span style="color: #a020f0;">do</span> i = 1, elec_num
gl(i,j,k) = gl_ee(i,j,k) + gl_en(i,j,k) + gl_een(i,j,k)
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">do</span> i = 1, elec_num
gl(i,4,k) = gl(i,4,k) + <span style="color: #a020f0;">&amp;</span>
gl(i,1,k) * gl(i,1,k) + <span style="color: #a020f0;">&amp;</span>
gl(i,2,k) * gl(i,2,k) + <span style="color: #a020f0;">&amp;</span>
gl(i,3,k) * gl(i,3,k)
<span style="color: #a020f0;">end do</span>
gl(:,:,k) = gl(:,:,k) * <span style="color: #a020f0;">value</span>(k)
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end function</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_gl_doc_f</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_gl</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">value</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">gl_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">gl_en</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">gl_een</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">gl</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_gl_doc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">value</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">gl_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">gl_en</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">gl_een</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">gl</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_gl_hpc</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">value</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">gl_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">gl_en</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">gl_een</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">gl</span> );
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_compute_jastrow_champ_gl</span> (
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">walk_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">elec_num</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">value</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">gl_ee</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">gl_en</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">gl_een</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">gl</span>)
{
<span style="color: #483d8b;">#ifdef</span> HAVE_HPC
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_gl_hpc
<span style="color: #483d8b;">#else</span>
<span style="color: #a020f0;">return</span> qmckl_compute_jastrow_champ_gl_doc
<span style="color: #483d8b;">#endif</span>
(context, walk_num, elec_num, value, gl_ee, gl_en, gl_een, gl);
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgcb4645f" class="outline-5">
<h5 id="orgcb4645f"><span class="section-number-5">3.4.2.3</span> Test</h5>
<div class="outline-text-5" id="text-3-4-2-3">
<div class="org-src-container">
<pre class="src src-c">printf(<span style="color: #8b2252;">"Total Jastrow derivatives\n"</span>);
/* <span style="color: #b22222;">Check if Jastrow is properly initialized</span> */
<span style="color: #0000ff;">assert</span>(<span style="color: #228b22;">qmckl_jastrow_champ_provided</span>(<span style="color: #a0522d;">context</span>));
rc = qmckl_check(context,
qmckl_get_jastrow_champ_factor_ee_gl(context, &amp;(factor_ee_gl[0][0][0]), walk_num*elec_num*4)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_get_jastrow_champ_factor_en_gl(context, &amp;(factor_en_gl[0][0][0]), walk_num*elec_num*4)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_get_jastrow_champ_factor_een_gl(context, &amp;(factor_een_gl[0][0][0]), walk_num*elec_num*4)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #228b22;">double</span> <span style="color: #a0522d;">total_j_deriv</span>[walk_num][4][elec_num];
rc = qmckl_check(context,
qmckl_get_jastrow_champ_gl(context, &amp;(total_j_deriv[0][0][0]), walk_num*elec_num*4)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
rc = qmckl_check(context,
qmckl_get_jastrow_champ_value(context, &amp;(total_j[0]), walk_num)
);
<span style="color: #0000ff;">assert</span>(rc == QMCKL_SUCCESS);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">k</span>=0 ; k&lt; walk_num ; ++k) {
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">m</span>=0 ; m&lt;4; ++m) {
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">e</span>=0 ; e&lt;elec_num; ++e) {
<span style="color: #a020f0;">if</span> (m &lt; 3) { /* <span style="color: #b22222;">test only gradients</span> */
assert (total_j_deriv[k][m][e]/total_j[k] - (factor_ee_gl[k][m][e] + factor_en_gl[k][m][e] + factor_een_gl[k][m][e]) &lt; 1.e-12);
}
}
}
}
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: TREX CoE</p>
<p class="date">Created: 2024-04-10 Wed 14:39</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>