maituoy / BayesianOpt4dftu

MIT License
37 stars 11 forks source link

BayesianOpt4dftu

This code determines the Hubbard U parameters in DFT+U via Bayesian Optimization approach.

Requirements

  1. Python 3.6+
  2. NumPy
  3. Pandas
  4. ASE (https://wiki.fysik.dtu.dk/ase/)
  5. pymatgen (https://pymatgen.org/)
  6. bayesian-optimization https://github.com/fmfn/BayesianOptimization
  7. Vienna Ab initio Simulation Package (VASP) https://www.vasp.at/
  8. Vaspvis (https://github.com/DerekDardzinski/vaspvis)

Set up the input file (input.json) before running the code

The input file contains these parts:

Installation

Usage

To run the examples in the example folder, you need to modify the environment settings in the example.py of the selected calculation based on the specs of your system and VASP binary.

I will use /example/2d as an example:

1. Setting environments

Set the running command for VASP executable

  VASP_RUN_COMMAND = 'srun -n 54 vasp_ncl'

Define the VASP output file name.

  OUTFILENAME = 'vasp.out'

Define the path direct to the VASP pesudoopotential. (P.S. It should be the directory containing the potpaw_PBE folder)

  VASP_PP_PATH = '/PATH/TO/THE/PESUDOPOTENTIAL/'

2. Arguments options

--which_u defines which element you would like to optimize the U for. For a unary substance, it has to be (1,). For compounds with over 2 elements, you can set each element to 0 or 1 to switch off/on the optimization for that element. For InAs, when optimizing for both In and As, it will be (1,1).

--br defines band range you would like to include in your Δband. It is a tuple of two integers, which define the number of valence bands and conduction bands from the Fermi level.

--kappa controls the exploration and exploitation when acquisition function sample the next points. Exploitation 0 <-- kappa --> 10 Exploration

--alpha1 and alpha2 are the weight coefficients of Δgap and Δband.

--threshold defines at what accuracy would you stop the BO process.

--urange defines the U parameter range for optimization, currently it's not supported to define different U ranges for different elements.

--import_kpath provides an external listing of high symmetry k-points in case some special k coordinates are not present in the ase library.

--elements defines the elements in your system. It is set for plotting the BO results. If it's a unary substance, it has to be (ele,).

--iteration defines the maximum steps that BO will be performed with.

3. Running the code

After setting up all these stuff, you can simply run the calculation by

cd example/1d

python example.py --arg1 XX --arg2 XX ...

4. Outputs

Once the threshold or the maximum iterations is reached, you will get two output files

u_xx.txt file consists of the U parameters, band gap, and the Δband at each step.

1D_xxx.png or 2D_xxx.png plots showing you the Gaussian process predicted mean and the acquisition function.

Example of BO plots

Optimal U values will be output at the end of entire process based on the interpolation from the predicted mean space. You can also pick up the Us that give you largest objective value from the u.txt file.

Citation

Please cite the following work if you use this code.

[1] M. Yu, S. Yang, C. Wu, N. Marom, Machine learning the Hubbard U parameter in DFT+ U using Bayesian optimization, npj Computational Materials, 6(1):1–6, 2020.