10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-14 01:53:39 +01:00
QCaml/docs/particles.html

1057 lines
67 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2021-01-20 Wed 23:52 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Common</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="Anthony Scemama" />
<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: auto;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<link rel="stylesheet" type="text/css" href="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/css/htmlize.css"/>
<link rel="stylesheet" type="text/css" href="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/css/readtheorg.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://fniessen.github.io/org-html-themes/src/lib/js/jquery.stickytableheaders.min.js"></script>
<script type="text/javascript" src="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/js/readtheorg.js"></script>
<script type="text/javascript">
// @license magnet:?xt=urn:btih:e95b018ef3580986a04669f1b5879592219e2a7a&dn=public-domain.txt Public Domain
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.classList.add("code-highlighted");
target.classList.add("code-highlighted");
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.classList.remove("code-highlighted");
target.classList.remove("code-highlighted");
}
}
/*]]>*///-->
// @license-end
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
displayAlign: "center",
displayIndent: "0em",
"HTML-CSS": { scale: 100,
linebreaks: { automatic: "false" },
webFont: "TeX"
},
SVG: {scale: 100,
linebreaks: { automatic: "false" },
font: "TeX"},
NativeMML: {scale: 100},
TeX: { equationNumbers: {autoNumber: "AMS"},
MultLineWidth: "85%",
TagSide: "right",
TagIndent: ".8em"
}
});
</script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body>
<div id="org-div-home-and-up">
<a accesskey="h" href=""> UP </a>
|
<a accesskey="H" href="index.html"> HOME </a>
</div><div id="content">
<h1 class="title">Common</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org775ffd4">1. Electrons</a>
<ul>
<li><a href="#org8d7eb03">1.1. Type</a></li>
<li><a href="#org828c0b4">1.2. Creation</a></li>
<li><a href="#org7990560">1.3. Access</a></li>
<li><a href="#orge31a496">1.4. Printers</a></li>
<li><a href="#org810810a">1.5. Tests</a></li>
</ul>
</li>
<li><a href="#org192b2be">2. Element</a>
<ul>
<li><a href="#org8abd3f7">2.1. Type</a></li>
<li><a href="#orgfb1e8c0">2.2. Conversion</a></li>
<li><a href="#org7920ab5">2.3. Database information</a></li>
<li><a href="#orgd9e4111">2.4. Printers</a></li>
</ul>
</li>
<li><a href="#org683f181">3. Atomic mass</a></li>
<li><a href="#org69bdfa4">4. Nuclei</a>
<ul>
<li><a href="#orgd713019">4.1. Type</a></li>
<li><a href="#org4bd7221">4.2. xyz file lexer/parser</a>
<ul>
<li><a href="#org7281519">4.2.1. Lexer</a></li>
<li><a href="#org0b56536">4.2.2. Parser</a></li>
</ul>
</li>
<li><a href="#orgf5cc2de">4.3. Conversion</a></li>
<li><a href="#org070bc98">4.4. <span class="todo TODO">TODO</span> Query</a></li>
<li><a href="#org1ab3f3a">4.5. Printers</a></li>
<li><a href="#org59045e6">4.6. Tests</a></li>
</ul>
</li>
<li><a href="#org35f99d4">5. Z-matrix</a>
<ul>
<li><a href="#org74ef0d8">5.1. Type</a></li>
<li><a href="#org4b91a4e">5.2. Conversion</a></li>
<li><a href="#orgbec757c">5.3. Printers</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="org-src-container">
<pre class="src src-ocaml" id="org5e7fdf1"><span class="org-string">"Information relative to particles (electrons and nuclei)."</span>
</pre>
</div>
<div id="outline-container-org775ffd4" class="outline-2">
<h2 id="org775ffd4"><span class="section-number-2">1</span> Electrons</h2>
<div class="outline-text-2" id="text-1">
<p>
Data structure which contains the number of &alpha; and &beta; electrons.
</p>
</div>
<div id="outline-container-org8d7eb03" class="outline-3">
<h3 id="org8d7eb03"><span class="section-number-3">1.1</span> Type</h3>
<div class="outline-text-3" id="text-1-1">
<div class="org-src-container">
<pre class="src src-ocaml" id="org777e0db"><span class="org-tuareg-font-lock-governing">type</span> <span class="org-type">t</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org828c0b4" class="outline-3">
<h3 id="org828c0b4"><span class="section-number-3">1.2</span> Creation</h3>
<div class="outline-text-3" id="text-1-2">
<div class="org-src-container">
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">open </span><span class="org-tuareg-font-lock-module">Common</span>
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">make</span> <span class="org-tuareg-font-lock-operator">:</span> int <span class="org-tuareg-font-lock-operator">-&gt;</span> int <span class="org-tuareg-font-lock-operator">-&gt;</span> t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">of_atoms</span> <span class="org-tuareg-font-lock-operator">:</span> <span class="org-tuareg-font-lock-label">?multiplicity</span><span class="org-tuareg-font-lock-operator">:</span>int <span class="org-tuareg-font-lock-operator">-&gt;</span> <span class="org-tuareg-font-lock-label">?charge</span><span class="org-tuareg-font-lock-operator">:</span>int <span class="org-tuareg-font-lock-operator">-&gt;</span> <span class="org-tuareg-font-lock-module">Nuclei.</span>t <span class="org-tuareg-font-lock-operator">-&gt;</span> t
<span class="org-comment-delimiter">(* </span><span class="org-comment">@param multiplicity default is 1</span>
<span class="org-comment"> @param charge default is 0</span>
<span class="org-comment"> @raise Invalid_argument if the spin multiplicity is not compatible with</span>
<span class="org-comment"> the molecule and the total charge.</span>
<span class="org-comment-delimiter">*)</span>
</pre>
</div>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left"><code>make</code></td>
<td class="org-left"><code>make n_alfa n_beta</code></td>
</tr>
<tr>
<td class="org-left"><code>of_atoms</code></td>
<td class="org-left">Creates the data relative to electrons for a molecular system described by <a href="#orgc195f64"><code>Nuclei.t</code></a> for a given total charge and spin multiplicity.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-org7990560" class="outline-3">
<h3 id="org7990560"><span class="section-number-3">1.3</span> Access</h3>
<div class="outline-text-3" id="text-1-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">charge</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> <span class="org-tuareg-font-lock-module">Charge.</span>t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">n_elec</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> int
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">n_alfa</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> int
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">n_beta</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> int
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">multiplicity</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> int
</pre>
</div>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left"><code>charge</code></td>
<td class="org-left">Sum of the charges of the electrons</td>
</tr>
<tr>
<td class="org-left"><code>n_elec</code></td>
<td class="org-left">Number of electrons</td>
</tr>
<tr>
<td class="org-left"><code>n_alfa</code></td>
<td class="org-left">Number of alpha electrons</td>
</tr>
<tr>
<td class="org-left"><code>n_beta</code></td>
<td class="org-left">Number of beta electrons</td>
</tr>
<tr>
<td class="org-left"><code>multiplicity</code></td>
<td class="org-left">Spin multiplicity: \(2S+1\)</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-orge31a496" class="outline-3">
<h3 id="orge31a496"><span class="section-number-3">1.4</span> Printers</h3>
<div class="outline-text-3" id="text-1-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">-&gt;</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> unit
</pre>
</div>
</div>
</div>
<div id="outline-container-org810810a" class="outline-3">
<h3 id="org810810a"><span class="section-number-3">1.5</span> Tests</h3>
</div>
</div>
<div id="outline-container-org192b2be" class="outline-2">
<h2 id="org192b2be"><span class="section-number-2">2</span> Element</h2>
<div class="outline-text-2" id="text-2">
<p>
Chemical elements.
</p>
</div>
<div id="outline-container-org8abd3f7" class="outline-3">
<h3 id="org8abd3f7"><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" id="orgc857d0f"><span class="org-tuareg-font-lock-governing">type</span> <span class="org-type">t</span> <span class="org-tuareg-font-lock-operator">=</span>
<span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">X</span>
<span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">H</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">He</span>
<span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Li</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Be</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">B</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">C</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">N</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">O</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">F</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Ne</span>
<span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Na</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Mg</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Al</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Si</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">P</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">S</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Cl</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Ar</span>
<span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">K</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Ca</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Sc</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Ti</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">V</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Cr</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Mn</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Fe</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Co</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Ni</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Cu</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Zn</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Ga</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Ge</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">As</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Se</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Br</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Kr</span>
<span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Rb</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Sr</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Y</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Zr</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Nb</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Mo</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Tc</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Ru</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Rh</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Pd</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Ag</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Cd</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">In</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Sn</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Sb</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Te</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">I</span> <span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Xe</span>
<span class="org-tuareg-font-lock-operator">|</span><span class="org-tuareg-font-lock-constructor">Pt</span>
<span class="org-keyword">exception</span> <span class="org-tuareg-font-lock-constructor">ElementError</span> <span class="org-keyword">of</span> string
<span class="org-tuareg-font-lock-governing">open </span><span class="org-tuareg-font-lock-module">Common</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgfb1e8c0" class="outline-3">
<h3 id="orgfb1e8c0"><span class="section-number-3">2.2</span> Conversion</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">of_string</span> <span class="org-tuareg-font-lock-operator">:</span> string <span class="org-tuareg-font-lock-operator">-&gt;</span> t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">to_string</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> string
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">to_long_string</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> string
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">to_int</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> int
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">of_int</span> <span class="org-tuareg-font-lock-operator">:</span> int <span class="org-tuareg-font-lock-operator">-&gt;</span> t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">to_charge</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> <span class="org-tuareg-font-lock-module">Charge.</span>t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">of_charge</span> <span class="org-tuareg-font-lock-operator">:</span> <span class="org-tuareg-font-lock-module">Charge.</span>t <span class="org-tuareg-font-lock-operator">-&gt;</span> t
</pre>
</div>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left"><code>of_string</code></td>
<td class="org-left">Creates an <code>Element.t</code> from a chemical symbol or from the full name of the element (case insensitive)</td>
</tr>
<tr>
<td class="org-left"><code>to_string</code></td>
<td class="org-left">Gets the chemical symbol of the <code>Element.t</code> in a string</td>
</tr>
<tr>
<td class="org-left"><code>to_long_string</code></td>
<td class="org-left">Gets the full name of the <code>Element.t</code> in a string</td>
</tr>
<tr>
<td class="org-left"><code>to_int</code></td>
<td class="org-left">Convert to the atomic charge, with <code>int</code> type</td>
</tr>
<tr>
<td class="org-left"><code>of_int</code></td>
<td class="org-left">Create from the atomic charge, with <code>int</code> type</td>
</tr>
<tr>
<td class="org-left"><code>to_charge</code></td>
<td class="org-left">Convert to the atomic charge, with <code>Charge.t</code> type</td>
</tr>
<tr>
<td class="org-left"><code>of_charge</code></td>
<td class="org-left">Create from the atomic charge, with <code>Charge.t</code> type</td>
</tr>
</tbody>
</table>
<pre class="example" id="org6c6cf9f">
Element.of_string "Fe" ;;
- : Element.t = Particles.Element.Fe
Element.of_string "hydrogen" ;;
- : Element.t = Particles.Element.H
Element.of_string "Kryptonite" ;;
Exception: Particles.Element.ElementError "Element Kryptonite unknown".
Element.(to_long_string Fe) ;;
- : string = "Iron"
Element.(to_string Fe);;
- : string = "Fe"
</pre>
</div>
</div>
<div id="outline-container-org7920ab5" class="outline-3">
<h3 id="org7920ab5"><span class="section-number-3">2.3</span> Database information</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">covalent_radius</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> <span class="org-tuareg-font-lock-module">Non_negative_float.</span>t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">vdw_radius</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> <span class="org-tuareg-font-lock-module">Non_negative_float.</span>t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">mass</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> <span class="org-tuareg-font-lock-module">Mass.</span>t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">small_core</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> int
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">large_core</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> int
</pre>
</div>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left"><code>covalent_radius</code></td>
<td class="org-left">Covalent radii of the elements, in atomic units</td>
</tr>
<tr>
<td class="org-left"><code>vdw_radius</code></td>
<td class="org-left">Van der Waals radii of the elements, in atomic units</td>
</tr>
<tr>
<td class="org-left"><code>mass</code></td>
<td class="org-left">Atomic mass of the elements, in atomic units)</td>
</tr>
<tr>
<td class="org-left"><code>small_core</code></td>
<td class="org-left">Number of electrons in the small core model (all except the outermost two shells)</td>
</tr>
<tr>
<td class="org-left"><code>large_core</code></td>
<td class="org-left">Number of electrons in the large core model (all except the outermost shell)</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-orgd9e4111" class="outline-3">
<h3 id="orgd9e4111"><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">-&gt;</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> unit
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">pp_long</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">-&gt;</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> unit
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org683f181" class="outline-2">
<h2 id="org683f181"><span class="section-number-2">3</span> Atomic mass</h2>
<div class="outline-text-2" id="text-3">
<p>
Atomic mass, a non-negative float.
</p>
<div class="org-src-container">
<pre class="src src-ocaml" id="org7467a2c"><span class="org-tuareg-font-lock-governing">include</span> <span class="org-tuareg-font-lock-governing">module type of</span> <span class="org-tuareg-font-lock-module">Common.Non_negative_float</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org69bdfa4" class="outline-2">
<h2 id="org69bdfa4"><span class="section-number-2">4</span> Nuclei</h2>
<div class="outline-text-2" id="text-4">
</div>
<div id="outline-container-orgd713019" class="outline-3">
<h3 id="orgd713019"><span class="section-number-3">4.1</span> Type</h3>
<div class="outline-text-3" id="text-4-1">
<p>
<a id="orgc195f64"><code>Nuclei.t</code></a>
</p>
<div class="org-src-container">
<pre class="src src-ocaml" id="orgf7c74d8"><span class="org-tuareg-font-lock-governing">open </span><span class="org-tuareg-font-lock-module">Common</span>
<span class="org-tuareg-font-lock-governing">type</span> <span class="org-type">t</span> <span class="org-tuareg-font-lock-operator">=</span> <span class="org-tuareg-font-lock-operator">(</span><span class="org-tuareg-font-lock-module">Element.</span>t <span class="org-tuareg-font-lock-operator">*</span> <span class="org-tuareg-font-lock-module">Coordinate.</span>t<span class="org-tuareg-font-lock-operator">)</span> array
</pre>
</div>
</div>
</div>
<div id="outline-container-org4bd7221" class="outline-3">
<h3 id="org4bd7221"><span class="section-number-3">4.2</span> xyz file lexer/parser</h3>
<div class="outline-text-3" id="text-4-2">
</div>
<div id="outline-container-org7281519" class="outline-4">
<h4 id="org7281519"><span class="section-number-4">4.2.1</span> Lexer</h4>
<div class="outline-text-4" id="text-4-2-1">
<p>
<code>nuclei_lexer.mll</code> contains the description of the lexemes used in
an xyz file.
</p>
<div class="org-src-container">
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-operator">{</span>
<span class="org-tuareg-font-lock-governing">open </span><span class="org-tuareg-font-lock-module">Xyz_parser</span>
<span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-governing">let</span> <span class="org-variable-name">eol</span> <span class="org-tuareg-font-lock-operator">=</span> <span class="org-tuareg-font-lock-operator">[</span><span class="org-string">'\n'</span><span class="org-tuareg-font-lock-operator">]</span>
<span class="org-tuareg-font-lock-governing">let</span> <span class="org-variable-name">white</span> <span class="org-tuareg-font-lock-operator">=</span> <span class="org-tuareg-font-lock-operator">[</span><span class="org-string">' '</span> <span class="org-string">'\t'</span><span class="org-tuareg-font-lock-operator">]+</span>
<span class="org-tuareg-font-lock-governing">let</span> <span class="org-variable-name">word</span> <span class="org-tuareg-font-lock-operator">=</span> <span class="org-tuareg-font-lock-operator">[^</span><span class="org-string">' '</span> <span class="org-string">'\t'</span> <span class="org-string">'\n'</span><span class="org-tuareg-font-lock-operator">]+</span>
<span class="org-tuareg-font-lock-governing">let</span> <span class="org-variable-name">letter</span> <span class="org-tuareg-font-lock-operator">=</span> <span class="org-tuareg-font-lock-operator">[</span><span class="org-string">'A'</span><span class="org-tuareg-font-lock-operator">-</span><span class="org-string">'Z'</span> <span class="org-string">'a'</span><span class="org-tuareg-font-lock-operator">-</span><span class="org-string">'z'</span><span class="org-tuareg-font-lock-operator">]</span>
<span class="org-tuareg-font-lock-governing">let</span> <span class="org-variable-name">integer</span> <span class="org-tuareg-font-lock-operator">=</span> <span class="org-tuareg-font-lock-operator">[</span><span class="org-string">'0'</span><span class="org-tuareg-font-lock-operator">-</span><span class="org-string">'9'</span><span class="org-tuareg-font-lock-operator">]+</span>
<span class="org-tuareg-font-lock-governing">let</span> <span class="org-variable-name">real</span> <span class="org-tuareg-font-lock-operator">=</span> <span class="org-string">'-'</span><span class="org-tuareg-font-lock-operator">?</span> <span class="org-tuareg-font-lock-operator">(</span>integer <span class="org-string">'.'</span> integer <span class="org-tuareg-font-lock-operator">|</span> integer <span class="org-string">'.'</span> <span class="org-tuareg-font-lock-operator">|</span> <span class="org-string">'.'</span> integer<span class="org-tuareg-font-lock-operator">)</span> <span class="org-tuareg-font-lock-operator">([</span><span class="org-string">'e'</span> <span class="org-string">'E'</span><span class="org-tuareg-font-lock-operator">]</span> <span class="org-tuareg-font-lock-operator">(</span><span class="org-string">'+'</span><span class="org-tuareg-font-lock-operator">|</span><span class="org-string">'-'</span><span class="org-tuareg-font-lock-operator">)?</span> integer<span class="org-tuareg-font-lock-operator">)?</span>
rule read_all <span class="org-tuareg-font-lock-operator">=</span> parse
<span class="org-tuareg-font-lock-operator">|</span> eof <span class="org-tuareg-font-lock-operator">{</span> <span class="org-tuareg-font-lock-constructor">EOF</span> <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> eol <span class="org-tuareg-font-lock-operator">{</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> white <span class="org-keyword">as</span> w <span class="org-tuareg-font-lock-operator">{</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> w <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> integer <span class="org-keyword">as</span> i <span class="org-tuareg-font-lock-operator">{</span> <span class="org-tuareg-font-lock-constructor">INTEGER</span> <span class="org-tuareg-font-lock-operator">(</span>int_of_string i<span class="org-tuareg-font-lock-operator">)</span> <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> real <span class="org-keyword">as</span> f <span class="org-tuareg-font-lock-operator">{</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-operator">(</span>float_of_string f<span class="org-tuareg-font-lock-operator">)</span> <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> word <span class="org-keyword">as</span> w <span class="org-tuareg-font-lock-operator">{</span> <span class="org-tuareg-font-lock-constructor">WORD</span> w <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">{</span>
<span class="org-comment-delimiter">(* </span><span class="org-comment">DEBUG</span>
<span class="org-comment"> let () =</span>
<span class="org-comment"> let ic = open_in "h2o.xyz" in</span>
<span class="org-comment"> let lexbuf = Lexing.from_channel ic in</span>
<span class="org-comment"> while true do</span>
<span class="org-comment"> let s =</span>
<span class="org-comment"> match read_all lexbuf with</span>
<span class="org-comment"> | EOL -&gt; "EOL"</span>
<span class="org-comment"> | SPACE w -&gt; "SPACE("^w^")"</span>
<span class="org-comment"> | INTEGER i -&gt; "INTEGER("^(string_of_int i)^")"</span>
<span class="org-comment"> | FLOAT f -&gt; "FLOAT("^(string_of_float f)^")"</span>
<span class="org-comment"> | WORD w -&gt; "WORD("^w^")"</span>
<span class="org-comment"> | EOF -&gt; "EOF"</span>
<span class="org-comment"> in</span>
<span class="org-comment"> print_endline s</span>
<span class="org-comment"> done;</span>
<span class="org-comment-delimiter">*)</span>
<span class="org-tuareg-font-lock-operator">}</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org0b56536" class="outline-4">
<h4 id="org0b56536"><span class="section-number-4">4.2.2</span> Parser</h4>
<div class="outline-text-4" id="text-4-2-2">
<p>
<code>xyz_parser.mly</code> parses nuclear coordinates in xyz format.
</p>
<div class="org-src-container">
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-operator">%{</span>
<span class="org-tuareg-font-lock-governing">open </span><span class="org-tuareg-font-lock-module">Common</span>
<span class="org-tuareg-font-lock-governing">let</span> <span class="org-function-name">make_angstrom</span><span class="org-variable-name"> x y z</span> <span class="org-tuareg-font-lock-operator">=</span>
<span class="org-tuareg-font-lock-module">Coordinate.</span><span class="org-tuareg-font-lock-operator">(</span>make_angstrom <span class="org-tuareg-font-lock-operator">{</span>
x <span class="org-tuareg-font-lock-operator">;</span> y <span class="org-tuareg-font-lock-operator">;</span> z
<span class="org-tuareg-font-lock-operator">})</span>
<span class="org-tuareg-font-lock-governing">let</span> <span class="org-function-name">output_of</span><span class="org-variable-name"> f x y z</span> <span class="org-tuareg-font-lock-operator">=</span>
<span class="org-tuareg-font-lock-governing">let</span> <span class="org-variable-name">a</span> <span class="org-tuareg-font-lock-operator">=</span> make_angstrom x y z <span class="org-tuareg-font-lock-governing">in</span>
<span class="org-keyword">fun</span> <span class="org-variable-name">e</span> <span class="org-tuareg-font-lock-operator">-&gt;</span>
<span class="org-tuareg-font-lock-operator">{</span>
<span class="org-tuareg-font-lock-module">Xyz_ast.</span>
element <span class="org-tuareg-font-lock-operator">=</span> f e<span class="org-tuareg-font-lock-operator">;</span>
coord <span class="org-tuareg-font-lock-operator">=</span> a <span class="org-tuareg-font-lock-operator">;</span>
<span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-governing">let</span> <span class="org-variable-name">output_of_string</span> <span class="org-tuareg-font-lock-operator">=</span> output_of <span class="org-tuareg-font-lock-module">Element.</span>of_string
<span class="org-tuareg-font-lock-governing">let</span> <span class="org-variable-name">output_of_int</span> <span class="org-tuareg-font-lock-operator">=</span> output_of <span class="org-tuareg-font-lock-module">Element.</span>of_int
<span class="org-tuareg-font-lock-operator">%}</span>
<span class="org-tuareg-font-lock-operator">%</span>token <span class="org-tuareg-font-lock-constructor">EOL</span>
<span class="org-tuareg-font-lock-operator">%</span>token <span class="org-tuareg-font-lock-operator">&lt;</span>string<span class="org-tuareg-font-lock-operator">&gt;</span> <span class="org-tuareg-font-lock-constructor">SPACE</span>
<span class="org-tuareg-font-lock-operator">%</span>token <span class="org-tuareg-font-lock-operator">&lt;</span>string<span class="org-tuareg-font-lock-operator">&gt;</span> <span class="org-tuareg-font-lock-constructor">WORD</span>
<span class="org-tuareg-font-lock-operator">%</span>token <span class="org-tuareg-font-lock-operator">&lt;</span>int<span class="org-tuareg-font-lock-operator">&gt;</span> <span class="org-tuareg-font-lock-constructor">INTEGER</span>
<span class="org-tuareg-font-lock-operator">%</span>token <span class="org-tuareg-font-lock-operator">&lt;</span>float<span class="org-tuareg-font-lock-operator">&gt;</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span>
<span class="org-tuareg-font-lock-operator">%</span>token <span class="org-tuareg-font-lock-constructor">EOF</span>
<span class="org-tuareg-font-lock-operator">%</span>start input
<span class="org-tuareg-font-lock-operator">%</span><span class="org-tuareg-font-lock-governing">type</span> <span class="org-tuareg-font-lock-operator">&lt;</span><span class="org-tuareg-font-lock-module">Xyz_ast.</span>xyz_file<span class="org-tuareg-font-lock-operator">&gt;</span> input
<span class="org-tuareg-font-lock-operator">%%</span> <span class="org-tuareg-font-lock-operator">/*</span> <span class="org-tuareg-font-lock-constructor">Grammar</span> rules <span class="org-tuareg-font-lock-governing">and</span> <span class="org-function-name">actions</span><span class="org-variable-name"> follow</span> <span class="org-tuareg-font-lock-operator">*/</span>
input<span class="org-tuareg-font-lock-operator">:</span>
<span class="org-tuareg-font-lock-operator">|</span> integer title atoms_xyz <span class="org-tuareg-font-lock-operator">{</span>
<span class="org-tuareg-font-lock-operator">{</span>
number_of_atoms <span class="org-tuareg-font-lock-operator">=</span> $1<span class="org-tuareg-font-lock-operator">;</span>
file_title <span class="org-tuareg-font-lock-operator">=</span> $2<span class="org-tuareg-font-lock-operator">;</span>
nuclei <span class="org-tuareg-font-lock-operator">=</span> $3<span class="org-tuareg-font-lock-operator">;</span>
<span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">;</span>
integer<span class="org-tuareg-font-lock-operator">:</span>
<span class="org-tuareg-font-lock-operator">|</span> <span class="org-tuareg-font-lock-constructor">INTEGER</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> <span class="org-tuareg-font-lock-constructor">INTEGER</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">INTEGER</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> $2 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">INTEGER</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> $2 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">;</span>
title<span class="org-tuareg-font-lock-operator">:</span>
<span class="org-tuareg-font-lock-operator">|</span> title_list <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">;</span>
text<span class="org-tuareg-font-lock-operator">:</span>
<span class="org-tuareg-font-lock-operator">|</span> <span class="org-tuareg-font-lock-constructor">WORD</span> <span class="org-tuareg-font-lock-operator">{</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-operator">{</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-operator">{</span> <span class="org-tuareg-font-lock-operator">(</span>string_of_float $1<span class="org-tuareg-font-lock-operator">)}</span>
<span class="org-tuareg-font-lock-operator">|</span> <span class="org-tuareg-font-lock-constructor">INTEGER</span> <span class="org-tuareg-font-lock-operator">{</span> <span class="org-tuareg-font-lock-operator">(</span>string_of_int $1<span class="org-tuareg-font-lock-operator">)}</span>
<span class="org-tuareg-font-lock-operator">;</span>
title_list<span class="org-tuareg-font-lock-operator">:</span>
<span class="org-tuareg-font-lock-operator">|</span> <span class="org-tuareg-font-lock-operator">{</span> <span class="org-string">""</span> <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> title_list text <span class="org-tuareg-font-lock-operator">{</span> <span class="org-tuareg-font-lock-operator">(</span>$1 <span class="org-tuareg-font-lock-operator">^</span> $2<span class="org-tuareg-font-lock-operator">)</span> <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">;</span>
atoms_xyz<span class="org-tuareg-font-lock-operator">:</span>
<span class="org-tuareg-font-lock-operator">|</span> atoms_list <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> <span class="org-tuareg-font-lock-module">List.</span>rev $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> atoms_list <span class="org-tuareg-font-lock-constructor">EOF</span> <span class="org-tuareg-font-lock-operator">{</span> <span class="org-tuareg-font-lock-module">List.</span>rev $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">;</span>
atoms_list<span class="org-tuareg-font-lock-operator">:</span>
<span class="org-tuareg-font-lock-operator">|</span> <span class="org-tuareg-font-lock-operator">{</span> <span class="org-tuareg-font-lock-operator">[]</span> <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> atoms_list <span class="org-tuareg-font-lock-constructor">WORD</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> output_of_string $4 $6 $8 $2 <span class="org-tuareg-font-lock-operator">::</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> atoms_list <span class="org-tuareg-font-lock-constructor">WORD</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> output_of_string $4 $6 $8 $2 <span class="org-tuareg-font-lock-operator">::</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> atoms_list <span class="org-tuareg-font-lock-constructor">INTEGER</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> output_of_int $4 $6 $8 $2 <span class="org-tuareg-font-lock-operator">::</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> atoms_list <span class="org-tuareg-font-lock-constructor">INTEGER</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> output_of_int $4 $6 $8 $2 <span class="org-tuareg-font-lock-operator">::</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> atoms_list <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">WORD</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> output_of_string $5 $7 $9 $3 <span class="org-tuareg-font-lock-operator">::</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> atoms_list <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">WORD</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> output_of_string $5 $7 $9 $3 <span class="org-tuareg-font-lock-operator">::</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> atoms_list <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">INTEGER</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> output_of_int $5 $7 $9 $3 <span class="org-tuareg-font-lock-operator">::</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">|</span> atoms_list <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">INTEGER</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">FLOAT</span> <span class="org-tuareg-font-lock-constructor">SPACE</span> <span class="org-tuareg-font-lock-constructor">EOL</span> <span class="org-tuareg-font-lock-operator">{</span> output_of_int $5 $7 $9 $3 <span class="org-tuareg-font-lock-operator">::</span> $1 <span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-operator">;</span>
</pre>
</div>
<p>
When an xyz file is read by <code>xyz_parser.mly</code>, it is converted into
an <code>xyz_file</code> data structure.
</p>
<div class="org-src-container">
<pre class="src src-ocaml"><span class="org-tuareg-font-lock-governing">open </span><span class="org-tuareg-font-lock-module">Common</span>
<span class="org-tuareg-font-lock-governing">type</span> <span class="org-type">nucleus</span> <span class="org-tuareg-font-lock-operator">=</span>
<span class="org-tuareg-font-lock-operator">{</span>
element<span class="org-tuareg-font-lock-operator">:</span> <span class="org-tuareg-font-lock-module">Element.</span>t <span class="org-tuareg-font-lock-operator">;</span>
coord <span class="org-tuareg-font-lock-operator">:</span> <span class="org-tuareg-font-lock-module">Coordinate.</span>angstrom <span class="org-tuareg-font-lock-module">Coordinate.</span>point<span class="org-tuareg-font-lock-operator">;</span>
<span class="org-tuareg-font-lock-operator">}</span>
<span class="org-tuareg-font-lock-governing">type</span> <span class="org-type">xyz_file</span> <span class="org-tuareg-font-lock-operator">=</span>
<span class="org-tuareg-font-lock-operator">{</span>
number_of_atoms <span class="org-tuareg-font-lock-operator">:</span> int <span class="org-tuareg-font-lock-operator">;</span>
file_title <span class="org-tuareg-font-lock-operator">:</span> string <span class="org-tuareg-font-lock-operator">;</span>
nuclei <span class="org-tuareg-font-lock-operator">:</span> nucleus list <span class="org-tuareg-font-lock-operator">;</span>
<span class="org-tuareg-font-lock-operator">}</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgf5cc2de" class="outline-3">
<h3 id="orgf5cc2de"><span class="section-number-3">4.3</span> Conversion</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">of_xyz_string</span> <span class="org-tuareg-font-lock-operator">:</span> string <span class="org-tuareg-font-lock-operator">-&gt;</span> t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">to_xyz_string</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> string
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">of_xyz_file</span> <span class="org-tuareg-font-lock-operator">:</span> string <span class="org-tuareg-font-lock-operator">-&gt;</span> t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">of_zmt_string</span> <span class="org-tuareg-font-lock-operator">:</span> string <span class="org-tuareg-font-lock-operator">-&gt;</span> t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">of_zmt_file</span> <span class="org-tuareg-font-lock-operator">:</span> string <span class="org-tuareg-font-lock-operator">-&gt;</span> t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">to_string</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> string
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">of_filename</span> <span class="org-tuareg-font-lock-operator">:</span> string <span class="org-tuareg-font-lock-operator">-&gt;</span> t
</pre>
</div>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left"><code>of_xyz_string</code></td>
<td class="org-left">Create from a string, in xyz format</td>
</tr>
<tr>
<td class="org-left"><code>of_xyz_file</code></td>
<td class="org-left">Create from a file, in xyz format</td>
</tr>
<tr>
<td class="org-left"><code>of_zmt_string</code></td>
<td class="org-left">Create from a string, in z-matrix format</td>
</tr>
<tr>
<td class="org-left"><code>of_zmt_file</code></td>
<td class="org-left">Create from a file, in z-matrix format</td>
</tr>
<tr>
<td class="org-left"><code>to_string</code></td>
<td class="org-left">Transform to a string, for printing</td>
</tr>
<tr>
<td class="org-left"><code>of_filename</code></td>
<td class="org-left">Detects the type of file (xyz, z-matrix) and reads the file</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-org070bc98" class="outline-3">
<h3 id="org070bc98"><span class="section-number-3">4.4</span> <span class="todo TODO">TODO</span> Query</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">formula</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> string
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">repulsion</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> float
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">charge</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> <span class="org-tuareg-font-lock-module">Charge.</span>t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">small_core</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> int
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">large_core</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> int
</pre>
</div>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left"><code>formula</code></td>
<td class="org-left">Returns the chemical formula</td>
</tr>
<tr>
<td class="org-left"><code>repulsion</code></td>
<td class="org-left">Nuclear repulsion energy, in atomic units</td>
</tr>
<tr>
<td class="org-left"><code>charge</code></td>
<td class="org-left">Sum of the charges of the nuclei</td>
</tr>
<tr>
<td class="org-left"><code>small_core</code></td>
<td class="org-left">Number of core electrons in the small core model</td>
</tr>
<tr>
<td class="org-left"><code>large_core</code></td>
<td class="org-left">Number of core electrons in the large core model</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-org1ab3f3a" class="outline-3">
<h3 id="org1ab3f3a"><span class="section-number-3">4.5</span> Printers</h3>
<div class="outline-text-3" id="text-4-5">
<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">-&gt;</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> unit
</pre>
</div>
</div>
</div>
<div id="outline-container-org59045e6" class="outline-3">
<h3 id="org59045e6"><span class="section-number-3">4.6</span> Tests</h3>
</div>
</div>
<div id="outline-container-org35f99d4" class="outline-2">
<h2 id="org35f99d4"><span class="section-number-2">5</span> Z-matrix</h2>
<div class="outline-text-2" id="text-5">
<p>
Z-matrix representation of nuclear coordinates.
</p>
</div>
<div id="outline-container-org74ef0d8" class="outline-3">
<h3 id="org74ef0d8"><span class="section-number-3">5.1</span> Type</h3>
<div class="outline-text-3" id="text-5-1">
<div class="org-src-container">
<pre class="src src-ocaml" id="org7111155"><span class="org-tuareg-font-lock-governing">type</span> <span class="org-type">t</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org4b91a4e" class="outline-3">
<h3 id="org4b91a4e"><span class="section-number-3">5.2</span> Conversion</h3>
<div class="outline-text-3" id="text-5-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">of_string</span> <span class="org-tuareg-font-lock-operator">:</span> string <span class="org-tuareg-font-lock-operator">-&gt;</span> t
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">to_xyz</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> <span class="org-tuareg-font-lock-operator">(</span><span class="org-tuareg-font-lock-module">Element.</span>t <span class="org-tuareg-font-lock-operator">*</span> float <span class="org-tuareg-font-lock-operator">*</span> float <span class="org-tuareg-font-lock-operator">*</span> float<span class="org-tuareg-font-lock-operator">)</span> array
<span class="org-tuareg-font-lock-governing">val</span> <span class="org-function-name">to_xyz_string</span> <span class="org-tuareg-font-lock-operator">:</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> string
</pre>
</div>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-left"><code>of_string</code></td>
<td class="org-left">Reads a z-matrix from a string</td>
</tr>
<tr>
<td class="org-left"><code>to_xyz</code></td>
<td class="org-left">Converts to xyz format, as in the <code>Nuclei</code> module</td>
</tr>
<tr>
<td class="org-left"><code>to_xyz_string</code></td>
<td class="org-left">Converts to xyz format, as a string</td>
</tr>
</tbody>
</table>
<pre class="example" id="org4da0c8d">
let zmt = Zmatrix.of_string "
n
n 1 nn
h 1 hn 2 hnn
h 2 hn 1 hnn 3 dih4
h 1 hn 2 hnn 4 dih5
h 2 hn 1 hnn 3 dih5
nn 1.446
hn 1.016
hnn 106.0
dih4 -54.38
dih5 54.38
" ;;
- : Zmatrix.t = N
N 1 1.446000
H 1 1.016000 2 106.000000
H 2 1.016000 1 106.000000 3 -54.380000
H 1 1.016000 2 106.000000 4 54.380000
H 2 1.016000 1 106.000000 3 54.380000
Zmatrix.to_xyz zmt ;;
- : (Element.t * float * float * float) array =
[|(N, 0., 0., 0.); (N, 0., 0., 1.446);
(H, -0.976641883073332107, 0., -0.280047553510071046);
(H, -0.568802835186988709, 0.793909757123734683, 1.726047553510071);
(H, 0.314092649983635563, 0.924756819385119, -0.280047553510071101);
(H, -0.568802835186988709, -0.793909757123734683, 1.726047553510071)|]
Zmatrix.to_xyz_string zmt ;;
- : string =
"N 0.000000 0.000000 0.000000
N 0.000000 0.000000 1.446000
H -0.976642 0.000000 -0.280048
H -0.568803 0.793910 1.726048
H 0.314093 0.924757 -0.280048
H -0.568803 -0.793910 1.726048"
</pre>
</div>
</div>
<div id="outline-container-orgbec757c" class="outline-3">
<h3 id="orgbec757c"><span class="section-number-3">5.3</span> Printers</h3>
<div class="outline-text-3" id="text-5-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">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">-&gt;</span> t <span class="org-tuareg-font-lock-operator">-&gt;</span> unit
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: Anthony Scemama</p>
<p class="date">Created: 2021-01-20 Wed 23:52</p>
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>