mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-18 12:03:40 +01:00
Parallelized ERI with Domainslib
This commit is contained in:
parent
b4211b8d85
commit
3f0dbfc928
@ -48,6 +48,7 @@ with open(dunetest,'w') as f:
|
||||
(synopsis "Test for {name} library")
|
||||
(libraries
|
||||
alcotest
|
||||
unix
|
||||
qcaml.{name}
|
||||
)
|
||||
)
|
||||
@ -61,6 +62,7 @@ with open(dunetest,'w') as f:
|
||||
str
|
||||
zarith
|
||||
getopt
|
||||
unix
|
||||
)
|
||||
#+end_src
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
(library
|
||||
(name common)
|
||||
(public_name qcaml.common)
|
||||
(synopsis
|
||||
(synopsis
|
||||
"Utility functions used by all the other directories."
|
||||
)
|
||||
(libraries
|
||||
@ -10,8 +10,9 @@
|
||||
zarith
|
||||
getopt
|
||||
camlp-streams
|
||||
unix
|
||||
)
|
||||
|
||||
|
||||
(c_names
|
||||
util
|
||||
)
|
||||
|
@ -1,7 +1,8 @@
|
||||
|
||||
|
||||
(* | ~root~ | Path to the QCaml source directory |
|
||||
* | ~name~ | ~"QCaml"~ | *)
|
||||
(* | ~root~ | Path to the QCaml source directory |
|
||||
* | ~name~ | ~"QCaml"~ |
|
||||
* | ~num_domains~ | Number of threads in parallel computations | *)
|
||||
|
||||
|
||||
(* [[file:~/QCaml/common/qcaml.org::*QCaml][QCaml:2]] *)
|
||||
@ -18,4 +19,14 @@ let root =
|
||||
|> chop
|
||||
|> List.rev
|
||||
|> String.concat Filename.dir_sep
|
||||
|
||||
|
||||
let num_domains =
|
||||
let result =
|
||||
try
|
||||
Unix.getenv "OMP_NUM_THREADS"
|
||||
|> int_of_string
|
||||
with Not_found -> 1
|
||||
in
|
||||
result - 1
|
||||
(* QCaml:2 ends here *)
|
||||
|
@ -9,4 +9,5 @@
|
||||
(* [[file:~/QCaml/common/qcaml.org::*QCaml][QCaml:1]] *)
|
||||
val root : string
|
||||
val name : string
|
||||
val num_domains : int
|
||||
(* QCaml:1 ends here *)
|
||||
|
@ -19,10 +19,12 @@
|
||||
#+begin_src ocaml :tangle (eval mli)
|
||||
val root : string
|
||||
val name : string
|
||||
val num_domains : int
|
||||
#+end_src
|
||||
|
||||
| ~root~ | Path to the QCaml source directory |
|
||||
| ~name~ | ~"QCaml"~ |
|
||||
| ~root~ | Path to the QCaml source directory |
|
||||
| ~name~ | ~"QCaml"~ |
|
||||
| ~num_domains~ | Number of threads in parallel computations |
|
||||
|
||||
#+begin_src ocaml :tangle (eval ml) :exports none
|
||||
let name = "QCaml"
|
||||
@ -40,5 +42,14 @@ let root =
|
||||
|> String.concat Filename.dir_sep
|
||||
|
||||
|
||||
let num_domains =
|
||||
let result =
|
||||
try
|
||||
Unix.getenv "OMP_NUM_THREADS"
|
||||
|> int_of_string
|
||||
with Not_found -> 1
|
||||
in
|
||||
result - 1
|
||||
|
||||
#+end_src
|
||||
|
||||
|
522
docs/common.html
522
docs/common.html
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2023-04-24 Mon 19:28 -->
|
||||
<!-- 2023-06-16 Fri 09:49 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Gaussian</title>
|
||||
@ -272,41 +272,41 @@ org_html_manager.setup(); // activate after the parameters are set
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents">
|
||||
<ul>
|
||||
<li><a href="#org8752877">1. Summary</a></li>
|
||||
<li><a href="#orgc12310c">2. Atomic shell</a>
|
||||
<li><a href="#org418bb17">1. Summary</a></li>
|
||||
<li><a href="#org3107c2d">2. Atomic shell</a>
|
||||
<ul>
|
||||
<li><a href="#org3e413df">2.1. Type</a></li>
|
||||
<li><a href="#orgaa9e5a8">2.2. Access</a></li>
|
||||
<li><a href="#org40ea971">2.3. Creation</a></li>
|
||||
<li><a href="#org76ce11e">2.4. Printers</a></li>
|
||||
<li><a href="#orgd3e8a3d">2.1. Type</a></li>
|
||||
<li><a href="#org3a79952">2.2. Access</a></li>
|
||||
<li><a href="#orgf649255">2.3. Creation</a></li>
|
||||
<li><a href="#orgb538194">2.4. Printers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org20ddf7f">3. Atomic shell pair couple</a>
|
||||
<li><a href="#org055d620">3. Atomic shell pair couple</a>
|
||||
<ul>
|
||||
<li><a href="#org79cc56e">3.1. Type</a></li>
|
||||
<li><a href="#org2486daa">3.2. Access</a></li>
|
||||
<li><a href="#org682c85c">3.3. Creation</a></li>
|
||||
<li><a href="#org6d637d8">3.4. Printers</a></li>
|
||||
<li><a href="#org85660fe">3.1. Type</a></li>
|
||||
<li><a href="#orgca1d510">3.2. Access</a></li>
|
||||
<li><a href="#orgd5c48bb">3.3. Creation</a></li>
|
||||
<li><a href="#org2949ca5">3.4. Printers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orge37a5fe">4. Atomic shell pair</a>
|
||||
<li><a href="#orge44bc1a">4. Atomic shell pair</a>
|
||||
<ul>
|
||||
<li><a href="#org791264a">4.1. Type</a></li>
|
||||
<li><a href="#orge08787d">4.2. Access</a></li>
|
||||
<li><a href="#org49ac790">4.3. Creation</a></li>
|
||||
<li><a href="#orgb4a074f">4.4. Printers</a></li>
|
||||
<li><a href="#org8d76a2d">4.1. Type</a></li>
|
||||
<li><a href="#orgdb75218">4.2. Access</a></li>
|
||||
<li><a href="#org813d710">4.3. Creation</a></li>
|
||||
<li><a href="#org864a734">4.4. Printers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org8752877" class="outline-2">
|
||||
<h2 id="org8752877"><span class="section-number-2">1</span> Summary</h2>
|
||||
<div id="outline-container-org418bb17" class="outline-2">
|
||||
<h2 id="org418bb17"><span class="section-number-2">1</span> Summary</h2>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgc12310c" class="outline-2">
|
||||
<h2 id="orgc12310c"><span class="section-number-2">2</span> Atomic shell</h2>
|
||||
<div id="outline-container-org3107c2d" class="outline-2">
|
||||
<h2 id="org3107c2d"><span class="section-number-2">2</span> Atomic shell</h2>
|
||||
<div class="outline-text-2" id="text-2">
|
||||
<p>
|
||||
Set of contracted Gaussians differing only by the powers of \(x\), \(y\) and \(z\), with a
|
||||
@ -339,8 +339,8 @@ particular powers of \(x,y,z\) (<code>PrimitiveShell.norm_coef_scale</code>)</li
|
||||
</div>
|
||||
|
||||
|
||||
<div id="outline-container-org3e413df" class="outline-3">
|
||||
<h3 id="org3e413df"><span class="section-number-3">2.1</span> Type</h3>
|
||||
<div id="outline-container-orgd3e8a3d" class="outline-3">
|
||||
<h3 id="orgd3e8a3d"><span class="section-number-3">2.1</span> Type</h3>
|
||||
<div class="outline-text-3" id="text-2-1">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">type</span> <span class="org-type">t</span>
|
||||
@ -351,8 +351,8 @@ particular powers of \(x,y,z\) (<code>PrimitiveShell.norm_coef_scale</code>)</li
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgaa9e5a8" class="outline-3">
|
||||
<h3 id="orgaa9e5a8"><span class="section-number-3">2.2</span> Access</h3>
|
||||
<div id="outline-container-org3a79952" class="outline-3">
|
||||
<h3 id="org3a79952"><span class="section-number-3">2.2</span> Access</h3>
|
||||
<div class="outline-text-3" id="text-2-2">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">ang_mom</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-></span> <span class="org-tuareg-font-lock-module">Angular_momentum.</span>t
|
||||
@ -429,14 +429,14 @@ particular powers of \(x,y,z\) (<code>PrimitiveShell.norm_coef_scale</code>)</li
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<pre class="example" id="orgd663d82">
|
||||
<pre class="example" id="org2dea601">
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org40ea971" class="outline-3">
|
||||
<h3 id="org40ea971"><span class="section-number-3">2.3</span> Creation</h3>
|
||||
<div id="outline-container-orgf649255" class="outline-3">
|
||||
<h3 id="orgf649255"><span class="section-number-3">2.3</span> Creation</h3>
|
||||
<div class="outline-text-3" id="text-2-3">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">make</span> <span class="org-tuareg-font-lock-operator">:</span> <span class="org-tuareg-font-lock-label">?index</span><span class="org-tuareg-font-lock-operator">:</span>int <span class="org-tuareg-font-lock-operator">-></span> <span class="org-tuareg-font-lock-module">Contracted_shell.</span>t array <span class="org-tuareg-font-lock-operator">-></span> t
|
||||
@ -468,8 +468,8 @@ particular powers of \(x,y,z\) (<code>PrimitiveShell.norm_coef_scale</code>)</li
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org76ce11e" class="outline-3">
|
||||
<h3 id="org76ce11e"><span class="section-number-3">2.4</span> Printers</h3>
|
||||
<div id="outline-container-orgb538194" class="outline-3">
|
||||
<h3 id="orgb538194"><span class="section-number-3">2.4</span> Printers</h3>
|
||||
<div class="outline-text-3" id="text-2-4">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">pp</span> <span class="org-tuareg-font-lock-operator">:</span> <span class="org-tuareg-font-lock-module">Format.</span>formatter <span class="org-tuareg-font-lock-operator">-></span> t <span class="org-tuareg-font-lock-operator">-></span> unit
|
||||
@ -479,8 +479,8 @@ particular powers of \(x,y,z\) (<code>PrimitiveShell.norm_coef_scale</code>)</li
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org20ddf7f" class="outline-2">
|
||||
<h2 id="org20ddf7f"><span class="section-number-2">3</span> Atomic shell pair couple</h2>
|
||||
<div id="outline-container-org055d620" class="outline-2">
|
||||
<h2 id="org055d620"><span class="section-number-2">3</span> Atomic shell pair couple</h2>
|
||||
<div class="outline-text-2" id="text-3">
|
||||
<p>
|
||||
An atomic shell pair couple is the cartesian product between two sets of functions, one
|
||||
@ -496,8 +496,8 @@ acting on different electrons, since they will be coupled by a two-electron oper
|
||||
</div>
|
||||
|
||||
|
||||
<div id="outline-container-org79cc56e" class="outline-3">
|
||||
<h3 id="org79cc56e"><span class="section-number-3">3.1</span> Type</h3>
|
||||
<div id="outline-container-org85660fe" class="outline-3">
|
||||
<h3 id="org85660fe"><span class="section-number-3">3.1</span> Type</h3>
|
||||
<div class="outline-text-3" id="text-3-1">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">type</span> <span class="org-type">t</span>
|
||||
@ -508,8 +508,8 @@ acting on different electrons, since they will be coupled by a two-electron oper
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org2486daa" class="outline-3">
|
||||
<h3 id="org2486daa"><span class="section-number-3">3.2</span> Access</h3>
|
||||
<div id="outline-container-orgca1d510" class="outline-3">
|
||||
<h3 id="orgca1d510"><span class="section-number-3">3.2</span> Access</h3>
|
||||
<div class="outline-text-3" id="text-3-2">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">ang_mom</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-></span> <span class="org-tuareg-font-lock-module">Angular_momentum.</span>t
|
||||
@ -594,8 +594,8 @@ acting on different electrons, since they will be coupled by a two-electron oper
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org682c85c" class="outline-3">
|
||||
<h3 id="org682c85c"><span class="section-number-3">3.3</span> Creation</h3>
|
||||
<div id="outline-container-orgd5c48bb" class="outline-3">
|
||||
<h3 id="orgd5c48bb"><span class="section-number-3">3.3</span> Creation</h3>
|
||||
<div class="outline-text-3" id="text-3-3">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">make</span> <span class="org-tuareg-font-lock-operator">:</span> <span class="org-tuareg-font-lock-label">?cutoff</span><span class="org-tuareg-font-lock-operator">:</span>float <span class="org-tuareg-font-lock-operator">-></span> <span class="org-tuareg-font-lock-module">Atomic_shell_pair.</span>t <span class="org-tuareg-font-lock-operator">-></span> <span class="org-tuareg-font-lock-module">Atomic_shell_pair.</span>t <span class="org-tuareg-font-lock-operator">-></span> t option
|
||||
@ -621,14 +621,14 @@ Default cutoff is \(\epsilon\).
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<pre class="example" id="orgff2a8ea">
|
||||
<pre class="example" id="org1d1eb7f">
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org6d637d8" class="outline-3">
|
||||
<h3 id="org6d637d8"><span class="section-number-3">3.4</span> Printers</h3>
|
||||
<div id="outline-container-org2949ca5" class="outline-3">
|
||||
<h3 id="org2949ca5"><span class="section-number-3">3.4</span> Printers</h3>
|
||||
<div class="outline-text-3" id="text-3-4">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">pp</span> <span class="org-tuareg-font-lock-operator">:</span> <span class="org-tuareg-font-lock-module">Format.</span>formatter <span class="org-tuareg-font-lock-operator">-></span> t <span class="org-tuareg-font-lock-operator">-></span> unit
|
||||
@ -638,8 +638,8 @@ Default cutoff is \(\epsilon\).
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orge37a5fe" class="outline-2">
|
||||
<h2 id="orge37a5fe"><span class="section-number-2">4</span> Atomic shell pair</h2>
|
||||
<div id="outline-container-orge44bc1a" class="outline-2">
|
||||
<h2 id="orge44bc1a"><span class="section-number-2">4</span> Atomic shell pair</h2>
|
||||
<div class="outline-text-2" id="text-4">
|
||||
<p>
|
||||
Data structure to represent pairs of atomic shells. The products of
|
||||
@ -651,8 +651,8 @@ An atomic shell pair is an array of pairs of contracted shells.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org791264a" class="outline-3">
|
||||
<h3 id="org791264a"><span class="section-number-3">4.1</span> Type</h3>
|
||||
<div id="outline-container-org8d76a2d" class="outline-3">
|
||||
<h3 id="org8d76a2d"><span class="section-number-3">4.1</span> Type</h3>
|
||||
<div class="outline-text-3" id="text-4-1">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">type</span> <span class="org-type">t</span>
|
||||
@ -663,8 +663,8 @@ An atomic shell pair is an array of pairs of contracted shells.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orge08787d" class="outline-3">
|
||||
<h3 id="orge08787d"><span class="section-number-3">4.2</span> Access</h3>
|
||||
<div id="outline-container-orgdb75218" class="outline-3">
|
||||
<h3 id="orgdb75218"><span class="section-number-3">4.2</span> Access</h3>
|
||||
<div class="outline-text-3" id="text-4-2">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">atomic_shell_a</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-></span> <span class="org-tuareg-font-lock-module">Atomic_shell.</span>t
|
||||
@ -731,8 +731,8 @@ An atomic shell pair is an array of pairs of contracted shells.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org49ac790" class="outline-3">
|
||||
<h3 id="org49ac790"><span class="section-number-3">4.3</span> Creation</h3>
|
||||
<div id="outline-container-org813d710" class="outline-3">
|
||||
<h3 id="org813d710"><span class="section-number-3">4.3</span> Creation</h3>
|
||||
<div class="outline-text-3" id="text-4-3">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">make</span> <span class="org-tuareg-font-lock-operator">:</span> <span class="org-tuareg-font-lock-label">?cutoff</span><span class="org-tuareg-font-lock-operator">:</span>float <span class="org-tuareg-font-lock-operator">-></span> <span class="org-tuareg-font-lock-module">Atomic_shell.</span>t <span class="org-tuareg-font-lock-operator">-></span> <span class="org-tuareg-font-lock-module">Atomic_shell.</span>t <span class="org-tuareg-font-lock-operator">-></span> t option
|
||||
@ -765,8 +765,8 @@ If an atomic shell pair is not significant, sets the value to <code>None</code>.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgb4a074f" class="outline-3">
|
||||
<h3 id="orgb4a074f"><span class="section-number-3">4.4</span> Printers</h3>
|
||||
<div id="outline-container-org864a734" class="outline-3">
|
||||
<h3 id="org864a734"><span class="section-number-3">4.4</span> Printers</h3>
|
||||
<div class="outline-text-3" id="text-4-4">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">pp</span> <span class="org-tuareg-font-lock-operator">:</span> <span class="org-tuareg-font-lock-module">Format.</span>formatter <span class="org-tuareg-font-lock-operator">-></span> t <span class="org-tuareg-font-lock-operator">-></span> unit
|
||||
@ -778,7 +778,7 @@ If an atomic shell pair is not significant, sets the value to <code>None</code>.
|
||||
</div>
|
||||
<div id="postamble" class="status">
|
||||
<p class="author">Author: Anthony Scemama</p>
|
||||
<p class="date">Created: 2023-04-24 Mon 19:28</p>
|
||||
<p class="date">Created: 2023-06-16 Fri 09:49</p>
|
||||
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||
</div>
|
||||
</body>
|
||||
|
@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2023-04-24 Mon 13:50 -->
|
||||
<!-- 2023-06-16 Fri 18:25 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Gaussian integrals</title>
|
||||
@ -250,18 +250,18 @@ org_html_manager.setup(); // activate after the parameters are set
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents">
|
||||
<ul>
|
||||
<li><a href="#orgdc976ae">1. Summary</a></li>
|
||||
<li><a href="#org78d032d">1. Summary</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgdc976ae" class="outline-2">
|
||||
<h2 id="orgdc976ae"><span class="section-number-2">1</span> Summary</h2>
|
||||
<div id="outline-container-org78d032d" class="outline-2">
|
||||
<h2 id="org78d032d"><span class="section-number-2">1</span> Summary</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div id="postamble" class="status">
|
||||
<p class="author">Author: Anthony Scemama</p>
|
||||
<p class="date">Created: 2023-04-24 Mon 13:50</p>
|
||||
<p class="date">Created: 2023-06-16 Fri 18:25</p>
|
||||
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||
</div>
|
||||
</body>
|
||||
|
@ -3,7 +3,7 @@
|
||||
"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-12-13 Tue 10:55 -->
|
||||
<!-- 2023-05-26 Fri 15:34 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Linear Algebra</title>
|
||||
@ -250,18 +250,18 @@ org_html_manager.setup(); // activate after the parameters are set
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents">
|
||||
<ul>
|
||||
<li><a href="#orgb899d84">1. Summary</a></li>
|
||||
<li><a href="#orgdf211e4">1. Summary</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgb899d84" class="outline-2">
|
||||
<h2 id="orgb899d84"><span class="section-number-2">1</span> Summary</h2>
|
||||
<div id="outline-container-orgdf211e4" class="outline-2">
|
||||
<h2 id="orgdf211e4"><span class="section-number-2">1</span> Summary</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div id="postamble" class="status">
|
||||
<p class="author">Author: Anthony Scemama</p>
|
||||
<p class="date">Created: 2022-12-13 Tue 10:55</p>
|
||||
<p class="date">Created: 2023-05-26 Fri 15:34</p>
|
||||
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||
</div>
|
||||
</body>
|
||||
|
@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2023-04-24 Mon 19:28 -->
|
||||
<!-- 2023-06-16 Fri 18:25 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Top-level</title>
|
||||
@ -250,18 +250,18 @@ org_html_manager.setup(); // activate after the parameters are set
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents">
|
||||
<ul>
|
||||
<li><a href="#orgab35359">1. Summary</a></li>
|
||||
<li><a href="#orga2f9258">1. Summary</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgab35359" class="outline-2">
|
||||
<h2 id="orgab35359"><span class="section-number-2">1</span> Summary</h2>
|
||||
<div id="outline-container-orga2f9258" class="outline-2">
|
||||
<h2 id="orga2f9258"><span class="section-number-2">1</span> Summary</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div id="postamble" class="status">
|
||||
<p class="author">Author: Anthony Scemama</p>
|
||||
<p class="date">Created: 2023-04-24 Mon 19:28</p>
|
||||
<p class="date">Created: 2023-06-16 Fri 18:25</p>
|
||||
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||
</div>
|
||||
</body>
|
||||
|
@ -25,7 +25,7 @@
|
||||
QCaml provides a programming framewrok work wave function methods
|
||||
in quantum chemistry.")
|
||||
(depends
|
||||
(ocaml (>= 4.10))
|
||||
(ocaml (>= 5.0))
|
||||
(dune (>= 1.10))
|
||||
(camlp-streams (>= 5.0))
|
||||
trexio
|
||||
@ -33,6 +33,7 @@ in quantum chemistry.")
|
||||
getopt
|
||||
zarith
|
||||
alcotest
|
||||
domainslib
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
(* [[file:~/QCaml/examples/ex_hartree_fock.org::*Header][Header:1]] *)
|
||||
(* [[file:ex_hartree_fock.org::*Header][Header:1]] *)
|
||||
module Command_line = Qcaml.Common.Command_line
|
||||
module Util = Qcaml.Common.Util
|
||||
|
||||
let () =
|
||||
(* Header:1 ends here *)
|
||||
|
||||
(* [[file:~/QCaml/examples/ex_hartree_fock.org::*Definition][Definition:1]] *)
|
||||
(* [[file:ex_hartree_fock.org::*Definition][Definition:1]] *)
|
||||
let open Command_line in
|
||||
begin
|
||||
set_header_doc (Sys.argv.(0));
|
||||
@ -31,7 +31,7 @@ begin
|
||||
end;
|
||||
(* Definition:1 ends here *)
|
||||
|
||||
(* [[file:~/QCaml/examples/ex_hartree_fock.org::*Interpretation][Interpretation:1]] *)
|
||||
(* [[file:ex_hartree_fock.org::*Interpretation][Interpretation:1]] *)
|
||||
let basis_file = Util.of_some @@ Command_line.get "basis" in
|
||||
let nuclei_file = Util.of_some @@ Command_line.get "xyz" in
|
||||
|
||||
@ -51,26 +51,26 @@ let multiplicity =
|
||||
in
|
||||
(* Interpretation:1 ends here *)
|
||||
|
||||
(* [[file:~/QCaml/examples/ex_hartree_fock.org::*Computation][Computation:1]] *)
|
||||
(* [[file:ex_hartree_fock.org::*Computation][Computation:1]] *)
|
||||
let nuclei =
|
||||
Qcaml.Particles.Nuclei.of_xyz_file nuclei_file
|
||||
in
|
||||
(* Computation:1 ends here *)
|
||||
|
||||
(* [[file:~/QCaml/examples/ex_hartree_fock.org::*Computation][Computation:2]] *)
|
||||
(* [[file:ex_hartree_fock.org::*Computation][Computation:2]] *)
|
||||
let ao_basis =
|
||||
Qcaml.Ao.Basis.of_nuclei_and_basis_filename ~nuclei basis_file
|
||||
in
|
||||
(* Computation:2 ends here *)
|
||||
|
||||
(* [[file:~/QCaml/examples/ex_hartree_fock.org::*Computation][Computation:3]] *)
|
||||
let simulation = Qcaml.Simulation.make ~charge ~multiplicity ~nuclei ao_basis in
|
||||
(* [[file:ex_hartree_fock.org::*Computation][Computation:3]] *)
|
||||
let simulation = Qcaml.Simulation.make ~multiplicity ~charge ~nuclei ao_basis in
|
||||
(* Computation:3 ends here *)
|
||||
|
||||
(* [[file:~/QCaml/examples/ex_hartree_fock.org::*Computation][Computation:4]] *)
|
||||
(* [[file:ex_hartree_fock.org::*Computation][Computation:4]] *)
|
||||
let hf = Qcaml.Mo.Hartree_fock.make ~guess:`Huckel simulation in
|
||||
(* Computation:4 ends here *)
|
||||
|
||||
(* [[file:~/QCaml/examples/ex_hartree_fock.org::*Output][Output:1]] *)
|
||||
(* [[file:ex_hartree_fock.org::*Output][Output:1]] *)
|
||||
Format.printf "@[%a@]" (Mo.Hartree_fock.pp) hf
|
||||
(* Output:1 ends here *)
|
||||
|
@ -75,14 +75,16 @@ in
|
||||
#+END_SRC
|
||||
|
||||
* Computation
|
||||
|
||||
We first read the =xyz= file to create a molecule:
|
||||
|
||||
#+BEGIN_SRC ocaml :comments link :exports code :tangle ex_hartree_fock.ml
|
||||
let nuclei =
|
||||
Qcaml.Particles.Nuclei.of_xyz_file nuclei_file
|
||||
in
|
||||
#+END_SRC
|
||||
|
||||
Then we create an Gaussian AO basis using the atomic coordinates:
|
||||
Then we create a Gaussian AO basis using the atomic coordinates:
|
||||
#+BEGIN_SRC ocaml :comments link :exports code :tangle ex_hartree_fock.ml
|
||||
let ao_basis =
|
||||
Qcaml.Ao.Basis.of_nuclei_and_basis_filename ~nuclei basis_file
|
||||
@ -91,7 +93,7 @@ in
|
||||
|
||||
We create a simulation from the nuclei and the basis set:
|
||||
#+BEGIN_SRC ocaml :comments link :exports code :tangle ex_hartree_fock.ml
|
||||
let simulation = Qcaml.Simulation.make ~nuclei ao_basis in
|
||||
let simulation = Qcaml.Simulation.make ~multiplicity ~charge ~nuclei ao_basis in
|
||||
#+END_SRC
|
||||
|
||||
and we can make the Hartree-Fock computation:
|
||||
|
@ -107,13 +107,6 @@ let of_nuclei_and_basis_filenames ~nuclei filenames =
|
||||
|
||||
let of_trexio f =
|
||||
let nuclei = Particles.Nuclei.of_trexio f in
|
||||
(*
|
||||
let nucl_num = Array.length nuclei in
|
||||
let prim_num = Trexio.read_basis_prim_num f in
|
||||
let shell_num = Trexio.read_basis_shell_num f in
|
||||
let shell_factor = Trexio.read_basis_shell_factor f in
|
||||
let prim_factor = Trexio.read_basis_prim_factor f in
|
||||
*)
|
||||
let shell_ang_mom = Trexio.read_basis_shell_ang_mom f
|
||||
|> Array.map Common.Angular_momentum.of_int
|
||||
in
|
||||
@ -137,7 +130,7 @@ let of_trexio f =
|
||||
| Some x -> x
|
||||
| None -> assert false)
|
||||
in
|
||||
|
||||
|
||||
let index_ = ref 0 in
|
||||
let contracted_shells =
|
||||
Array.mapi (fun i (_,center) ->
|
||||
@ -180,9 +173,24 @@ let of_trexio f =
|
||||
{ contracted_shells ; atomic_shells ; size = !index_;
|
||||
general_basis = [];
|
||||
}
|
||||
|
||||
let to_trexio _ _ =
|
||||
|
||||
let to_trexio _f _t =
|
||||
failwith "Not implemented"
|
||||
(*
|
||||
Trexio.write_basis_type f "Gaussian" ;
|
||||
Trexio.write_basis_shell_num f t.size;
|
||||
let prim_num =
|
||||
Array.fold_left (fun accu i -> accu + Array.length i) 0 t.contracted_shells
|
||||
in
|
||||
Trexio.read_basis_prim_num f prim_num;
|
||||
let nucleus_index =
|
||||
Array.map
|
||||
in
|
||||
let shell_factor = Trexio.read_basis_shell_factor f in
|
||||
let prim_factor =
|
||||
Trexio.read_basis_prim_factor f in
|
||||
()
|
||||
*)
|
||||
|
||||
let pp ppf t =
|
||||
Format.fprintf ppf "@[%s@]" (to_string t)
|
||||
|
@ -50,6 +50,7 @@ with open(dunetest,'w') as f:
|
||||
alcotest
|
||||
unix
|
||||
trexio
|
||||
domainslib
|
||||
qcaml.{name}
|
||||
)
|
||||
)
|
||||
|
@ -2,7 +2,7 @@
|
||||
(library
|
||||
(name gaussian_integrals)
|
||||
(public_name qcaml.gaussian_integrals)
|
||||
(synopsis
|
||||
(synopsis
|
||||
"Integrals on the Gaussian basis sets"
|
||||
)
|
||||
(libraries
|
||||
@ -11,8 +11,9 @@
|
||||
qcaml.gaussian
|
||||
qcaml.operators
|
||||
unix
|
||||
domainslib
|
||||
)
|
||||
(modules_without_implementation matrix_on_basis)
|
||||
|
||||
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
(** Two electron integrals
|
||||
*)
|
||||
|
||||
|
||||
open Common
|
||||
open Linear_algebra
|
||||
open Gaussian
|
||||
@ -9,11 +10,12 @@ open Operators
|
||||
open Constants
|
||||
let cutoff = integrals_cutoff
|
||||
|
||||
module Bs = Basis
|
||||
module Cs = Contracted_shell
|
||||
module Csp = Contracted_shell_pair
|
||||
module Bs = Basis
|
||||
module Cs = Contracted_shell
|
||||
module Csp = Contracted_shell_pair
|
||||
module Cspc = Contracted_shell_pair_couple
|
||||
module Fis = Four_idx_storage
|
||||
module Fis = Four_idx_storage
|
||||
|
||||
|
||||
module type Two_ei_structure =
|
||||
sig
|
||||
@ -23,15 +25,16 @@ module type Two_ei_structure =
|
||||
end
|
||||
|
||||
|
||||
|
||||
module Make(T : Two_ei_structure) = struct
|
||||
|
||||
include Four_idx_storage
|
||||
type t = Basis.t Four_idx_storage.t
|
||||
|
||||
let class_of_contracted_shell_pair_couple = T.class_of_contracted_shell_pair_couple
|
||||
let class_of_contracted_shell_pair_couple = T.class_of_contracted_shell_pair_couple
|
||||
|
||||
let store_class ?(cutoff=integrals_cutoff) data contracted_shell_pair_couple cls =
|
||||
let to_powers x =
|
||||
let store_class ?(cutoff=integrals_cutoff) data contracted_shell_pair_couple cls =
|
||||
let to_powers x =
|
||||
let open Zkey in
|
||||
match to_powers x with
|
||||
| Three x -> x
|
||||
@ -49,7 +52,7 @@ module Make(T : Two_ei_structure) = struct
|
||||
let j_c = Cs.index (Csp.shell_b shell_p) + j_c + 1 in
|
||||
let xj = to_powers powers_j in
|
||||
Array.iteri (fun k_c powers_k ->
|
||||
let k_c = Cs.index (Csp.shell_a shell_q) + k_c + 1 in
|
||||
let k_c = Cs.index (Csp.shell_a shell_q) + k_c + 1 in
|
||||
let xk = to_powers powers_k in
|
||||
Array.iteri (fun l_c powers_l ->
|
||||
let l_c = Cs.index (Csp.shell_b shell_q) + l_c + 1 in
|
||||
@ -69,13 +72,13 @@ module Make(T : Two_ei_structure) = struct
|
||||
|
||||
|
||||
|
||||
let of_basis ?operator basis =
|
||||
let of_basis ?operator basis =
|
||||
|
||||
let n = Bs.size basis
|
||||
and shell = Bs.contracted_shells basis
|
||||
in
|
||||
|
||||
let eri_array =
|
||||
let eri_array =
|
||||
Fis.create ~size:n `Dense
|
||||
(*
|
||||
Fis.create ~size:n `Sparse
|
||||
@ -92,19 +95,11 @@ module Make(T : Two_ei_structure) = struct
|
||||
Printf.printf "%d significant shell pairs computed in %f seconds\n"
|
||||
(List.length shell_pairs) (Unix.gettimeofday () -. t0);
|
||||
|
||||
let ishell = ref max_int in
|
||||
|
||||
|
||||
|
||||
let t0 = Unix.gettimeofday () in
|
||||
|
||||
let f shell_p =
|
||||
let () =
|
||||
(*
|
||||
if Parallel.rank < 2 && Cs.index (Csp.shell_a shell_p) < !ishell then
|
||||
*)
|
||||
if Cs.index (Csp.shell_a shell_p) < !ishell then
|
||||
(ishell := Cs.index (Csp.shell_a shell_p) ; print_int !ishell ; print_newline ())
|
||||
let () =
|
||||
Printf.printf "%3d %3d\n%!" (Cs.index (Csp.shell_a shell_p)) (Cs.index (Csp.shell_b shell_p))
|
||||
in
|
||||
|
||||
let sp =
|
||||
@ -113,13 +108,13 @@ module Make(T : Two_ei_structure) = struct
|
||||
|
||||
try
|
||||
List.iter (fun shell_q ->
|
||||
let () =
|
||||
let () =
|
||||
if Cs.index (Csp.shell_a shell_q) >
|
||||
Cs.index (Csp.shell_a shell_p) then
|
||||
raise Exit
|
||||
in
|
||||
let sq = Csp.shell_pairs shell_q in
|
||||
let cspc =
|
||||
let cspc =
|
||||
if Array.length sp < Array.length sq then
|
||||
Cspc.make ~cutoff shell_p shell_q
|
||||
else
|
||||
@ -137,15 +132,19 @@ module Make(T : Two_ei_structure) = struct
|
||||
with Exit -> ()
|
||||
in
|
||||
|
||||
(*
|
||||
List.rev shell_pairs
|
||||
*)
|
||||
shell_pairs
|
||||
(*
|
||||
|> Parallel.list_iter f ;
|
||||
*)
|
||||
|> List.iter f;
|
||||
Printf.printf "Computed %s Integrals in parallel in %f seconds\n%!"
|
||||
|
||||
|
||||
let pool = Domainslib.Task.setup_pool ~num_domains:Qcaml.num_domains () in
|
||||
let _ =
|
||||
Domainslib.Task.run pool (fun _ ->
|
||||
shell_pairs
|
||||
|> List.map (fun sp ->
|
||||
Domainslib.Task.async pool (fun _ -> f sp) )
|
||||
|> List.iter (fun task -> ignore (Domainslib.Task.await pool task) ) ;
|
||||
)
|
||||
in
|
||||
Domainslib.Task.teardown_pool pool;
|
||||
Printf.printf "Computed %s Integrals in %f seconds\n%!"
|
||||
T.name (Unix.gettimeofday () -. t0);
|
||||
eri_array
|
||||
|
||||
|
229
linear_algebra/lib/cholesky.ml
Normal file
229
linear_algebra/lib/cholesky.ml
Normal file
@ -0,0 +1,229 @@
|
||||
open Lacaml.D
|
||||
|
||||
let full_ldl m_A =
|
||||
|
||||
let n = Mat.dim1 m_A in
|
||||
assert (Mat.dim2 m_A = n);
|
||||
|
||||
let v_D = Vec.make0 n in
|
||||
let m_Lt = Mat.identity n in
|
||||
|
||||
let v_D_inv = Vec.make0 n in
|
||||
|
||||
let compute_d j =
|
||||
let l_jk =
|
||||
Mat.col m_Lt j
|
||||
in
|
||||
let l_jk__d_k =
|
||||
Vec.mul ~n:(j-1) l_jk v_D
|
||||
in
|
||||
m_A.{j,j} -. dot ~n:(j-1) l_jk l_jk__d_k
|
||||
in
|
||||
|
||||
let compute_l i =
|
||||
let l_ik__d_k =
|
||||
Mat.col m_Lt i
|
||||
|> Vec.mul ~n:(i-1) v_D
|
||||
in
|
||||
fun j ->
|
||||
assert (i > j);
|
||||
let l_jk =
|
||||
Mat.col m_Lt j
|
||||
in
|
||||
v_D_inv.{j} *. ( m_A.{j,i} -. dot ~n:(j-1) l_ik__d_k l_jk )
|
||||
in
|
||||
|
||||
for i=1 to n do
|
||||
for j=1 to (i-1) do
|
||||
m_Lt.{j,i} <- compute_l i j;
|
||||
done;
|
||||
let d_i = compute_d i in
|
||||
v_D.{i} <- d_i;
|
||||
v_D_inv.{i} <- 1. /. d_i;
|
||||
done;
|
||||
m_Lt, v_D
|
||||
|
||||
|
||||
|
||||
|
||||
let pivoted_ldl threshold m_A =
|
||||
(* {% $P A P^\dagger = L D L^\dagger$. %}
|
||||
Input : Matrix $A$
|
||||
Output : Matrices $L, D, P$.
|
||||
*)
|
||||
|
||||
let n = Mat.dim1 m_A in
|
||||
assert (Mat.dim2 m_A = n);
|
||||
|
||||
let pi = Array.init (n+1) (fun i -> i) in
|
||||
|
||||
let v_D = Vec.init n (fun i -> abs_float m_A.{i,i}) in
|
||||
let m_Lt = Mat.identity n in
|
||||
|
||||
let v_D_inv = Vec.make0 n in
|
||||
|
||||
let compute_d i =
|
||||
let l_ik =
|
||||
Mat.col m_Lt i
|
||||
in
|
||||
let l_ik__d_k =
|
||||
Vec.mul ~n:(i-1) l_ik v_D
|
||||
in
|
||||
m_A.{pi.(i),pi.(i)} -. dot ~n:(i-1) l_ik l_ik__d_k
|
||||
in
|
||||
|
||||
let compute_l i =
|
||||
let l_ik__d_k =
|
||||
Mat.col m_Lt i
|
||||
|> Vec.mul ~n:(i-1) v_D
|
||||
in
|
||||
fun j ->
|
||||
assert (i > j);
|
||||
let l_jk =
|
||||
Mat.col m_Lt j
|
||||
in
|
||||
v_D_inv.{j} *. ( m_A.{pi.(j),pi.(i)} -. dot ~n:(j-1) l_ik__d_k l_jk )
|
||||
in
|
||||
|
||||
let maxloc v i =
|
||||
let rec aux pos value i =
|
||||
if i > n then
|
||||
pos
|
||||
else if v_D.{i} > value then
|
||||
aux i v_D.{i} (i+1)
|
||||
else
|
||||
aux pos value (i+1)
|
||||
in
|
||||
aux i v.{i} (i+1)
|
||||
in
|
||||
|
||||
|
||||
let pivot i =
|
||||
let j = maxloc v_D i in
|
||||
let p_i, p_j = pi.(i), pi.(j) in
|
||||
pi.(i) <- p_j;
|
||||
pi.(j) <- p_i;
|
||||
in
|
||||
|
||||
|
||||
let () =
|
||||
try
|
||||
for i=1 to n do
|
||||
pivot i;
|
||||
for j=1 to (i-1) do
|
||||
m_Lt.{j,i} <- compute_l i j;
|
||||
done;
|
||||
let d_i = compute_d i in
|
||||
if abs_float d_i < threshold then
|
||||
raise Exit;
|
||||
v_D.{i} <- d_i;
|
||||
v_D_inv.{i} <- 1. /. d_i;
|
||||
done
|
||||
with Exit -> ()
|
||||
in
|
||||
m_Lt, v_D, pi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(*
|
||||
let test_case () =
|
||||
|
||||
let matrix_diff m_A m_B =
|
||||
Mat.syrk_trace (Mat.sub m_A m_B)
|
||||
in
|
||||
|
||||
let vector_diff v_A v_B =
|
||||
let v = Vec.sub v_A v_B in
|
||||
dot v v
|
||||
in
|
||||
|
||||
let m_A = Mat.random 1000 1000 in
|
||||
let m_A = Mat.add m_A (Mat.transpose_copy m_A) in
|
||||
|
||||
let test_full_small () =
|
||||
let m_A =
|
||||
Mat.of_array [| [| 4. ; 12. ; -16. |] ;
|
||||
[| 12. ; 37. ; -43. |] ;
|
||||
[| -16. ; -43. ; 98. |] |]
|
||||
in
|
||||
|
||||
let m_L_ref =
|
||||
Mat.of_array [| [| 1. ; 0. ; 0. |] ;
|
||||
[| 3. ; 1. ; 0. |] ;
|
||||
[| -4. ; 5. ; 1. |] |]
|
||||
in
|
||||
|
||||
let m_Lt_ref =
|
||||
Mat.transpose_copy m_L_ref
|
||||
in
|
||||
|
||||
let v_D_ref =
|
||||
Vec.of_array [| 4. ; 1. ; 9. |]
|
||||
in
|
||||
|
||||
let m_Lt, v_D = full_ldl m_A in
|
||||
Alcotest.(check (float 1.e-15)) "full L" 0. (matrix_diff m_Lt m_Lt_ref);
|
||||
Alcotest.(check (float 1.e-15)) "full D" 0. (vector_diff v_D v_D_ref);
|
||||
let m_D = Mat.of_diag v_D in
|
||||
let m_B = gemm ~transa:`T m_Lt @@ gemm m_D m_Lt in
|
||||
Alcotest.(check (float 1.e-15)) "full L" 0. (matrix_diff m_A m_B);
|
||||
()
|
||||
in
|
||||
|
||||
let test_full () =
|
||||
let m_Lt, v_D = full_ldl m_A in
|
||||
let m_D = Mat.of_diag v_D in
|
||||
let m_B = gemm ~transa:`T m_Lt @@ gemm m_D m_Lt in
|
||||
Alcotest.(check (float 1.e-15)) "full D" 0. (matrix_diff m_A m_B);
|
||||
()
|
||||
in
|
||||
|
||||
let test_pivoted () =
|
||||
let m_Lt, v_D, pi = pivoted_ldl 0. m_A in
|
||||
let n = Mat.dim1 m_A in
|
||||
let m_P = Mat.make0 n n in
|
||||
for i=1 to n do
|
||||
m_P.{i,pi.(i)} <- 1.
|
||||
done;
|
||||
let m_D = Mat.of_diag v_D in
|
||||
let m_B =
|
||||
gemm ~transa:`T m_P @@
|
||||
gemm ~transa:`T m_Lt @@
|
||||
gemm m_D @@
|
||||
gemm m_Lt m_P
|
||||
in
|
||||
Alcotest.(check (float 1.e-14)) "pivoted D" 0. (matrix_diff m_A m_B);
|
||||
()
|
||||
in
|
||||
|
||||
let test_truncated () =
|
||||
let m_Lt, v_D, pi = pivoted_ldl 0.001 m_A in
|
||||
let n = Mat.dim1 m_Lt in
|
||||
let m_P = Mat.make0 n n in
|
||||
for i=1 to n do
|
||||
m_P.{i,pi.(i)} <- 1.
|
||||
done;
|
||||
let m_D = Mat.of_diag v_D in
|
||||
let m_B =
|
||||
gemm ~transa:`T m_P @@
|
||||
gemm ~transa:`T m_Lt @@
|
||||
gemm m_D @@
|
||||
gemm m_Lt m_P
|
||||
in
|
||||
Alcotest.(check (float 1.e-3)) "full D" 0. (matrix_diff m_A m_B);
|
||||
()
|
||||
in
|
||||
[
|
||||
"Small", `Quick, test_full_small;
|
||||
"Full", `Quick, test_full;
|
||||
"Pivoted", `Quick, test_pivoted ;
|
||||
"Truncated", `Quick, test_truncated ;
|
||||
]
|
||||
|
||||
*)
|
@ -18,7 +18,7 @@ description: """
|
||||
QCaml provides a programming framewrok work wave function methods
|
||||
in quantum chemistry."""
|
||||
depends: [
|
||||
"ocaml" {>= "4.10"}
|
||||
"ocaml" {>= "5.0"}
|
||||
"dune" {>= "1.10"}
|
||||
"camlp-streams" {>= "5.0"}
|
||||
"trexio"
|
||||
@ -26,4 +26,5 @@ depends: [
|
||||
"getopt"
|
||||
"zarith"
|
||||
"alcotest"
|
||||
"domainslib"
|
||||
]
|
||||
|
@ -1,10 +1,10 @@
|
||||
(* [[file:~/QCaml/simulation/simulation.org::*Simulation][Simulation:2]] *)
|
||||
(* [[file:../simulation.org::*Simulation][Simulation:2]] *)
|
||||
open Common
|
||||
open Particles
|
||||
open Operators
|
||||
(* Simulation:2 ends here *)
|
||||
|
||||
(* [[file:~/QCaml/simulation/simulation.org::*Type][Type:2]] *)
|
||||
(* [[file:../simulation.org::*Type][Type:2]] *)
|
||||
type t = {
|
||||
charge : Charge.t;
|
||||
electrons : Electrons.t;
|
||||
@ -24,7 +24,7 @@ type t = {
|
||||
* | ~operators~ | List of extra operators (range-separation, f12, etc) | *)
|
||||
|
||||
|
||||
(* [[file:~/QCaml/simulation/simulation.org::*Access][Access:2]] *)
|
||||
(* [[file:../simulation.org::*Access][Access:2]] *)
|
||||
let nuclei t = t.nuclei
|
||||
let charge t = t.charge
|
||||
let electrons t = t.electrons
|
||||
@ -41,7 +41,7 @@ let operators t = t.operators
|
||||
* - operators : ~[]~ *)
|
||||
|
||||
|
||||
(* [[file:~/QCaml/simulation/simulation.org::*Creation][Creation:2]] *)
|
||||
(* [[file:../simulation.org::*Creation][Creation:2]] *)
|
||||
let make
|
||||
?(multiplicity=1)
|
||||
?(charge=0)
|
||||
@ -65,7 +65,7 @@ let make
|
||||
{ charge ; nuclei ; electrons ; ao_basis ; operators}
|
||||
(* Creation:2 ends here *)
|
||||
|
||||
(* [[file:~/QCaml/simulation/simulation.org::*Printers][Printers:2]] *)
|
||||
(* [[file:../simulation.org::*Printers][Printers:2]] *)
|
||||
let pp ppf t =
|
||||
let formula = Nuclei.formula t.nuclei in
|
||||
let n_aos = Ao.Basis.size t.ao_basis in
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
* #+NAME: open *)
|
||||
|
||||
(* [[file:~/QCaml/simulation/simulation.org::open][open]] *)
|
||||
(* [[file:../simulation.org::open][open]] *)
|
||||
open Common
|
||||
open Particles
|
||||
open Operators
|
||||
@ -17,14 +17,14 @@ open Operators
|
||||
*
|
||||
* #+NAME: types *)
|
||||
|
||||
(* [[file:~/QCaml/simulation/simulation.org::types][types]] *)
|
||||
(* [[file:../simulation.org::types][types]] *)
|
||||
type t
|
||||
(* types ends here *)
|
||||
|
||||
(* Access *)
|
||||
|
||||
|
||||
(* [[file:~/QCaml/simulation/simulation.org::*Access][Access:1]] *)
|
||||
(* [[file:../simulation.org::*Access][Access:1]] *)
|
||||
val nuclei : t -> Nuclei.t
|
||||
val charge : t -> Charge.t
|
||||
val electrons : t -> Electrons.t
|
||||
@ -36,7 +36,7 @@ val operators : t -> Operator.t list
|
||||
(* Creation *)
|
||||
|
||||
|
||||
(* [[file:~/QCaml/simulation/simulation.org::*Creation][Creation:1]] *)
|
||||
(* [[file:../simulation.org::*Creation][Creation:1]] *)
|
||||
val make : ?multiplicity:int -> ?charge:int ->
|
||||
?operators:Operator.t list-> nuclei:Nuclei.t ->
|
||||
Ao.Basis.t -> t
|
||||
@ -45,6 +45,6 @@ val make : ?multiplicity:int -> ?charge:int ->
|
||||
(* Printers *)
|
||||
|
||||
|
||||
(* [[file:~/QCaml/simulation/simulation.org::*Printers][Printers:1]] *)
|
||||
(* [[file:../simulation.org::*Printers][Printers:1]] *)
|
||||
val pp : Format.formatter -> t -> unit
|
||||
(* Printers:1 ends here *)
|
||||
|
Loading…
Reference in New Issue
Block a user