Skip to content

Commit 35b225c

Browse files
committed
Added documentation
1 parent be22d1c commit 35b225c

File tree

4 files changed

+131
-1
lines changed

4 files changed

+131
-1
lines changed

docs/toolbox/basis/basis.rst

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Basis optimization
2+
==================
3+
4+
.. currentmodule:: sisl_toolbox.siesta.minimizer
5+
6+
Optimizing a basis set for SIESTA is a cumbersome task.
7+
The goal of this toolbox is to allow users to **optimize a basis set with just one CLI command.**
8+
9+
The commands and their options can be accessed like:
10+
11+
.. code-block:: bash
12+
13+
stoolbox basis --help
14+
15+
In summary, whenever one wants to optimize a basis set for a given system,
16+
the first step is to create a directory with the input files to run the
17+
calculation. This directory should contain, as usual:
18+
19+
- The ``.fdf`` files with all the input parameters for the calculation.
20+
- The pseudopotentials (``.psf`` or ``.psml`` files).
21+
22+
Then, one can directly run the optimization:
23+
24+
.. code-block:: bash
25+
26+
stoolbox basis optim --geometry input.fdf
27+
28+
with ``input.fdf`` being the input file for the calculation. This will use all the default
29+
values. Since there are many possible tweaks, we invite you to read carefully the help
30+
message from the CLI. Here we will just mention some important things that could go unnoticed.
31+
32+
**Basis enthalpy:** The quantity that is minimized is the basis enthalpy. This is :math:`H = E + pV`
33+
with :math:`E` being the energy of the system, :math:`V` the volume of the basis and :math:`p` a "pressure" that
34+
is defined in the fdf file with the `BasisPressure` table. This "pressure" penalizes bigger
35+
basis, which result in more expensive calculations. It is the responsibility of the user to
36+
set this value. As a rule of thumb, we recommend to set it to `0.02 GPa` for the first two
37+
rows of the periodic table and `0.2 GPa` for the rest.
38+
39+
**The SIESTA command:** There is a ``--siesta-cmd`` option to specify the way of executing SIESTA. By default, it
40+
is simply calling the ``siesta`` command, but you could set it for example to ``mpirun -n 4 siesta``
41+
so that SIESTA is ran in parallel.
42+
43+
There is no problem with using this CLI in clusters inside a submitted job, for example.
44+
45+
**A custom basis definition:** It may happen that the conventional optimizable parameters as well as their lower and
46+
upper bounds are not good for your case (e.g. you would like the upper bound for a cutoff
47+
radius to be higher). In that case, you can create a custom ``--basis-spec``. The best way
48+
to do it is by calling
49+
50+
.. code-block:: bash
51+
52+
stoolbox basis build --geometry input.fdf
53+
54+
which will generate a yaml file with a basis specification that you can tweak manually.
55+
Then, you can pass it directly to the optimization using the ``--config`` option:
56+
57+
.. code-block:: bash
58+
59+
stoolbox basis optim --geometry input.fdf --config my_config.yaml
60+
61+
**Installing the optimizers:** The default optimizer is BADS (https://github.com/acerbilab/bads)
62+
which is the one that we have found works best to optimize basis sets. The optimizer is however
63+
not installed by default. You can install it using pip:
64+
65+
.. code-block:: bash
66+
67+
pip install pybads
68+
69+
and the same would apply for other optimizers that you may want to use.
70+
71+
**Output:** The output that appears on the terminal is left to the particular optimizer.
72+
However, sisl generates `.dat` files which contain information about each SIESTA execution.
73+
These files contain one column for each variable being optimized and one column for the
74+
metric to minimize.
75+
76+
77+
Python API
78+
----------
79+
80+
The functions that do the work are also usable in python code by importing them:
81+
82+
.. code-block:: python
83+
84+
from sisl_toolbox.siesta.minimizer import optimize_basis, write_basis_to_yaml
85+
86+
Here is their documentation:
87+
88+
.. autosummary::
89+
:toctree: generated/
90+
:nosignatures:
91+
92+
optimize_basis
93+
write_basis_to_yaml

docs/toolbox/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ Toolboxes should be imported directly.
2222
2323
2424
The implemented toolboxes are listed here:
25-
25+
2626
.. toctree::
2727
:maxdepth: 1
2828

2929
transiesta/ts_fft
3030
siesta/atom_plot
3131
btd/btd
32+
siesta/minimizer
33+
basis/basis

docs/toolbox/siesta/minimizer.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Minimizers
2+
=================
3+
4+
.. currentmodule:: sisl_toolbox.siesta.minimizer
5+
6+
In `sisl_toolbox.siesta.minimizer` there is a collection of minimizers
7+
that given some `variables`, a `runner` and a `metric` optimizes the
8+
variables to minimize the metric.
9+
10+
These are the minimizer classes implemented:
11+
12+
.. autosummary::
13+
:toctree: generated/
14+
:nosignatures:
15+
16+
BaseMinimize
17+
LocalMinimize
18+
DualAnnealingMinimize
19+
BADSMinimize
20+
ParticleSwarmsMinimize
21+
22+
For each of them, there is a subclass particularly tailored to optimize
23+
SIESTA runs:
24+
25+
.. autosummary::
26+
:toctree: generated/
27+
:nosignatures:
28+
29+
MinimizeSiesta
30+
LocalMinimizeSiesta
31+
DualAnnealingMinimizeSiesta
32+
BADSMinimizeSiesta
33+
ParticleSwarmsMinimizeSiesta

src/sisl_toolbox/siesta/minimizer/_minimize_siesta.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,11 @@ class DualAnnealingMinimizeSiesta(DualAnnealingMinimize, MinimizeSiesta):
230230
pass
231231

232232

233+
@set_module("sisl_toolbox.siesta.minimizer")
233234
class BADSMinimizeSiesta(BADSMinimize, MinimizeSiesta):
234235
pass
235236

236237

238+
@set_module("sisl_toolbox.siesta.minimizer")
237239
class ParticleSwarmsMinimizeSiesta(ParticleSwarmsMinimize, MinimizeSiesta):
238240
pass

0 commit comments

Comments
 (0)