Skip to content

Commit ca6bb14

Browse files
committed
Add some docs for external interface
1 parent 55ec5a6 commit ca6bb14

4 files changed

Lines changed: 165 additions & 0 deletions

File tree

doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Getting started <user/getting_started/index>
77
Installation <user/getting_started/installing>
88
User Guide <user/guide/index>
9+
Utilities <user/utilities/index>
910

1011
.. toctree::
1112
:caption: Developer

doc/user/guide/io.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ The produced LaTeX code is not self-contained. It needs to be embedded in a suit
2828

2929

3030

31+
.. _io-Serialization:
32+
3133
Serialization
3234
=============
3335

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
External interface
2+
==================
3+
4+
The external interface is supposed to allow interfacing with SeQuant from the outside, without having to write a C++ program that links to the SeQuant
5+
library. The idea is to specify equations in text form and then submit them to SeQuant for processing. This works by using a JSON driver file that
6+
contains instructions for what you want SeQuant to do.
7+
8+
9+
.. _extint-input:
10+
11+
Input format
12+
------------
13+
14+
See :ref:`io-Serialization`.
15+
16+
.. note::
17+
It is assumed that the input always specifies a result. That is, it is of the format :code:`lhs = rhs`. Furthermore, every input file may only
18+
contain a single result.
19+
20+
21+
Driver file
22+
-----------
23+
24+
The top-level entry in the JSON file specifies what action SeQuant should take. At the moment, only code-generation into the ITF format is supported.
25+
Hence, every driver file currently has to start like this:
26+
27+
.. code-block:: json
28+
{
29+
"code_generation": {
30+
"output_format": "itf",
31+
...
32+
}
33+
}
34+
35+
.. note::
36+
All paths specified in the driver file are understood to be relative to the JSON file's location (unless absolute paths are used, of course).
37+
38+
Beyond :code:`output_format`, the following top-level fields exist:
39+
40+
* :code:`output_path` (required): The path to the file the generated code is written to
41+
* :code:`default_options` (optional): Allows specification of default processing options
42+
* :code:`code_blocks` (required): Specifies a list of code blocks (groups of expressions)
43+
44+
Code block
45+
^^^^^^^^^^
46+
Every code block has to have a :code:`name` and a list of :code:`results`. The former is effectively the name of the to-be-generated function that
47+
computes the individual results (expressions), whereas the latter is a list of expressions that shall be computed.
48+
49+
Every result has these mandatory fields:
50+
51+
* :code:`name`: The name of the tensor/scalar variable that shall hold the result of the computed expression
52+
* :code:`equation_file`: Path to the file containing the input expression (cmp :ref:`extint-input`)
53+
54+
Additionally, the following *processing options* may be given. All of them may also be specified as part of the :code:`default_options` block in which
55+
case those values are used, unless explicitly overwritten.
56+
57+
* :code:`density_fitting`: Whether to perform the density-fitting decomposition of the two-electron integral
58+
* :code:`term_by_term`: Whether to split sums into individual summands for processing and code-generation. This yields to more readable but less
59+
performant code.
60+
* :code:`optimize`: Whether to factorize the equations into a series of binary contractions
61+
* :code:`subexpression_elimination`: Whether to eliminate common subexpressions (only possible when factorizing into binary contractions)
62+
* :code:`expand_symmetrizer`: Whether to explicitly expand (write out) symmetrization operators
63+
* :code:`spintracing`: What kind of spintracing to perform (if any). Possible options are
64+
65+
* :code:`none`: Don't perform spintracing
66+
* :code: `closed_shell`: Apply spintracing using an algorithm suitable for closed-shell systems
67+
* :code: `rigorous`: Apply spintracing using an algorithm that should work for all cases, but is less efficient than :code:`closed_shell`
68+
69+
* :code:`projection`: What kind of projection/transformation to perform with the final result
70+
71+
* :code:`primitive`: Don't do anything
72+
* :code:`biorthogonal`: Transform the result into a biorthogonal basis (only applicable to non-scalar results)
73+
74+
75+
Index space specification
76+
^^^^^^^^^^^^^^^^^^^^^^^^^
77+
78+
Every driver file has to contain the definition of index spaces that are used in expressions. This definition lives under the :code:`index_spaces`
79+
element. Every specification has to provide the following attributes:
80+
81+
* :code:`name`: Name of the index space
82+
* :code:`tag`: Tag for this index space (if any). Tags are used to encode the spaces of a tensor's indices in its name. May be empty.
83+
* :code:`label`: Label used in expressions for indices in this space, e.g. in :code:`i1` the label is :code:`i`.
84+
* :code:`size`: The size/dimension of indices in this index space. This affects factorization into binary contractions.
85+
86+
Example
87+
^^^^^^^
88+
89+
.. code-block:: json
90+
{
91+
"code_generation": {
92+
"output_format": "itf",
93+
"default_options": {
94+
"density_fitting": false,
95+
"term_by_term": false,
96+
"spintracing": "closed_shell",
97+
"projection": "biorthogonal"
98+
},
99+
"output_path": "something.itfaa",
100+
"code_blocks": [
101+
{
102+
"name": "First",
103+
"results": [
104+
{
105+
"name": "One",
106+
"equation_file": "first.inp",
107+
"projection": "primitive"
108+
}
109+
]
110+
},
111+
{
112+
"name": "Second",
113+
"results": [
114+
{
115+
"name": "Two",
116+
"equation_file": "second.inp",
117+
"projection": "primitive"
118+
},
119+
{
120+
"name": "Three",
121+
"equation_file": "third.inp",
122+
"spintracing": "rigorous"
123+
}
124+
]
125+
},
126+
]
127+
},
128+
"index_spaces": [
129+
{
130+
"name": "virtual",
131+
"tag": "e",
132+
"label": "a",
133+
"size": 100
134+
},
135+
{
136+
"name": "active",
137+
"tag": "a",
138+
"label": "u",
139+
"size": 5
140+
},
141+
{
142+
"name": "occupied",
143+
"tag": "c",
144+
"label": "i",
145+
"size": 10
146+
}
147+
]
148+
}

doc/user/utilities/index.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Utilities
2+
=========
3+
4+
SeQuant's main power lies in the fact that it is written as a library. This ensures a modular design and allows users the most flexibility in using
5+
specific functionalities in whatever way they want.
6+
7+
However, sometimes all that is needed is to perform a specific/standard workflow for which readily-available executables are most convenient. This is
8+
where utility programs come into play, of which we bundle a couple directly with SeQuant.
9+
10+
.. toctree::
11+
:maxdepth: 2
12+
13+
external_interface
14+

0 commit comments

Comments
 (0)