ASE

Here is list and explanation of common ASE commands.

For ASE program and more detailed information refer to: https://wiki.fysik.dtu.dk/ase/about.html

Setting up ASE/GPAW/xtb using conda (e.g. on cluster)

  1. Collect the miniconda instalation

    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

  2. Install it

    bash Miniconda3-latest-Linux-x86_64.sh

  3. Create enviroment for gpaw/ase/(xtb) by reusing my configuration saving it in file named "gpaw_xtb_ase.txt" (alternatively - install as usual )

    conda config --add channels conda-forge

    conda create -n test_gpaw --file gpaw_xtb_ase.txt

  4. Enviroment can be activated for sbatch jobs by including following lines in the submision script:

    source ~/.bashrc   # not needed after shell restart
    conda activate test_gpaw
    

    e.g

    #!/bin/bash
    
    #SBATCH -p testing
    #SBATCH -J conda_env_test
    #SBATCH -N 1
    #SBATCH --ntasks-per-node=1
    #SBATCH -t 00:01:00
    
    source ~/.bashrc   # not needed after shell restart
    conda activate test_gpaw
    
    conda info --envs
    

TBlite instalation for ASE

Installing dependencies

    $ sudo apt install libopenblas-dev libopenblas-base
    $ sudo apt install ninja-build  # make sure that $ninja --version > 1.10
    $ sudo apt install meson        # make sure that $meson --version > 0.57.2
    $ sudo apt install gfortran 

Download source code and install (NB! make sure that you are in same conda envir as ASE)

    $ git clone https://github.com/awvwgk/tblite.git
    $ cd tblite
    $ meson setup _build --prefix=$HOME/.local -Dpython=true
    $ meson compile -C _build
    $ meson test -C _build --print-errorlogs
    $ meson install -C _build

Test that it is installed okay

    $ python
    >>> import tblite # if no errors, install is okay and can be used in ase

Example in use as ASE calculator

To use in calculator we also need to specify dynamic library before each run, to do this we specify: it should be consistent with the previously used "--prefix=$HOME/.local".

    $ # change USER to your username
    $ export LD_LIBRARY_PATH=/home/USER/.local/lib64:$LD_LIBRARY_PATH

and now test python script

    from tblite.ase import TBLite
    from ase.io import read

    molecule = read("0001_EMIm2Cl1_200009.xyz")
    molecule.calc = TBLite(method="GFN2-xTB")
    print(molecule.get_potential_energy())

in this case I get following output

    ------------------------------------------------------------
    cycle        total energy    energy error   density error
    ------------------------------------------------------------
        1     -28.81274330989  -2.9143341E+01   1.2352334E-01
        2     -28.84660040760  -3.3857098E-02   6.4650265E-02
        3     -28.85701312556  -1.0412718E-02   2.9906540E-02
        4     -28.86460020405  -7.5870785E-03   1.3721682E-02
        5     -28.86442867236   1.7153170E-04   5.9934071E-03
        6     -28.86497828184  -5.4960949E-04   4.0006412E-03
        7     -28.86503693474  -5.8652894E-05   2.6845932E-03
        8     -28.86499187517   4.5059572E-05   1.9701876E-03
        9     -28.86507935587  -8.7480698E-05   6.6133790E-04
        10     -28.86517950771  -1.0015184E-04   2.8980811E-04
        11     -28.86516025617   1.9251534E-05   8.4206259E-05
        12     -28.86515067125   9.5849170E-06   2.3619936E-05
        13     -28.86515092195  -2.5069780E-07   8.2079959E-06
    ------------------------------------------------------------

    -785.4607643888482

compare to XTB:

    (test_gpaw) ritum@reiko:~/Downloads/tests$ cat test_xtb.py 
    from xtb.ase.calculator import XTB
    from ase.io import read

    molecule = read("0001_EMIm2Cl1_200009.xyz")
    molecule.calc = XTB(method="GFN2-xTB")
    print(molecule.get_potential_energy())

    (test_gpaw) ritum@reiko:~/Downloads/tests$ python test_xtb.py 
    -785.4607487988382