|
| 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 |
0 commit comments