Skip to content

Commit

Permalink
Refactor&Feature: Mixing module (deepmodeling#2998)
Browse files Browse the repository at this point in the history
* Fix: bug of NAN in SDFT

* Refactor: add Mixing module temporarily; abacus_pw can be compiled now

* <Feature> Add Pulay Mixing

* Merge https://github.com/Qianruipku/abacus-develop/tree/hotfix2

* Merge https://github.com/Qianruipku/abacus-develop/tree/hotfix2

* Change examples/bsse/water/result.ref

* fix compiling

* fix bug of plain mixing

* fix bug of broyden_mixing

* change default pulay to broyden

* add unit test

* add DCOPY

* <Fix> Update pulay mixing

* <Test> Add unit tests for plain, pulay, and broyden mixing.

* fix bug in relax & add reset function

* Merge https://github.com/Qianruipku/abacus-develop/tree/hotfix2

* add reset for pulay

* <Fix> Update Broyden and Pulay

* <Test> Update the unit tests of mixing.

* finish all tests about mixing module

* delete useless cout

* add mix_reset into test

* mix_rho doesnot depend on iter

* fix a bug in pulay

* fix bug for exx calculation

* fix unit test stuck

* delete openmp in global function to fix stuck in UTs

* add openmp for mixing

* fix warning: On entry to DGEMV  parameter number  6 had an illegal value

* add code coverage for mixing

* change UT name for mixing_test

* add annotations for mixing

* add global variable for mixing

---------

Co-authored-by: sunliang98 <[email protected]>
  • Loading branch information
Qianruipku and sunliang98 authored Oct 9, 2023
1 parent a5abaea commit 2ffa3d4
Show file tree
Hide file tree
Showing 326 changed files with 2,897 additions and 2,207 deletions.
2 changes: 1 addition & 1 deletion docs/advanced/elec_properties/potential.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ smearing_method gaussian
smearing_sigma 0.01
#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.4
out_pot 2
```
Expand Down
8 changes: 4 additions & 4 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,9 @@ calculations.
- **Availability**: `smearing_method` is not `fixed`.
- **Description**: Charge mixing methods.
- **plain**: Just simple mixing.
- **pulay**: Standard Pulay method.
- **broyden**: Broyden method.
- **Default**: pulay
- **pulay**: Standard Pulay method. [P. Pulay Chemical Physics Letters, (1980)](https://www.sciencedirect.com/science/article/abs/pii/0009261480803964)
- **broyden**: Simplified modified Broyden method. [D.D. Johnson Physical Review B (1988)](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.38.12807)
- **Default**: broyden

### mixing_beta

Expand All @@ -929,7 +929,7 @@ calculations.
### mixing_ndim

- **Type**: Integer
- **Description**: It indicates the mixing dimensions in Pulay, Pulay method uses the density from previous mixing_ndim steps and do a charge mixing based on this density.
- **Description**: It indicates the mixing dimensions in Pulay or Broyden. Pulay and Broyden method use the density from previous mixing_ndim steps and do a charge mixing based on this density.
- **Default**: 8

### mixing_gg0
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/interface/dpgen.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Next, for the "dpgen run" step, the following `run_param.json` should be provide
"user_fp_params":{ # All the ABACUS input paramters are defined here
"ntype": 1, # defining input parameters from INPUT files is not supported yet.
"ecutwfc": 80,
"mixing_type": "pulay",
"mixing_type": "broyden",
"mixing_beta": 0.8,
"symmetry": 1,
"nspin": 1,
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/interface/pyatb.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ks_solver genelpa
nspin 4
smearing_method gauss
smearing_sigma 0.02
mixing_type pulay
mixing_type broyden
mixing_beta 0.7
scf_nmax 200
scf_thr 1e-8
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/scf/converge.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ By mixing the electron density with that obtained from previous steps, numerical

For each of the mixing types, we also provide variables for controlling relevant parameters, including `mixing_beta`, `mixing_ndim`, and `mixing_gg0`.

The default choice is `pulay`, which should work fine in most cases. If convergence issue arises in metallic systems, inclusion of Kerker preconditioning may be helpful, which can be achieved by setting [mixing_gg0](../input_files/input-main.md#mixing_gg0) to be a positive number. For the default pulay method, a choice of 1.5 might be a good start.
The default choice is `broyden`, which should work fine in most cases. If convergence issue arises in metallic systems, inclusion of Kerker preconditioning may be helpful, which can be achieved by setting [mixing_gg0](../input_files/input-main.md#mixing_gg0) to be a positive number. For the default broyden method, a choice of 1.5 might be a good start.

A large `mixing_beta` means a larger change in electron density for each SCF step. For well-behaved systems, a larger `mixing_beta` leads to faster convergence. However, for some difficult cases, a smaller `mixing_beta` is preferred to avoid numerical instabilities.

Expand Down
2 changes: 1 addition & 1 deletion examples/charge_density/pw_nspin2_Fe/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ ks_solver cg
smearing_method gaussian
smearing_sigma 0.07

mixing_type pulay
mixing_type broyden
mixing_beta 0.5

2 changes: 1 addition & 1 deletion examples/charge_mixing/pw_Al/INPUT_1
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ smearing_method gauss
smearing_sigma 0.002

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.7
2 changes: 1 addition & 1 deletion examples/charge_mixing/pw_Al/INPUT_3
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ smearing_method gauss
smearing_sigma 0.002

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.2
4 changes: 2 additions & 2 deletions examples/charge_mixing/pw_Al/README
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Showcasing different charge mixing methods
- INPUT_1 : pulay mixing with beta=0.7, takes 5 steps to converge
- INPUT_1 : broyden mixing with beta=0.7, takes 5 steps to converge
- INPUT_2 : plain mixing with beta=0.7, takes 8 steps to converge
- INPUT_3 : pulay mixing with beta=0.2, takes 6 steps to converge
- INPUT_3 : broyden mixing with beta=0.2, takes 6 steps to converge
- INPUT_4 : plain mixing with beta=0.2, takes 37 steps to converge
2 changes: 1 addition & 1 deletion examples/compensating_charge/Pt-slab/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ basis_type pw
gamma_only 1
smearing_method gauss
smearing_sigma 0.02
mixing_type pulay
mixing_type broyden
mixing_beta 0.1

#Parameters (compensating charge)
Expand Down
2 changes: 1 addition & 1 deletion examples/deepks/lcao_CsPbI3/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ smearing_method gaussian
smearing_sigma 0.0015

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.4

#Parameters (6.Deepks)
Expand Down
2 changes: 1 addition & 1 deletion examples/deepks/lcao_H2O/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ smearing_method gaussian
smearing_sigma 0.02

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.4

#Parameters (6.Deepks)
Expand Down
2 changes: 1 addition & 1 deletion examples/deepks/pw_H2O/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ smearing_method gaussian
smearing_sigma 0.1

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.4

#Parameters (6. Bessel function)
Expand Down
2 changes: 1 addition & 1 deletion examples/dft_plus_u/NiO/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ smearing_method gaussian
smearing_sigma 0.05


mixing_type pulay
mixing_type broyden
mixing_beta 0.4
#mixing_gg0 1.5

Expand Down
2 changes: 1 addition & 1 deletion examples/dipole_correction/Pt-slab/INPUT1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ basis_type pw
gamma_only 1
smearing_method gauss
smearing_sigma 0.02
mixing_type pulay
mixing_type broyden
mixing_beta 0.1

#Parameters (dipole correction)
Expand Down
2 changes: 1 addition & 1 deletion examples/dipole_correction/Pt-slab/INPUT2
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ basis_type pw
gamma_only 1
smearing_method gauss
smearing_sigma 0.02
mixing_type pulay
mixing_type broyden
mixing_beta 0.1

#Parameters (electric field and dipole correction)
Expand Down
2 changes: 1 addition & 1 deletion examples/electric_field/Pt-slab/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ basis_type pw
gamma_only 1
smearing_method gauss
smearing_sigma 0.02
mixing_type pulay
mixing_type broyden
mixing_beta 0.1

#Parameters (electric field)
Expand Down
2 changes: 1 addition & 1 deletion examples/electrostatic_potential/lcao_Si/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ basis_type lcao

smearing_method gaussian
smearing_sigma 0.01
mixing_type pulay
mixing_type broyden
mixing_beta 0.4

out_pot 2
2 changes: 1 addition & 1 deletion examples/fixed_occupations/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ scf_nmax 400
scf_thr 1e-08
basis_type lcao
ks_solver genelpa
mixing_type pulay
mixing_type broyden
mixing_beta 0.4
mixing_gg0 1.5
pseudo_dir ../../tests/PP_ORB
Expand Down
2 changes: 1 addition & 1 deletion examples/gpu/si16_pw/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ smearing_method gauss
smearing_sigma 0.002

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.3
2 changes: 1 addition & 1 deletion examples/hefei-namd/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ INPUT_PARAMETERS
force_thr_ev 1.0e-3

ks_solver genelpa
mixing_type pulay
mixing_type broyden
mixing_beta 0.7

md_type nve
Expand Down
2 changes: 1 addition & 1 deletion examples/hse/lcao_Si2/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ scf_nmax 100
gamma_only 0
symmetry -1
smearing_method gauss
mixing_type pulay
mixing_type broyden
mixing_beta 0.4

dft_functional hse
2 changes: 1 addition & 1 deletion examples/implicit_solvation_model/Pt-slab/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ basis_type pw
gamma_only 1
smearing_method gauss
smearing_sigma 0.02
mixing_type pulay
mixing_type broyden
mixing_beta 0.1

#Parameters (Solvation Model)
Expand Down
2 changes: 1 addition & 1 deletion examples/interface_ShengBTE/LCAO/2nd/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ks_solver genelpa
gamma_only 0
smearing_method gauss
smearing_sigma 0.01
mixing_type pulay
mixing_type broyden
mixing_beta 0.7

stru_file STRU-001
2 changes: 1 addition & 1 deletion examples/interface_ShengBTE/LCAO/3rd/run_stru.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ks_solver genelpa
gamma_only 0
smearing_method gauss
smearing_sigma 0.01
mixing_type pulay
mixing_type broyden
mixing_beta 0.7
stru_file STRU_$stru
Expand Down
2 changes: 1 addition & 1 deletion examples/interface_ShengBTE/PW/2nd/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ basis_type pw
ks_solver cg
smearing_method gauss
smearing_sigma 0.01
mixing_type pulay
mixing_type broyden
mixing_beta 0.7

stru_file STRU-001
2 changes: 1 addition & 1 deletion examples/interface_ShengBTE/PW/3rd/run_stru.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ basis_type pw
ks_solver cg
smearing_method gauss
smearing_sigma 0.01
mixing_type pulay
mixing_type broyden
mixing_beta 0.7
stru_file STRU_$stru
Expand Down
2 changes: 1 addition & 1 deletion examples/interface_dpgen/autotest/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ basis_type lcao
ks_solver genelpa
smearing_method gaussian
smearing_sigma 0.01
mixing_type pulay
mixing_type broyden
mixing_beta 0.7
scf_nmax 100
scf_thr 1e-08
Expand Down
2 changes: 1 addition & 1 deletion examples/interface_dpgen/autotest/INPUT.rlx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ basis_type lcao
ks_solver genelpa
smearing_method gaussian
smearing_sigma 0.01
mixing_type pulay
mixing_type broyden
mixing_beta 0.7
scf_nmax 100
scf_thr 1e-08
Expand Down
2 changes: 1 addition & 1 deletion examples/interface_dpgen/init_and_run/run_param.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"user_fp_params":{
"ntype": 1,
"ecutwfc": 40,
"mixing_type": "pulay",
"mixing_type": "broyden",
"mixing_beta": 0.8,
"symmetry": 1,
"nspin": 1,
Expand Down
2 changes: 1 addition & 1 deletion examples/interface_phonopy/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ smearing_method gauss
smearing_sigma 0.01

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.7

pseudo_mesh 1
Expand Down
2 changes: 1 addition & 1 deletion examples/matrix_hs/out_hs2_multik/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ smearing_method gauss
smearing_sigma 0.002

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.7

out_mat_hs2 1
Expand Down
2 changes: 1 addition & 1 deletion examples/matrix_hs/out_hs_gammaonly/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ smearing_sigma 0.002
out_mat_hs 1

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.7
mixing_gg0 1.5

Expand Down
2 changes: 1 addition & 1 deletion examples/matrix_hs/out_hs_multik/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ smearing_method gauss
smearing_sigma 0.002

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.7

out_mat_hs 1
Expand Down
2 changes: 1 addition & 1 deletion examples/matrix_hs/out_s_multik/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ smearing_method gauss
smearing_sigma 0.002

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.7

out_mat_hs 1
Expand Down
2 changes: 1 addition & 1 deletion examples/md/lcao_gammaonly_Si8/INPUT_0
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ smearing_method gaussian
smearing_sigma 0.001

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.3
chg_extrap second-order

Expand Down
2 changes: 1 addition & 1 deletion examples/md/lcao_gammaonly_Si8/INPUT_1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ smearing_method gaussian
smearing_sigma 0.001

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.3
chg_extrap second-order

Expand Down
2 changes: 1 addition & 1 deletion examples/md/lcao_gammaonly_Si8/INPUT_2
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ smearing_method gaussian
smearing_sigma 0.001

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.3
chg_extrap second-order

Expand Down
2 changes: 1 addition & 1 deletion examples/md/lcao_gammaonly_Si8/INPUT_3
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ smearing_method gaussian
smearing_sigma 0.001

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.3
chg_extrap second-order

Expand Down
2 changes: 1 addition & 1 deletion examples/md/lcao_gammaonly_Si8/INPUT_4
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ smearing_method gaussian
smearing_sigma 0.001

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.3
chg_extrap second-order

Expand Down
2 changes: 1 addition & 1 deletion examples/md/lcao_gammaonly_Si8/INPUT_5
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ smearing_method gaussian
smearing_sigma 0.001

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.3
chg_extrap second-order

Expand Down
2 changes: 1 addition & 1 deletion examples/md/lcao_gammaonly_Si8/INPUT_6
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ smearing_method gaussian
smearing_sigma 0.001

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.3
chg_extrap second-order

Expand Down
2 changes: 1 addition & 1 deletion examples/md/lcao_gammaonly_Si8/INPUT_7
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ smearing_method gaussian
smearing_sigma 0.001

#Parameters (5.Mixing)
mixing_type pulay
mixing_type broyden
mixing_beta 0.3
chg_extrap second-order

Expand Down
Loading

0 comments on commit 2ffa3d4

Please sign in to comment.