Abinit

Software name: 
Abinit
Policy 

Abinit is freely available to users at HPC2N. See here for how to include acknowlegdement of the use of this program into scientific papers.

General 

Abinit is a freely available program to find the total energy, charge density and electronic structure of systems.

Description 

Abinit is a freely available (GPL) program. It is a package whose main program allows one to find the total energy, charge density and electronic structure of systems made of electrons and nuclei (molecules and periodic solids) within Density Functional Theory (DFT), using pseudopotentials and a planewave or wavelet basis.

Abinit also includes options to optimize the geometry according to the DFT forces and stresses, or to perform molecular dynamics simulations using these forces, or to generate dynamical matrices, Born effective charges, and dielectric tensors, based on Density-Functional Perturbation Theory, and many more properties. Excited states can be computed within the Many-Body Perturbation Theory (the GW approximation and the Bethe-Salpeter equation), and Time-Dependent Density Functional Theory (for molecules). In addition to the main ABINIT code, different utility programs are provided.

Availability 

On HPC2N we have abinit available as a module on Kebnekaise. Binaries are compiled for MPI.

Usage at HPC2N 

To use the abinit module, add it to your environment. You can see how to do that with:

ml spider abinit

Remember to load the prerequisites mentioned first! Despite what the text from ml spider may say, you need to load the prerequisite modules on both lines.

The above command also tells you which versions of abinit are available.

You run abinit with

abinit

Do

abinit --help

to get a short list of flags which can be set.

A number of example input files can be found in

$EBROOTABINIT/share/abinit-test/tutorial/Input/

NOTE that the above environment variable is not set until you have loaded the ABINIT module.

In the examples below I am going to use version 8.0.8b. The example input files for this version are found in

/hpc2n/eb/software/MPI/intel/2017.1.132-GCC-5.4.0-2.26/impi/2017.1.132/ABINIT/8.0.8b/share/abinit-test/tutorial/Input

Serial example

This is an example from the official abinit tutorial, and are using the examples included with the program. The file tbase1_x.files is the file that contains information needed for the code to build other file names. You make changes to it according to the names of the files you use.

Computing the (psuedo) total energy and some associated quantities

  1. Make a test-directory and copy the example input files there from
    /hpc2n/eb/software/MPI/intel/2017.1.132-GCC-5.4.0-2.26/impi/2017.1.132/ABINIT/8.0.8b/share/abinit-test/tutorial/Input

    (in this example we are going to need the files tbase1_x.files and tbase1_1.in)

  2. Edit the file tbase1_x.files (this file gives the information needed for the code to build other file names). You should modify the first and second lines, as well as the last line of the tbase1_x.files so you get:
    tbase1_1.in
    tbase1_1.out
    tbase1_xi
    tbase1_xo
    tbase1_x
    /hpc2n/eb/software/MPI/intel/2017.1.132-GCC-5.4.0-2.26/impi/2017.1.132/ABINIT/8.0.8b/share/abinit-test/Psps_for_tests/01h.pspgth
    
  3. Now run the code with
    abinit < tbase1_x.files > log 2>&1
  4. The output files log and tbase1_1.out have been created. You can check that all went well by comparing tbase1_1.out to a reference file that can be found in
    /hpc2n/eb/software/MPI/intel/2017.1.132-GCC-5.4.0-2.26/impi/2017.1.132/ABINIT/8.0.8b/share/abinit-test/tutorial/Refs
  5. Note that if you rerun the command in 3. you will get a new output file, with an added 'A' at the end.
  6. You can find information here about how to read the log-file and the output-file.

Computation of the interatomic distance (method 1)

  1. There are three ways of computing the optimal distance between the two Hydrogen atoms
    1. Compute the total energy for different values of the interatomic distance, make a fit through the different points, and then determine the minimum of the fitting function.
    2. Compute the forces for different values of the interatomic distance, make a fit through the different values, and determine the zero of the fitting function
    3. Use an automatic algorithm for minimizing the energy (or finding the zero of forces)
  2. We will look at the computation of energy and forces for different values of the interatomic distance.
  3. The interatomic distance in the tbase1_1.in file was 1.4 Bohr. Let us assume you decide to examine the interatomic distances from 1.0 Bohr to 2.0 Bohr, by steps of 0.05 Bohr (21 calculations). This can be done in abinit, using multi-dataset mode.
  4. The file tbase1_2.in will do the trick. Remember to make changes to tbase_1x.files in order to make sure the right files are accessed:
    tbase1_2.in
    tbase1_2.out
    tbase1_xi
    tbase1_xo
    tbase1_x
    /hpc2n/eb/software/MPI/intel/2017.1.132-GCC-5.4.0-2.26/impi/2017.1.132/ABINIT/8.0.8b/share/abinit-test/Psps_for_tests/01h.pspgth
    
  5. Run the program with
    abinit < tbase1_x.files > log 2>&1
  6. Looking in the output file (tbase1_2.out), you should find the output energies near the end of the file, looking like this
     -outvars: echo values of variables after computation  --------
                acell      1.0000000000E+01  1.0000000000E+01  1.0000000000E+01 Bohr
                  amu      1.00794000E+00
               diemac      2.00000000E+00
                 ecut      1.00000000E+01 Hartree
               etotal1    -1.0368223891E+00
               etotal2    -1.0538645433E+00
               etotal3    -1.0674504851E+00
               etotal4    -1.0781904896E+00
               etotal5    -1.0865814785E+00
               etotal6    -1.0930286804E+00
               etotal7    -1.0978628207E+00
               etotal8    -1.1013539124E+00
               etotal9    -1.1037224213E+00
               etotal10   -1.1051483730E+00
               etotal11   -1.1057788247E+00
               etotal12   -1.1057340254E+00
               etotal13   -1.1051125108E+00
               etotal14   -1.1039953253E+00
               etotal15   -1.1024495225E+00
               etotal16   -1.1005310615E+00
               etotal17   -1.0982871941E+00
               etotal18   -1.0957584182E+00
               etotal19   -1.0929800578E+00
               etotal20   -1.0899835224E+00
               etotal21   -1.0867972868E+00

Computation of the interatomic distance (method 2)

This method is based on an automatic computation of the minimum. There are different algorithms do that. There is a walk-through of this method to be found here.
You can test it by running the file tbase1_3.in, in the same way as tbase1_2.in was run (remember to make the changes to the file tbase1_x.files).

Computation of the charge density

The charge density has actually already been computed, for all geometries, in the above-mentioned runs. This will show you how to print the quantity. There are more detailed explanations here.

  1. Look in the file tbase1_4.in. This contains an example of how to print the density. In order to use it, remember to make changes to the two first lines in the tbase1_x.files file.
  2. Run the file
    abinit < tbase1_x.files > log 2>&1
  3. The density will be output in the file tbase1_xo_DEN. This is a binary file, and it cannot be viewed normally. Instead, they can be read by the abinit utility program 'cut3d'. It can be used to generate things like a two-dimensional cut in the density, or to visualize the density contours. It is suggested that you first try to translate the unformatted density data to indexed formatted data, by using option 6 of the appropriate menu.
  4. Run the utility 'cut3d', then answer the questions (1. -> tbase1_xp_DEN, 2. -> 1, 3. -> 6, 4. -> tbase1_xo_DEN_indexed)
    $ cut3d
    
    .Version 8.0.8 of CUT3D
    .(MPI version, prepared for a x86_64_linux_intel17.0 computer)
    
    .... <some info cut for brevity>   
    
      What is the name of the 3D function (density, potential or wavef) file ?
    tbase1_xo_DEN
      => Your 3D function file is : tbase1_xo_DEN
    
    
    - Your file contains unformatted binary header + 3D data
     
     ===============================================================================
     ECHO of the ABINIT file header
     
     < stuff cut for brevity ... > 
     
       #    Atomic positions (cartesian coordinates - Bohr)
       1   -7.610000E-01    0.000000E+00    0.000000E+00
       2    7.610000E-01    0.000000E+00    0.000000E+00
     
      This file is a Density or Potential file
     
      3D function was read. Ready for further treatment.
     
     ===========================================================
     
      What is your choice ? Type:
       0 => exit
       1 => point  (interpolation of data for a single point)
       2 => line   (interpolation of data along a line)
       3 => plane  (interpolation of data in a plane)
       4 => volume (interpolation of data in a volume)
       5 => 3D formatted data (output the bare 3D data - one column)
       6 => 3D indexed data (bare 3D data, preceeded by 3D index)
       7 => 3D Molekel formatted data
       8 => 3D data with coordinates (tecplot ASCII format)
       9 => output .xsf file for XCrysDen
      11 => compute atomic charge using the Hirshfeld method
      14 => Gaussian/cube wavefunction module
    
    6
    
     Your choice is  6 
    
    	Enter the name of an output file:
    
    	tbase1_xo_DEN_indexed
    
    	   The name of your file is : t1xo_DEN_indexed
    
    	  Task            6  has been done !
    
      More analysis of the 3D file ? ( 0=no ; 1=default=yes ; 2= treat another file - restricted usage)
    0
       
      Provide some global information about the density and/or potential file(s)
     
    -  File number     1, with name "tbase1_xo_DEN"
      Number of grid points =       27000 ; Volume of real space cell (Bohr^3)=  1.000000E+03
       Spin-component number     1
          Sum of values, mean, mean times cell volume=    5.400000E+01    2.000000E-03    2.000000E+00
     
     Provide some global joint information about the stored density and potential file(s)
     
      File numbers:     1    1
       Spin-component number     1
          Dot product of values, mean, mean times cell volume=    3.697887E+00    1.369588E-04    1.369588E-01
    -
    - Proc.   0 individual time (sec): cpu=          0.2  wall=        290.3
     
      Thank you for using me
  5. You can now look at t1xo_DEN_indexed. If you want, you could choose another option than 6. (3D indexed data (bare 3D data, preceeded by 3D index). For instance, if you have MATLAB, you could choose option 5 and get a file you can work with further in MATLAB.

Computation of the atomisation energy
The atomisation energy is the energy needed to separate a molecule in its constituent atoms, each being neutral. Here, you must first compute the total energy of an isolated hydrogen atom. The atomisation energy will be the difference bwtween the total energy of H2 and twice the total energy of H. You can read more about this here.

There is an example file, tbase1_5.in, which can be used to test this. Remember to make the necessary changes to the file tbase1_x.files.

  1. Run
    $ abinit < tbase1_x.files > log 2>&1
  2. Look at the output file, tbase1_5.out, for the electronic eigenvalues, the spin polarisation, and the total energy (etotal).

Parallel example

This is an example is from the official abinit tutorial, and are using the examples included with the program. The file tbasepar_1.files is the file that contains information needed for the code to build other file names. You make changes to it according to the names of the files you use.

In this example I am using version 8.0.8b of abinit. The example files can be copied from /hpc2n/eb/software/MPI/intel/2017.1.132-GCC-5.4.0-2.26/impi/2017.1.132/ABINIT/8.0.8b/share/abinit-test/tutorial/Input. More information about running a parallel job can be found here.

Start out by making a directory for running in and copy these files from the above location: tbasepar_1.files, tbasepar_1.in. Preferably, you should run in your project storage.

Running a job

We will start by looking at tbasepar_1.in. It is a good idea to first do a sequential run, in order to have a reference CPU time.

  1. Change tbasepar_1.files to look like this
    tbasepar_1.in
    tbasepar_1.out
    tbasepar_1i
    tbasepar_1o
    tbasepar_1
    /hpc2n/eb/software/MPI/intel/2017.1.132-GCC-5.4.0-2.26/impi/2017.1.132/ABINIT/8.0.8b/share/abinit-test/Psps_for_tests/HGH/82pb.4.hgh
    
  2. Run
    abinit < tbasepar_1.files > log 2>&1
  3. In order to avoid unneccessary network communications for the parallel cases, it is a good idea to provide a path to a local /tmp or /scratch for every node, so the program uses that. This can be achieved by changing the file tbasepar_1.files to look like this
    tbasepar_1.in
    tbasepar_1.out
    tbasepar_1i
    tbasepar_1o
    /tmp/tbasepar_1
    /hpc2n/eb/software/MPI/intel/2017.1.132-GCC-5.4.0-2.26/impi/2017.1.132/ABINIT/8.0.8b/share/abinit-test/Psps_for_tests/HGH/82pb.4.hgh
  4. The most favourable case for a parallel run is to treat the k-points concurrently, since it can be done independently for each one of them. We will be running tbasepar_1.in, as this corresponds to the investigation of a fcc crystal of lead, which requires a high number of k-points to get a realistic description of the ground state. Take a look at the file and see that the values are realistic.
  5. Change to your directory (on your project storage) in order to run a batch-job, and create a test-directory to run in.
    $ cd <my project storage dir>
    $ mkdir abinit_test
    $ cd abinit_test
    
  6. Copy your example files to this test-directory
  7. Create a job script to run your files. For this example you can use this
    #!/bin/bash
    # Project you are running under - change to actual
    #SBATCH -A SNICXXX-YY-ZZ
    # Here I am asking for 4 processors, and a walltime of 30 minutes. 
    # Change to what you want. 
    #SBATCH -n 4
    #SBATCH --time==00:30:00
    
    # Load the abinit module
    ml icc/2017.1.132-GCC-5.4.0-2.26  impi/2017.1.132
    ml ifort/2017.1.132-GCC-5.4.0-2.26  impi/2017.1.132
    ml ABINIT/8.0.8b
    
    #Run abinit in parallel 
    srun abinit < tbasepar_1.files > tbasepar_1.log 2>&1
  8. Submit your script
    sbatch my_abinit_script.submit
  9. It will create files tbasepar_1.log and tbasepar_1.out (it will add A, B, ... when you rerun, instead of overwriting). This output file can be compared with the output-file you create under 1) and 2), and you will see that the results are close to the same. One thing will be different; the value of mkmem is 60 in the serially run case, but 15 in the parallel case (the set of 60 k-points have been split into four sets, each of 15 k-points, treated by one of the four processors.)
  10. You can find the timing at the end of the file. I got 16.9 s for the sequential run. This is the results I got for 4 cores
    - Proc.   0 individual time (sec): cpu=          4.4  wall=          4.4
    
    ================================================================================
    
     Calculation completed.
    .Delivered    4 WARNINGs and   1 COMMENTs to log file.
    +Overall time at end (sec) : cpu=         17.7  wall=         17.7
    

    So close to 1/4 of the time it took for 1 core, which is what we hoped for.

  11. You can try running the example with different number of cores and see which results you get for the speed-up
Additional info 

More information can be found on the official website.

Updated: 2024-03-21, 12:31