1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-11-04 05:03:59 +01:00
qmckl/qmckl_trexio.html

1804 lines
85 KiB
HTML
Raw Normal View History

<?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>
<!-- 2022-01-08 Sat 15:05 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>TREXIO I/O library</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; }
.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-2019 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-2019 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-2019 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>
</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">TREXIO I/O library</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org1ca1c13">1. Local functions</a>
<ul>
<li><a href="#org309d3f8">1.1. Open file</a></li>
<li><a href="#org227e213">1.2. Electron</a></li>
<li><a href="#org602af11">1.3. Nucleus</a>
<ul>
<li><a href="#org6c920df">1.3.1. Number of nuclei</a></li>
<li><a href="#orgc901341">1.3.2. Nuclear charges</a></li>
<li><a href="#orgda668c3">1.3.3. Nuclear coordinates</a></li>
</ul>
</li>
<li><a href="#org4a0097a">1.4. Basis set and AOs</a>
<ul>
<li><a href="#org8cf2e75">1.4.1. Basis set type</a></li>
<li><a href="#org3e572c0">1.4.2. Number of shells</a></li>
<li><a href="#org46e7bff">1.4.3. Number of primitives</a></li>
<li><a href="#org3d257b6">1.4.4. Number of atomic orbitals</a></li>
<li><a href="#org61727ac">1.4.5. Nucleus<sub>index</sub> array</a></li>
<li><a href="#org7a4a4b0">1.4.6. Number of shells per nucleus</a></li>
<li><a href="#org4635aa1">1.4.7. Angular momentum</a></li>
<li><a href="#orga41b53a">1.4.8. Number of primitives per shell</a></li>
<li><a href="#orgec91027">1.4.9. Indices of the primitives</a></li>
<li><a href="#orgae728fe">1.4.10. Normalization of the shells</a></li>
<li><a href="#org07ece03">1.4.11. Exponents</a></li>
<li><a href="#org6cab85b">1.4.12. Coefficients</a></li>
<li><a href="#orgb578c69">1.4.13. Normalization of the primitivies</a></li>
<li><a href="#org6fcfad0">1.4.14. AO Normalization</a></li>
</ul>
</li>
<li><a href="#orgc287251">1.5. Molecular orbitals</a>
<ul>
<li><a href="#orgb0d1d42">1.5.1. Number of MOs</a></li>
<li><a href="#org973153e">1.5.2. MO coefficients</a></li>
</ul>
</li>
<li><a href="#org774c5a0">1.6. <span class="todo TODO">TODO</span> ECP</a></li>
</ul>
</li>
<li><a href="#org5f596da">2. Read everything</a></li>
<li><a href="#org540329a">3. Test</a>
<ul>
<li>
<ul>
<li><a href="#org3448942">3.0.1. Electrons</a></li>
<li><a href="#org0c9412e">3.0.2. Nuclei</a></li>
<li><a href="#org61c0409">3.0.3. Atomic basis</a></li>
<li><a href="#org8722bdc">3.0.4. MO Basis</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org1ca1c13" class="outline-2">
<h2 id="org1ca1c13"><span class="section-number-2">1</span> Local functions</h2>
<div class="outline-text-2" id="text-1">
<p>
Functions defined in this section are all local: they should not be
exposed in the API. To identify them, we append <code>_X</code> to
their name.
</p>
<p>
Users are not able to call directly these functions, so by
construction the context can't be <code>NULL</code>, hence we can check this
with an <code>assert</code> statement.
</p>
<p>
In the functions defined in this section, we use as local variables
</p>
<ul class="org-ul">
<li><code>rc</code>: the return code for QMCkl functions</li>
<li><code>rcio</code>: the return code for TREXIO functions.</li>
</ul>
</div>
<div id="outline-container-org309d3f8" class="outline-3">
<h3 id="org309d3f8"><span class="section-number-3">1.1</span> Open file</h3>
<div class="outline-text-3" id="text-1-1">
<p>
We first define a helper function to open a file by first trying to
use the TEXT back end, and then the HDF5 back end. If both
strategies fail, a <code>NULL</code> pointer is returned. This will allow to
open only once the file and call multiple small functions to read
groups of data by passing the <code>trexio_t</code> handle.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">trexio_t</span>* <span style="color: #0000ff;">qmckl_trexio_open_X</span>(<span style="color: #a020f0;">const</span> <span style="color: #228b22;">char</span>* <span style="color: #a0522d;">file_name</span>, <span style="color: #228b22;">qmckl_exit_code</span>* <span style="color: #a0522d;">rc</span>)
{
*rc = QMCKL_SUCCESS;
<span style="color: #228b22;">trexio_t</span>* <span style="color: #a0522d;">file</span> = <span style="color: #008b8b;">NULL</span>;
file = trexio_open(file_name, <span style="color: #8b2252;">'r'</span>, TREXIO_TEXT, rc);
<span style="color: #a020f0;">if</span> (file != <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> file;
file = trexio_open(file_name, <span style="color: #8b2252;">'r'</span>, TREXIO_HDF5, rc);
<span style="color: #a020f0;">if</span> (file != <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> file;
*rc = QMCKL_FAILURE;
<span style="color: #a020f0;">return</span> <span style="color: #008b8b;">NULL</span>;
}
<span style="color: #483d8b;">#endif</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org227e213" class="outline-3">
<h3 id="org227e213"><span class="section-number-3">1.2</span> Electron</h3>
<div class="outline-text-3" id="text-1-2">
<p>
In this section we read all the data into the electron data structure.
We read the number of up-spin and down-spin electrons.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_trexio_read_electron_X</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>)
{
assert (context != (<span style="color: #228b22;">qmckl_context</span>) 0);
assert (file != <span style="color: #008b8b;">NULL</span>);
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rcio</span> = 0;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">up_num</span> = 0L;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dn_num</span> = 0L;
rcio = trexio_read_electron_up_num_64(file, &amp;up_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_electron_up_num"</span>,
trexio_string_of_error(rcio));
}
assert (up_num &gt;= 0L);
rcio = trexio_read_electron_dn_num_64(file, &amp;dn_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_electron_dn_num"</span>,
trexio_string_of_error(rcio));
}
assert (dn_num &gt;= 0L);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #a0522d;">rc</span>;
rc = qmckl_set_electron_num(context, up_num, dn_num);
<span style="color: #a020f0;">return</span> rc;
}
<span style="color: #483d8b;">#endif</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org602af11" class="outline-3">
<h3 id="org602af11"><span class="section-number-3">1.3</span> Nucleus</h3>
<div class="outline-text-3" id="text-1-3">
<p>
In this section we read the number of nuclei, the molecular geometry and nuclear charges.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_trexio_read_nucleus_X</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>)
{
assert (context != (<span style="color: #228b22;">qmckl_context</span>) 0);
assert (file != <span style="color: #008b8b;">NULL</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #a0522d;">rc</span>;
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rcio</span> = 0;
</pre>
</div>
</div>
<div id="outline-container-org6c920df" class="outline-4">
<h4 id="org6c920df"><span class="section-number-4">1.3.1</span> Number of nuclei</h4>
<div class="outline-text-4" id="text-1-3-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucleus_num</span> = 0L;
rcio = trexio_read_nucleus_num_64(file, &amp;nucleus_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_nucleus_num"</span>,
trexio_string_of_error(rcio));
}
<span style="color: #0000ff;">assert</span> (nucleus_num &gt; 0);
rc = qmckl_set_nucleus_num(context, nucleus_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
</div>
<div id="outline-container-orgc901341" class="outline-4">
<h4 id="orgc901341"><span class="section-number-4">1.3.2</span> Nuclear charges</h4>
<div class="outline-text-4" id="text-1-3-2">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
mem_info.size = nucleus_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">nucl_charge</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (nucl_charge == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_nucleus_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (nucl_charge != <span style="color: #008b8b;">NULL</span>);
rcio = trexio_read_safe_nucleus_charge_64(file, nucl_charge, nucleus_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_nucleus_charge"</span>,
trexio_string_of_error(rcio));
}
//<span style="color: #b22222;">rc = qmckl_set_nucleus_charge(context, nucl_charge, nucleus_num);</span>
rc = qmckl_set_nucleus_charge(context, nucl_charge);
qmckl_free(context, nucl_charge);
nucl_charge = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgda668c3" class="outline-4">
<h4 id="orgda668c3"><span class="section-number-4">1.3.3</span> Nuclear coordinates</h4>
<div class="outline-text-4" id="text-1-3-3">
<p>
Now, we read the molecular geometry. It is stored in normal format
in the TREXIO file (<code>'N'</code>), so it will be automatically transposed internally.
</p>
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
mem_info.size = nucleus_num * 3 * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">nucl_coord</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (nucl_coord == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_nucleus_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (nucl_coord != <span style="color: #008b8b;">NULL</span>);
rcio = trexio_read_safe_nucleus_coord_64(file, nucl_coord, 3*nucleus_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_nucleus_charge"</span>,
trexio_string_of_error(rcio));
}
//<span style="color: #b22222;">rc = qmckl_set_nucleus_coord(context, 'N', nucl_coord, 3*nucleus_num);</span>
rc = qmckl_set_nucleus_coord(context, <span style="color: #8b2252;">'N'</span>, nucl_coord);
qmckl_free(context, nucl_coord);
nucl_coord = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS) {
<span style="color: #a020f0;">return</span> rc;
}
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c">
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
<span style="color: #483d8b;">#endif</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org4a0097a" class="outline-3">
<h3 id="org4a0097a"><span class="section-number-3">1.4</span> Basis set and AOs</h3>
<div class="outline-text-3" id="text-1-4">
<p>
In this section we read the atomic basis set and atomic orbitals.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_trexio_read_ao_X</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>)
{
assert (context != (<span style="color: #228b22;">qmckl_context</span>) 0);
assert (file != <span style="color: #008b8b;">NULL</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #a0522d;">rc</span>;
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rcio</span> = 0;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucleus_num</span> = 0L;
rc = qmckl_get_nucleus_num(context, &amp;nucleus_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
<div id="outline-container-org8cf2e75" class="outline-4">
<h4 id="org8cf2e75"><span class="section-number-4">1.4.1</span> Basis set type</h4>
<div class="outline-text-4" id="text-1-4-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#define</span> <span style="color: #a0522d;">MAX_STR_LEN</span> 1024
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">basis_type</span>[MAX_STR_LEN];
rcio = trexio_read_basis_type(file, basis_type, MAX_STR_LEN);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_type"</span>,
trexio_string_of_error(rcio));
}
<span style="color: #a020f0;">if</span> (basis_type[0] == <span style="color: #8b2252;">'G'</span>) {
rc = qmckl_set_ao_basis_type(context, basis_type[0]);
} <span style="color: #a020f0;">else</span> {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_type"</span>,
<span style="color: #8b2252;">"Invalid basis type"</span>);
}
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
</div>
<div id="outline-container-org3e572c0" class="outline-4">
<h4 id="org3e572c0"><span class="section-number-4">1.4.2</span> Number of shells</h4>
<div class="outline-text-4" id="text-1-4-2">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">shell_num</span> = 0L;
rcio = trexio_read_basis_shell_num_64(file, &amp;shell_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_shell_num"</span>,
trexio_string_of_error(rcio));
}
<span style="color: #0000ff;">assert</span> (shell_num &gt; 0);
rc = qmckl_set_ao_basis_shell_num(context, shell_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
</div>
<div id="outline-container-org46e7bff" class="outline-4">
<h4 id="org46e7bff"><span class="section-number-4">1.4.3</span> Number of primitives</h4>
<div class="outline-text-4" id="text-1-4-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">prim_num</span> = 0L;
rcio = trexio_read_basis_prim_num_64(file, &amp;prim_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_prim_num"</span>,
trexio_string_of_error(rcio));
}
<span style="color: #0000ff;">assert</span> (prim_num &gt; 0);
rc = qmckl_set_ao_basis_prim_num(context, prim_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
</div>
<div id="outline-container-org3d257b6" class="outline-4">
<h4 id="org3d257b6"><span class="section-number-4">1.4.4</span> Number of atomic orbitals</h4>
<div class="outline-text-4" id="text-1-4-4">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">ao_num</span> = 0LL;
rcio = trexio_read_ao_num_64(file, &amp;ao_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_ao_num"</span>,
trexio_string_of_error(rcio));
}
<span style="color: #0000ff;">assert</span> (ao_num &gt; 0);
rc = qmckl_set_ao_basis_ao_num(context, ao_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
</div>
<div id="outline-container-org61727ac" class="outline-4">
<h4 id="org61727ac"><span class="section-number-4">1.4.5</span> Nucleus<sub>index</sub> array</h4>
<div class="outline-text-4" id="text-1-4-5">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data </span>*/
mem_info.size = nucleus_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">nucleus_index</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (nucleus_index == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_nucleus_index_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (nucleus_index != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Allocate temporary array </span>*/
mem_info.size = shell_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">tmp_array</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (tmp_array == <span style="color: #008b8b;">NULL</span>) {
qmckl_free(context, nucleus_index);
nucleus_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_nucleus_index_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (tmp_array != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read in the temporary array </span>*/
rcio = trexio_read_safe_basis_nucleus_index_64(file, tmp_array, shell_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, nucleus_index);
nucleus_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_nucleus_index"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Reformat data </span>*/
rc = qmckl_set_ao_basis_nucleus_index(context, nucleus_index, nucleus_num);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=shell_num-1 ; i&gt;=0 ; --i) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span> = tmp_array[i];
<span style="color: #a020f0;">if</span> (k &lt; 0 || k &gt;= nucleus_num) {
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, nucleus_index);
nucleus_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_nucleus_index"</span>,
<span style="color: #8b2252;">"Irrelevant data in TREXIO file"</span>);
}
nucleus_index[k] = i;
}
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
/* <span style="color: #b22222;">Store data </span>*/
rc = qmckl_set_ao_basis_nucleus_index(context, nucleus_index, shell_num);
qmckl_free(context, nucleus_index);
nucleus_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org7a4a4b0" class="outline-4">
<h4 id="org7a4a4b0"><span class="section-number-4">1.4.6</span> Number of shells per nucleus</h4>
<div class="outline-text-4" id="text-1-4-6">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data </span>*/
mem_info.size = nucleus_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">nucleus_shell_num</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (nucleus_shell_num == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_nucleus_shell_num_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (nucleus_shell_num != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Allocate temporary array </span>*/
mem_info.size = shell_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">tmp_array</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (tmp_array == <span style="color: #008b8b;">NULL</span>) {
qmckl_free(context, nucleus_shell_num);
nucleus_shell_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_nucleus_shell_num_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (tmp_array != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read in the temporary array </span>*/
rcio = trexio_read_safe_basis_nucleus_index_64(file, tmp_array, shell_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, nucleus_shell_num);
nucleus_shell_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_nucleus_shell_num"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Reformat data </span>*/
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;nucleus_num ; ++i) {
nucleus_shell_num[i] = 0;
}
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;shell_num ; ++i) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span> = tmp_array[i];
<span style="color: #a020f0;">if</span> (k &lt; 0 || k &gt;= nucleus_num) {
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, nucleus_shell_num);
nucleus_shell_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_nucleus_shell_num"</span>,
<span style="color: #8b2252;">"Irrelevant data in TREXIO file"</span>);
}
nucleus_shell_num[k] += 1;
}
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
/* <span style="color: #b22222;">Store data </span>*/
rc = qmckl_set_ao_basis_nucleus_shell_num(context, nucleus_shell_num, shell_num);
qmckl_free(context, nucleus_shell_num);
nucleus_shell_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org4635aa1" class="outline-4">
<h4 id="org4635aa1"><span class="section-number-4">1.4.7</span> Angular momentum</h4>
<div class="outline-text-4" id="text-1-4-7">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data </span>*/
mem_info.size = shell_num * <span style="color: #a020f0;">sizeof</span>(int32_t);
<span style="color: #228b22;">int32_t</span>* <span style="color: #a0522d;">shell_ang_mom</span> = (<span style="color: #228b22;">int32_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (shell_ang_mom == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_ang_mom_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (shell_ang_mom != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data </span>*/
rcio = trexio_read_safe_basis_shell_ang_mom_32(file, shell_ang_mom, shell_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, shell_ang_mom);
shell_ang_mom = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_shell_ang_mom"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Store data </span>*/
rc = qmckl_set_ao_basis_shell_ang_mom(context, shell_ang_mom, shell_num);
qmckl_free(context, shell_ang_mom);
shell_ang_mom = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orga41b53a" class="outline-4">
<h4 id="orga41b53a"><span class="section-number-4">1.4.8</span> Number of primitives per shell</h4>
<div class="outline-text-4" id="text-1-4-8">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data </span>*/
mem_info.size = shell_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">shell_prim_num</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (shell_prim_num == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_prim_num_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (shell_prim_num != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Allocate temporary array </span>*/
mem_info.size = prim_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">tmp_array</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (tmp_array == <span style="color: #008b8b;">NULL</span>) {
qmckl_free(context, shell_prim_num);
shell_prim_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_prim_num_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (tmp_array != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data </span>*/
rcio = trexio_read_safe_basis_shell_index_64 (file, tmp_array, prim_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, shell_prim_num);
shell_prim_num = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_shell_prim_num"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Reformat data </span>*/
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;shell_num ; ++i) {
shell_prim_num[i] = 0;
}
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;prim_num ; ++i) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span> = tmp_array[i];
<span style="color: #a020f0;">if</span> (k &lt; 0 || k &gt;= shell_num) {
qmckl_free(context, tmp_array);
qmckl_free(context, shell_prim_num);
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_shell_prim_num"</span>,
<span style="color: #8b2252;">"Irrelevant data in TREXIO file"</span>);
}
shell_prim_num[k] += 1;
}
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
/* <span style="color: #b22222;">Store data </span>*/
rc = qmckl_set_ao_basis_shell_prim_num(context, shell_prim_num, shell_num);
qmckl_free(context, shell_prim_num);
shell_prim_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgec91027" class="outline-4">
<h4 id="orgec91027"><span class="section-number-4">1.4.9</span> Indices of the primitives</h4>
<div class="outline-text-4" id="text-1-4-9">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data </span>*/
mem_info.size = shell_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">shell_prim_index</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (shell_prim_index == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_prim_index_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (shell_prim_index != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Allocate temporary array </span>*/
mem_info.size = prim_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">tmp_array</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (tmp_array == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_prim_index_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (tmp_array != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data </span>*/
rcio = trexio_read_safe_basis_shell_index_64(file, tmp_array, prim_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, shell_prim_index);
shell_prim_index = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_shell_prim_index"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Reformat data </span>*/
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=prim_num-1 ; i&gt;=0 ; --i) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span> = tmp_array[i];
<span style="color: #a020f0;">if</span> (k &lt; 0 || k &gt;= shell_num) {
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, shell_prim_index);
shell_prim_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_shell_prim_index"</span>,
<span style="color: #8b2252;">"Irrelevant data in TREXIO file"</span>);
}
shell_prim_index[k] = i;
}
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
/* <span style="color: #b22222;">Store data </span>*/
rc = qmckl_set_ao_basis_shell_prim_index(context, shell_prim_index, shell_num);
qmckl_free(context, shell_prim_index);
shell_prim_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgae728fe" class="outline-4">
<h4 id="orgae728fe"><span class="section-number-4">1.4.10</span> Normalization of the shells</h4>
<div class="outline-text-4" id="text-1-4-10">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data </span>*/
mem_info.size = shell_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">shell_factor</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (shell_factor == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_factor_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (shell_factor != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data </span>*/
rcio = trexio_read_safe_basis_shell_factor_64(file, shell_factor, shell_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, shell_factor);
shell_factor = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_shell_factor"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Store data </span>*/
rc = qmckl_set_ao_basis_shell_factor(context, shell_factor, shell_num);
qmckl_free(context, shell_factor);
shell_factor = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org07ece03" class="outline-4">
<h4 id="org07ece03"><span class="section-number-4">1.4.11</span> Exponents</h4>
<div class="outline-text-4" id="text-1-4-11">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data </span>*/
mem_info.size = prim_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">exponent</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (exponent == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_exponent_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (exponent != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data </span>*/
rcio = trexio_read_safe_basis_exponent_64(file, exponent, prim_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, exponent);
exponent = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_exponent"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Store data </span>*/
rc = qmckl_set_ao_basis_exponent(context, exponent, prim_num);
qmckl_free(context, exponent);
exponent = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org6cab85b" class="outline-4">
<h4 id="org6cab85b"><span class="section-number-4">1.4.12</span> Coefficients</h4>
<div class="outline-text-4" id="text-1-4-12">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data </span>*/
mem_info.size = prim_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">coefficient</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (coefficient == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_coefficient_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (coefficient != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data </span>*/
rcio = trexio_read_safe_basis_coefficient_64(file, coefficient, prim_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, coefficient);
coefficient = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_coefficient"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Store data </span>*/
rc = qmckl_set_ao_basis_coefficient(context, coefficient, prim_num);
qmckl_free(context, coefficient);
coefficient = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgb578c69" class="outline-4">
<h4 id="orgb578c69"><span class="section-number-4">1.4.13</span> Normalization of the primitivies</h4>
<div class="outline-text-4" id="text-1-4-13">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data </span>*/
mem_info.size = prim_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">prim_factor</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (prim_factor == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_prim_factor_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (prim_factor != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data </span>*/
rcio = trexio_read_safe_basis_prim_factor_64(file, prim_factor, prim_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, prim_factor);
prim_factor = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_prim_factor"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Read data </span>*/
rc = qmckl_set_ao_basis_prim_factor(context, prim_factor, prim_num);
qmckl_free(context, prim_factor);
prim_factor = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org6fcfad0" class="outline-4">
<h4 id="org6fcfad0"><span class="section-number-4">1.4.14</span> AO Normalization</h4>
<div class="outline-text-4" id="text-1-4-14">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data </span>*/
mem_info.size = ao_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ao_normalization</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (ao_normalization == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_ao_normalization_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (ao_normalization != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data </span>*/
rcio = trexio_read_safe_ao_normalization_64(file, ao_normalization, ao_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, ao_normalization);
ao_normalization = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_ao_normalization"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Store data </span>*/
rc = qmckl_set_ao_basis_ao_factor(context, ao_normalization, ao_num);
qmckl_free(context, ao_normalization);
ao_normalization = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c">
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
<span style="color: #483d8b;">#endif</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgc287251" class="outline-3">
<h3 id="orgc287251"><span class="section-number-3">1.5</span> Molecular orbitals</h3>
<div class="outline-text-3" id="text-1-5">
<p>
In this section we read the MO coefficients.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_trexio_read_mo_X</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>)
{
assert (context != (<span style="color: #228b22;">qmckl_context</span>) 0);
assert (file != <span style="color: #008b8b;">NULL</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #a0522d;">rc</span>;
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rcio</span> = 0;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">ao_num</span> = 0L;
rc = qmckl_get_ao_basis_ao_num(context, &amp;ao_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
<div id="outline-container-orgb0d1d42" class="outline-4">
<h4 id="orgb0d1d42"><span class="section-number-4">1.5.1</span> Number of MOs</h4>
<div class="outline-text-4" id="text-1-5-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">mo_num</span> = 0L;
rcio = trexio_read_mo_num_64(file, &amp;mo_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_mo_num"</span>,
trexio_string_of_error(rcio));
}
<span style="color: #0000ff;">assert</span> (mo_num &gt; 0);
rc = qmckl_set_mo_basis_mo_num(context, mo_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
</div>
<div id="outline-container-org973153e" class="outline-4">
<h4 id="org973153e"><span class="section-number-4">1.5.2</span> MO coefficients</h4>
<div class="outline-text-4" id="text-1-5-2">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
mem_info.size = ao_num * mo_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">mo_coef</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (mo_coef == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_mo_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (mo_coef != <span style="color: #008b8b;">NULL</span>);
rcio = trexio_read_mo_coefficient_64(file, mo_coef);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_mo_coefficient"</span>,
trexio_string_of_error(rcio));
}
rc = qmckl_set_mo_basis_coefficient(context, mo_coef);
qmckl_free(context, mo_coef);
mo_coef = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c">
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
<span style="color: #483d8b;">#endif</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org774c5a0" class="outline-3">
<h3 id="org774c5a0"><span class="section-number-3">1.6</span> <span class="todo TODO">TODO</span> ECP</h3>
</div>
</div>
<div id="outline-container-org5f596da" class="outline-2">
<h2 id="org5f596da"><span class="section-number-2">2</span> Read everything</h2>
<div class="outline-text-2" id="text-2">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #0000ff;">qmckl_trexio_read</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;">char</span>* <span style="color: #a0522d;">file_name</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_trexio_read</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;">char</span>* <span style="color: #a0522d;">file_name</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_exit_code</span> <span style="color: #a0522d;">rc</span>;
<span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">trexio_t</span>* <span style="color: #a0522d;">file</span> = qmckl_trexio_open_X(file_name, &amp;rc);
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) {
trexio_close(file);
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_INVALID_ARG_2,
<span style="color: #8b2252;">"qmckl_trexio_read"</span>,
trexio_string_of_error(rc));
}
assert (file != <span style="color: #008b8b;">NULL</span>);
rc = qmckl_trexio_read_electron_X(context, file);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS) {
trexio_close(file);
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"qmckl_trexio_read"</span>,
<span style="color: #8b2252;">"Error reading electron"</span>);
}
rc = qmckl_trexio_read_nucleus_X(context, file);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS) {
trexio_close(file);
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"qmckl_trexio_read"</span>,
<span style="color: #8b2252;">"Error reading nucleus"</span>);
}
rc = qmckl_trexio_read_ao_X(context, file);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS) {
trexio_close(file);
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"qmckl_trexio_read"</span>,
<span style="color: #8b2252;">"Error reading AOs"</span>);
}
rc = qmckl_trexio_read_mo_X(context, file);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS) {
trexio_close(file);
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"qmckl_trexio_read"</span>,
<span style="color: #8b2252;">"Error reading MOs"</span>);
}
trexio_close(file);
file = <span style="color: #008b8b;">NULL</span>;
<span style="color: #483d8b;">#else</span>
rc = qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"qmckl_trexio_read"</span>,
<span style="color: #8b2252;">"QMCkl was not compiled without TREXIO"</span>);
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org540329a" class="outline-2">
<h2 id="org540329a"><span class="section-number-2">3</span> Test</h2>
<div class="outline-text-2" id="text-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #483d8b;">#define</span> <span style="color: #a0522d;">walk_num</span> 2
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #a0522d;">rc</span>;
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">fname</span>[256];
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">message</span>[256];
<span style="color: #483d8b;">#if</span><span style="color: #483d8b;">n</span><span style="color: #483d8b;">def</span> QMCKL_TEST_DIR
<span style="color: #483d8b;">#error</span> <span style="color: #8b2252;">"QMCKL_TEST_DIR is not defined"</span>
<span style="color: #483d8b;">#endif</span>
<span style="color: #0000ff;">strncpy</span>(fname, QMCKL_TEST_DIR,255);
<span style="color: #0000ff;">strncat</span>(fname, <span style="color: #8b2252;">"/chbrclf"</span>, 255);
printf(<span style="color: #8b2252;">"Test file: %s\n"</span>, fname);
rc = qmckl_set_electron_walk_num(context, walk_num);
rc = qmckl_trexio_read(context, fname);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS) {
printf(<span style="color: #8b2252;">"%s\n"</span>, qmckl_string_of_error(rc));
qmckl_get_error(context, &amp;rc, fname, message);
printf(<span style="color: #8b2252;">"%s\n"</span>, fname);
printf(<span style="color: #8b2252;">"%s\n"</span>, message);
}
<span style="color: #0000ff;">assert</span> ( rc == QMCKL_SUCCESS );
</pre>
</div>
</div>
<div id="outline-container-org3448942" class="outline-4">
<h4 id="org3448942"><span class="section-number-4">3.0.1</span> Electrons</h4>
<div class="outline-text-4" id="text-3-0-1">
<div class="org-src-container">
<pre class="src src-c">printf(<span style="color: #8b2252;">"Electrons\n"</span>);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">up_num</span>, <span style="color: #a0522d;">dn_num</span>;
rc = qmckl_get_electron_up_num(context, &amp;up_num);
<span style="color: #0000ff;">assert</span> (rc == QMCKL_SUCCESS);
<span style="color: #0000ff;">assert</span> (up_num == chbrclf_elec_up_num);
rc = qmckl_get_electron_down_num(context, &amp;dn_num);
<span style="color: #0000ff;">assert</span> (rc == QMCKL_SUCCESS);
<span style="color: #0000ff;">assert</span> (dn_num == chbrclf_elec_dn_num);
</pre>
</div>
</div>
</div>
<div id="outline-container-org0c9412e" class="outline-4">
<h4 id="org0c9412e"><span class="section-number-4">3.0.2</span> Nuclei</h4>
<div class="outline-text-4" id="text-3-0-2">
<div class="org-src-container">
<pre class="src src-c">printf(<span style="color: #8b2252;">"Nuclei\n"</span>);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>;
rc = qmckl_get_nucleus_num(context, &amp;nucl_num);
<span style="color: #0000ff;">assert</span> (rc == QMCKL_SUCCESS);
<span style="color: #0000ff;">assert</span> (nucl_num == chbrclf_nucl_num);
printf(<span style="color: #8b2252;">"Nuclear charges\n"</span>);
<span style="color: #228b22;">double</span> * <span style="color: #a0522d;">charge</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">nucl_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_nucleus_charge(context, charge);
<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;nucl_num ; i++) {
assert (charge[i] == chbrclf_charge[i]);
}
<span style="color: #0000ff;">free</span>(charge);
charge = <span style="color: #008b8b;">NULL</span>;
printf(<span style="color: #8b2252;">"Nuclear coordinates\n"</span>);
<span style="color: #228b22;">double</span> * <span style="color: #a0522d;">coord</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">nucl_num</span> * 3 * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_nucleus_coord(context, <span style="color: #8b2252;">'T'</span>, coord);
<span style="color: #0000ff;">assert</span> (rc == QMCKL_SUCCESS);
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span>=0;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">j</span>=0 ; j&lt;3 ; ++j) {
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;nucl_num ; ++i) {
// <span style="color: #b22222;">printf("%f %f\n", coord[k], chbrclf_nucl_coord[j][i]);</span>
assert (coord[k] == chbrclf_nucl_coord[j][i]);
++k;
}
}
<span style="color: #0000ff;">free</span>(coord);
coord = <span style="color: #008b8b;">NULL</span>;
</pre>
</div>
</div>
</div>
<div id="outline-container-org61c0409" class="outline-4">
<h4 id="org61c0409"><span class="section-number-4">3.0.3</span> Atomic basis</h4>
<div class="outline-text-4" id="text-3-0-3">
<div class="org-src-container">
<pre class="src src-c">printf(<span style="color: #8b2252;">"Atomic basis\n"</span>);
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">basis_type</span>;
rc = qmckl_get_ao_basis_type(context, &amp;basis_type);
<span style="color: #0000ff;">assert</span> (basis_type == <span style="color: #8b2252;">'G'</span>);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">shell_num</span>;
rc = qmckl_get_ao_basis_shell_num(context, &amp;shell_num);
<span style="color: #0000ff;">assert</span> (shell_num == chbrclf_shell_num);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">prim_num</span>;
rc = qmckl_get_ao_basis_prim_num(context, &amp;prim_num);
<span style="color: #0000ff;">assert</span> (prim_num == chbrclf_prim_num);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">ao_num</span>;
rc = qmckl_get_ao_basis_ao_num(context, &amp;ao_num);
<span style="color: #0000ff;">assert</span> (ao_num == chbrclf_ao_num);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">nucleus_index</span> = (<span style="color: #228b22;">int64_t</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">nucl_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">int64_t</span>));
rc = qmckl_get_ao_basis_nucleus_index(context, nucleus_index, 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;nucl_num ; i++) {
assert (nucleus_index[i] == chbrclf_basis_nucleus_index[i]);
}
<span style="color: #0000ff;">free</span>(nucleus_index);
nucleus_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">nucleus_shell_num</span> = (<span style="color: #228b22;">int64_t</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">nucl_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">int64_t</span>));
rc = qmckl_get_ao_basis_nucleus_shell_num(context, nucleus_shell_num, 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;nucl_num ; i++) {
assert (nucleus_shell_num[i] == chbrclf_basis_nucleus_shell_num[i]);
}
<span style="color: #0000ff;">free</span>(nucleus_shell_num);
nucleus_shell_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">int32_t</span>* <span style="color: #a0522d;">shell_ang_mom</span> = (<span style="color: #228b22;">int32_t</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">shell_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">int32_t</span>));
rc = qmckl_get_ao_basis_shell_ang_mom(context, shell_ang_mom, shell_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;shell_num ; i++) {
assert (shell_ang_mom[i] == chbrclf_basis_shell_ang_mom[i]);
}
<span style="color: #0000ff;">free</span>(shell_ang_mom);
shell_ang_mom = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">shell_prim_num</span> = (<span style="color: #228b22;">int64_t</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">shell_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">int64_t</span>));
rc = qmckl_get_ao_basis_shell_prim_num(context, shell_prim_num, shell_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;shell_num ; i++) {
assert (shell_prim_num[i] == chbrclf_basis_shell_prim_num[i]);
}
<span style="color: #0000ff;">free</span>(shell_prim_num);
shell_prim_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">shell_prim_index</span> = (<span style="color: #228b22;">int64_t</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">shell_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">int64_t</span>));
rc = qmckl_get_ao_basis_shell_prim_index(context, shell_prim_index, shell_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;shell_num ; i++) {
assert (shell_prim_index[i] == chbrclf_basis_shell_prim_index[i]);
}
<span style="color: #0000ff;">free</span>(shell_prim_index);
shell_prim_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">shell_factor</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">shell_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_ao_basis_shell_factor(context, shell_factor, shell_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;shell_num ; i++) {
assert (fabs(shell_factor[i] - chbrclf_basis_shell_factor[i]) &lt; 1.e-6);
}
<span style="color: #0000ff;">free</span>(shell_factor);
shell_factor = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">exponent</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">prim_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_ao_basis_exponent(context, exponent, prim_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;prim_num ; i++) {
assert (fabs((exponent[i] - chbrclf_basis_exponent[i])/chbrclf_basis_exponent[i]) &lt; 1.e-7);
}
<span style="color: #0000ff;">free</span>(exponent);
exponent = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">coefficient</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">prim_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_ao_basis_coefficient(context, coefficient, prim_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;prim_num ; i++) {
assert (fabs((coefficient[i] - chbrclf_basis_coefficient[i])/chbrclf_basis_coefficient[i]) &lt; 1.e-7);
}
<span style="color: #0000ff;">free</span>(coefficient);
coefficient = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">prim_factor</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">prim_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_ao_basis_prim_factor(context, prim_factor, prim_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;prim_num ; i++) {
assert (fabs((prim_factor[i] - chbrclf_basis_prim_factor[i])/chbrclf_basis_prim_factor[i]) &lt; 1.e-7);
}
<span style="color: #0000ff;">free</span>(prim_factor);
prim_factor = <span style="color: #008b8b;">NULL</span>;
<span style="color: #483d8b;">#endif</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org8722bdc" class="outline-4">
<h4 id="org8722bdc"><span class="section-number-4">3.0.4</span> MO Basis</h4>
<div class="outline-text-4" id="text-3-0-4">
<div class="org-src-container">
<pre class="src src-c">printf(<span style="color: #8b2252;">"MOs\n"</span>);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">mo_num</span>;
rc = qmckl_get_mo_basis_mo_num(context, &amp;mo_num);
<span style="color: #0000ff;">assert</span> (rc == QMCKL_SUCCESS);
<span style="color: #0000ff;">assert</span> (mo_num == chbrclf_mo_num);
printf(<span style="color: #8b2252;">"MO coefs\n"</span>);
<span style="color: #228b22;">double</span> * <span style="color: #a0522d;">mo_coef</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">ao_num</span> * <span style="color: #0000ff;">mo_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_mo_basis_coefficient(context, mo_coef, mo_num*ao_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;ao_num * mo_num ; i++) {
printf(<span style="color: #8b2252;">"%d %e %e %e\n"</span>, i, mo_coef[i], chbrclf_mo_coef[i],
( fabs(mo_coef[i] - chbrclf_mo_coef[i])/fabs(mo_coef[i])) );
assert ( fabs(mo_coef[i] - chbrclf_mo_coef[i])/fabs(mo_coef[i]) &lt; 1.e-12 );
}
<span style="color: #0000ff;">free</span>(mo_coef);
charge = <span style="color: #008b8b;">NULL</span>;
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: TREX CoE</p>
<p class="date">Created: 2022-01-08 Sat 15:05</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>