Skip to content

Commit

Permalink
Doc : relaxation & pp_orb (#1317)
Browse files Browse the repository at this point in the history
* doc : update for VdW correction

* doc : fix bug in index.rst

* doc : add another layer in example/vdw

* doc : add link for vdw example

* doc : add part for XC functionals

* docs : update deeph and out_mat_XX

* docs : update session for converging SCF

* docs : update part on structure optimization

* docs : update pp_orb

* docs : add examples

* docs : update typo

* docs : update interface list(only 1 layer)

Co-authored-by: wenfei-li <liwenfei@gmail.com>
  • Loading branch information
wenfei-li and wenfei-li committed Sep 26, 2022
1 parent 7d6b0db commit 9e1a3cd
Show file tree
Hide file tree
Showing 19 changed files with 6,672 additions and 161 deletions.
8 changes: 6 additions & 2 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ This part of variables are used to control general system parameters.
- **Description**: Specify the type of calculation.
- *scf*: do self-consistent electronic structure calculation
- *relax*: do structure relaxation calculation, one can ues `relax_nmax` to decide how many ionic relaxations you want.
- *cell-relax*: do cell relaxation calculation.
- *cell-relax*: do variable-cell relaxation calculation.
- *nscf*: do the non self-consistent electronic structure calculations. For this option, you need a charge density file. For nscf calculations with planewave basis set, pw_diag_thr should be <= 1d-3.
- *istate*: For LCAO basis. Please see the explanation for variable `nbands_istate`.
- *ienvelope*: Envelope function for LCAO basis. Please see the explanation for variable `nbands_istate`.
Expand Down Expand Up @@ -721,7 +721,11 @@ This part of variables are used to control the geometry relaxation.
#### relax_method

- **Type**: String
- **Description**: The method to do geometry optimizations. If set to bfgs, using BFGS algorithm. If set to cg, using cg algorithm. If set to sd, using steepest-descent lgorithm.
- **Description**: The method to do geometry optimizations:
- bfgs: using BFGS algorithm.
- sd: using steepest-descent algorithm.
- cg: using cg algorithm.
- cg-bfgs:
- **Default**: cg

#### relax_cg_thr
Expand Down
13 changes: 12 additions & 1 deletion docs/advanced/input_files/stru.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,17 @@ information that comes below.
```

Here `Si_ONCV_PBE-1.0.upf` is the pseudopotential file. When the path is not specified, the file is assumed to be located in work directory. Otherwise, please explicitly specify the location of the pseudopotential files.

After the pseudopotential file, `upf201` is the type of pseudopotential. There are five options: `upf`(.UPF format), `upf201`(the new .UPF format), `vwr`(.vwr format), `blps`(bulk-derived local pseudopotential), and `auto`(automatically identified). If no pseudopotential type is assigned, the default value is `auto`, and the pseudopotential type will be automatically identified.
Different types of pseudopotentials can be used for different elements, but note that the XC functionals assigned by all pseudopotentials shouldl be the same one.

Different types of pseudopotentials can be used for different elements, but note that the XC functionals assigned by all pseudopotentials should be the same one. If not, the choice of XC functional must be set explicitly using the [dft_functional](./input-main.md#dftfunctional) keyword.

Common sources of the pseudopotential files include:
1. [Quantum ESPRESSO](http://www.quantum-espresso.org/pseudopotentials/).
2. [SG15-ONCV](http://quantum-simulation.org/potentials/sg15_oncv/upf/).
3. [DOJO](http://www.pseudo-dojo.org/).


- NUMERICAL_ORBITAL

Numerical atomic orbitals are only needed for `LCAO` calculations. Thus this section will be neglected in calcultions with plane wave basis. In the above example, numerical atomic orbitals is specified for the element `Si`:
Expand All @@ -93,6 +102,8 @@ information that comes below.
```

‘Si_gga_8au_60Ry_2s2p1d.orb’ is name of the numerical orbital file. Again here the path is not specified, which means that this file is located in the work directory.

Numerical atomic orbitals may be downloaded from the [official website](http://abacus.ustc.edu.cn/pseudo/list.htm).
- LATTICE_CONSTANT

The lattice constant of the system in unit of Bohr.
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/interface/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Interfaces to Other Softwares
=================================================

.. toctree::
:maxdepth: 2
:maxdepth: 1
:caption: Examples

deepks
Expand Down
1 change: 1 addition & 0 deletions docs/advanced/md.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ To run any of the fix cases, users may enter the directory, copy the correspondi

## FIRE
[FIRE](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.97.170201) (fast inertial relaxation engine) is a MD-based minimization algorithm. It is based on conventional molecular dynamics with additional velocity modifications and adaptive time steps. The MD trajectory will descend to an energy-minimum.

## NVE

NVE ensemble (i. e. microcanonical ensemble) is a statistical ensemble that represents the possible states of a mechanical system whose total energy is exactly specified. The system is assumed to be isolated in the sense that it cannot exchange energy or particles with its environment, so that the energy of the system does not change with time.
Expand Down
73 changes: 69 additions & 4 deletions docs/advanced/opt.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,72 @@
# Geometry Optimization

## Methods
### BFGS
### CG
By setting `calculation` to be `relax` or `cell-relax`, ABACUS supports structural relaxation and variable-cell relaxation.

## Constrained Optimization
Current implementation of variable-cell relaxation in ABACUS now follows a nested procedure: fixed cell structural relaxation will be performed, followed by an update of the cell parameters, and the process is repeated until convergence is achieved.

An example of the variable cell relaxation can be found in our [repository](https://github.com/deepmodeling/abacus-develop/tree/develop/examples/relax/pw_al), which is provided with the reference output file log.ref. Note that in log.ref, each ionic step is labelled in the following manner:
```
-------------------------------------------
RELAX CELL : 3
RELAX IONS : 1 (in total: 15)
-------------------------------------------
```

indicating that this is the first ionic step of the 3rd cell configuration, and it is the 15-th ionic step in total.


## Optimization Algorithms
In the nested procedure mentioned above, we used CG method to perform cell relaxation, while offering four different algorithms for doing fixed-cell structural relaxation: BFGS, SD(steepest descent), CG(conjugate gradient), as well as a mixed CG-BFGS method. The optimziation algorithm can be selected using keyword [relax_method](./input_files/input-main.md#relaxmethod). We also provide a [list of keywords](./input_files/input-main.md#geometry-relaxation) for controlling the relaxation process.

### BFGS method

The [BFGS method](https://en.wikipedia.org/wiki/Broyden%E2%80%93Fletcher%E2%80%93Goldfarb%E2%80%93Shanno_algorithm) is a quasi-Newton method for solving nonlinear optimization problem. It belongs to the class of quasi-Newton method where the Hessian matrix is approximated during the optimization process. If the initial point is not far from the extrema, BFGS tends to work better than gradient-based methods.

In ABACUS, we implemented the BFGS method for doing fixed-cell structural relaxation.

### SD method

The [SD (steepest descent) method](https://en.wikipedia.org/wiki/Gradient_descent) is one of the simplest first-order optimization methods, where in each step the motion is along the direction of the gradient, where the function descents the fastest.

In practice, SD method may take many iterations to converge, and is generally not used.

### CG method

The [CG (conjugate gradient) method](https://en.wikipedia.org/wiki/Conjugate_gradient_method) is one of the most widely used methods for solving optimization problems.

In ABACUS, we implemented the CG method for doing fixed-cell structural relaxation as well as the optimization of cell parameters.

## Constrained Optimization

Apart from conventional optimization where all degrees of freedom are allowed to move, we also offer the option of doing constrained optimization in ABACUS.

### Fixing Atomic Positions
Users may note that in the above-mentioned [example](), the atomic positions in STRU file are given along with three integers:

```
Al
0.0
4
0.00 0.00 0.00 1 1 1
0.53 0.50 0.00 1 1 1
0.50 0.00 0.52 1 1 1
0.00 0.50 0.50 1 1 1
```

For relaxation calculations, the three integers denote whether the corresponding degree of freedom is allowed to move. For example, if we replace the STRU file by:
```
Al
0.0
4
0.00 0.00 0.00 1 1 0
0.53 0.50 0.00 1 1 1
0.50 0.00 0.52 1 1 1
0.00 0.50 0.50 1 1 1
```

then the first Al atom will not be allowed to move in z direction.

Fixing atomic position is sometimes helpful during relaxation of isolated molecule/cluster, to prevent the system from drifting in space.

### Fixing Cell Parameters
Sometimes we want to do variable-cell relaxation with some of the cell degrees of freedom fixed. This is achieved by the [fixed_axes](./input_files/input-main.md#fixedaxes) keyword. We offer the options of fixing certain axis(axes), or fixing the volume.
183 changes: 31 additions & 152 deletions docs/advanced/pp_orb.md
Original file line number Diff line number Diff line change
@@ -1,171 +1,50 @@
# Basis set and Pseudopotentials
# Basis Set and Pseudopotentials

## Basis Set

ABACUS supports both pw and lcao XXXXX
ABACUS supports both PW and LCAO basis set, controlled by keyword [basis_type](./input_files/input-main.md#basistype) in INPUT file.

## Generating atomic orbital bases

In ABACUS, the atomic orbital bases are generated using a scheme developed in the [paper](https://iopscience.iop.org/article/10.1088/0953-8984/22/44/445501). We provide a script named “generate_orbital.sh” under the directory tools/ to generate the atomic orbitals bases. In order to run this script, an ORBITAL_INPUT file is required.

An example of this ORBITAL_INPUT file can be found in $ABACUS/tools/SIAB/SimulatedAnnealing/example_N:
```
#1.exe_dir
#----------------------------------------------------------------------------
EXE_pw bin/ABACUS.fp_mpi.x
EXE_orbital bin/SIA_s.exe
#----------------------------------------------------------------------------
#( In this part, the direction of the two used exe is provided )
#2.electronic calculatation
#----------------------------------------------------------------------------
targets 07_N # element
ref_bands 5 # reference bands
nbands 8 # num of bands for calculate ( > reference bands)
Ecut 50 # cutoff energy (in Ry)
Rcut 6 # cutoff radius (in a.u.)
Pseudo_dir ./
Pseudo N.LDA.UPF
smearing_sigma 0.01 # energy range for gauss smearing (in Ry)
#----------------------------------------------------------------------------
#( In this part , some parameters of calculating are given )
#3.structure information
#----------------------------------------------------------------------------
Dis 1.0 1.1 1.5 2.0 3.0
#----------------------------------------------------------------------------
#( In this part , it gives us the bond length of the reference system( in
#angstrom) )
#4.orbital calculatation
#----------------------------------------------------------------------------
maxL 2 # the max angular momentum (L<=2)
Level 2 # num of levels to generate orbitals(<=5)
#(num) (the max ang) (num of S) (num of P) (num of D)
level1 1 1 1
level2 2 1 1 1
#----------------------------------------------------------------------------
#( In this part, some information of orbital is given )
#5.Metropolis parameters (in most cases do not need to change)
#----------------------------------------------------------------------------
Start_tem_S 1.0e-4 # start temperature for optimize Spillage(default 1.0e-4)
Start_tem_K 1.0e-2 # start temperature for optimize Kinetic (default 1.0e-2)
Step_S 20 # num of steps for optimize Spillage (default 20)
Step_K 15 # num of steps for optimize Kinetic (default 15)
Delta_kappa 0.01 # delta kappa (default 0.01)
#----------------------------------------------------------------------------
#(In this part, some parameters of Metropolis is given. In most cases, they
#do not need to be changed , only when you run into a situation , that the
#Kinnetic energy is larger than the maximum value allowed , you can enlarge
#the start temperature appropritely, or you can enlarge the delta_kappa, e.g.
#start_tem_k 1.0e-2 to 5.0e-1, delta_kappa 0.01 to 0.02. more steps can make
#the orbitals better , too)
```

The ORBITAL_INPUT file contains 5 parts :
1. exe_dir

The paths of two executable files:

- EXE_pw: executable file of ABACUS
- EXE_orbital: executable file of orbital generation

We can get the exe file of orbital generation as below:
```
cd tools/SIAB/1_Source/
make s
```
2. electronic calculation

Parameters for electronic calculations:

- targets

the element type of which orbitals are to be generated. Its value has form of ‘element.id_element’, for example 07_N.
- ref_bands

the number of reference bands for orbital generation. We usually take the number of occupied bands of the system. For the N element, we take its “dimers” as the reference systems, so the number of ref_bands should be 5 (valence electrons of this element)\*2(number of the atoms of the system)/2 (1 band contain 2 electrons)=5. While for Na element, we take trimer as reference systems, and the number of the ref_bands should be 1\*3/2=1.5 for 1.5 is not a integer, here we use 2 for its ref_bands. Most elements use dimer as reference systems, except for Li, Na, K, Ca, which use trimer instead.
- nbands
The default value of basis_type is pw. The size of pw basis set is controlled by imposing an upper bound for the [kinetic energy cutoff](./input_files/input-main.md#ecutwfc) of the plane wave.

the number of bands to be calculated in electronic calculation. Here, we use the gaussian smearing for the electronic structure calculation, so the value of this parameter can not be smaller than the value of ref_bands
- Ecut
When choosing lcao basis set, users need to prepare a set of atomic orbitals. Such files may be downloaded from the [official website](http://abacus.ustc.edu.cn/pseudo/list.htm). For more information, also check the `NUMERICAL_ORBITAL` section in the specification of the [STRU file](./input_files/stru.md).

the Energy cutoff (in Ry)
- Rcut

the radius cutoff of atomic orbital (in a.u)
- Pseudo_dir

the path to the directory where the pseudopotential file is.
- Pseudo
## Generating atomic orbital bases

the file name of pseudopotential
- smearing_sigma
Users may also choose to generate their own atomic obitals. In ABACUS, the atomic orbital bases are generated using a scheme developed in the [paper](https://iopscience.iop.org/article/10.1088/0953-8984/22/44/445501). A detailed description of the procedure for generating orbitals will be provided later.

the gaussian smearing (in Ry) for scf calculations. The default vaule is 0.01. In case that the scf iterations don’t converage (which could happen, e.g., for transition metal dimers), the user may increase this parameter, say, to 0.05.
3. structure information
## BSSE Correction

This part gives the bond lengths of the reference systems (dimer or trimer). Generally, the bond lengths are chosen to distribute on both sides of the equilibrium value. For example, for N dimer we use (in Å):
- Dis 1.0 1.1 1.5 2.0 3.0
For treating BSSE(Basis Set Superposition Error), we allow for the inclusion of "empty" or "ghost" atoms in the calculation. Namely, when expanding the Hamiltonian, basis sets on the atoms are used, while the ionic potentials on those atoms are not included when constructing the Hamiltonian.

It means we take 5 reference systems (dimer), and the bond lengths are 1.0 1.1 1.5 2.0 3.0 angstrom, respectively. Every element has reference systems with different bond lengths, which could be found in file $ABACUS/tools/SIAB/DIS.txt.
4. orbital generation
An empty atom is defined in the `STRU` file when an element name contains the "empty" suffix, such as "H_empty", "O_empty" and so on. Here we provide an [example]() of calculating the molecular formation energy of $H_2O$ with BSSE correction.

The main parameters for orbital generation
In the example, we provide four STRU files:

- maxL

the max angular momentum for orbitals to be generated
- level

number of levels to generate orbitals. In the main part of this section, level1, level2... provide the information of each layer, the max angular momentum and the number of s, p, d orbitals.
- STRU_0 : used along with ntype = 2;normal calculation of water molecule ($E(\text{H}_2\text{O})$)

For example, if we want to use 2 steps to generate DZP basis for N, we can set this part like this:
```
maxL 2 # the max angular momentum (L<=2)
level 2 # num of levels to generate orbitals(<=5)
(num) (the max ang) (num of S) (num of P) (num of D)
level1 1 1 1
level2 2 1 1 1
```
Because of the property of symmetry, taking dimer or trimer as reference systems can not generate the f orbitals very well. And test results show that f orbital has little effect on improving the results. It means we generate one s orbital and one p orbital in first step (level1), and generate one s, p, d orbital in the second step (level2).
5. Metropolis parameters

The main parameters for Metropolis optimization.

- Start_tem_S

start temperature for spillage optimization
- Start_tem_K

start temperature for kinetic energy optimization
- Step_S

number of steps for spillage optimization
- Step_K

number of steps for kinetic energy optimization
- Delta_kappa

the accept rise of spillage when optimizing the kinetic energy

After preparing the ORBITAL_INPUT file, one just needs to run the script "$PATH_TO/generate_orbital.sh ORBITAL_INPUT" and wait for the results. The results will be written into several output files under the directory $element.id_element/$Rcut/, for example 07_N/6/.
obtained total energy of -466.4838149140513 eV
- STRU_1 : used along with ntype = 2;calculation of single O atom ($E_O$)

obtained total energy of -427.9084406198214 eV
- STRU_2 : used along with ntype = 3;calculation of 1st H atom ($E_{H1}$)

obtained total energy of -12.59853381731160 eV
- STRU_3 : used along with ntype = 3;calculation of 2nd H atom ($E_{H2}$)

Some output files listed here are useful.
- ORBITAL_RESULTS.txt
obtained total energy of -12.59853378720844 eV

this file shows some important information of the orbital, we can see the spillage of the orbital to judge whether the orbital is good enough for us to use.
- running_1.txt
the details of generating orbitals
- ORBITAL_PLOTU.dat
you can open it by using any drawing softwares to visualize the shape of the orbital
- ORBITAL_7U.dat
the general type is ORBITAL_($element.id)U.dat . This is the orbital file we will use in the calculation. And you can rename it as anything you want. We usually use the covention “element_xc_rcut_ecut_XsY pZd”, e.g., N_lda_6.0au_50Ry_2s2p1d, which tells the key parameters for the basis set construction.
> Note : Remember to adjust the parameter `ntype` in INPUT file
For some elements, you can download the reference ORBITAL_INPUT files and pseudopotentials from our [website](http://abacus.ustc.edu.cn/pseudo.html).
Thus, the formation energy is given by:
$$
\Delta E(\text{H}_2\text{O}) = E(\text{H}_2\text{O}) - E(\text{O}) - E(\text{H}^1) - E(\text{H}^2) \approx -13.38 eV
$$

A file README is also given and you can decide the parameters with it as a reference.
In most cases, you just need to modify the parameters in Section 1, 2. Section 4 may be
partially modified if you need higher precision orbitals. The users are not encouraged to change
the settings in sections 5, unless you are very familiar with the code generating algorithms.
## Pseudopotentials

## BSSE
In ABACUS, we only supports norm-conserving pseudopotentials. We support four different formats of the pseudopotential files: UPF, UPF2, VWR, and BLPS. For more information, check the `ATOMIC_SPECIES` section in the specification of the [STRU file](./input_files/stru.md).

## Pseudopotentials
Here we list some common sources of the pseudopotential files:
1. [Quantum ESPRESSO](http://www.quantum-espresso.org/pseudopotentials/).
2. [SG15-ONCV](http://quantum-simulation.org/potentials/sg15_oncv/upf/).
3. [DOJO](http://www.pseudo-dojo.org/).
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Hi everyone, here are ABACUS Documentations.

.. toctree::
:maxdepth: 2
:caption: Developing team
:caption: Developing Team

DevelopingTeam

Expand Down

0 comments on commit 9e1a3cd

Please sign in to comment.