diff --git a/docs/advanced/elec_properties/potential.md b/docs/advanced/elec_properties/potential.md index 4a5439d652..00732f407b 100644 --- a/docs/advanced/elec_properties/potential.md +++ b/docs/advanced/elec_properties/potential.md @@ -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 ``` diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index 341214aa57..705ce8e03b 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -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 @@ -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 diff --git a/docs/advanced/interface/dpgen.md b/docs/advanced/interface/dpgen.md index 5ca9ae425e..bcfb1b1cb7 100644 --- a/docs/advanced/interface/dpgen.md +++ b/docs/advanced/interface/dpgen.md @@ -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, diff --git a/docs/advanced/interface/pyatb.md b/docs/advanced/interface/pyatb.md index 109a1e13fb..7c1ed0b9f2 100644 --- a/docs/advanced/interface/pyatb.md +++ b/docs/advanced/interface/pyatb.md @@ -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 diff --git a/docs/advanced/scf/converge.md b/docs/advanced/scf/converge.md index e6d65dc4a7..d068784ff2 100644 --- a/docs/advanced/scf/converge.md +++ b/docs/advanced/scf/converge.md @@ -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. diff --git a/examples/charge_density/pw_nspin2_Fe/INPUT b/examples/charge_density/pw_nspin2_Fe/INPUT index b45d1180d9..9f085fa8e3 100644 --- a/examples/charge_density/pw_nspin2_Fe/INPUT +++ b/examples/charge_density/pw_nspin2_Fe/INPUT @@ -15,6 +15,6 @@ ks_solver cg smearing_method gaussian smearing_sigma 0.07 -mixing_type pulay +mixing_type broyden mixing_beta 0.5 diff --git a/examples/charge_mixing/pw_Al/INPUT_1 b/examples/charge_mixing/pw_Al/INPUT_1 index 8d935ad09b..e6948715d5 100644 --- a/examples/charge_mixing/pw_Al/INPUT_1 +++ b/examples/charge_mixing/pw_Al/INPUT_1 @@ -20,5 +20,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/examples/charge_mixing/pw_Al/INPUT_3 b/examples/charge_mixing/pw_Al/INPUT_3 index 3eae901cac..21145210ca 100644 --- a/examples/charge_mixing/pw_Al/INPUT_3 +++ b/examples/charge_mixing/pw_Al/INPUT_3 @@ -20,5 +20,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.2 diff --git a/examples/charge_mixing/pw_Al/README b/examples/charge_mixing/pw_Al/README index 396e6b3d66..376796ba4a 100644 --- a/examples/charge_mixing/pw_Al/README +++ b/examples/charge_mixing/pw_Al/README @@ -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 diff --git a/examples/compensating_charge/Pt-slab/INPUT b/examples/compensating_charge/Pt-slab/INPUT index 8c301271da..913c384fd3 100644 --- a/examples/compensating_charge/Pt-slab/INPUT +++ b/examples/compensating_charge/Pt-slab/INPUT @@ -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) diff --git a/examples/deepks/lcao_CsPbI3/INPUT b/examples/deepks/lcao_CsPbI3/INPUT index a3130f5f0f..b89be68bc5 100644 --- a/examples/deepks/lcao_CsPbI3/INPUT +++ b/examples/deepks/lcao_CsPbI3/INPUT @@ -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) diff --git a/examples/deepks/lcao_H2O/INPUT b/examples/deepks/lcao_H2O/INPUT index 5272a435e6..cce57df555 100644 --- a/examples/deepks/lcao_H2O/INPUT +++ b/examples/deepks/lcao_H2O/INPUT @@ -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) diff --git a/examples/deepks/pw_H2O/INPUT b/examples/deepks/pw_H2O/INPUT index c74f159d1a..2b66703b4a 100644 --- a/examples/deepks/pw_H2O/INPUT +++ b/examples/deepks/pw_H2O/INPUT @@ -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) diff --git a/examples/dft_plus_u/NiO/INPUT b/examples/dft_plus_u/NiO/INPUT index e6bd9150eb..47bdc70395 100644 --- a/examples/dft_plus_u/NiO/INPUT +++ b/examples/dft_plus_u/NiO/INPUT @@ -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 diff --git a/examples/dipole_correction/Pt-slab/INPUT1 b/examples/dipole_correction/Pt-slab/INPUT1 index 5b1505d7a6..23575c12d7 100644 --- a/examples/dipole_correction/Pt-slab/INPUT1 +++ b/examples/dipole_correction/Pt-slab/INPUT1 @@ -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) diff --git a/examples/dipole_correction/Pt-slab/INPUT2 b/examples/dipole_correction/Pt-slab/INPUT2 index 278961a84c..7c420e4c52 100644 --- a/examples/dipole_correction/Pt-slab/INPUT2 +++ b/examples/dipole_correction/Pt-slab/INPUT2 @@ -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) diff --git a/examples/electric_field/Pt-slab/INPUT b/examples/electric_field/Pt-slab/INPUT index e376dcbc1c..96c7c5d532 100644 --- a/examples/electric_field/Pt-slab/INPUT +++ b/examples/electric_field/Pt-slab/INPUT @@ -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) diff --git a/examples/electrostatic_potential/lcao_Si/INPUT b/examples/electrostatic_potential/lcao_Si/INPUT index 5faee85a52..9a6512c86e 100644 --- a/examples/electrostatic_potential/lcao_Si/INPUT +++ b/examples/electrostatic_potential/lcao_Si/INPUT @@ -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 diff --git a/examples/fixed_occupations/INPUT b/examples/fixed_occupations/INPUT index 5bafeae180..dff57c79a3 100644 --- a/examples/fixed_occupations/INPUT +++ b/examples/fixed_occupations/INPUT @@ -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 diff --git a/examples/gpu/si16_pw/INPUT b/examples/gpu/si16_pw/INPUT index 307bff22e2..0d7c21fc22 100644 --- a/examples/gpu/si16_pw/INPUT +++ b/examples/gpu/si16_pw/INPUT @@ -20,5 +20,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/examples/hefei-namd/INPUT b/examples/hefei-namd/INPUT index 07416526c5..b7a1bd42b0 100644 --- a/examples/hefei-namd/INPUT +++ b/examples/hefei-namd/INPUT @@ -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 diff --git a/examples/hse/lcao_Si2/INPUT b/examples/hse/lcao_Si2/INPUT index b46e36a08e..642e2ccb4a 100644 --- a/examples/hse/lcao_Si2/INPUT +++ b/examples/hse/lcao_Si2/INPUT @@ -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 diff --git a/examples/implicit_solvation_model/Pt-slab/INPUT b/examples/implicit_solvation_model/Pt-slab/INPUT index 76d2eecc2e..c9d082bab2 100644 --- a/examples/implicit_solvation_model/Pt-slab/INPUT +++ b/examples/implicit_solvation_model/Pt-slab/INPUT @@ -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) diff --git a/examples/interface_ShengBTE/LCAO/2nd/INPUT b/examples/interface_ShengBTE/LCAO/2nd/INPUT index d2cbd3bda0..a1ee39afe1 100644 --- a/examples/interface_ShengBTE/LCAO/2nd/INPUT +++ b/examples/interface_ShengBTE/LCAO/2nd/INPUT @@ -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 diff --git a/examples/interface_ShengBTE/LCAO/3rd/run_stru.sh b/examples/interface_ShengBTE/LCAO/3rd/run_stru.sh index 90730c27d2..14566f6421 100644 --- a/examples/interface_ShengBTE/LCAO/3rd/run_stru.sh +++ b/examples/interface_ShengBTE/LCAO/3rd/run_stru.sh @@ -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 diff --git a/examples/interface_ShengBTE/PW/2nd/INPUT b/examples/interface_ShengBTE/PW/2nd/INPUT index 54948472b3..e8ab80e49b 100644 --- a/examples/interface_ShengBTE/PW/2nd/INPUT +++ b/examples/interface_ShengBTE/PW/2nd/INPUT @@ -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 diff --git a/examples/interface_ShengBTE/PW/3rd/run_stru.sh b/examples/interface_ShengBTE/PW/3rd/run_stru.sh index c077494dad..0543347c86 100644 --- a/examples/interface_ShengBTE/PW/3rd/run_stru.sh +++ b/examples/interface_ShengBTE/PW/3rd/run_stru.sh @@ -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 diff --git a/examples/interface_dpgen/autotest/INPUT b/examples/interface_dpgen/autotest/INPUT index 75bfa208aa..a1634e3742 100644 --- a/examples/interface_dpgen/autotest/INPUT +++ b/examples/interface_dpgen/autotest/INPUT @@ -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 diff --git a/examples/interface_dpgen/autotest/INPUT.rlx b/examples/interface_dpgen/autotest/INPUT.rlx index 00bbe53869..8b8ec4f341 100644 --- a/examples/interface_dpgen/autotest/INPUT.rlx +++ b/examples/interface_dpgen/autotest/INPUT.rlx @@ -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 diff --git a/examples/interface_dpgen/init_and_run/run_param.json b/examples/interface_dpgen/init_and_run/run_param.json index d33edcd298..2a3bcf16f7 100644 --- a/examples/interface_dpgen/init_and_run/run_param.json +++ b/examples/interface_dpgen/init_and_run/run_param.json @@ -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, diff --git a/examples/interface_phonopy/INPUT b/examples/interface_phonopy/INPUT index a02821b6ab..edcff1016d 100644 --- a/examples/interface_phonopy/INPUT +++ b/examples/interface_phonopy/INPUT @@ -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 diff --git a/examples/matrix_hs/out_hs2_multik/INPUT b/examples/matrix_hs/out_hs2_multik/INPUT index bf4c1743f6..60eef1d436 100644 --- a/examples/matrix_hs/out_hs2_multik/INPUT +++ b/examples/matrix_hs/out_hs2_multik/INPUT @@ -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 diff --git a/examples/matrix_hs/out_hs_gammaonly/INPUT b/examples/matrix_hs/out_hs_gammaonly/INPUT index d3b0662b07..5ea35883b8 100644 --- a/examples/matrix_hs/out_hs_gammaonly/INPUT +++ b/examples/matrix_hs/out_hs_gammaonly/INPUT @@ -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 diff --git a/examples/matrix_hs/out_hs_multik/INPUT b/examples/matrix_hs/out_hs_multik/INPUT index b388056b7e..e0e3159a8b 100644 --- a/examples/matrix_hs/out_hs_multik/INPUT +++ b/examples/matrix_hs/out_hs_multik/INPUT @@ -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 diff --git a/examples/matrix_hs/out_s_multik/INPUT b/examples/matrix_hs/out_s_multik/INPUT index 6eb35b0f2a..91e81498a2 100644 --- a/examples/matrix_hs/out_s_multik/INPUT +++ b/examples/matrix_hs/out_s_multik/INPUT @@ -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 diff --git a/examples/md/lcao_gammaonly_Si8/INPUT_0 b/examples/md/lcao_gammaonly_Si8/INPUT_0 index d53a328626..5827a8c017 100644 --- a/examples/md/lcao_gammaonly_Si8/INPUT_0 +++ b/examples/md/lcao_gammaonly_Si8/INPUT_0 @@ -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 diff --git a/examples/md/lcao_gammaonly_Si8/INPUT_1 b/examples/md/lcao_gammaonly_Si8/INPUT_1 index 4dc5660daf..c49ff60e92 100644 --- a/examples/md/lcao_gammaonly_Si8/INPUT_1 +++ b/examples/md/lcao_gammaonly_Si8/INPUT_1 @@ -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 diff --git a/examples/md/lcao_gammaonly_Si8/INPUT_2 b/examples/md/lcao_gammaonly_Si8/INPUT_2 index de66ab9ad9..4db4b4ec77 100644 --- a/examples/md/lcao_gammaonly_Si8/INPUT_2 +++ b/examples/md/lcao_gammaonly_Si8/INPUT_2 @@ -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 diff --git a/examples/md/lcao_gammaonly_Si8/INPUT_3 b/examples/md/lcao_gammaonly_Si8/INPUT_3 index c591f0cfe5..88816f5a53 100644 --- a/examples/md/lcao_gammaonly_Si8/INPUT_3 +++ b/examples/md/lcao_gammaonly_Si8/INPUT_3 @@ -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 diff --git a/examples/md/lcao_gammaonly_Si8/INPUT_4 b/examples/md/lcao_gammaonly_Si8/INPUT_4 index 355b2f4c08..c970548f3f 100644 --- a/examples/md/lcao_gammaonly_Si8/INPUT_4 +++ b/examples/md/lcao_gammaonly_Si8/INPUT_4 @@ -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 diff --git a/examples/md/lcao_gammaonly_Si8/INPUT_5 b/examples/md/lcao_gammaonly_Si8/INPUT_5 index f2ca6a1bf4..9b95073fcf 100644 --- a/examples/md/lcao_gammaonly_Si8/INPUT_5 +++ b/examples/md/lcao_gammaonly_Si8/INPUT_5 @@ -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 diff --git a/examples/md/lcao_gammaonly_Si8/INPUT_6 b/examples/md/lcao_gammaonly_Si8/INPUT_6 index 223575ae88..a0a6a4d24d 100644 --- a/examples/md/lcao_gammaonly_Si8/INPUT_6 +++ b/examples/md/lcao_gammaonly_Si8/INPUT_6 @@ -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 diff --git a/examples/md/lcao_gammaonly_Si8/INPUT_7 b/examples/md/lcao_gammaonly_Si8/INPUT_7 index e36f385afc..a2e686ea40 100644 --- a/examples/md/lcao_gammaonly_Si8/INPUT_7 +++ b/examples/md/lcao_gammaonly_Si8/INPUT_7 @@ -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 diff --git a/examples/scf/lcao_Cu/INPUT b/examples/scf/lcao_Cu/INPUT index 536485ad7c..58a67a4496 100644 --- a/examples/scf/lcao_Cu/INPUT +++ b/examples/scf/lcao_Cu/INPUT @@ -11,7 +11,7 @@ scf_nmax 100 smearing_method gaussian smearing_sigma 0.02 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 basis_type lcao diff --git a/examples/scf/lcao_ZnO/INPUT b/examples/scf/lcao_ZnO/INPUT index abe9fa6ac6..2d13bae3b5 100644 --- a/examples/scf/lcao_ZnO/INPUT +++ b/examples/scf/lcao_ZnO/INPUT @@ -11,7 +11,7 @@ scf_nmax 100 smearing_method gaussian smearing_sigma 0.02 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 basis_type lcao diff --git a/examples/smearing/lcao_fe/INPUT_1 b/examples/smearing/lcao_fe/INPUT_1 index 44e33a159d..fcf174286f 100644 --- a/examples/smearing/lcao_fe/INPUT_1 +++ b/examples/smearing/lcao_fe/INPUT_1 @@ -11,7 +11,7 @@ out_chg 0 smearing_method gaussian smearing_sigma 0.02 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 ks_solver genelpa diff --git a/examples/smearing/lcao_fe/INPUT_2 b/examples/smearing/lcao_fe/INPUT_2 index 6ee281426c..f4314410d6 100644 --- a/examples/smearing/lcao_fe/INPUT_2 +++ b/examples/smearing/lcao_fe/INPUT_2 @@ -10,7 +10,7 @@ out_chg 0 smearing_method fixed -mixing_type pulay +mixing_type broyden mixing_beta 0.4 ks_solver genelpa diff --git a/examples/vc-Si-Al-Nacl-example/a-Si2_diamond/pw-basis/02-10.00a0/INPUT b/examples/vc-Si-Al-Nacl-example/a-Si2_diamond/pw-basis/02-10.00a0/INPUT index 745fa3456d..327eabf538 100644 --- a/examples/vc-Si-Al-Nacl-example/a-Si2_diamond/pw-basis/02-10.00a0/INPUT +++ b/examples/vc-Si-Al-Nacl-example/a-Si2_diamond/pw-basis/02-10.00a0/INPUT @@ -29,4 +29,4 @@ cal_stress 1 #cell_factor 10 stress_thr 1e-6 -mixing_type pulay +mixing_type broyden diff --git a/source/Makefile.Objects b/source/Makefile.Objects index f8357fd187..8e1146d8cb 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -22,6 +22,7 @@ VPATH=./src_global:\ ./module_base/module_container/base/core:\ ./module_base/module_container/ATen/core:\ ./module_base/module_container/ATen/kernels:\ +./module_base/module_mixing:\ ./module_md:\ ./module_basis/module_pw:\ ./module_esolver:\ @@ -141,6 +142,8 @@ OBJS_BASE=abfs-vector3_order.o\ formatter_contextfmt.o\ cubic_spline.o\ spherical_bessel_transformer.o\ + mixing_data.o\ + OBJS_CELL=atom_pseudo.o\ atom_spec.o\ @@ -478,7 +481,8 @@ OBJS_MODULE_RI=conv_coulomb_pot_k.o\ Matrix_Orbs21.o\ Matrix_Orbs22.o\ RI_2D_Comm.o\ - Mix_DMk_2D.o + Mix_DMk_2D.o\ + Mix_Matrix.o\ OBJS_PARALLEL=parallel_common.o\ parallel_global.o\ @@ -494,10 +498,8 @@ OBJS_SRCPW=H_Ewald_pw.o\ charge.o\ charge_init.o\ charge_mpi.o\ - charge_broyden.o\ charge_extra.o\ charge_mixing.o\ - charge_pulay.o\ fp_energy.o\ forces.o\ force_op.o\ diff --git a/source/module_base/CMakeLists.txt b/source/module_base/CMakeLists.txt index f3aa16ec2e..f3bd53aee2 100644 --- a/source/module_base/CMakeLists.txt +++ b/source/module_base/CMakeLists.txt @@ -52,6 +52,7 @@ add_library( formatter_physfmt.cpp formatter_table.cpp formatter_contextfmt.cpp + module_mixing/mixing_data.cpp ${LIBM_SRC} ) @@ -74,6 +75,7 @@ if(BUILD_TESTING) add_subdirectory(test) add_subdirectory(test_parallel) add_subdirectory(kernels/test) + add_subdirectory(module_mixing/test) if (USE_ABACUS_LIBM) add_subdirectory(libm/test) endif() diff --git a/source/module_base/global_variable.cpp b/source/module_base/global_variable.cpp index 0a712b0cd6..f060c530b8 100644 --- a/source/module_base/global_variable.cpp +++ b/source/module_base/global_variable.cpp @@ -242,6 +242,13 @@ int of_full_pw_dim = 0; bool of_read_kernel = false; std::string of_kernel_file = "WTkernel.txt"; +// mixing parameters +std::string MIXING_MODE = "broyden"; +double MIXING_BETA = 0.7; +int MIXING_NDIM = 8; +double MIXING_GG0 = 0.0; +bool MIXING_TAU = 0; + //========================================================== // device flags added by denghui //========================================================== diff --git a/source/module_base/global_variable.h b/source/module_base/global_variable.h index 83f2db967e..66465532ba 100644 --- a/source/module_base/global_variable.h +++ b/source/module_base/global_variable.h @@ -270,6 +270,13 @@ extern int of_full_pw_dim; // If of_full_pw = 1, the dimention of FFT will be t extern bool of_read_kernel; // If set to 1, the kernel of WT KEDF will be filled from file of_kernel_file, not from formula. Only usable for WT KEDF. extern std::string of_kernel_file; // The name of WT kernel file. +// mixing parameters +extern std::string MIXING_MODE; +extern double MIXING_BETA; +extern int MIXING_NDIM; +extern double MIXING_GG0; +extern bool MIXING_TAU; + //========================================================== // device flags added by denghui //========================================================== diff --git a/source/module_base/lapack_connector.h b/source/module_base/lapack_connector.h index 29d70e8e34..5865e178be 100644 --- a/source/module_base/lapack_connector.h +++ b/source/module_base/lapack_connector.h @@ -94,7 +94,7 @@ extern "C" // dsytrf_ computes the Bunch-Kaufman factorization of a double precision // symmetric matrix, while dsytri takes its output to perform martrix inversion void dsytrf_(const char* uplo, const int* n, double * a, const int* lda, - int *ipiv,double *work, int* lwork ,int *info); + int *ipiv,double *work, const int* lwork ,int *info); void dsytri_(const char* uplo,const int* n,double *a, const int *lda, int *ipiv, double * work,int *info); // Peize Lin add dsptrf and dsptri 2016-06-21, to compute inverse real symmetry indefinit matrix. diff --git a/source/module_base/module_mixing/broyden_mixing.h b/source/module_base/module_mixing/broyden_mixing.h new file mode 100755 index 0000000000..cc94bd471a --- /dev/null +++ b/source/module_base/module_mixing/broyden_mixing.h @@ -0,0 +1,318 @@ +#ifndef BROYDEN_MIXING_H_ +#define BROYDEN_MIXING_H_ +#include "mixing.h" +#include "module_base/lapack_connector.h" +#include "module_base/matrix.h" +#include "module_base/memory.h" +#include "module_base/timer.h" +#include "module_base/tool_title.h" + +namespace Base_Mixing +{ +/** + * @brief Simplified modified broyden_mixing method. + * Ref: D.D. Johnson PRB 38, 12807 (1988) + * Here the weight w0 of the error of the inverse Jacobian is set to 0 and the weight wn of + * the error of each previous iteration is set to same. + * @note Formula: + * F = n_out - n_in + * dF{i} = F_{i-1} - F{i} //different from Ref + * dn_in{i} = n_in_{i-1} - n_in{i} //different from Ref + * alpha{ij} = + * beta{ij} = inv(alpha){ij} + * c{mk} = + * gamma{mn} = \sum_k c{mk} * beta{kn} + * n{m+1} = n_in{m} + mixing_beta*F{m} - \sum_n gamma{mn} * (dn_in{n} + mixing_beta*dF{n}) + * mixing_data{i} = n_in{i} + mixing_beta*F{i} + * n{m+1} = \sum_i coef{i} * mixing_data{i} + */ +class Broyden_Mixing : public Mixing +{ + public: + Broyden_Mixing(const int& mixing_ndim, const double& mixing_beta) + { + this->mixing_ndim = mixing_ndim; + this->data_ndim = mixing_ndim + 1; + this->mixing_beta = mixing_beta; + this->coef = std::vector(mixing_ndim + 1); + this->beta = ModuleBase::matrix(mixing_ndim, mixing_ndim, true); + } + virtual ~Broyden_Mixing() override + { + if (F != nullptr) + free(F); + if (dF != nullptr) + free(dF); + }; + /** + * @brief reset mixing + * + */ + virtual void reset() override + { + this->ndim_cal_dF = 0; + this->start_dF = -1; + this->address = nullptr; + } + + /** + * @brief + * + * @param mdata store information of this iterative step + * @param data_in x_in + * @param data_out x_out = f(x_in) + * @param screen pointer to the screen function for Ker-Ker mixing + * @param need_calcoef whether need to calculate the coef + * + */ + virtual void push_data(Mixing_Data& mdata, + const double* data_in, + const double* data_out, + std::function screen, + const bool& need_calcoef) override + { + this->tem_push_data(mdata, data_in, data_out, screen, need_calcoef); + }; + virtual void push_data(Mixing_Data& mdata, + const std::complex* data_in, + const std::complex* data_out, + std::function*)> screen, + const bool& need_calcoef) override + { + this->tem_push_data(mdata, data_in, data_out, screen, need_calcoef); + }; + + /** + * @brief calculate coeficients for mixing + * + * @param mdata Mixing_Data + * @param inner_product pointer to the inner dot function + */ + virtual void cal_coef(const Mixing_Data& mdata, std::function inner_product) override + { + tem_cal_coef(mdata, inner_product); + } + virtual void cal_coef(const Mixing_Data& mdata, + std::function*, std::complex*)> inner_product) override + { + tem_cal_coef(mdata, inner_product); + } + + private: + /** + * @brief + * + * @param mdata store information of this iterative step + * @param data_in x_in + * @param data_out x_out = f(x_in) + * @param screen pointer to the screen function for Ker-Ker mixing + * @param need_calcoef whether need to calculate the coef + * + */ + template + void tem_push_data(Mixing_Data& mdata, + const FPTYPE* data_in, + const FPTYPE* data_out, + std::function screen, + const bool& need_calcoef) + { + const size_t length = mdata.length; + std::vector F_tmp(length); +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE)) +#endif + for (int i = 0; i < length; ++i) + { + F_tmp[i] = data_out[i] - data_in[i]; + } + + // get screened F + if (screen != nullptr) + screen(F_tmp.data()); + + // container::Tensor data = data_in + mixing_beta * F; + std::vector data(length); +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE)) +#endif + for (int i = 0; i < length; ++i) + { + data[i] = data_in[i] + this->mixing_beta * F_tmp[i]; + } + + mdata.push(data.data()); + + if (!need_calcoef) + return; + + if (address != &mdata && address != nullptr) + ModuleBase::WARNING_QUIT( + "Broyden_Mixing", + "One Broyden_Mixing object can only bind one Mixing_Data object to calculate coefficients"); + + FPTYPE* FP_dF = static_cast(dF); + FPTYPE* FP_F = static_cast(F); + if (mdata.ndim_use == 1) + { + address = &mdata; + // allocate + if (F != nullptr) + free(F); + F = malloc(sizeof(FPTYPE) * length); + FP_F = static_cast(F); + if (dF != nullptr) + free(dF); + dF = malloc(sizeof(FPTYPE) * length * mixing_ndim); + FP_dF = static_cast(dF); +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE)) +#endif + for (int i = 0; i < length; ++i) + { + FP_F[i] = F_tmp[i]; + } + } + else + { + this->ndim_cal_dF = std::min(this->ndim_cal_dF + 1, this->mixing_ndim); + start_dF = (this->start_dF + 1) % this->mixing_ndim; +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE)) +#endif + for (int i = 0; i < length; ++i) + { + FP_F[i] = F_tmp[i]; + // dF{n} = F{n-1} - F{n} = -(F{n} - F{n-1}) + FP_dF[start_dF * length + i] -= FP_F[i]; + } + } + }; + + /** + * @brief calculate coeficients for mixing + * + * @param mdata Mixing_Data + * @param inner_product pointer to the inner dot function + */ + template + void tem_cal_coef(const Mixing_Data& mdata, std::function inner_product) + { + ModuleBase::TITLE("Charge_Mixing", "Simplified_Broyden_mixing"); + ModuleBase::timer::tick("Charge", "Broyden_mixing"); + if (address != &mdata && address != nullptr) + ModuleBase::WARNING_QUIT( + "Broyden_mixing", + "One Broyden_Mixing object can only bind one Mixing_Data object to calculate coefficients"); + const int length = mdata.length; + FPTYPE* FP_dF = static_cast(dF); + FPTYPE* FP_F = static_cast(F); + if (ndim_cal_dF > 0) + { + ModuleBase::matrix beta_tmp(ndim_cal_dF, ndim_cal_dF); + // beta(i, j) = + for (int i = 0; i < ndim_cal_dF; ++i) + { + FPTYPE* dFi = FP_dF + i * length; + for (int j = i; j < ndim_cal_dF; ++j) + { + if (i != start_dF && j != start_dF) + { + beta_tmp(i, j) = beta(i, j); + } + else + { + FPTYPE* dFj = FP_dF + j * length; + beta(i, j) = beta_tmp(i, j) = inner_product(dFi, dFj); + } + if (j != i) + { + beta_tmp(j, i) = beta_tmp(i, j); + } + } + } + double* work = new double[ndim_cal_dF]; + int* iwork = new int[ndim_cal_dF]; + char uu = 'U'; + int info; + dsytrf_(&uu, &ndim_cal_dF, beta_tmp.c, &ndim_cal_dF, iwork, work, &ndim_cal_dF, &info); + if (info != 0) + ModuleBase::WARNING_QUIT("Charge_Mixing", "Error when factorizing beta."); + dsytri_(&uu, &ndim_cal_dF, beta_tmp.c, &ndim_cal_dF, iwork, work, &info); + if (info != 0) + ModuleBase::WARNING_QUIT("Charge_Mixing", "Error when DSYTRI beta."); + for (int i = 0; i < ndim_cal_dF; ++i) + { + for (int j = i + 1; j < ndim_cal_dF; ++j) + { + beta_tmp(i, j) = beta_tmp(j, i); + } + } + for (int i = 0; i < ndim_cal_dF; ++i) + { + FPTYPE* dFi = FP_dF + i * length; + work[i] = inner_product(dFi, FP_F); + } + // gamma[i] = \sum_j beta_tmp(i,j) * work[j] + std::vector gamma(ndim_cal_dF); + container::BlasConnector::gemv('N', + ndim_cal_dF, + ndim_cal_dF, + 1.0, + beta_tmp.c, + ndim_cal_dF, + work, + 1, + 0.0, + gamma.data(), + 1); + coef[mdata.start] = 1 + gamma[dFindex_move(0)]; + for (int i = 1; i < ndim_cal_dF; ++i) + { + coef[mdata.index_move(-i)] = gamma[dFindex_move(-i)] - gamma[dFindex_move(-i + 1)]; + } + coef[mdata.index_move(-ndim_cal_dF)] = -gamma[dFindex_move(-ndim_cal_dF + 1)]; + + delete[] work; + delete[] iwork; + } + else + { + beta(0, 0) = inner_product(FP_dF, FP_dF); + coef[0] = 1.0; + } + + FPTYPE* dFnext = FP_dF + dFindex_move(1) * length; +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE)) +#endif + for (int i = 0; i < length; ++i) + { + dFnext[i] = FP_F[i]; + } + ModuleBase::timer::tick("Charge", "Broyden_mixing"); + }; + + private: + // F = data_out - data_in + void* F = nullptr; + // dF = F_{n+1} - F_n + void* dF = nullptr; + // binded mixing_data + Mixing_Data* address = nullptr; + // beta_ij = + ModuleBase::matrix beta; + // mixing_ndim = data_ndim - 1 + int mixing_ndim = -1; + + // start index for dF + int start_dF = -1; + // get the index of i-th dF vector + int dFindex_move(const int& index) + { + return (start_dF + index + mixing_ndim) % mixing_ndim; + } + // the number of calculated dF + int ndim_cal_dF = 0; +}; +} // namespace Base_Mixing +#endif \ No newline at end of file diff --git a/source/module_base/module_mixing/mixing.h b/source/module_base/module_mixing/mixing.h new file mode 100644 index 0000000000..ff2e9d76eb --- /dev/null +++ b/source/module_base/module_mixing/mixing.h @@ -0,0 +1,151 @@ +#ifndef MIXING_H_ +#define MIXING_H_ +#include + +#include "mixing_data.h" +#include "module_base/module_container/base/third_party/blas.h" +namespace Base_Mixing +{ + +/** + * @brief Mixing class can mixing different steps of data to solver the iteration problem. + * For equation x = f(x), we can use iterative process to solve it: + * x_{n+1} = f(x_n), n = 0, 1, 2, ... + * To acceralte the convergence, we can use mixing method, we need information including + * x_in, x_out=f(x_in) in each iterative step. + * + */ +class Mixing +{ + public: + Mixing(){}; + virtual ~Mixing(){}; + + /** + * @brief init mixing data + * + * @param mdata mixing data + * @param length the length of each vector + * @param type_size size of type + * + */ + virtual void init_mixing_data(Mixing_Data& mdata, const int& length, const size_t& type_size) const + { + mdata.resize(data_ndim, length, type_size); + } + + /** + * @brief + * + * @param mdata store information of this iterative step + * @param data_in x_in + * @param data_out x_out = f(x_in) + * @param screen pointer to the screen function for Ker-Ker mixing + * @param need_calcoef whether need to calculate the coef + * + */ + virtual void push_data(Mixing_Data& mdata, + const double* data_in, + const double* data_out, + std::function screen, + const bool& need_calcoef) + = 0; + virtual void push_data(Mixing_Data& mdata, + const std::complex* data_in, + const std::complex* data_out, + std::function*)> screen, + const bool& need_calcoef) + = 0; + + /** + * @brief calculate coeficients for mixing + * + * @param mdata Mixing_Data + * @param inner_product pointer to the inner dot function + */ + virtual void cal_coef(const Mixing_Data& mdata, std::function inner_product) = 0; + virtual void cal_coef(const Mixing_Data& mdata, + std::function*, std::complex*)> inner_product) + = 0; + + /** + * @brief calculate the mixing data + * + * @param mdata Mixing_Data + * @param data_mix output data + */ + void mix_data(const Mixing_Data& mdata, double* data_mix) + { + if (mdata.length <= 0) + return; + double* FP_data = static_cast(mdata.data); + if (mdata.ndim_use == 1) + { +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 512) +#endif + for (int i = 0; i < mdata.length; ++i) + data_mix[i] = FP_data[i]; + return; + } + container::BlasConnector::gemv('N', + mdata.length, + mdata.ndim_use, + 1.0, + FP_data, + mdata.length, + coef.data(), + 1, + 0.0, + data_mix, + 1); + } + void mix_data(const Mixing_Data& mdata, std::complex* data_mix) + { + if (mdata.length <= 0) + return; + std::complex* FP_data = static_cast*>(mdata.data); + if (mdata.ndim_use == 1) + { +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 256) +#endif + for (int i = 0; i < mdata.length; ++i) + data_mix[i] = FP_data[i]; + return; + } + // conver coef to complex + std::vector> coef_complex(coef.size()); + for (int i = 0; i < coef.size(); ++i) + coef_complex[i] = coef[i]; + container::BlasConnector::gemv('N', + mdata.length, + mdata.ndim_use, + 1.0, + FP_data, + mdata.length, + coef_complex.data(), + 1, + 0.0, + data_mix, + 1); + } + + /** + * @brief reset mixing + * + */ + virtual void reset() = 0; + + public: + // mixing_beta from INPUT + double mixing_beta = 0.7; + // coeficients for mixing + std::vector coef; + // ndim for mixing + int data_ndim = 1; +}; + +} // namespace Base_Mixing + +#endif \ No newline at end of file diff --git a/source/module_base/module_mixing/mixing_data.cpp b/source/module_base/module_mixing/mixing_data.cpp new file mode 100644 index 0000000000..a257f4e788 --- /dev/null +++ b/source/module_base/module_mixing/mixing_data.cpp @@ -0,0 +1,32 @@ +#include "mixing_data.h" + +namespace Base_Mixing +{ + +Mixing_Data::Mixing_Data(const int& ndim, const int& length, const size_t &type_size) +{ + this->ndim_tot = ndim; + this->length = length; + this->data = malloc(ndim * length * type_size); +} + +Mixing_Data::~Mixing_Data() +{ + if(this->data != nullptr) + free(this->data); +} + +void Mixing_Data::resize(const int& ndim, const int& length, const size_t &type_size) +{ + this->ndim_tot = ndim; + this->length = length; + if(this->data != nullptr) + free(this->data); + this->data = malloc(ndim * length * type_size); + this->start = -1; + this->ndim_use = 0; + this->ndim_history = 0; +} + + +} diff --git a/source/module_base/module_mixing/mixing_data.h b/source/module_base/module_mixing/mixing_data.h new file mode 100644 index 0000000000..69c2629c65 --- /dev/null +++ b/source/module_base/module_mixing/mixing_data.h @@ -0,0 +1,99 @@ +#ifndef MIXING_DATA_H_ +#define MIXING_DATA_H_ +#include + +#include "module_base/module_container/ATen/tensor.h" +namespace Base_Mixing +{ + +/** + * @brief data for Mixing class + * + */ +class Mixing_Data +{ + public: + Mixing_Data() = default; + /** + * @brief Construct a new Mixing_Data object + * + * @param ndim store ndim vectors for mixing + * @param length the length of each vector + * @param type_size size of type + * + */ + Mixing_Data(const int& ndim, const int& length, const size_t& type_size); + + /** + * @brief Destroy the Mixing_Data object + * + */ + ~Mixing_Data(); + + /** + * @brief resize the data + * + * @param ndim store ndim vectors for mixing + * @param length the length of each vector + * @param type_size size of type + * + */ + void resize(const int& ndim, const int& length, const size_t& type_size); + + /** + * @brief push data to the tensor + * + */ + template + void push(const FPTYPE* data_in) + { + this->start = (this->start + 1) % this->ndim_tot; + this->ndim_use = std::min(this->ndim_use + 1, this->ndim_tot); + ++this->ndim_history; + FPTYPE* FP_startdata = static_cast(this->data) + this->start * this->length; +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096/sizeof(FPTYPE)) +#endif + for (int i = 0; i < length; ++i) + { + FP_startdata[i] = data_in[i]; + } + } + + /** + * @brief reset mixing + * + */ + void reset() + { + this->ndim_use = 0; + this->ndim_history = 0; + this->start = -1; + } + + /** + * @brief get the index of i-th vector + * + */ + int index_move(const int& n) const + { + return (n + this->start + ndim_tot) % ndim_tot; + } + + public: + // Tensor pointer to store the data + void* data = nullptr; + // the number of vectors for mixing + int ndim_tot = 0; + // the length of each vector + int length = 0; + // the start index for vector: start = this->index_move(0) + int start = -1; + // the number of used vectors for mixing + int ndim_use = 0; + // the number of history vectors + int ndim_history = 0; +}; + +} // namespace Base_Mixing +#endif \ No newline at end of file diff --git a/source/module_base/module_mixing/plain_mixing.h b/source/module_base/module_mixing/plain_mixing.h new file mode 100644 index 0000000000..ba18b6f554 --- /dev/null +++ b/source/module_base/module_mixing/plain_mixing.h @@ -0,0 +1,123 @@ +#ifndef PLAIN_MIXING_H_ +#define PLAIN_MIXING_H_ +#include "mixing.h" +#include "module_base/memory.h" +#include "module_base/timer.h" +#include "module_base/tool_title.h" + +namespace Base_Mixing +{ +/** + * @brief Plain mixing : rho_new = rho_in + mixing_beta * (rho_out - rho_in) + * + */ +class Plain_Mixing : public Mixing +{ + public: + Plain_Mixing(const double& mixing_beta) + { + this->mixing_beta = mixing_beta; + this->data_ndim = 1; + this->coef = std::vector(1, 1.0); + } + virtual ~Plain_Mixing() override{}; + + /** + * @brief reset mixing + * + */ + virtual void reset() override + { + return; + } + + /** + * @brief + * + * @param mdata store information of this iterative step + * @param data_in x_in + * @param data_out x_out = f(x_in) + * @param screen pointer to the screen function for Ker-Ker mixing + * @param need_calcoef whether need to calculate the coef + * + */ + virtual void push_data(Mixing_Data& mdata, + const double* data_in, + const double* data_out, + std::function screen, + const bool& need_calcoef) override + { + this->tem_push_data(mdata, data_in, data_out, screen, need_calcoef); + }; + virtual void push_data(Mixing_Data& mdata, + const std::complex* data_in, + const std::complex* data_out, + std::function*)> screen, + const bool& need_calcoef) override + { + this->tem_push_data(mdata, data_in, data_out, screen, need_calcoef); + }; + + /** + * @brief calculate coeficients for mixing + * + * @param mdata Mixing_Data + * @param inner_product pointer to the inner dot function + */ + virtual void cal_coef(const Mixing_Data& mdata, std::function inner_product) override + { + return; + } + virtual void cal_coef(const Mixing_Data& mdata, + std::function*, std::complex*)> inner_product) override + { + return; + } + + private: + /** + * @brief + * + * @param mdata store information of this iterative step + * @param data_in x_in + * @param data_out x_out = f(x_in) + * @param screen pointer to the screen function for Ker-Ker mixing + * @param need_calcoef whether need to calculate the coef + * + */ + template + void tem_push_data(Mixing_Data& mdata, + const FPTYPE* data_in, + const FPTYPE* data_out, + std::function screen, + const bool& need_calcoef) + { + const size_t length = mdata.length; + std::vector F_tmp(length); +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE)) +#endif + for (int i = 0; i < length; ++i) + { + F_tmp[i] = data_out[i] - data_in[i]; + } + + // get screened F + if (screen != nullptr) + screen(F_tmp.data()); + + // container::Tensor data = data_in + mixing_beta * F; + std::vector data(length); +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE)) +#endif + for (int i = 0; i < length; ++i) + { + data[i] = data_in[i] + this->mixing_beta * F_tmp[i]; + } + + mdata.push(data.data()); + }; +}; +} // namespace Base_Mixing +#endif \ No newline at end of file diff --git a/source/module_base/module_mixing/pulay_mixing.h b/source/module_base/module_mixing/pulay_mixing.h new file mode 100644 index 0000000000..b5ca6544ab --- /dev/null +++ b/source/module_base/module_mixing/pulay_mixing.h @@ -0,0 +1,280 @@ +#ifndef PULAY_MIXING_H_ +#define PULAY_MIXING_H_ +#include "mixing.h" +#include "module_base/lapack_connector.h" +#include "module_base/matrix.h" +#include "module_base/memory.h" +#include "module_base/timer.h" +#include "module_base/tool_title.h" + +namespace Base_Mixing +{ +/** + * @brief Pulay mixing method. + * Ref: Pulay P. Chemical Physics Letters, 1980, 73(2): 393-398. + * @note Formula: + * F = n_out - n_in + * alpha{ij} = + * beta{ij} = inv(alpha){ij} + * coef{i} = \sum_j beta{ij} / \sum_k \sum_j beta{kj} + * mixing_data{i} = n_in{i} + mixing_beta*F{i} + * n{m+1} = \sum_n coef{i} * mixing_data{i} + */ +class Pulay_Mixing : public Mixing +{ + public: + Pulay_Mixing(const int& mixing_ndim, const double& mixing_beta) + { + this->mixing_ndim = mixing_ndim; + this->data_ndim = mixing_ndim; + this->mixing_beta = mixing_beta; + this->coef = std::vector(mixing_ndim); + this->beta = ModuleBase::matrix(mixing_ndim, mixing_ndim, true); + } + virtual ~Pulay_Mixing() override + { + if (F != nullptr) + free(F); + } + /** + * @brief reset mixing + * + */ + virtual void reset() override + { + this->start_F = 0; + this->address = nullptr; + } + + /** + * @brief + * + * @param mdata store information of this iterative step + * @param data_in x_in + * @param data_out x_out = f(x_in) + * @param screen pointer to the screen function for Ker-Ker mixing + * @param need_calcoef whether need to calculate the coef + * + */ + virtual void push_data(Mixing_Data& mdata, + const double* data_in, + const double* data_out, + std::function screen, + const bool& need_calcoef) override + { + this->tem_push_data(mdata, data_in, data_out, screen, need_calcoef); + }; + virtual void push_data(Mixing_Data& mdata, + const std::complex* data_in, + const std::complex* data_out, + std::function*)> screen, + const bool& need_calcoef) override + { + this->tem_push_data(mdata, data_in, data_out, screen, need_calcoef); + }; + + /** + * @brief calculate coeficients for mixing + * + * @param mdata Mixing_Data + * @param inner_product pointer to the inner dot function + */ + virtual void cal_coef(const Mixing_Data& mdata, std::function inner_product) override + { + tem_cal_coef(mdata, inner_product); + } + virtual void cal_coef(const Mixing_Data& mdata, + std::function*, std::complex*)> inner_product) override + { + tem_cal_coef(mdata, inner_product); + } + + private: + /** + * @brief + * + * @param mdata store information of this iterative step + * @param data_in x_in + * @param data_out x_out = f(x_in) + * @param screen pointer to the screen function for Ker-Ker mixing + * @param need_calcoef whether need to calculate the coef + * + */ + template + void tem_push_data(Mixing_Data& mdata, + const FPTYPE* data_in, + const FPTYPE* data_out, + std::function screen, + const bool& need_calcoef) + { + const size_t length = mdata.length; + std::vector F_tmp(length); + +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE)) +#endif + for (int i = 0; i < length; ++i) + { + F_tmp[i] = data_out[i] - data_in[i]; + } + + // get screened F + if (screen != nullptr) + screen(F_tmp.data()); + + // container::Tensor data = data_in + mixing_beta * F; + std::vector data(length); +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE)) +#endif + for (int i = 0; i < length; ++i) + { + data[i] = data_in[i] + this->mixing_beta * F_tmp[i]; + } + + mdata.push(data.data()); + + if (!need_calcoef) + return; + + if (address != &mdata && address != nullptr) + ModuleBase::WARNING_QUIT( + "Pulay_Mixing", + "One Pulay_Mixing object can only bind one Mixing_Data object to calculate coefficients"); + + FPTYPE* FP_F = static_cast(F); + if (mdata.ndim_use == 1) + { + address = &mdata; + // allocate + if (F != nullptr) + free(F); + F = malloc(sizeof(FPTYPE) * length * mixing_ndim); + FP_F = static_cast(F); +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE)) +#endif + for (int i = 0; i < length; ++i) + { + FP_F[i] = F_tmp[i]; + } + } + else + { + start_F = (this->start_F + 1) % this->mixing_ndim; + FPTYPE* FP_startF = FP_F + start_F * length; +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE)) +#endif + for (int i = 0; i < length; ++i) + { + FP_startF[i] = F_tmp[i]; + } + } + }; + + /** + * @brief calculate coeficients for mixing + * + * @param mdata Mixing_Data + * @param inner_product pointer to the inner dot function + */ + template + void tem_cal_coef(const Mixing_Data& mdata, std::function inner_product) + { + ModuleBase::TITLE("Charge_Mixing", "Pulay_mixing"); + ModuleBase::timer::tick("Charge", "Pulay_mixing"); + if (address != &mdata && address != nullptr) + ModuleBase::WARNING_QUIT( + "Pulay_mixing", + "One Pulay_Mixing object can only bind one Mixing_Data object to calculate coefficients"); + const int length = mdata.length; + FPTYPE* FP_F = static_cast(F); + + if (mdata.ndim_use > 1) + { + const int ndim_use = mdata.ndim_use; + ModuleBase::matrix beta_tmp(ndim_use, ndim_use); + // beta(i, j) = + for (int i = 0; i < ndim_use; ++i) + { + FPTYPE* Fi = FP_F + i * length; + for (int j = i; j < ndim_use; ++j) + { + if (i != start_F && j != start_F) + { + beta_tmp(i, j) = beta(i, j); + } + else + { + FPTYPE* Fj = FP_F + j * length; + beta(i, j) = beta_tmp(i, j) = inner_product(Fi, Fj); + } + if (j != i) + { + beta(j, i) = beta_tmp(j, i) = beta_tmp(i, j); + } + } + } + + double* work = new double[ndim_use]; + int* iwork = new int[ndim_use]; + char uu = 'U'; + int info; + dsytrf_(&uu, &ndim_use, beta_tmp.c, &ndim_use, iwork, work, &ndim_use, &info); + if (info != 0) + ModuleBase::WARNING_QUIT("Charge_Mixing", "Error when factorizing beta."); + dsytri_(&uu, &ndim_use, beta_tmp.c, &ndim_use, iwork, work, &info); + if (info != 0) + ModuleBase::WARNING_QUIT("Charge_Mixing", "Error when DSYTRI beta."); + for (int i = 0; i < ndim_use; ++i) + { + for (int j = i + 1; j < ndim_use; ++j) + { + beta_tmp(i, j) = beta_tmp(j, i); + } + } + + // coef{i} = \sum_j beta{ij} / \sum_k \sum_j beta{kj} + double sum_beta = 0.; + for (int i = 0; i < ndim_use; ++i) + { + for (int j = 0; j < ndim_use; ++j) + { + sum_beta += beta_tmp(j, i); + } + } + for (int i = 0; i < ndim_use; ++i) + { + coef[i] = 0.; + for (int j = 0; j < ndim_use; ++j) + { + coef[i] += beta_tmp(i, j); + } + coef[i] /= sum_beta; + } + delete[] work; + delete[] iwork; + } + else + { + beta(0, 0) = inner_product(FP_F, FP_F); + coef[0] = 1.0; + } + + ModuleBase::timer::tick("Charge", "Pulay_mixing"); + }; + + // F = data_out - data_in + void* F = nullptr; + // binded mixing_data + Mixing_Data* address = nullptr; + // beta_ij = + ModuleBase::matrix beta; + // mixing_ndim = data_ndim - 1 + int mixing_ndim = -1; + // start index for F + int start_F = 0; +}; +} // namespace Base_Mixing +#endif \ No newline at end of file diff --git a/source/module_base/module_mixing/test/CMakeLists.txt b/source/module_base/module_mixing/test/CMakeLists.txt new file mode 100644 index 0000000000..16a3049783 --- /dev/null +++ b/source/module_base/module_mixing/test/CMakeLists.txt @@ -0,0 +1,6 @@ +remove_definitions(-D__MPI) +AddTest( + TARGET test_mixing + LIBS base device ${math_libs} + SOURCES mixing_test.cpp +) \ No newline at end of file diff --git a/source/module_base/module_mixing/test/mixing_test.cpp b/source/module_base/module_mixing/test/mixing_test.cpp new file mode 100755 index 0000000000..972c12ece9 --- /dev/null +++ b/source/module_base/module_mixing/test/mixing_test.cpp @@ -0,0 +1,268 @@ +#include "../broyden_mixing.h" +#include "../plain_mixing.h" +#include "../pulay_mixing.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include + +#define DOUBLETHRESHOLD 1e-8 +double ext_inner_product_mock(double* x1, double* x2) +{ +} +class Mixing_Test : public testing::Test +{ + protected: + Mixing_Test() + { + } + ~Mixing_Test() + { + delete this->mixing; + } + const double mixing_beta = 0.6; + const int mixing_ndim = 3; + Base_Mixing::Mixing_Data xdata; + Base_Mixing::Mixing* mixing = nullptr; + double thr = 1e-8; + int niter = 0; + int maxiter = 10; + std::vector xd_ref = {0.0, 0.0, 0.0}; + std::vector> xc_ref = { + {0.0, 1.0}, + {1.0, 0.0}, + 0.0 + }; + void init_method(std::string method) + { + if (method == "broyden") + { + this->mixing = new Base_Mixing::Broyden_Mixing(this->mixing_ndim, this->mixing_beta); + } + else if (method == "pulay") + { + this->mixing = new Base_Mixing::Pulay_Mixing(this->mixing_ndim, this->mixing_beta); + } + else if (method == "plain") + { + this->mixing = new Base_Mixing::Plain_Mixing(this->mixing_beta); + } + } + + void clear() + { + delete this->mixing; + this->mixing = nullptr; + } + + /** + * @brief sover linear equation: + * [ 8 -3 2 ][x1] [20] [3] + * [ 4 11 -1 ][x2] = [33] x = [2] + * [ 6 3 12 ][x3] [36] [1] + * + * [x1] [ 3/8 -2/8 20/8 ][x1] + * [x2] = [-4/11 1/11 -33/11][x2] + * [x3] [-6/12 -3/12 36/12][x3] + */ + template + void solve_linear_eq(FPTYPE* x_in, FPTYPE* x_out) + { + this->mixing->init_mixing_data(xdata, 3, sizeof(FPTYPE)); + std::vector delta_x(3); + + auto screen = std::bind(&Mixing_Test::Kerker_mock, this, std::placeholders::_1); + auto inner_product + = std::bind(static_cast(&Mixing_Test::inner_product_mock), + this, + std::placeholders::_1, + std::placeholders::_2); + + double residual = 10.; + this->niter = 0; + while (niter < maxiter) + { + x_out[0] = (3. * x_in[1] - 2. * x_in[2] + 20.) / 8.; + x_out[1] = (-4. * x_out[0] + 1. * x_in[2] + 33.) / 11.; + x_out[2] = (-6. * x_out[0] - 3. * x_out[1] + 36.) / 12.; + + niter++; + + for (int i = 0; i < 3; ++i) + { + delta_x[i] = x_out[i] - x_in[i]; + } + residual = this->inner_product_mock(delta_x.data(), delta_x.data()); + if (residual <= thr) + { + break; + } + + this->mixing->push_data(this->xdata, x_in, x_out, screen, true); + + this->mixing->cal_coef(this->xdata, inner_product); + + this->mixing->mix_data(this->xdata, x_in); + } + } + + template + void Kerker_mock(FPTYPE* drho) + { + } + + double inner_product_mock(double* x1, double* x2) + { + double xnorm = 0.0; + for (int ir = 0; ir < 3; ++ir) + { + xnorm += x1[ir] * x2[ir]; + } + return xnorm; + } + double inner_product_mock(std::complex* x1, std::complex* x2) + { + double xnorm = 0.0; + for (int ir = 0; ir < 3; ++ir) + { + xnorm += x1[ir].real() * x2[ir].real() + x1[ir].imag() * x2[ir].imag(); + } + return xnorm; + } +}; + +TEST_F(Mixing_Test, BroydenSolveLinearEq) +{ + omp_set_num_threads(1); + init_method("broyden"); + std::vector x_in = xd_ref; + std::vector x_out(3); + solve_linear_eq(x_in.data(), x_out.data()); + EXPECT_NEAR(x_out[0], 2.9999999999999996, DOUBLETHRESHOLD); + EXPECT_NEAR(x_out[1], 2.0000000000000004, DOUBLETHRESHOLD); + EXPECT_NEAR(x_out[2], 1.0000000000000000, DOUBLETHRESHOLD); + ASSERT_EQ(niter, 5); + + this->mixing->reset(); + xdata.reset(); + + std::vector> xc_in = xc_ref; + std::vector> xc_out(3); + solve_linear_eq>(xc_in.data(), xc_out.data()); + EXPECT_NEAR(xc_out[0].real(), 3.0000000000000009, DOUBLETHRESHOLD); + EXPECT_NEAR(xc_out[1].real(), 1.9999999999999998, DOUBLETHRESHOLD); + EXPECT_NEAR(xc_out[2].real(), 0.99999999999999944, DOUBLETHRESHOLD); + ASSERT_EQ(niter, 5); + std::string output; + Base_Mixing::Mixing_Data testdata; + this->mixing->init_mixing_data(testdata, 3, sizeof(double)); + + testing::internal::CaptureStdout(); + EXPECT_EXIT(this->mixing->push_data(testdata, x_in.data(), x_out.data(), nullptr, true), + ::testing::ExitedWithCode(0), + ""); + output = testing::internal::GetCapturedStdout(); + EXPECT_THAT( + output, + testing::HasSubstr("One Broyden_Mixing object can only bind one Mixing_Data object to calculate coefficients")); + + testing::internal::CaptureStdout(); + EXPECT_EXIT(this->mixing->cal_coef(testdata, ext_inner_product_mock), + ::testing::ExitedWithCode(0), + ""); + output = testing::internal::GetCapturedStdout(); + EXPECT_THAT( + output, + testing::HasSubstr("One Broyden_Mixing object can only bind one Mixing_Data object to calculate coefficients")); + + clear(); +} + +TEST_F(Mixing_Test, PulaySolveLinearEq) +{ + omp_set_num_threads(1); + init_method("pulay"); + std::vector x_in = xd_ref; + std::vector x_out(3); + solve_linear_eq(x_in.data(), x_out.data()); + EXPECT_NEAR(x_out[0], 2.9999959638248037, DOUBLETHRESHOLD); + EXPECT_NEAR(x_out[1], 2.0000002552633349, DOUBLETHRESHOLD); + EXPECT_NEAR(x_out[2], 1.0000019542717642, DOUBLETHRESHOLD); + ASSERT_EQ(niter, 6); + + this->mixing->reset(); + xdata.reset(); + + std::vector> xc_in = xc_ref; + std::vector> xc_out(3); + solve_linear_eq>(xc_in.data(), xc_out.data()); + EXPECT_NEAR(xc_out[0].real(), 3.0000063220482565, DOUBLETHRESHOLD); + EXPECT_NEAR(xc_out[1].real(), 1.9999939191147462, DOUBLETHRESHOLD); + EXPECT_NEAR(xc_out[2].real(), 0.99999835919718549, DOUBLETHRESHOLD); + ASSERT_EQ(niter, 6); + + std::string output; + Base_Mixing::Mixing_Data testdata; + this->mixing->init_mixing_data(testdata, 3, sizeof(double)); + + testing::internal::CaptureStdout(); + EXPECT_EXIT(this->mixing->push_data(testdata, x_in.data(), x_out.data(), nullptr, true), + ::testing::ExitedWithCode(0), + ""); + output = testing::internal::GetCapturedStdout(); + EXPECT_THAT( + output, + testing::HasSubstr("One Pulay_Mixing object can only bind one Mixing_Data object to calculate coefficients")); + + testing::internal::CaptureStdout(); + EXPECT_EXIT(this->mixing->cal_coef(testdata, ext_inner_product_mock), + ::testing::ExitedWithCode(0), + ""); + output = testing::internal::GetCapturedStdout(); + EXPECT_THAT( + output, + testing::HasSubstr("One Pulay_Mixing object can only bind one Mixing_Data object to calculate coefficients")); + + clear(); +} + +TEST_F(Mixing_Test, PlainSolveLinearEq) +{ + omp_set_num_threads(1); + init_method("plain"); + std::vector x_in = xd_ref; + std::vector x_out(3); + solve_linear_eq(x_in.data(), x_out.data()); + EXPECT_NEAR(x_out[0], 2.9999613068687698, DOUBLETHRESHOLD); + EXPECT_NEAR(x_out[1], 2.0000472873362103, DOUBLETHRESHOLD); + EXPECT_NEAR(x_out[2], 1.0000075247315625, DOUBLETHRESHOLD); + ASSERT_EQ(niter, 10); + + this->mixing->reset(); + xdata.reset(); + + std::vector> xc_in = xc_ref; + std::vector> xc_out(3); + solve_linear_eq>(xc_in.data(), xc_out.data()); + EXPECT_NEAR(xc_out[0].real(), 2.9999418982632711, DOUBLETHRESHOLD); + EXPECT_NEAR(xc_out[1].real(), 2.0000317031363761, DOUBLETHRESHOLD); + EXPECT_NEAR(xc_out[2].real(), 1.0000211250842703, DOUBLETHRESHOLD); + ASSERT_EQ(niter, 10); + + this->mixing->reset(); + + clear(); +} + +TEST_F(Mixing_Test, OtherCover) +{ + this->mixing = new Base_Mixing::Broyden_Mixing(2, 0.7); + Base_Mixing::Mixing_Data nodata; + this->mixing->init_mixing_data(nodata, 0, sizeof(double)); + this->mixing->push_data(nodata, (double*)nullptr, (double*)nullptr, nullptr, false); + this->mixing->push_data(nodata, (double*)nullptr, (double*)nullptr, nullptr, false); + this->mixing->mix_data(nodata, (double*)nullptr); + this->mixing->mix_data(nodata, (std::complex*)nullptr); + EXPECT_EQ(nodata.length, 0); + + clear(); +} \ No newline at end of file diff --git a/source/module_basis/module_pw/pw_transform.cpp b/source/module_basis/module_pw/pw_transform.cpp index 86f4b9edca..ca523ace85 100644 --- a/source/module_basis/module_pw/pw_transform.cpp +++ b/source/module_basis/module_pw/pw_transform.cpp @@ -38,22 +38,24 @@ void PW_Basis::real2recip(const std::complex* in, if(add) { + FPTYPE tmpfac = factor / FPTYPE(this->nxyz); #ifdef _OPENMP #pragma omp parallel for schedule(static, 4096/sizeof(FPTYPE)) #endif for(int ig = 0 ; ig < this->npw ; ++ig) { - out[ig] += factor / FPTYPE(this->nxyz) * this->ft.get_auxg_data()[this->ig2isz[ig]]; + out[ig] += tmpfac * this->ft.get_auxg_data()[this->ig2isz[ig]]; } } else { + FPTYPE tmpfac = 1.0 / FPTYPE(this->nxyz); #ifdef _OPENMP #pragma omp parallel for schedule(static, 4096/sizeof(FPTYPE)) #endif for(int ig = 0 ; ig < this->npw ; ++ig) { - out[ig] = this->ft.get_auxg_data()[this->ig2isz[ig]] / FPTYPE(this->nxyz); + out[ig] = tmpfac * this->ft.get_auxg_data()[this->ig2isz[ig]]; } } ModuleBase::timer::tick(this->classname, "real2recip"); @@ -103,22 +105,24 @@ void PW_Basis::real2recip(const FPTYPE* in, std::complex* out, const boo if(add) { + FPTYPE tmpfac = factor / FPTYPE(this->nxyz); #ifdef _OPENMP #pragma omp parallel for schedule(static, 4096/sizeof(FPTYPE)) #endif for(int ig = 0 ; ig < this->npw ; ++ig) { - out[ig] += factor / FPTYPE(this->nxyz) * this->ft.get_auxg_data()[this->ig2isz[ig]]; + out[ig] += tmpfac * this->ft.get_auxg_data()[this->ig2isz[ig]]; } } else { + FPTYPE tmpfac = 1.0 / FPTYPE(this->nxyz); #ifdef _OPENMP #pragma omp parallel for schedule(static, 4096/sizeof(FPTYPE)) #endif for(int ig = 0 ; ig < this->npw ; ++ig) { - out[ig] = this->ft.get_auxg_data()[this->ig2isz[ig]] / FPTYPE(this->nxyz); + out[ig] = tmpfac * this->ft.get_auxg_data()[this->ig2isz[ig]]; } } ModuleBase::timer::tick(this->classname, "real2recip"); diff --git a/source/module_basis/module_pw/pw_transform_k.cpp b/source/module_basis/module_pw/pw_transform_k.cpp index 740165e386..4d22fd8b8d 100644 --- a/source/module_basis/module_pw/pw_transform_k.cpp +++ b/source/module_basis/module_pw/pw_transform_k.cpp @@ -45,21 +45,23 @@ void PW_Basis_K::real2recip(const std::complex* in, const int npwk = this->npwk[ik]; auto* auxg = this->ft.get_auxg_data(); if(add) { + FPTYPE tmpfac = factor / FPTYPE(this->nxyz); #ifdef _OPENMP #pragma omp parallel for schedule(static, 4096/sizeof(FPTYPE)) #endif for (int igl = 0; igl < npwk; ++igl) { - out[igl] += factor / FPTYPE(this->nxyz) * auxg[this->igl2isz_k[igl + startig]]; + out[igl] += tmpfac * auxg[this->igl2isz_k[igl + startig]]; } } else { + FPTYPE tmpfac = 1.0 / FPTYPE(this->nxyz); #ifdef _OPENMP #pragma omp parallel for schedule(static, 4096/sizeof(FPTYPE)) #endif for (int igl = 0; igl < npwk; ++igl) { - out[igl] = auxg[this->igl2isz_k[igl + startig]] / FPTYPE(this->nxyz); + out[igl] = tmpfac * auxg[this->igl2isz_k[igl + startig]]; } } ModuleBase::timer::tick(this->classname, "real2recip"); @@ -111,22 +113,24 @@ void PW_Basis_K::real2recip(const FPTYPE* in, auto* auxg = this->ft.get_auxg_data(); if(add) { + FPTYPE tmpfac = factor / FPTYPE(this->nxyz); #ifdef _OPENMP #pragma omp parallel for schedule(static, 4096/sizeof(FPTYPE)) #endif for (int igl = 0;igl < npwk; ++igl) { - out[igl] += factor / FPTYPE(this->nxyz) * auxg[this->igl2isz_k[igl + startig]]; + out[igl] += tmpfac * auxg[this->igl2isz_k[igl + startig]]; } } else { + FPTYPE tmpfac = 1.0 / FPTYPE(this->nxyz); #ifdef _OPENMP #pragma omp parallel for schedule(static, 4096/sizeof(FPTYPE)) #endif for (int igl = 0; igl < npwk; ++igl) { - out[igl] = auxg[this->igl2isz_k[igl + startig]] / FPTYPE(this->nxyz); + out[igl] = tmpfac * auxg[this->igl2isz_k[igl + startig]]; } } ModuleBase::timer::tick(this->classname, "real2recip"); diff --git a/source/module_basis/module_pw/test/Makefile b/source/module_basis/module_pw/test/Makefile index a7a6640fe4..13c4a1c80d 100644 --- a/source/module_basis/module_pw/test/Makefile +++ b/source/module_basis/module_pw/test/Makefile @@ -110,6 +110,10 @@ matrix3.o\ tool_quit.o\ mymath.o\ timer.o\ +formatter_fmt.o\ +formatter_physfmt.o\ +formatter_table.o\ +formatter_contextfmt.o\ pw_basis.o\ pw_distributer.o\ pw_init.o\ @@ -121,7 +125,7 @@ fft.o\ pw_basis_k.o\ pw_transform_k.o\ memory.o\ -memory_op.o\ +psi_memory_op.o\ depend_mock.o OTHER_OBJS0= diff --git a/source/module_cell/test/read_pp_test.cpp b/source/module_cell/test/read_pp_test.cpp index be238d32ee..8a1fc88e54 100644 --- a/source/module_cell/test/read_pp_test.cpp +++ b/source/module_cell/test/read_pp_test.cpp @@ -1,7 +1,6 @@ #include "gtest/gtest.h" #include "gmock/gmock.h" #include - /************************************************ * unit test of read_pp ***********************************************/ diff --git a/source/module_elecstate/CMakeLists.txt b/source/module_elecstate/CMakeLists.txt index fe4f37e641..d4cb9fdd85 100644 --- a/source/module_elecstate/CMakeLists.txt +++ b/source/module_elecstate/CMakeLists.txt @@ -18,10 +18,8 @@ list(APPEND objects module_charge/charge.cpp module_charge/charge_init.cpp module_charge/charge_mpi.cpp - module_charge/charge_broyden.cpp module_charge/charge_extra.cpp module_charge/charge_mixing.cpp - module_charge/charge_pulay.cpp module_charge/symmetry_rho.cpp module_charge/symmetry_rhog.cpp fp_energy.cpp diff --git a/source/module_elecstate/module_charge/charge.cpp b/source/module_elecstate/module_charge/charge.cpp index ec4ffeb546..825c1b57bd 100644 --- a/source/module_elecstate/module_charge/charge.cpp +++ b/source/module_elecstate/module_charge/charge.cpp @@ -62,15 +62,6 @@ void Charge::destroy() { for (int i = 0; i < GlobalV::NSPIN; i++) { - delete[] rho[i]; - delete[] rhog[i]; - delete[] rho_save[i]; - delete[] rhog_save[i]; - if (elecstate::get_xc_func_type() == 3 || elecstate::get_xc_func_type() == 5) - { - delete[] kin_r[i]; - delete[] kin_r_save[i]; - } if(GlobalV::use_paw) { delete[] nhat[i]; @@ -83,6 +74,12 @@ void Charge::destroy() delete[] rhog_save; delete[] rho_core; delete[] rhog_core; + delete[] _space_rho; + delete[] _space_rho_save; + delete[] _space_rhog; + delete[] _space_rhog_save; + delete[] _space_kin_r; + delete[] _space_kin_r_save; if (elecstate::get_xc_func_type() == 3 || elecstate::get_xc_func_type() == 5) { delete[] kin_r; @@ -120,6 +117,15 @@ void Charge::allocate(const int& nspin_in) } // allocate memory + _space_rho = new double[nspin * nrxx]; + _space_rho_save = new double[nspin * nrxx]; + _space_rhog = new std::complex[nspin * ngmc]; + _space_rhog_save = new std::complex[nspin * ngmc]; + if (elecstate::get_xc_func_type() == 3 || elecstate::get_xc_func_type() == 5) + { + _space_kin_r = new double[nspin * nrxx]; + _space_kin_r_save = new double[nspin * nrxx]; + } rho = new double*[nspin]; rhog = new std::complex*[nspin]; rho_save = new double*[nspin]; @@ -137,19 +143,21 @@ void Charge::allocate(const int& nspin_in) for (int is = 0; is < nspin; is++) { - rho[is] = new double[nrxx]; - rhog[is] = new std::complex[ngmc]; - rho_save[is] = new double[nrxx]; - rhog_save[is] = new std::complex[ngmc]; + rho[is] = _space_rho + is * nrxx; + rhog[is] = _space_rhog + is * ngmc; + rho_save[is] = _space_rho_save + is * nrxx; + rhog_save[is] = _space_rhog_save + is * ngmc; ModuleBase::GlobalFunc::ZEROS(rho[is], nrxx); ModuleBase::GlobalFunc::ZEROS(rhog[is], ngmc); ModuleBase::GlobalFunc::ZEROS(rho_save[is], nrxx); ModuleBase::GlobalFunc::ZEROS(rhog_save[is], ngmc); if (elecstate::get_xc_func_type() == 3 || elecstate::get_xc_func_type() == 5) { - kin_r[is] = new double[nrxx]; + _space_kin_r = new double[nspin * nrxx]; + _space_kin_r_save = new double[nspin * nrxx]; + kin_r[is] = _space_kin_r + is * nrxx; ModuleBase::GlobalFunc::ZEROS(kin_r[is], nrxx); - kin_r_save[is] = new double[nrxx]; + kin_r_save[is] = _space_kin_r_save + is * nrxx; ModuleBase::GlobalFunc::ZEROS(kin_r_save[is], nrxx); } if(GlobalV::use_paw) diff --git a/source/module_elecstate/module_charge/charge.h b/source/module_elecstate/module_charge/charge.h index 829e2ff777..5abcb64530 100644 --- a/source/module_elecstate/module_charge/charge.h +++ b/source/module_elecstate/module_charge/charge.h @@ -42,7 +42,13 @@ class Charge double **kin_r = nullptr; // kinetic energy density in real space, for meta-GGA double **kin_r_save = nullptr; // kinetic energy density in real space, for meta-GGA // wenfei 2021-07-28 + private: + //temporary + double *_space_rho = nullptr, *_space_rho_save = nullptr; + std::complex *_space_rhog = nullptr, *_space_rhog_save = nullptr; + double *_space_kin_r = nullptr, *_space_kin_r_save = nullptr; + public: double **nhat = nullptr; //compensation charge for PAW double **nhat_save = nullptr; //compensation charge for PAW // wenfei 2023-09-05 diff --git a/source/module_elecstate/module_charge/charge_broyden.cpp b/source/module_elecstate/module_charge/charge_broyden.cpp deleted file mode 100644 index 728c770441..0000000000 --- a/source/module_elecstate/module_charge/charge_broyden.cpp +++ /dev/null @@ -1,181 +0,0 @@ -#include "charge_mixing.h" -#include "module_hamilt_pw/hamilt_pwdft/global.h" -#include "module_base/global_variable.h" -#include "module_base/inverse_matrix.h" -#include "module_base/lapack_connector.h" -#include "module_base/parallel_reduce.h" -#include "module_base/memory.h" -#include "module_base/timer.h" - -void Charge_Mixing::Simplified_Broyden_mixing(const int &iter, - Charge* chr) -{ - ModuleBase::TITLE("Charge_Mixing","Simplified_Broyden_mixing"); - ModuleBase::timer::tick("Charge", "Broyden_mixing"); - //It is a simplified modified broyden_mixing method. - //Ref: D.D. Johnson PRB 38, 12807 (1988) - //Here the weight w0 of the error of the inverse Jacobian is set to 0 and the weight wn of - //the error of each previous iteration is set to same. - - // (1) - this->allocate_Broyden(); - - int iter_used = std::min(iter-1, mixing_ndim); - int ipos = iter-2 - int((iter-2)/mixing_ndim) * mixing_ndim; - if(iter > 1) - { -#ifdef _OPENMP -#pragma omp parallel for collapse(2) schedule(static, 128) -#endif - for(int is=0; isrhopw->npw; ++ig) - { - dF[ipos][is][ig] -= chr->rhog[is][ig]; - dn[ipos][is][ig] -= chr->rhog_save[is][ig]; - } - } - } -#ifdef _OPENMP -#pragma omp parallel for collapse(2) schedule(static, 128) -#endif - for(int is=0; isrhopw->npw; ++ig) - { - dF[mixing_ndim][is][ig] = chr->rhog[is][ig]; - dn[mixing_ndim][is][ig] = chr->rhog_save[is][ig]; - } - } - - if(iter_used > 0) - { - this->beta.create(iter_used, iter_used,false); - for(int i = 0; i < iter_used; ++i) - { - for(int j = i; j < iter_used; ++j) - { - beta(i,j) = rhog_dot_product( this->dF[i], this->dF[j] ); - if(j != i) - { - beta(j,i)=beta(i,j); - } - } - } - double * work = new double [iter_used]; - int * iwork = new int [iter_used]; - char uu='U'; - int info; - dsytrf_(&uu,&iter_used,beta.c,&iter_used,iwork,work,&iter_used,&info); - if(info != 0) ModuleBase::WARNING_QUIT("Charge_Mixing", "Error when factorizing beta."); - dsytri_(&uu,&iter_used,beta.c,&iter_used,iwork,work,&info); - if(info != 0) ModuleBase::WARNING_QUIT("Charge_Mixing", "Error when DSYTRI beta."); - for(int i = 0; i < iter_used; ++i) - { - for(int j = i + 1; j < iter_used; ++j) - { - beta(i,j) = beta(j,i); - } - } - for(int i = 0 ; i < iter_used ; ++i) - { - work[i] = rhog_dot_product( this->dF[i], chr->rhog ); - } - for(int i = 0 ; i < iter_used ; ++i) - { - double gamma0 = 0; - for(int j = 0; j < iter_used ; ++j) - { - gamma0 += beta(i,j) * work[j]; - } -#ifdef _OPENMP -#pragma omp parallel for collapse(2) schedule(static, 512) -#endif - for(int is=0; isrhopw->npw; ++ig) - { - chr->rhog[is][ig] -= gamma0 * dF[i][is][ig]; - chr->rhog_save[is][ig] -= gamma0 * dn[i][is][ig]; - } - } - - } - delete[] work; - delete[] iwork; - } - int inext = iter-1 - int((iter-1)/mixing_ndim) * mixing_ndim; - -#ifdef _OPENMP -#pragma omp parallel for collapse(2) schedule(static, 128) -#endif - for(int is=0; isrhopw->npw; ++ig) - { - dF[inext][is][ig] = dF[mixing_ndim][is][ig]; - dn[inext][is][ig] = dn[mixing_ndim][is][ig]; - } - } - - - for(int is=0; isrhopw->npw; ++ig) - { - chr->rhog_save[is][ig] += mixing_beta * chr->rhog[is][ig]; - } - this->rhopw->recip2real( chr->rhog_save[is], chr->rho[is]); - } - ModuleBase::timer::tick("Charge", "Broyden_mixing"); - return; -} - -void Charge_Mixing::allocate_Broyden() -{ - if(!initb) - { - int npdim = mixing_ndim + 1; // another array is used for temporarily store - this->dF = new std::complex**[npdim]; - this->dn = new std::complex**[npdim]; - - for (int i=0; i*[GlobalV::NSPIN]; - dn[i] = new std::complex*[GlobalV::NSPIN]; - for (int is=0; is[this->rhopw->npw]; - dn[i][is] = new std::complex[this->rhopw->npw]; - } - } - ModuleBase::Memory::record("ChgMix::dF", sizeof(std::complex) * GlobalV::NSPIN*npdim*this->rhopw->npw); - ModuleBase::Memory::record("ChgMix::dn", sizeof(std::complex) * GlobalV::NSPIN*npdim*this->rhopw->npw); - this->initb = true; - } - - return; -} - -void Charge_Mixing::deallocate_Broyden() -{ - if (initb) - { - for (int i=0; iinitb = false; - } -} \ No newline at end of file diff --git a/source/module_elecstate/module_charge/charge_mixing.cpp b/source/module_elecstate/module_charge/charge_mixing.cpp old mode 100644 new mode 100755 index 05799ad9d5..f5cff2c9a6 --- a/source/module_elecstate/module_charge/charge_mixing.cpp +++ b/source/module_elecstate/module_charge/charge_mixing.cpp @@ -1,489 +1,586 @@ #include "charge_mixing.h" -#include "module_hamilt_pw/hamilt_pwdft/global.h" + +#include "module_base/element_elec_config.h" #include "module_base/inverse_matrix.h" +#include "module_base/module_mixing/broyden_mixing.h" +#include "module_base/module_mixing/plain_mixing.h" +#include "module_base/module_mixing/pulay_mixing.h" #include "module_base/parallel_reduce.h" #include "module_base/timer.h" -#include "module_base/element_elec_config.h" - +#include "module_hamilt_pw/hamilt_pwdft/global.h" Charge_Mixing::Charge_Mixing() { - rstep = 0; - dstep = rstep - 1;//alway like this. - initp = false; - initb = false; } Charge_Mixing::~Charge_Mixing() { - if (initp) - { - deallocate_Pulay(); - } - if (initb) - { - deallocate_Broyden(); - } + delete this->mixing; } -void Charge_Mixing::set_mixing -( - const std::string &mixing_mode_in, - const double &mixing_beta_in, - const int &mixing_ndim_in, - const double &mixing_gg0_in, - const bool &mixing_tau_in -) +void Charge_Mixing::set_mixing(const std::string& mixing_mode_in, + const double& mixing_beta_in, + const int& mixing_ndim_in, + const double& mixing_gg0_in, + const bool& mixing_tau_in) { this->mixing_mode = mixing_mode_in; this->mixing_beta = mixing_beta_in; this->mixing_ndim = mixing_ndim_in; - this->mixing_gg0 = mixing_gg0_in; //mohan add 2014-09-27 - this->mixing_tau = mixing_tau_in; + this->mixing_gg0 = mixing_gg0_in; // mohan add 2014-09-27 + this->mixing_tau = mixing_tau_in; - if(mixing_tau && mixing_mode == "broyden") - { - GlobalV::ofs_running << "Note : mixing_tau has only been implemented for plain and pulay mixing" << std::endl; - } + if (this->mixing_mode == "broyden") + { + delete this->mixing; + this->mixing = new Base_Mixing::Broyden_Mixing(this->mixing_ndim, this->mixing_beta); + } + else if (this->mixing_mode == "plain") + { + delete this->mixing; + this->mixing = new Base_Mixing::Plain_Mixing(this->mixing_beta); + } + else if (this->mixing_mode == "pulay") + { + this->mixing = new Base_Mixing::Pulay_Mixing(this->mixing_ndim, this->mixing_beta); + } + else + { + ModuleBase::WARNING_QUIT("Charge_Mixing", "This Mixing mode is not implemended yet,coming soon."); + } + if (GlobalV::SCF_THR_TYPE == 1) + { + this->mixing->init_mixing_data(this->rho_mdata, + this->rhopw->npw * GlobalV::NSPIN, + sizeof(std::complex)); + } + else + { + this->mixing->init_mixing_data(this->rho_mdata, this->rhopw->nrxx * GlobalV::NSPIN, sizeof(double)); + } + // Note: we can not init tau_mdata here temporarily, since set_xc_type() is after it. + // this->mixing->init_mixing_data(this->tau_mdata, this->rhopw->nrxx * GlobalV::NSPIN, sizeof(double)); return; } +void Charge_Mixing::set_rhopw(ModulePW::PW_Basis* rhopw_in) +{ + this->rhopw = rhopw_in; +} + void Charge_Mixing::need_auto_set() { - this->autoset = true; + this->autoset = true; } void Charge_Mixing::auto_set(const double& bandgap_in, const UnitCell& ucell_) { - //auto set parameters once - if(!this->autoset) - { - return; - } - else { - this->autoset = false; - } - GlobalV::ofs_running<<"--------------AUTO-SET---------------"<mixing_beta = 0.2; - } - else - { - this->mixing_beta = 0.7; - } - GlobalV::ofs_running<<" Autoset mixing_beta to "<mixing_beta<mixing_gg0 = 1.5; - } - else - { - this->mixing_gg0 = 0.0; - } - GlobalV::ofs_running<<" Autoset mixing_gg0 to "<mixing_gg0<autoset) + { + return; + } + else + { + this->autoset = false; + } + GlobalV::ofs_running << "--------------AUTO-SET---------------" << std::endl; + // 0.2 for metal and 0.7 for others + if (bandgap_in * ModuleBase::Ry_to_eV < 1.0) + { + this->mixing->mixing_beta = this->mixing_beta = 0.2; + } + else + { + this->mixing->mixing_beta = this->mixing_beta = 0.7; + } + GlobalV::ofs_running << " Autoset mixing_beta to " << this->mixing_beta << std::endl; + bool has_trans_metal = false; + // find elements of cell + for (int it = 0; it < ucell_.ntype; it++) + { + if (ModuleBase::IsTransMetal.find(ucell_.atoms[it].ncpp.psd) != ModuleBase::IsTransMetal.end()) + { + if (ModuleBase::IsTransMetal.at(ucell_.atoms[it].ncpp.psd)) + { + has_trans_metal = true; + } + } + } + // auto set kerker mixing for trans metal system + if (has_trans_metal) + { + this->mixing_gg0 = 1.5; + } + else + { + this->mixing_gg0 = 0.0; + } + GlobalV::ofs_running << " Autoset mixing_gg0 to " << this->mixing_gg0 << std::endl; + GlobalV::ofs_running << "-------------------------------------" << std::endl; + // auto set for inhomogeneous system } double Charge_Mixing::get_drho(Charge* chr, const double nelec) { - for (int is=0; isrhopw->real2recip(chr->rho[is], chr->rhog[is]); + ModuleBase::TITLE("Charge_Mixing", "get_drho"); + ModuleBase::timer::tick("Charge_Mixing", "get_drho"); + double drho = 0.0; - ModuleBase::GlobalFunc::NOTE("Perform FFT on rho_save(r) to obtain rho_save(G)."); - this->rhopw->real2recip(chr->rho_save[is], chr->rhog_save[is]); + if (GlobalV::SCF_THR_TYPE == 1) + { + for (int is = 0; is < GlobalV::NSPIN; ++is) + { + ModuleBase::GlobalFunc::NOTE("Perform FFT on rho(r) to obtain rho(G)."); + this->rhopw->real2recip(chr->rho[is], chr->rhog[is]); + ModuleBase::GlobalFunc::NOTE("Perform FFT on rho_save(r) to obtain rho_save(G)."); + this->rhopw->real2recip(chr->rho_save[is], chr->rhog_save[is]); + } - ModuleBase::GlobalFunc::NOTE("Calculate the charge difference between rho(G) and rho_save(G)"); + ModuleBase::GlobalFunc::NOTE("Calculate the charge difference between rho(G) and rho_save(G)"); + std::vector> drhog(GlobalV::NSPIN * this->rhopw->npw); #ifdef _OPENMP -#pragma omp parallel for schedule(static, 512) +#pragma omp parallel for collapse(2) schedule(static, 512) #endif - for (int ig=0; igrhopw->npw; ig++) + for (int is = 0; is < GlobalV::NSPIN; ++is) { - chr->rhog[is][ig] -= chr->rhog_save[is][ig]; + for (int ig = 0; ig < this->rhopw->npw; ig++) + { + drhog[is * rhopw->npw + ig] = chr->rhog[is][ig] - chr->rhog_save[is][ig]; + } } - } - ModuleBase::GlobalFunc::NOTE("Calculate the norm of the Residual std::vector: < R[rho] | R[rho_save] >"); - double scf_thr = this->rhog_dot_product( chr->rhog, chr->rhog); - - if(GlobalV::test_charge)GlobalV::ofs_running << " scf_thr from rhog_dot_product is " << scf_thr << std::endl; - - // This is a temporary method to choose the type of scf_thr, in order to test different scf_thr_type. - // Charge mixing will be refactored later. - if(GlobalV::SCF_THR_TYPE == 1 && !GlobalV::test_charge) - { - return scf_thr; - } - - // scf_thr calculated from real space. - double scf_thr2 = 0.0; - for(int is=0; is"); + drho = this->inner_product_recip(drhog.data(), drhog.data()); + } + else + { + // Note: Maybe it is wrong. + // The inner_product_real function (L1-norm) is different from that (L2-norm) in mixing. + for (int is = 0; is < GlobalV::NSPIN; is++) + { + if (is != 0 && is != 3 && GlobalV::DOMAG_Z) + { + continue; + } #ifdef _OPENMP -#pragma omp parallel for reduction(+:scf_thr2) +#pragma omp parallel for reduction(+ : drho) #endif - for(int ir=0; irrhopw->nrxx; ir++) - { - scf_thr2 += std::abs( chr->rho[is][ir] - chr->rho_save[is][ir] ); - } - } - - Parallel_Reduce::reduce_double_pool( scf_thr2 ); - assert( nelec != 0); - assert( GlobalC::ucell.omega > 0); - assert( this->rhopw->nxyz > 0); - scf_thr2 *= GlobalC::ucell.omega / static_cast( this->rhopw->nxyz ); - scf_thr2 /= nelec; - if(GlobalV::test_charge)GlobalV::ofs_running << " scf_thr from real space grid is " << scf_thr2 << std::endl; - - // mohan add 2011-01-22 - //if(LINEAR_SCALING && LOCAL_BASIS) xiaohui modify 2013-09-01 - if(GlobalV::SCF_THR_TYPE == 2) - { - scf_thr = scf_thr2; - } - return scf_thr; + for (int ir = 0; ir < this->rhopw->nrxx; ir++) + { + drho += std::abs(chr->rho[is][ir] - chr->rho_save[is][ir]); + } + } +#ifdef __MPI + Parallel_Reduce::reduce_double_pool(drho); +#endif + assert(nelec != 0); + assert(GlobalC::ucell.omega > 0); + assert(this->rhopw->nxyz > 0); + drho *= GlobalC::ucell.omega / static_cast(this->rhopw->nxyz); + drho /= nelec; + } + + ModuleBase::timer::tick("Charge_Mixing", "get_drho"); + return drho; +} + +void Charge_Mixing::mix_rho_recip(Charge* chr) +{ + // electronic density + // rhog and rhog_save are calculated in get_drho() function + std::complex* rhog_in = chr->rhog_save[0]; + std::complex* rhog_out = chr->rhog[0]; + + auto screen = std::bind(&Charge_Mixing::Kerker_screen_recip, this, std::placeholders::_1); + this->mixing->push_data(this->rho_mdata, rhog_in, rhog_out, screen, true); + + auto inner_product + = std::bind(&Charge_Mixing::inner_product_recip, this, std::placeholders::_1, std::placeholders::_2); + this->mixing->cal_coef(this->rho_mdata, inner_product); + + this->mixing->mix_data(this->rho_mdata, rhog_out); + + for (int is = 0; is < GlobalV::NSPIN; is++) + { + this->rhopw->recip2real(chr->rhog[is], chr->rho[is]); + } + + // For kinetic energy density + if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) + { + std::vector> taug_in(GlobalV::NSPIN * this->rhopw->npw); + std::vector> taug_out(GlobalV::NSPIN * this->rhopw->npw); + for (int is = 0; is < GlobalV::NSPIN; ++is) + { + this->rhopw->real2recip(chr->kin_r[is], &taug_out[is * rhopw->npw]); + this->rhopw->real2recip(chr->kin_r_save[is], &taug_in[is * rhopw->npw]); + } + // Note: there is no kerker modification for tau because I'm not sure + // if we should have it. If necessary we can try it in the future. + this->mixing->push_data(this->tau_mdata, taug_in.data(), taug_out.data(), nullptr, false); + + this->mixing->mix_data(this->tau_mdata, taug_out.data()); + + for (int is = 0; is < GlobalV::NSPIN; is++) + { + this->rhopw->recip2real(&taug_out[is * rhopw->npw], chr->kin_r[is]); + } + } + + return; } -void Charge_Mixing::mix_rho(const int &iter, Charge* chr) +void Charge_Mixing::mix_rho_real(Charge* chr) { - ModuleBase::TITLE("Charge_Mixing","mix_rho"); - ModuleBase::timer::tick("Charge", "mix_rho"); - - // the charge before mixing. - double **rho123 = new double*[GlobalV::NSPIN]; - for(int is=0; isrhopw->nrxx]; - if(is!=0 && is!=3 && GlobalV::DOMAG_Z) - { - ModuleBase::GlobalFunc::ZEROS(rho123[is], this->rhopw->nrxx); - continue; - } + // electronic density + double* rhor_in = chr->rho_save[0]; + double* rhor_out = chr->rho[0]; + + auto screen = std::bind(&Charge_Mixing::Kerker_screen_real, this, std::placeholders::_1); + this->mixing->push_data(this->rho_mdata, rhor_in, rhor_out, screen, true); + + auto inner_product + = std::bind(&Charge_Mixing::inner_product_real, this, std::placeholders::_1, std::placeholders::_2); + this->mixing->cal_coef(this->rho_mdata, inner_product); + + this->mixing->mix_data(this->rho_mdata, rhor_out); + + double *taur_out, *taur_in; + if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) + { + taur_in = chr->kin_r_save[0]; + taur_out = chr->kin_r[0]; + // Note: there is no kerker modification for tau because I'm not sure + // if we should have it. If necessary we can try it in the future. + this->mixing->push_data(this->tau_mdata, taur_in, taur_out, nullptr, false); + + this->mixing->mix_data(this->tau_mdata, taur_out); + } +} + +void Charge_Mixing::mix_reset() +{ + this->mixing->reset(); + this->rho_mdata.reset(); + if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) + { + if (GlobalV::SCF_THR_TYPE == 1) + { + this->mixing->init_mixing_data(this->tau_mdata, + this->rhopw->npw * GlobalV::NSPIN, + sizeof(std::complex)); + } + else + { + this->mixing->init_mixing_data(this->tau_mdata, this->rhopw->nrxx * GlobalV::NSPIN, sizeof(double)); + } + } +} + +void Charge_Mixing::mix_rho(Charge* chr) +{ + ModuleBase::TITLE("Charge_Mixing", "mix_rho"); + ModuleBase::timer::tick("Charge", "mix_rho"); + + // the charge before mixing. + const int nrxx = this->rhopw->nrxx; + std::vector rho123(GlobalV::NSPIN * nrxx); + for (int is = 0; is < GlobalV::NSPIN; ++is) + { + if (is == 0 || is == 3 || !GlobalV::DOMAG_Z) + { + double* rho123_is = rho123.data() + is * nrxx; #ifdef _OPENMP #pragma omp parallel for schedule(static, 512) #endif - for(int ir=0; irrhopw->nrxx; ++ir) - { - rho123[is][ir] = chr->rho[is][ir]; - } - } - - double **kin_r123; - if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) - { - kin_r123 = new double*[GlobalV::NSPIN]; - for(int is=0; isrhopw->nrxx]; + for(int ir = 0 ; ir < nrxx ; ++ir) + { + rho123_is[ir] = chr->rho[is][ir]; + } + } + } + std::vector kin_r123; + if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) + { + kin_r123.resize(GlobalV::NSPIN * nrxx); #ifdef _OPENMP #pragma omp parallel for schedule(static, 512) #endif - for(int ir=0; irrhopw->nrxx; ++ir) - { - kin_r123[is][ir] = chr->kin_r[is][ir]; - } - } - } - - if ( this->mixing_mode == "plain") - { - this->plain_mixing(chr); - } - else if ( this->mixing_mode == "pulay") - { - this->Pulay_mixing(chr); + for(int ir = 0 ; ir < GlobalV::NSPIN * nrxx ; ++ir) + { + kin_r123[ir] = chr->kin_r[0][ir]; + } } - else if ( this->mixing_mode == "broyden") + + // --------------------Mixing Body-------------------- + if (GlobalV::SCF_THR_TYPE == 1) { - this->Simplified_Broyden_mixing(iter, chr); + mix_rho_recip(chr); } else { - ModuleBase::WARNING_QUIT("Charge_Mixing","Not implemended yet,coming soon."); + mix_rho_real(chr); } + // --------------------------------------------------- - // mohan add 2012-06-05 - // rho_save is the charge before mixing - for(int is=0; isrhopw->nrxx; ++ir) - { - chr->rho_save[is][ir] = rho123[is][ir]; - } + for(int ir = 0 ; ir < nrxx ; ++ir) + { + chr->rho_save[is][ir] = rho123_is[ir]; + } + } } - for(int is=0; isrhopw->nrxx; ++ir) - { - chr->kin_r_save[is][ir] = kin_r123[is][ir]; - } - } - - for(int is=0; iskin_r_save[0][ir] = kin_r123[ir]; + } + } - ModuleBase::timer::tick("Charge","mix_rho"); + if (new_e_iteration) + new_e_iteration = false; + ModuleBase::timer::tick("Charge", "mix_rho"); return; } -void Charge_Mixing::plain_mixing(Charge* chr) const +void Charge_Mixing::Kerker_screen_recip(std::complex* drhog) { - ModuleBase::timer::tick("Charge", "plain_mixing"); - // if mixing_beta == 1, each electron iteration, - // use all new charge density, - // on the contrary, if mixing_beta == 0, - // no new charge will be generated! - const double mix_old = 1 - mixing_beta; - -//xiaohui add 2014-12-09 - for (int is=0; ismixing_gg0 > 0.0) - { - double* Rrho = new double[this->rhopw->nrxx]; - std::complex *kerpulay = new std::complex[this->rhopw->npw]; - double* kerpulayR = new double[this->rhopw->nrxx]; + if (this->mixing_gg0 <= 0.0) + return; + const double fac = this->mixing_gg0; + const double gg0 = std::pow(fac * 0.529177 / GlobalC::ucell.tpiba, 2); #ifdef _OPENMP -#pragma omp parallel for schedule(static, 512) +#pragma omp parallel for collapse(2) schedule(static, 512) #endif - for(int ir=0; irrhopw->nrxx; ir++) - { - Rrho[ir] = chr->rho[is][ir] - chr->rho_save[is][ir]; - } - this->rhopw->real2recip(Rrho, kerpulay); - - const double fac = this->mixing_gg0; - const double gg0 = std::pow(fac * 0.529177 / GlobalC::ucell.tpiba, 2); - double* filter_g = new double[this->rhopw->npw]; + for (int is = 0; is < GlobalV::NSPIN; ++is) + { + for (int ig = 0; ig < this->rhopw->npw; ++ig) + { + double gg = this->rhopw->gg[ig]; + double filter_g = std::max(gg / (gg + gg0), 0.1); + drhog[is * this->rhopw->npw + ig] *= filter_g; + } + } + return; +} + +void Charge_Mixing::Kerker_screen_real(double* drhor) +{ + if (this->mixing_gg0 <= 0.0) + return; + std::vector> drhog(this->rhopw->npw * GlobalV::NSPIN); + std::vector drhor_filter(this->rhopw->nrxx * GlobalV::NSPIN); + for (int is = 0; is < GlobalV::NSPIN; ++is) + { + // Note after this process some G which is higher than Gmax will be filtered. + // Thus we cannot use Kerker_screen_recip(drhog.data()) directly after it. + this->rhopw->real2recip(drhor + is * this->rhopw->nrxx, drhog.data() + is * this->rhopw->npw); + } + // Kerker_screen_recip(drhog.data()); Note that we can not use it. + // However, we should rewrite it: + const double fac = this->mixing_gg0; + const double gg0 = std::pow(fac * 0.529177 / GlobalC::ucell.tpiba, 2); #ifdef _OPENMP -#pragma omp parallel for schedule(static, 256) +#pragma omp parallel for collapse(2) schedule(static, 512) #endif - for(int ig=0; igrhopw->npw; ig++) - { - double gg = this->rhopw->gg[ig]; - filter_g[ig] = std::max(gg / (gg + gg0), 0.1); - - kerpulay[ig] = (1 - filter_g[ig]) * kerpulay[ig]; - } - this->rhopw->recip2real(kerpulay, kerpulayR); + for (int is = 0; is < GlobalV::NSPIN; is++) + { + for (int ig = 0; ig < this->rhopw->npw; ig++) + { + double gg = this->rhopw->gg[ig]; + double filter_g = std::max(gg / (gg + gg0), 0.1); + drhog[is * this->rhopw->npw + ig] *= (1 - filter_g); + } + } + + for (int is = 0; is < GlobalV::NSPIN; ++is) + { + this->rhopw->recip2real(drhog.data() + is * this->rhopw->npw, drhor_filter.data() + is * this->rhopw->nrxx); + } + #ifdef _OPENMP -#pragma omp parallel for schedule(static, 128) +#pragma omp parallel for schedule(static, 512) #endif - for(int ir=0; irrhopw->nrxx; ir++) - { - Rrho[ir] = Rrho[ir] - kerpulayR[ir]; - chr->rho[is][ir] = Rrho[ir] * mixing_beta + chr->rho_save[is][ir]; - chr->rho_save[is][ir] = chr->rho[is][ir]; - } - - delete[] Rrho; - delete[] kerpulay; - delete[] kerpulayR; - delete[] filter_g; - } - else - { + for (int ir = 0; ir < this->rhopw->nrxx * GlobalV::NSPIN; ir++) + { + drhor[ir] -= drhor_filter[ir]; + } +} + +double Charge_Mixing::inner_product_recip(std::complex* rho1, std::complex* rho2) +{ + std::complex** rho1_2d = new std::complex*[GlobalV::NSPIN]; + std::complex** rho2_2d = new std::complex*[GlobalV::NSPIN]; + for (int is = 0; is < GlobalV::NSPIN; is++) + { + rho1_2d[is] = rho1 + is * this->rhopw->npw; + rho2_2d[is] = rho2 + is * this->rhopw->npw; + } + double result = this->rhog_dot_product(rho1_2d, rho2_2d); + delete[] rho1_2d; + delete[] rho2_2d; + return result; +} + +double Charge_Mixing::inner_product_real(double* rho1, double* rho2) +{ + double rnorm = 0.0; #ifdef _OPENMP -#pragma omp parallel for schedule(static, 256) +#pragma omp parallel for reduction(+ : rnorm) #endif - for (int ir=0; irrhopw->nrxx; ir++) - { - chr->rho[is][ir] = chr->rho[is][ir]*mixing_beta + mix_old*chr->rho_save[is][ir]; - chr->rho_save[is][ir] = chr->rho[is][ir]; - } - } - - if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) - { -#ifdef _OPENMP -#pragma omp parallel for schedule(static, 256) + for (int ir = 0; ir < this->rhopw->nrxx * GlobalV::NSPIN; ++ir) + { + rnorm += rho1[ir] * rho2[ir]; + } +#ifdef __MPI + Parallel_Reduce::reduce_double_pool(rnorm); #endif - for (int ir=0; irrhopw->nrxx; ir++) - { - chr->kin_r[is][ir] = chr->kin_r[is][ir]*mixing_beta + mix_old*chr->kin_r_save[is][ir]; - chr->kin_r_save[is][ir] = chr->kin_r[is][ir]; - } - } - - } - ModuleBase::timer::tick("Charge", "plain_mixing"); - return; + return rnorm; } -double Charge_Mixing::rhog_dot_product( - const std::complex*const*const rhog1, - const std::complex*const*const rhog2 -) const +double Charge_Mixing::rhog_dot_product(const std::complex* const* const rhog1, + const std::complex* const* const rhog2) const { - ModuleBase::TITLE("Charge_Mixing","rhog_dot_product"); - ModuleBase::timer::tick("Charge_Mixing","rhog_dot_product"); + ModuleBase::TITLE("Charge_Mixing", "rhog_dot_product"); + ModuleBase::timer::tick("Charge_Mixing", "rhog_dot_product"); static const double fac = ModuleBase::e2 * ModuleBase::FOUR_PI / GlobalC::ucell.tpiba2; static const double fac2 = ModuleBase::e2 * ModuleBase::FOUR_PI / (ModuleBase::TWO_PI * ModuleBase::TWO_PI); double sum = 0.0; - - auto part_of_noncolin = [&]() // Peize Lin change goto to function at 2020.01.31 - { - double sum = 0.0; + + auto part_of_noncolin = [&]() // Peize Lin change goto to function at 2020.01.31 + { + double sum = 0.0; #ifdef _OPENMP -#pragma omp parallel for reduction(+:sum) +#pragma omp parallel for reduction(+ : sum) #endif - for (int ig=0; igrhopw->npw; ++ig) - { - if(this->rhopw->gg[ig]<1e-8) continue; - sum += ( conj( rhog1[0][ig] )* rhog2[0][ig] ).real() / this->rhopw->gg[ig]; - } - sum *= fac; - return sum; - }; - - switch ( GlobalV::NSPIN ) - { - case 1: - sum += part_of_noncolin(); - break; - - case 2: - { - // (1) First part of density error. + for (int ig = 0; ig < this->rhopw->npw; ++ig) + { + if (this->rhopw->gg[ig] < 1e-8) + continue; + sum += (conj(rhog1[0][ig]) * rhog2[0][ig]).real() / this->rhopw->gg[ig]; + } + sum *= fac; + return sum; + }; + + switch (GlobalV::NSPIN) + { + case 1: + sum += part_of_noncolin(); + break; + + case 2: { + // (1) First part of density error. #ifdef _OPENMP -#pragma omp parallel for reduction(+:sum) +#pragma omp parallel for reduction(+ : sum) #endif - for (int ig=0; igrhopw->npw; ++ig) - { - if(this->rhopw->gg[ig]<1e-8) continue; - sum += ( conj( rhog1[0][ig]+rhog1[1][ig] ) * (rhog2[0][ig]+rhog2[1][ig]) ).real() / this->rhopw->gg[ig]; - } - sum *= fac; + for (int ig = 0; ig < this->rhopw->npw; ++ig) + { + if (this->rhopw->gg[ig] < 1e-8) + continue; + sum += (conj(rhog1[0][ig] + rhog1[1][ig]) * (rhog2[0][ig] + rhog2[1][ig])).real() / this->rhopw->gg[ig]; + } + sum *= fac; - if(GlobalV::GAMMA_ONLY_PW) - { - sum *= 2.0; - } + if (GlobalV::GAMMA_ONLY_PW) + { + sum *= 2.0; + } - // (2) Second part of density error. - // including |G|=0 term. - double sum2 = 0.0; + // (2) Second part of density error. + // including |G|=0 term. + double sum2 = 0.0; - sum2 += fac2 * ( conj( rhog1[0][0]-rhog1[1][0] ) * ( rhog2[0][0]-rhog2[1][0] ) ).real(); + sum2 += fac2 * (conj(rhog1[0][0] - rhog1[1][0]) * (rhog2[0][0] - rhog2[1][0])).real(); - double mag = 0.0; + double mag = 0.0; #ifdef _OPENMP -#pragma omp parallel for reduction(+:mag) +#pragma omp parallel for reduction(+ : mag) #endif - for (int ig=0; igrhopw->npw; ig++) - { - mag += ( conj( rhog1[0][ig]-rhog1[1][ig] ) * ( rhog2[0][ig]-rhog2[1][ig] ) ).real(); - } - mag *= fac2; - - //if(GlobalV::GAMMA_ONLY_PW); - if(GlobalV::GAMMA_ONLY_PW) // Peize Lin delete ; 2020.01.31 - { - mag *= 2.0; - } - - //std::cout << " sum=" << sum << " mag=" << mag << std::endl; - sum2 += mag; - sum += sum2; - break; - } - case 4: - // non-collinear spin, added by zhengdy - if(!GlobalV::DOMAG&&!GlobalV::DOMAG_Z) - sum += part_of_noncolin(); - else - { - //another part with magnetization + for (int ig = 0; ig < this->rhopw->npw; ig++) + { + mag += (conj(rhog1[0][ig] - rhog1[1][ig]) * (rhog2[0][ig] - rhog2[1][ig])).real(); + } + mag *= fac2; + + // if(GlobalV::GAMMA_ONLY_PW); + if (GlobalV::GAMMA_ONLY_PW) // Peize Lin delete ; 2020.01.31 + { + mag *= 2.0; + } + + // std::cout << " sum=" << sum << " mag=" << mag << std::endl; + sum2 += mag; + sum += sum2; + break; + } + case 4: + // non-collinear spin, added by zhengdy + if (!GlobalV::DOMAG && !GlobalV::DOMAG_Z) + sum += part_of_noncolin(); + else + { + // another part with magnetization #ifdef _OPENMP -#pragma omp parallel for reduction(+:sum) +#pragma omp parallel for reduction(+ : sum) #endif - for (int ig=0; igrhopw->npw; ig++) - { - if(ig==this->rhopw->ig_gge0) continue; - sum += ( conj( rhog1[0][ig] )* rhog2[0][ig] ).real() / this->rhopw->gg[ig]; - } - sum *= fac; - const int ig0 = this->rhopw->ig_gge0; - if(ig0 > 0) - { - sum += fac2 * ((conj( rhog1[1][ig0])*rhog2[1][ig0]).real() + - (conj( rhog1[2][ig0])*rhog2[2][ig0]).real() + - (conj( rhog1[3][ig0])*rhog2[3][ig0]).real()); - } - double fac3 = fac2; - if(GlobalV::GAMMA_ONLY_PW) - { - fac3 *= 2.0; - } + for (int ig = 0; ig < this->rhopw->npw; ig++) + { + if (ig == this->rhopw->ig_gge0) + continue; + sum += (conj(rhog1[0][ig]) * rhog2[0][ig]).real() / this->rhopw->gg[ig]; + } + sum *= fac; + const int ig0 = this->rhopw->ig_gge0; + if (ig0 > 0) + { + sum += fac2 + * ((conj(rhog1[1][ig0]) * rhog2[1][ig0]).real() + (conj(rhog1[2][ig0]) * rhog2[2][ig0]).real() + + (conj(rhog1[3][ig0]) * rhog2[3][ig0]).real()); + } + double fac3 = fac2; + if (GlobalV::GAMMA_ONLY_PW) + { + fac3 *= 2.0; + } #ifdef _OPENMP -#pragma omp parallel for reduction(+:sum) +#pragma omp parallel for reduction(+ : sum) #endif - for (int ig=0; igrhopw->npw; ig++) - { - if(ig == ig0) continue; - sum += fac3 * ((conj( rhog1[1][ig])*rhog2[1][ig]).real() + - (conj( rhog1[2][ig])*rhog2[2][ig]).real() + - (conj( rhog1[3][ig])*rhog2[3][ig]).real()); - } - } - break; + for (int ig = 0; ig < this->rhopw->npw; ig++) + { + if (ig == ig0) + continue; + sum += fac3 + * ((conj(rhog1[1][ig]) * rhog2[1][ig]).real() + (conj(rhog1[2][ig]) * rhog2[2][ig]).real() + + (conj(rhog1[3][ig]) * rhog2[3][ig]).real()); + } + } + break; } +#ifdef __MPI + Parallel_Reduce::reduce_double_pool(sum); +#endif + ModuleBase::timer::tick("Charge_Mixing", "rhog_dot_product"); - Parallel_Reduce::reduce_double_pool( sum ); - - ModuleBase::timer::tick("Charge_Mixing","rhog_dot_product"); - - sum *= GlobalC::ucell.omega * 0.5; + sum *= GlobalC::ucell.omega * 0.5; return sum; } - diff --git a/source/module_elecstate/module_charge/charge_mixing.h b/source/module_elecstate/module_charge/charge_mixing.h index 5cfb6bf492..cfc2bcae08 100644 --- a/source/module_elecstate/module_charge/charge_mixing.h +++ b/source/module_elecstate/module_charge/charge_mixing.h @@ -1,148 +1,143 @@ -//================================= -// Mohan add 2010-02-01 -//================================= + #ifndef CHARGE_MIXING_H #define CHARGE_MIXING_H - -//================================== -// (1) Plain Mixing -// (2) KerKer Mixing -// (3) Pulay Mixing -// (4) Modified Broden Mixing -//=================================== +#include "charge.h" #include "module_base/global_function.h" #include "module_base/global_variable.h" -#include "module_base/matrix.h" +#include "module_base/module_mixing/mixing.h" #include "module_cell/unitcell.h" -#include "charge.h" class Charge_Mixing { - public: - Charge_Mixing(); - ~Charge_Mixing(); - -//====================================== -// General interfaces, in charge_mixing.cpp -//====================================== - void set_mixing - ( - const std::string &mixing_mode_in, - const double &mixing_beta_in, - const int &mixing_ndim_in, - const double &mixing_gg0_in, - const bool &mixing_tau_in - );//mohan add mixing_gg0_in 2014-09-27 - - void need_auto_set(); - void auto_set(const double& bandgap_in, const UnitCell& ucell_); - - double get_drho(Charge* chr, const double nelec); - - void mix_rho(const int &iter, Charge* chr);// mix rho - - //for Pulay method - //if first electronic step, then reset charge mixing - void reset(); - - // init pwrho, sunliang add 2023-05-08 - void set_rhopw(ModulePW::PW_Basis* rhopw_in); + public: + Charge_Mixing(); + ~Charge_Mixing(); + Base_Mixing::Mixing* mixing = nullptr; + Base_Mixing::Mixing_Data rho_mdata; + Base_Mixing::Mixing_Data tau_mdata; + + /** + * @brief reset mixing + * + */ + void mix_reset(); + + /** + * @brief charge mixing + * + */ + void mix_rho(Charge* chr); + + /** + * @brief charge mixing for reciprocal space + * + */ + void mix_rho_recip(Charge* chr); + + /** + * @brief charge mixing for real space + * + */ + void mix_rho_real(Charge* chr); + + /** + * @brief Kerker screen method for reciprocal space + * + */ + void Kerker_screen_recip(std::complex* rhog); + + /** + * @brief Kerker screen method for real space + * + */ + void Kerker_screen_real(double* rho); + + /** + * @brief Inner product of two complex vectors + * + */ + double inner_product_recip(std::complex* rho1, std::complex* rho2); + + /** + * @brief Inner product of two double vectors + * + */ + double inner_product_real(double* rho1, double* rho2); + + /** + * @brief Set the mixing object + * + * @param mixing_mode_in mixing mode: "plain", "broyden", "pulay" + * @param mixing_beta_in mixing beta + * @param mixing_ndim_in mixing ndim + * @param mixing_gg0_in mixing gg0 for Kerker screen + * @param mixing_tau_in whether to use tau mixing + */ + void set_mixing(const std::string& mixing_mode_in, + const double& mixing_beta_in, + const int& mixing_ndim_in, + const double& mixing_gg0_in, + const bool& mixing_tau_in); // mohan add mixing_gg0_in 2014-09-27 + + /** + * @brief use auto set + * + */ + void need_auto_set(); + + /** + * @brief auto set mixing gg0 and mixing_beta + * + */ + void auto_set(const double& bandgap_in, const UnitCell& ucell_); + + /** + * @brief Get the drho + * + */ + double get_drho(Charge* chr, const double nelec); + + // init pwrho, sunliang add 2023-05-08 + void set_rhopw(ModulePW::PW_Basis* rhopw_in); // extracting parameters - // normally these parameters will not be used - // outside charge mixing, but Exx is using them + // normally these parameters will not be used + // outside charge mixing, but Exx is using them // as well as some other places - const std::string &get_mixing_mode() const {return mixing_mode;} - double get_mixing_beta() const {return mixing_beta;} - int get_mixing_ndim() const {return mixing_ndim;} - double get_mixing_gg0() const {return mixing_gg0;} - - int get_totstep() const {return totstep;} - int get_rstep() const {return rstep;} - int get_dstep() const {return dstep;} - int get_idstep() const {return idstep;} - double* get_alpha() const {return alpha;} - - private: - -//====================================== -// General parameters -//====================================== - std::string mixing_mode; - double mixing_beta; - int mixing_ndim; - double mixing_gg0; //mohan add 2014-09-27 - bool mixing_tau; - - bool new_e_iteration; - - ModulePW::PW_Basis* rhopw = nullptr; - -//====================================== -// simple plain mixing method, in charge_mixing.cpp -//====================================== - void plain_mixing(Charge* chr) const; - - double rhog_dot_product(const std::complex*const*const rhog1, const std::complex*const*const rhog2) const; - -//====================================== -// Pulay mixing method, in charge_pulay.cpp -//====================================== - - void Pulay_mixing(Charge* chr); - - bool initp; // p stands for pulay algorithms - void allocate_Pulay(); - void deallocate_Pulay(); - - // auxiliary variables / subroutines - int irstep; //mohan add 2012-02-10 - int idstep; - int totstep; - int rstep; // the record step; - int dstep; // Delta step " dstep = rstep-1 ". - double* alpha; // - sum (Abar * dRR) - - double*** Rrho;// Rrho(i) = rho(i) - rho_save(i), (GlobalV::NSPIN, rstep, pw.nrxx) - double*** dRrho;// dRrho(i) = Rrho(i+1) - Rrho(i), (GlobalV::NSPIN, dstep, pw.nrxx) - double*** drho;// drho(i)= rho_save(i+1) - rho_save2(i), (GlobalV::NSPIN, dstep, pw.nrxx) - double** rho_save2;//rho_save: rho_in, rho_save2: rho_in(last step) - - double*** Rtau;//same things, but for kinetic energy density - double*** dRtau; - double*** dtau; - double** tau_save2; - - ModuleBase::matrix Abar; // ^{-1} - double* dRR; // - - void generate_datas(const int &irstep, const int &idstep, const int &totstep, Charge* chr); - void generate_Abar(ModuleBase::matrix &A)const; - void inverse_preA(const int &dim, ModuleBase::matrix &preA)const; - void inverse_real_symmetry_matrix(ModuleBase::matrix &A)const; // indicate the spin. - void generate_dRR(const int &m); - void generate_alpha(); - void generate_new_rho(const int &is,const int &m, Charge* chr); - - void generate_residual_vector(double *residual, const double* rho_out, const double* rho_in)const; - -//====================================== -// Broyden mixing method, in charge_broyden.cpp -//====================================== - - void Simplified_Broyden_mixing(const int &iter, - Charge* chr); //qianrui created 2021-5-15 - - bool initb; // b stands for Broyden algorithms. - void allocate_Broyden(); - void deallocate_Broyden(); - - ModuleBase::matrix beta; // (dstep, dstep) - - std::complex*** dF; // dF(i) = rhog(i) - rhog_save(i), (GlobalV::NSPIN, rstep, rhopw->npw) - std::complex*** dn; // dn(i) = rhog(i+1) - rhog(i), (GlobalV::NSPIN, rstep, rhopw->npw) - - private: - bool autoset = false; + const std::string& get_mixing_mode() const + { + return mixing_mode; + } + double get_mixing_beta() const + { + return mixing_beta; + } + int get_mixing_ndim() const + { + return mixing_ndim; + } + double get_mixing_gg0() const + { + return mixing_gg0; + } + + private: + //====================================== + // General parameters + //====================================== + std::string mixing_mode = "broyden"; + double mixing_beta = 0.7; + int mixing_ndim = 8; + double mixing_gg0 = 0.0; // mohan add 2014-09-27 + bool mixing_tau = false; + + bool new_e_iteration = true; + + ModulePW::PW_Basis* rhopw = nullptr; + bool autoset = false; + + private: + double rhog_dot_product(const std::complex* const* const rhog1, + const std::complex* const* const rhog2) const; }; #endif diff --git a/source/module_elecstate/module_charge/charge_pulay.cpp b/source/module_elecstate/module_charge/charge_pulay.cpp deleted file mode 100644 index 899a055e1d..0000000000 --- a/source/module_elecstate/module_charge/charge_pulay.cpp +++ /dev/null @@ -1,696 +0,0 @@ -#include "charge_mixing.h" -#include "module_hamilt_pw/hamilt_pwdft/global.h" -#include "module_base/inverse_matrix.h" -#include "module_base/parallel_reduce.h" -#include "module_base/memory.h" -#include "module_base/tool_threading.h" -#include "module_base/timer.h" - -static inline double calculate_residual_norm(int nrxx, double *residual1, double* residual2) -{ - // calculate the norm of the residual std::vector: - // (the target to minimize in Pulay's algorithm) - double rnorm = 0.0; -#ifdef _OPENMP -#pragma omp parallel for reduction(+:rnorm) -#endif - for(int ir=0; irmixing_ndim; - dstep = this->mixing_ndim - 1; - assert(dstep>0); - - // (1) allocate - this->allocate_Pulay(); - - if (irstep==rstep) irstep=0; - if (idstep==dstep) idstep=0; - - if(GlobalV::test_charge)ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"irstep",irstep); - if(GlobalV::test_charge)ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"idstep",idstep); - if(GlobalV::test_charge)ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"totstep",totstep); - - //---------------------------------------------- - // calculate "dR^{i} = R^{i+1} - R^{i}" - // calculate "drho^{i} = rho^{i+1} - rho^{i}" - //---------------------------------------------- - this->generate_datas(irstep, idstep, totstep, chr); - - // not enough steps, not full matrix. - if(totstep < dstep) - { - int premix = 1; - - // mohan update 2011-06-14 - if(totstep==0) premix = 2; - - if(premix == 1) - { - this->generate_Abar(Abar); - - //----------------------------- - // inverse part of the matrix. - //----------------------------- - const int predim = idstep+1; - ModuleBase::matrix preA(predim, predim); - for(int i=0; iinverse_preA(predim,preA); - - - //---------------------------------------------- - // get the information from part of the matrix. - //---------------------------------------------- - Abar.zero_out(); - for(int i=0; igenerate_dRR(irstep); - - this->generate_alpha(); - - for(int is=0; isgenerate_new_rho(is,irstep,chr); - } - } - - if(premix == 2) - { - // if not enough step, take kerker mixing method. - this->plain_mixing(chr); - } - - if(totstep>0) - { - ++idstep; - } - ++irstep; - ++totstep; - } - else - { - // generate matrix A = - this->generate_Abar(Abar); - - // inverse A matrix to become Abar. - this->inverse_real_symmetry_matrix(Abar); - - this->generate_dRR(irstep); - - this->generate_alpha(); - - for(int is=0; isgenerate_new_rho(is,irstep,chr); - } - - ++irstep; - ++idstep; - ++totstep; - } - - ModuleBase::timer::tick("Charge", "Pulay_mixing"); - return; -} - -void Charge_Mixing::reset() // Peize Lin add 2018-11-01 -{ - this->new_e_iteration = true; - - irstep = 0; - idstep = 0; - totstep = 0; - - // liuyu add 2023-03-29 - // if md_prec_level == 2, charge mixing should re-allocate - // due to the change of FFT grids - if (GlobalV::md_prec_level == 2) - { - if (this->mixing_mode == "pulay") - { - this->deallocate_Pulay(); - } - else if (this->mixing_mode == "broyden") - { - this->deallocate_Broyden(); - } - } -} - -void Charge_Mixing::set_rhopw(ModulePW::PW_Basis* rhopw_in) -{ - this->rhopw = rhopw_in; -} - -void Charge_Mixing::allocate_Pulay() -{ - auto zeros_kernel = [&](int num_threads, int thread_id) - { - int beg, len; - ModuleBase::TASK_DIST_1D(num_threads, thread_id, this->rhopw->nrxx, beg, len); - for(int i=0; iinitp) - { - ModuleBase::TITLE("Charge_Mixing","allocate_pulay"); - ModuleBase::GlobalFunc::NOTE("rstep is used to record Rrho"); - if(GlobalV::test_charge)ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"rstep",rstep); - ModuleBase::GlobalFunc::NOTE("dstep is used to record dRrho, drho"); - if(GlobalV::test_charge)ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"dstep",dstep); - assert(rstep>1); - dstep = rstep - 1; - - // (1) allocate Rrho[i]: rho_out[i] - rho_in[i] - this->Rrho = new double**[GlobalV::NSPIN]; - for (int is=0; isrhopw->nrxx]; - } - } - ModuleBase::Memory::record("ChgMix::Rrho", sizeof(double) * GlobalV::NSPIN*rstep*this->rhopw->nrxx); - - // (2) allocate "dRrho[i] = Rrho[i+1] - Rrho[i]" of the last few steps. - // allocate "drho[i] = rho[i+1] - rho[i]" of the last few steps. - // allocate rho_save2: rho[i] of the last few steps. - this->dRrho = new double**[GlobalV::NSPIN]; - this->drho = new double**[GlobalV::NSPIN]; - this->rho_save2 = new double*[GlobalV::NSPIN]; - - for (int is=0; isrhopw->nrxx]; - - for (int i=0; irhopw->nrxx]; - drho[is][i] = new double[this->rhopw->nrxx]; - } - } - ModuleBase::Memory::record("ChgMix::dRrho", sizeof(double) * GlobalV::NSPIN*dstep*this->rhopw->nrxx); - ModuleBase::Memory::record("ChgMix::drho", sizeof(double) * GlobalV::NSPIN*dstep*this->rhopw->nrxx); - ModuleBase::Memory::record("ChgMix::rho_save2", sizeof(double) * GlobalV::NSPIN*this->rhopw->nrxx); - - if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) - { - this->Rtau = new double**[GlobalV::NSPIN]; - for (int is=0; isrhopw->nrxx]; - } - } - ModuleBase::Memory::record("ChgMix::Rtau", sizeof(double) * GlobalV::NSPIN*rstep*this->rhopw->nrxx); - - this->dRtau = new double**[GlobalV::NSPIN]; - this->dtau = new double**[GlobalV::NSPIN]; - this->tau_save2 = new double*[GlobalV::NSPIN]; - - for (int is=0; isrhopw->nrxx]; - - for (int i=0; irhopw->nrxx]; - dtau[is][i] = new double[this->rhopw->nrxx]; - } - } - ModuleBase::Memory::record("ChgMix::dRtau", sizeof(double) * GlobalV::NSPIN*dstep*this->rhopw->nrxx); - ModuleBase::Memory::record("ChgMix::dtau", sizeof(double) * GlobalV::NSPIN*dstep*this->rhopw->nrxx); - ModuleBase::Memory::record("ChgMix::tau_save2", sizeof(double) * GlobalV::NSPIN*this->rhopw->nrxx); - } - - ModuleBase::GlobalFunc::NOTE("Allocate Abar = , dimension = dstep."); - this->Abar.create(dstep, dstep); - ModuleBase::Memory::record("ChgMix::Abar", sizeof(double) * dstep*dstep); - - // (4) allocate dRR = - ModuleBase::GlobalFunc::NOTE("Allocate dRR = < dR | R >, dimension = dstep"); - this->dRR = new double[dstep]; - - // (5) allocate alpha - ModuleBase::GlobalFunc::NOTE("Allocate alpha, dimension = dstep"); - this->alpha = new double[dstep]; - - // (6) zeros all arrays - ModuleBase::OMP_PARALLEL(zeros_kernel); - - this->initp = true; - } - - // mohan add 2010-07-16 - if(this->new_e_iteration) - { - ModuleBase::OMP_PARALLEL(zeros_kernel); - } - return; -} - -void Charge_Mixing::deallocate_Pulay() -{ - if (!this->initp) return; - // delete: Rrho[i] = rho_out[i] - rho_in[i]; - for (int is=0; isrhopw->nrxx) - for (int is=0; isinitp = false; -} - -// calculate < dR | dR > -// if spin is considered, double the size. -// < dR1,dR2 | dR1,dR2 > = < dR1 | dR1 > + < dR2 | dR2 > -void Charge_Mixing::generate_Abar(ModuleBase::matrix &A)const -{ - int step = 0; - - step=dstep; - - A.zero_out(); - - for(int is=0; isrhopw->nrxx, this->dRrho[is][j], this->dRrho[is][i] ); - if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) - { - A(i,j) += calculate_residual_norm(this->rhopw->nrxx, this->dRtau[is][j], this->dRtau[is][i] ); - } - A(j,i) = A(i,j); - } - } - } - Parallel_Reduce::reduce_double_pool(A.c, A.nr * A.nc); - return; -} - -#include "module_base/complexmatrix.h" -void Charge_Mixing::inverse_preA(const int &dim, ModuleBase::matrix &preA)const -{ - ModuleBase::ComplexMatrix B(dim, dim); - ModuleBase::ComplexMatrix C(dim, dim); - for(int i=0; i (preA(i,j), 0.0); - } - } - ModuleBase::Inverse_Matrix_Complex IMC; - IMC.init(dim); - IMC.using_zheev(B,C); - - for(int i=0; i (A(i,j),0.0); - } - } - - ModuleBase::Inverse_Matrix_Complex IMC; - IMC.init(step); - IMC.using_zheev(B,C); - - for(int i=0; idRR[i] += calculate_residual_norm(this->rhopw->nrxx, this->dRrho[is][i], this->Rrho[is][m]); - if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) - { - this->dRR[i] += calculate_residual_norm(this->rhopw->nrxx, this->dRtau[is][i], this->Rtau[is][m]); - } - } - } - Parallel_Reduce::reduce_double_pool(dRR, dstep); - - return; -} - -// use dstep to genearte Abar(dstep, dstep) -void Charge_Mixing::generate_alpha() -{ - for(int i=0; ialpha[i] = 0; - for(int j=0; jalpha[i] -= this->Abar(j,i) * this->dRR[j]; - } - } - - return; -} - -void Charge_Mixing::generate_new_rho(const int &is, const int &m, Charge* chr) -{ - double mixp = this->mixing_beta; -#ifdef _OPENMP -#pragma omp parallel for -#endif - for(int ir=0; irrhopw->nrxx; ir++) - { - double rhonew = chr->rho_save[is][ir] + mixp * this->Rrho[is][m][ir]; - for(int i=0; ialpha[i] * ( this->drho[is][i][ir] + mixp * this->dRrho[is][i][ir] ); - } - chr->rho[is][ir] = rhonew; - } - - if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) - { -#ifdef _OPENMP -#pragma omp parallel for -#endif - for(int ir=0; irrhopw->nrxx; ir++) - { - double rhonew = chr->kin_r_save[is][ir] + mixp * this->Rtau[is][m][ir]; - for(int i=0; ialpha[i] * ( this->dtau[is][i][ir] + mixp * this->dRtau[is][i][ir] ); - } - chr->kin_r[is][ir] = rhonew; - } - } - return; -} - -void Charge_Mixing::generate_residual_vector(double *residual, const double* rho_out, const double* rho_in)const -{ -#ifdef _OPENMP -#pragma omp parallel for schedule(static, 512) -#endif - for (int ir=0; irrhopw->nrxx; ir++) - { - residual[ir]= rho_out[ir] - rho_in[ir]; - } - return; -} - - -// calculate "dR^{i} = R^{i+1} - R^{i}" -// calculate "drho^{i} = rho^{i+1} - rho^{i}" -void Charge_Mixing::generate_datas(const int &irstep, const int &idstep, const int &totstep, Charge* chr) -{ - //=============================================== - // calculate the important "Rrho". - // init the "Rrho = rho - rho_save" - // which Rrho to be update now? answer: irstep - //=============================================== - - ModuleBase::GlobalFunc::NOTE("Generate Residual std::vector from rho and rho_save."); - for (int is=0; isgenerate_residual_vector( this->Rrho[is][irstep], chr->rho[is], chr->rho_save[is]); - if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) - { - this->generate_residual_vector( this->Rtau[is][irstep], chr->kin_r[is], chr->kin_r_save[is]); - } - - // Note: there is no kerker modification for tau because I'm not sure - // if we should have it. If necessary we can try it in the future. - - if(this->mixing_gg0 > 0.0) - { - std::complex *kerpulay = new std::complex[this->rhopw->npw]; - double* kerpulayR = new double[this->rhopw->nrxx]; - - this->rhopw->real2recip(Rrho[is][irstep], kerpulay); - - const double fac = this->mixing_gg0; - const double gg0 = std::pow(fac * 0.529177 /GlobalC::ucell.tpiba, 2); -#ifdef _OPENMP -#pragma omp parallel for schedule(static, 128) -#endif - for(int ig=0; igrhopw->npw; ig++) - { - double gg = this->rhopw->gg[ig]; - double filter_g = std::max(gg / (gg + gg0), 0.1); - kerpulay[ig] = (1 - filter_g) * kerpulay[ig]; - } - - this->rhopw->recip2real(kerpulay, kerpulayR); -#ifdef _OPENMP -#pragma omp parallel for schedule(static, 256) -#endif - for(int ir=0; irrhopw->nrxx; ir++) - { - Rrho[is][irstep][ir] = Rrho[is][irstep][ir] - kerpulayR[ir]; - } - - delete[] kerpulay; - delete[] kerpulayR; - } - } - - ModuleBase::OMP_PARALLEL([&](int num_threads, int thread_id) - { - int irbeg, irend; - ModuleBase::TASK_DIST_1D(num_threads, thread_id, this->rhopw->nrxx, irbeg, irend); - irend = irbeg + irend; - if(totstep==0) - { - // don't need to calculate 'dRrho' and 'drho'. - - // mohan fix the bug 2010/03/26. - // save 'rho_save2' in order to calculate drho in - // the next iteration. - for(int is=0; isrho_save2[is][ir] = chr->rho_save[is][ir]; - } - } - - if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) - { - for(int is=0; istau_save2[is][ir] = chr->kin_r_save[is][ir]; - } - } - } - } - else if(totstep>0) - { - // which dRrho to be update now? answer: dstep=istep-1; - // irstep range: [0, rstep) - const int nowR = irstep; - int lastR = irstep - 1; - - if (thread_id == 0) - { - if(GlobalV::test_charge)ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "now irstep", nowR); - if(GlobalV::test_charge)ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "last irstep",lastR); - } - - if(lastR < 0) lastR += rstep; - for (int is=0; isdRrho[is][idstep][ir] = this->Rrho[is][nowR][ir] - this->Rrho[is][lastR][ir]; - this->drho[is][idstep][ir] = chr->rho_save[is][ir] - this->rho_save2[is][ir]; - // save 'rho_save2' in order to calculate drho in - this->rho_save2[is][ir] = chr->rho_save[is][ir]; - } - } - - if ((XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) && mixing_tau) - { - for (int is=0; isdRtau[is][idstep][ir] = this->Rtau[is][nowR][ir] - this->Rtau[is][lastR][ir]; - this->dtau[is][idstep][ir] = chr->kin_r_save[is][ir] - this->tau_save2[is][ir]; - // save 'tau_save2' in order to calculate drho in - this->tau_save2[is][ir] = chr->kin_r_save[is][ir]; - } - } - } - } - }); - - ModuleBase::GlobalFunc::NOTE("Calculate drho = rho_{in}^{i+1} - rho_{in}^{i}"); - return; -} - diff --git a/source/module_elecstate/test/CMakeLists.txt b/source/module_elecstate/test/CMakeLists.txt index 7de565770e..6beb502a1f 100644 --- a/source/module_elecstate/test/CMakeLists.txt +++ b/source/module_elecstate/test/CMakeLists.txt @@ -86,8 +86,6 @@ AddTest( LIBS base ${math_libs} psi device planewave_serial cell_info SOURCES charge_mixing_test.cpp ../module_charge/charge_mixing.cpp - ../module_charge/charge_broyden.cpp - ../module_charge/charge_pulay.cpp ../../module_io/output.cpp ) diff --git a/source/module_elecstate/test/charge_mixing_test.cpp b/source/module_elecstate/test/charge_mixing_test.cpp index c1c67900fa..fdde781018 100644 --- a/source/module_elecstate/test/charge_mixing_test.cpp +++ b/source/module_elecstate/test/charge_mixing_test.cpp @@ -1,51 +1,405 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "module_hamilt_general/module_xc/xc_functional.h" +#include "module_base/module_mixing/broyden_mixing.h" #define private public #include "../module_charge/charge_mixing.h" +#include "module_basis/module_pw/pw_basis.h" +#include "module_hamilt_general/module_xc/xc_functional.h" +#include + +int FUNC_TYPE = 1; // mock function -Magnetism::~Magnetism(){} -Magnetism::Magnetism(){} -int XC_Functional::get_func_type(){return 1;} +Magnetism::~Magnetism() +{ +} +Magnetism::Magnetism() +{ +} +Charge::~Charge() +{ +} +Charge::Charge() +{ +} +int XC_Functional::get_func_type() +{ + return FUNC_TYPE; +} #ifdef __LCAO -InfoNonlocal::InfoNonlocal(){} -InfoNonlocal::~InfoNonlocal(){} +InfoNonlocal::InfoNonlocal() +{ +} +InfoNonlocal::~InfoNonlocal() +{ +} #endif // mock class cell -namespace GlobalC{ - UnitCell ucell; +namespace GlobalC +{ +UnitCell ucell; }; - /************************************************ * unit test of charge_mixing.cpp ***********************************************/ /** * - Tested Functions: - * - SetMixingTest: Charge_Mixing::set_mixing(mixing_mode_in,mixing_beta_in,mixing_ndim_in,mixing_gg0_in,mixing_tau_in) + * - SetMixingTest: + * Charge_Mixing::set_mixing(mixing_mode_in,mixing_beta_in,mixing_ndim_in,mixing_gg0_in,mixing_tau_in) + * Charge_Mixing::set_rhopw(rhopw_in) + * Charge_Mixing::get_mixing_mode() + * Charge_Mixing::get_mixing_beta() + * Charge_Mixing::get_mixing_ndim() + * Charge_Mixing::get_mixing_gg0() * - set the basic parameters of class charge_mixing + * - AutoSetTest: Charge_Mixing::auto_set(bandgap_in, ucell_) + * Charge_Mixing::need_auto_set() + * - auto-set the parameters of class charge_mixing + * - KerkerScreenTest: Charge_Mixing::Kerker_screen_recip(drhog) + * Charge_Mixing::Kerker_screen_real(drhog) + * - screen drho with Kerker method + * - InnerDotTest: Charge_Mixing::inner_product_recip(rhog1, rhog2) + * Charge_Mixing::rhog_dot_product(rhog1, rhog2) + * Charge_Mixing::inner_product_real(rho1, rho2) + * - calculate the inner product of two vectors + * - MixRhoTest: Charge_Mixing::mix_rho(chr) + * Charge_Mixing::mix_rho_recip(chr) + * Charge_Mixing::mix_rho_real(chr) + * - mix rho with different methods + * */ class ChargeMixingTest : public ::testing::Test { - + public: + ChargeMixingTest() + { + // Init pw_basis + pw_basis.initgrids(4, ModuleBase::Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1), 20); + pw_basis.initparameters(false, 20); + pw_basis.setuptransform(); + pw_basis.collect_local_pw(); + } + ModulePW::PW_Basis pw_basis; + Charge charge; }; -TEST_F(ChargeMixingTest,SetMixingTest) +TEST_F(ChargeMixingTest, SetMixingTest) +{ + omp_set_num_threads(1); + GlobalV::NSPIN = 1; + Charge_Mixing CMtest; + CMtest.set_rhopw(&pw_basis); + double beta = 1.0; + int dim = 1; + double gg0 = 1; + + FUNC_TYPE = 1; + bool mixingtau = false; + GlobalV::SCF_THR_TYPE = 1; + std::string mode = "broyden"; + CMtest.set_mixing(mode, beta, dim, gg0, mixingtau); + EXPECT_EQ(CMtest.rho_mdata.length, pw_basis.npw); + + GlobalV::SCF_THR_TYPE = 2; + mode = "broyden"; + CMtest.set_mixing(mode, beta, dim, gg0, mixingtau); + EXPECT_EQ(CMtest.rho_mdata.length, pw_basis.nrxx); + EXPECT_EQ(CMtest.get_mixing_mode(), "broyden"); + EXPECT_EQ(CMtest.get_mixing_beta(), 1.0); + EXPECT_EQ(CMtest.get_mixing_ndim(), 1); + EXPECT_EQ(CMtest.get_mixing_gg0(), 1.0); + + FUNC_TYPE = 3; + mixingtau = true; + mode = "plain"; + GlobalV::SCF_THR_TYPE = 1; + CMtest.set_mixing(mode, beta, dim, gg0, mixingtau); + CMtest.mix_reset(); + EXPECT_EQ(CMtest.tau_mdata.length, pw_basis.npw); + + GlobalV::SCF_THR_TYPE = 2; + CMtest.set_mixing(mode, beta, dim, gg0, mixingtau); + CMtest.mix_reset(); + EXPECT_EQ(CMtest.tau_mdata.length, pw_basis.nrxx); + + mode = "nothing"; + std::string output; + testing::internal::CaptureStdout(); + EXPECT_EXIT(CMtest.set_mixing(mode, beta, dim, gg0, mixingtau);, ::testing::ExitedWithCode(0), ""); + output = testing::internal::GetCapturedStdout(); + EXPECT_THAT(output, testing::HasSubstr("This Mixing mode is not implemended yet,coming soon.")); +} + +TEST_F(ChargeMixingTest, AutoSetTest) { Charge_Mixing CMtest; - std::string mode ="1"; - double beta=1.0; - int dim=1; - double gg0=1; - bool tau= true; - CMtest.set_mixing(mode,beta,dim,gg0,tau); - EXPECT_EQ(CMtest.mixing_mode, "1"); + CMtest.set_rhopw(&pw_basis); + GlobalV::SCF_THR_TYPE = 1; + GlobalV::NSPIN = 1; + + CMtest.set_mixing("broyden", 1.0, 1, 0.2, false); + CMtest.auto_set(0.0, GlobalC::ucell); EXPECT_EQ(CMtest.mixing_beta, 1.0); - EXPECT_EQ(CMtest.mixing_ndim, 1); - EXPECT_EQ(CMtest.mixing_gg0, 1); - EXPECT_EQ(CMtest.mixing_tau, true); + EXPECT_EQ(CMtest.mixing_gg0, 0.2); + + CMtest.need_auto_set(); + CMtest.auto_set(0.0, GlobalC::ucell); + EXPECT_EQ(CMtest.mixing_beta, 0.2); + EXPECT_EQ(CMtest.mixing->mixing_beta, 0.2); + EXPECT_EQ(CMtest.mixing_gg0, 0.0); + + CMtest.need_auto_set(); + CMtest.auto_set(1.0, GlobalC::ucell); + EXPECT_EQ(CMtest.mixing_beta, 0.7); + EXPECT_EQ(CMtest.mixing->mixing_beta, 0.7); + EXPECT_EQ(CMtest.mixing_gg0, 0.0); + + GlobalC::ucell.atoms = new Atom[1]; + GlobalC::ucell.ntype = 1; + GlobalC::ucell.atoms[0].ncpp.psd = "Sc"; + CMtest.need_auto_set(); + CMtest.auto_set(1.0, GlobalC::ucell); + EXPECT_EQ(CMtest.mixing_gg0, 1.5); +} + +TEST_F(ChargeMixingTest, KerkerScreenRecipTest) +{ + Charge_Mixing CMtest; + CMtest.set_rhopw(&pw_basis); + GlobalV::NSPIN = 1; + GlobalC::ucell.tpiba = 1.0; + + CMtest.mixing_gg0 = 0.0; + std::complex* drhog = new std::complex[pw_basis.npw]; + std::complex* drhog_old = new std::complex[pw_basis.npw]; + double* drhor = new double[pw_basis.nrxx]; + double* drhor_ref = new double[pw_basis.nrxx]; + for (int i = 0; i < pw_basis.npw; ++i) + { + drhog_old[i] = drhog[i] = std::complex(1.0, 1.0); + } + CMtest.Kerker_screen_recip(drhog); + for (int i = 0; i < pw_basis.npw; ++i) + { + EXPECT_EQ(drhog[i], drhog_old[i]); + } + + // RECIPROCAL + CMtest.mixing_gg0 = 1.0; + CMtest.Kerker_screen_recip(drhog); + const double gg0 = std::pow(0.529177, 2); + for (int i = 0; i < pw_basis.npw; ++i) + { + std::complex ration = drhog[i] / drhog_old[i]; + double gg = this->pw_basis.gg[i]; + double ration_ref = std::max(gg / (gg + gg0), 0.1); + EXPECT_NEAR(ration.real(), ration_ref, 1e-10); + EXPECT_NEAR(ration.imag(), 0, 1e-10); + } + + // REAL + pw_basis.recip2real(drhog, drhor_ref); + pw_basis.recip2real(drhog_old, drhor); + + CMtest.mixing_gg0 = 0.0; + // nothing happens + CMtest.Kerker_screen_real(drhor); + + CMtest.mixing_gg0 = 1.0; + CMtest.Kerker_screen_real(drhor); + for (int i = 0; i < pw_basis.nrxx; ++i) + { + EXPECT_NEAR(drhor[i], drhor_ref[i], 1e-8); + } + + delete[] drhog; + delete[] drhog_old; + delete[] drhor; + delete[] drhor_ref; } +TEST_F(ChargeMixingTest, InnerDotTest) +{ + // REAL + Charge_Mixing CMtest; + CMtest.set_rhopw(&pw_basis); + GlobalV::NSPIN = 1; + std::vector drhor1(pw_basis.nrxx); + std::vector drhor2(pw_basis.nrxx); + for (int i = 0; i < pw_basis.nrxx; ++i) + { + drhor1[i] = 1.0; + drhor2[i] = double(i); + } + double inner = CMtest.inner_product_real(drhor1.data(), drhor2.data()); + EXPECT_NEAR(inner, 0.5 * pw_basis.nrxx * (pw_basis.nrxx - 1), 1e-8); + + // RECIPROCAL + GlobalC::ucell.tpiba2 = 1.0; + GlobalC::ucell.omega = 2.0; + + GlobalV::NSPIN = 1; + std::vector> drhog1(pw_basis.npw); + std::vector> drhog2(pw_basis.npw); + for (int i = 0; i < pw_basis.nrxx; ++i) + { + drhor1[i] = 0.0; + } + drhor1[2] = 1.0; + pw_basis.real2recip(drhor1.data(), drhog1.data()); + pw_basis.real2recip(drhor2.data(), drhog2.data()); + + inner = CMtest.inner_product_recip(drhog1.data(), drhog2.data()); + EXPECT_NEAR(inner, -0.3 * ModuleBase::e2 * ModuleBase::FOUR_PI, 1e-8); + + GlobalV::NSPIN = 2; + drhog1.resize(pw_basis.npw * GlobalV::NSPIN); + drhog2.resize(pw_basis.npw * GlobalV::NSPIN); + for (int i = 0; i < pw_basis.npw * GlobalV::NSPIN; ++i) + { + drhog1[i] = std::complex(1.0, double(i)); + drhog2[i] = std::complex(1.0, 1.0); + } + GlobalV::GAMMA_ONLY_PW = false; + inner = CMtest.inner_product_recip(drhog1.data(), drhog2.data()); + EXPECT_NEAR(inner, 236763.82650318215, 1e-8); + GlobalV::GAMMA_ONLY_PW = true; + inner = CMtest.inner_product_recip(drhog1.data(), drhog2.data()); + EXPECT_NEAR(inner, 236763.82650318215 * 2, 1e-8); + + GlobalV::NSPIN = 4; + drhog1.resize(pw_basis.npw * GlobalV::NSPIN); + drhog2.resize(pw_basis.npw * GlobalV::NSPIN); + for (int i = 0; i < pw_basis.npw * GlobalV::NSPIN; ++i) + { + drhog1[i] = std::complex(1.0, double(i)); + drhog2[i] = std::complex(1.0, 1.0); + } + + GlobalV::DOMAG = false; + GlobalV::DOMAG_Z = false; + inner = CMtest.inner_product_recip(drhog1.data(), drhog2.data()); + EXPECT_NEAR(inner, 28260.091995611871, 1e-8); + GlobalV::GAMMA_ONLY_PW = true; + GlobalV::DOMAG = true; + GlobalV::DOMAG_Z = true; + inner = CMtest.inner_product_recip(drhog1.data(), drhog2.data()); + EXPECT_NEAR(inner, 110668.61166927818, 1e-8); +} + +TEST_F(ChargeMixingTest, MixRhoTest) +{ + const int nspin = GlobalV::NSPIN = 1; + GlobalV::DOMAG_Z = false; + FUNC_TYPE = 3; + double beta = 0.7; + int dim = 1; + double gg0 = 0.0; + bool mixingtau = true; + std::string mode = "plain"; + const int nrxx = pw_basis.nrxx; + const int npw = pw_basis.npw; + charge._space_rho = new double[nspin * nrxx]; + charge._space_rho_save = new double[nspin * nrxx]; + charge._space_rhog = new std::complex[nspin * npw]; + charge._space_rhog_save = new std::complex[nspin * npw]; + charge._space_kin_r = new double[nspin * nrxx]; + charge._space_kin_r_save = new double[nspin * nrxx]; + charge.rho = new double*[nspin]; + charge.rhog = new std::complex*[nspin]; + charge.rho_save = new double*[nspin]; + charge.rhog_save = new std::complex*[nspin]; + charge.kin_r = new double*[nspin]; + charge.kin_r_save = new double*[nspin]; + for (int is = 0; is < nspin; is++) + { + charge.rho[is] = charge._space_rho + is * nrxx; + charge.rhog[is] = charge._space_rhog + is * npw; + charge.rho_save[is] = charge._space_rho_save + is * nrxx; + charge.rhog_save[is] = charge._space_rhog_save + is * npw; + charge.kin_r[is] = charge._space_kin_r + is * nrxx; + charge.kin_r_save[is] = charge._space_kin_r_save + is * nrxx; + } + std::vector real_ref(nspin * nrxx); + std::vector real_save_ref(nspin * nrxx); + std::vector> recip_ref(nspin * npw); + std::vector> recip_save_ref(nspin * npw); + for(int i = 0 ; i < nspin * npw; ++i) + { + recip_ref[i] = std::complex(double(i), 1.0); + recip_save_ref[i] = std::complex(double(i), 0.0); + } + for(int i = 0 ; i < nspin ; ++i) + { + pw_basis.recip2real(recip_ref.data() + i * npw, real_ref.data() + i * nrxx); + pw_basis.recip2real(recip_save_ref.data() + i * npw, real_save_ref.data() + i * nrxx); + } + //--------------------------------MAIN BODY-------------------------------- + // RECIPROCAL + Charge_Mixing CMtest_recip; + CMtest_recip.set_rhopw(&pw_basis); + GlobalV::SCF_THR_TYPE = 1; + CMtest_recip.set_mixing(mode, beta, dim, gg0, mixingtau); + CMtest_recip.mix_reset(); + for(int i = 0 ; i < nspin * npw; ++i) + { + charge._space_rhog[i] = recip_ref[i]; + charge._space_rhog_save[i] = recip_save_ref[i]; + } + for(int i = 0 ; i < nspin * nrxx; ++i) + { + charge._space_rho[i] = real_ref[i]; + charge._space_rho_save[i] = real_save_ref[i]; + } + CMtest_recip.mix_rho(&charge); + for(int is = 0 ; is < nspin; ++is) + { + for(int ir = 0 ; ir < nrxx ; ++ir) + { + EXPECT_NEAR(charge.rho_save[is][ir], real_ref[is*nrxx + ir], 1e-8); + } + for(int ig = 0; ig < npw ; ++ig) + { + EXPECT_NEAR(charge.rhog[is][ig].real(), recip_save_ref[is*npw + ig].real(), 1e-8); + EXPECT_NEAR(charge.rhog[is][ig].imag(), recip_save_ref[is*npw + ig].imag() + 0.7, 1e-8); + } + } + + // REAL + Charge_Mixing CMtest_real; + GlobalV::SCF_THR_TYPE = 2; + CMtest_real.set_rhopw(&pw_basis); + CMtest_real.set_mixing(mode, beta, dim, gg0, mixingtau); + CMtest_real.mix_reset(); + for(int i = 0 ; i < nspin * nrxx; ++i) + { + charge._space_rho[i] = real_ref[i]; + charge._space_rho_save[i] = real_save_ref[i]; + } + CMtest_recip.mix_rho(&charge); + for(int is = 0 ; is < nspin; ++is) + { + for(int ir = 0 ; ir < nrxx ; ++ir) + { + EXPECT_NEAR(charge.rho_save[is][ir], real_ref[is*nrxx + ir], 1e-8); + EXPECT_NEAR(charge.rho[is][ir], 0.3*real_save_ref[is*nrxx+ir] + 0.7*real_ref[is*nrxx+ir], 1e-8); + } + } + + //------------------------------------------------------------------------- + delete[] charge._space_rho; + delete[] charge._space_rho_save; + delete[] charge._space_rhog; + delete[] charge._space_rhog_save; + delete[] charge._space_kin_r; + delete[] charge._space_kin_r_save; + delete[] charge.rho; + delete[] charge.rhog; + delete[] charge.rho_save; + delete[] charge.rhog_save; + delete[] charge.kin_r; + delete[] charge.kin_r_save; +} #undef private diff --git a/source/module_esolver/esolver_ks.cpp b/source/module_esolver/esolver_ks.cpp index 0f63ac6de6..4c547183db 100644 --- a/source/module_esolver/esolver_ks.cpp +++ b/source/module_esolver/esolver_ks.cpp @@ -48,20 +48,6 @@ namespace ModuleESolver ///---------------------------------------------------------- p_chgmix = new Charge_Mixing(); p_chgmix->set_rhopw(this->pw_rho); - p_chgmix->set_mixing(INPUT.mixing_mode, - INPUT.mixing_beta, - INPUT.mixing_ndim, - INPUT.mixing_gg0, - INPUT.mixing_tau); - // using bandgap to auto set mixing_beta - if (std::abs(INPUT.mixing_beta + 10.0) < 1e-6) - { - p_chgmix->need_auto_set(); - } - else if (INPUT.mixing_beta > 1.0 || INPUT.mixing_beta < 0.0) - { - ModuleBase::WARNING("INPUT", "You'd better set mixing_beta to [0.0, 1.0]!"); - } ///---------------------------------------------------------- /// wavefunc @@ -85,6 +71,23 @@ namespace ModuleESolver void ESolver_KS::Init(Input& inp, UnitCell& ucell) { ESolver_FP::Init(inp,ucell); + + //------------------Charge Mixing------------------ + p_chgmix->set_mixing(GlobalV::MIXING_MODE, + GlobalV::MIXING_BETA, + GlobalV::MIXING_NDIM, + GlobalV::MIXING_GG0, + GlobalV::MIXING_TAU); + // using bandgap to auto set mixing_beta + if (std::abs(GlobalV::MIXING_BETA + 10.0) < 1e-6) + { + p_chgmix->need_auto_set(); + } + else if (GlobalV::MIXING_BETA > 1.0 || GlobalV::MIXING_BETA < 0.0) + { + ModuleBase::WARNING("INPUT", "You'd better set mixing_beta to [0.0, 1.0]!"); + } + #ifdef USE_PAW if(GlobalV::use_paw) { @@ -398,8 +401,8 @@ namespace ModuleESolver } p_chgmix->auto_set(bandgap_for_autoset, GlobalC::ucell); } - //conv_elec = this->estate.mix_rho(); - p_chgmix->mix_rho(iter, pelec->charge); + + p_chgmix->mix_rho(pelec->charge); //----------charge mixing done----------- } } diff --git a/source/module_esolver/esolver_ks_lcao.cpp b/source/module_esolver/esolver_ks_lcao.cpp index 9e0adb1cb1..d6d9c18651 100644 --- a/source/module_esolver/esolver_ks_lcao.cpp +++ b/source/module_esolver/esolver_ks_lcao.cpp @@ -501,11 +501,8 @@ void ESolver_KS_LCAO::Init_Basis_lcao(ORB_control& orb_con, Input& inp, UnitCell void ESolver_KS_LCAO::eachiterinit(const int istep, const int iter) { - - // mohan add 2010-07-16 - // used for pulay mixing. if (iter == 1) - this->p_chgmix->reset(); + this->p_chgmix->mix_reset(); // mohan update 2012-06-05 this->pelec->f_en.deband_harris = this->pelec->cal_delta_eband(); diff --git a/source/module_esolver/esolver_ks_pw.cpp b/source/module_esolver/esolver_ks_pw.cpp index 04ee43555f..9a7812bfa0 100644 --- a/source/module_esolver/esolver_ks_pw.cpp +++ b/source/module_esolver/esolver_ks_pw.cpp @@ -444,9 +444,8 @@ void ESolver_KS_PW::othercalculation(const int istep) template void ESolver_KS_PW::eachiterinit(const int istep, const int iter) { - // mohan add 2010-07-16 if (iter == 1) - this->p_chgmix->reset(); + this->p_chgmix->mix_reset(); // mohan move harris functional to here, 2012-06-05 // use 'rho(in)' and 'v_h and v_xc'(in) diff --git a/source/module_hamilt_pw/hamilt_pwdft/stress_func_kin.cpp b/source/module_hamilt_pw/hamilt_pwdft/stress_func_kin.cpp index 6e3a0aec8e..b4b2cd579f 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/stress_func_kin.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/stress_func_kin.cpp @@ -156,6 +156,7 @@ void Stress_Func::stress_kin(ModuleBase::matrix& sigma, delete[] gk[1]; delete[] gk[2]; delete[] gk; + delete[] kfac; ModuleBase::timer::tick("Stress_Func","stress_kin"); return; diff --git a/source/module_io/DEFAULT_VALUE.conf b/source/module_io/DEFAULT_VALUE.conf index 14377d1173..f04ac97887 100644 --- a/source/module_io/DEFAULT_VALUE.conf +++ b/source/module_io/DEFAULT_VALUE.conf @@ -121,7 +121,7 @@ occupations "smearing" smearing_method "fixed" smearing_sigma 0.01 - mixing_mode "pulay" + mixing_mode "broyden" mixing_beta -10.0 mixing_ndim 8 mixing_gg0 0.00 diff --git a/source/module_io/input.cpp b/source/module_io/input.cpp index 268f0eb019..5946b6ff21 100644 --- a/source/module_io/input.cpp +++ b/source/module_io/input.cpp @@ -296,7 +296,7 @@ void Input::Default(void) //---------------------------------------------------------- // charge mixing //---------------------------------------------------------- - mixing_mode = "pulay"; + mixing_mode = "broyden"; mixing_beta = -10.0; mixing_ndim = 8; mixing_gg0 = 0.00; // used in kerker method. mohan add 2014-09-27 diff --git a/source/module_io/input_conv.cpp b/source/module_io/input_conv.cpp index f27de037d7..10fed05f59 100644 --- a/source/module_io/input_conv.cpp +++ b/source/module_io/input_conv.cpp @@ -719,6 +719,13 @@ void Input_Conv::Convert(void) GlobalV::of_read_kernel = INPUT.of_read_kernel; GlobalV::of_kernel_file = INPUT.of_kernel_file; + // mixing parameters + GlobalV::MIXING_MODE = INPUT.mixing_mode; + GlobalV::MIXING_BETA = INPUT.mixing_beta; + GlobalV::MIXING_NDIM = INPUT.mixing_ndim; + GlobalV::MIXING_GG0 = INPUT.mixing_gg0; + GlobalV::MIXING_TAU = INPUT.mixing_tau; + ModuleBase::timer::tick("Input_Conv", "Convert"); return; } diff --git a/source/module_io/test/input_test.cpp b/source/module_io/test/input_test.cpp index 37bded9b4a..576378f882 100644 --- a/source/module_io/test/input_test.cpp +++ b/source/module_io/test/input_test.cpp @@ -150,7 +150,7 @@ TEST_F(InputTest, Default) EXPECT_EQ(INPUT.occupations,"smearing"); EXPECT_EQ(INPUT.smearing_method,"fixed"); EXPECT_DOUBLE_EQ(INPUT.smearing_sigma,0.01); - EXPECT_EQ(INPUT.mixing_mode,"pulay"); + EXPECT_EQ(INPUT.mixing_mode,"broyden"); EXPECT_DOUBLE_EQ(INPUT.mixing_beta,-10.0); EXPECT_EQ(INPUT.mixing_ndim,8); EXPECT_DOUBLE_EQ(INPUT.mixing_gg0,0.00); @@ -500,7 +500,7 @@ TEST_F(InputTest, Read) EXPECT_EQ(INPUT.occupations,"smearing"); EXPECT_EQ(INPUT.smearing_method,"gauss"); EXPECT_DOUBLE_EQ(INPUT.smearing_sigma,0.002); - EXPECT_EQ(INPUT.mixing_mode,"pulay"); + EXPECT_EQ(INPUT.mixing_mode,"broyden"); EXPECT_DOUBLE_EQ(INPUT.mixing_beta,0.7); EXPECT_EQ(INPUT.mixing_ndim,8); EXPECT_DOUBLE_EQ(INPUT.mixing_gg0,0.00); diff --git a/source/module_io/test/input_test_para.cpp b/source/module_io/test/input_test_para.cpp index 9c39723400..ee3cbdc499 100644 --- a/source/module_io/test/input_test_para.cpp +++ b/source/module_io/test/input_test_para.cpp @@ -156,7 +156,7 @@ TEST_F(InputParaTest,Bcast) // EXPECT_EQ(INPUT.occupations,"smearing"); EXPECT_EQ(INPUT.smearing_method,"fixed"); EXPECT_DOUBLE_EQ(INPUT.smearing_sigma,0.01); - EXPECT_EQ(INPUT.mixing_mode,"pulay"); + EXPECT_EQ(INPUT.mixing_mode,"broyden"); EXPECT_DOUBLE_EQ(INPUT.mixing_beta,-10.0); EXPECT_EQ(INPUT.mixing_ndim,8); EXPECT_DOUBLE_EQ(INPUT.mixing_gg0,0.00); diff --git a/source/module_io/test/parameter_pool_test.cpp b/source/module_io/test/parameter_pool_test.cpp index e4de830c62..6bd80d95ce 100644 --- a/source/module_io/test/parameter_pool_test.cpp +++ b/source/module_io/test/parameter_pool_test.cpp @@ -146,7 +146,7 @@ // // EXPECT_EQ(INPUT.occupations,"smearing"); // EXPECT_EQ(INPUT.smearing_method, "fixed"); // EXPECT_DOUBLE_EQ(INPUT.smearing_sigma, 0.01); -// EXPECT_EQ(INPUT.mixing_mode, "pulay"); +// EXPECT_EQ(INPUT.mixing_mode, "broyden"); // EXPECT_DOUBLE_EQ(INPUT.mixing_beta, -10.0); // EXPECT_EQ(INPUT.mixing_ndim, 8); // EXPECT_DOUBLE_EQ(INPUT.mixing_gg0, 0.00); diff --git a/source/module_io/test/support/INPUT b/source/module_io/test/support/INPUT index 44dd66d714..2db53dbb04 100644 --- a/source/module_io/test/support/INPUT +++ b/source/module_io/test/support/INPUT @@ -159,9 +159,9 @@ smearing_method gauss #type of smearing_method: gauss; fd; fixed; smearing_sigma 0.002 #energy range for smearing #Parameters (7.Charge Mixing) -mixing_type pulay #plain; pulay; broyden +mixing_type broyden #plain; pulay; broyden mixing_beta 0.7 #mixing parameter: 0 means no new charge -mixing_ndim 8 #mixing dimension in pulay +mixing_ndim 8 #mixing dimension in pulay or broyden mixing_gg0 0 #mixing parameter in kerker #Parameters (8.DOS) diff --git a/source/module_io/test/support/witestfile b/source/module_io/test/support/witestfile index f583487c4d..a600fb5c1c 100644 --- a/source/module_io/test/support/witestfile +++ b/source/module_io/test/support/witestfile @@ -156,9 +156,9 @@ smearing_method gauss #type of smearing_method: gauss; fd; fixed; smearing_sigma 0.002 #energy range for smearing #Parameters (7.Charge Mixing) -mixing_type pulay #plain; pulay; broyden +mixing_type broyden #plain; pulay; broyden mixing_beta 0.7 #mixing parameter: 0 means no new charge -mixing_ndim 8 #mixing dimension in pulay +mixing_ndim 8 #mixing dimension in pulay or broyden mixing_gg0 0 #mixing parameter in kerker #Parameters (8.DOS) diff --git a/source/module_io/test/write_input_test.cpp b/source/module_io/test/write_input_test.cpp index 3af8f3900f..5b1edd3a5b 100644 --- a/source/module_io/test/write_input_test.cpp +++ b/source/module_io/test/write_input_test.cpp @@ -176,9 +176,9 @@ TEST_F(write_input,print) EXPECT_THAT(output,testing::HasSubstr("smearing_sigma 0.002 #energy range for smearing")); EXPECT_THAT(output,testing::HasSubstr("")); EXPECT_THAT(output,testing::HasSubstr("#Parameters (7.Charge Mixing)")); - EXPECT_THAT(output,testing::HasSubstr("mixing_type pulay #plain; pulay; broyden")); + EXPECT_THAT(output,testing::HasSubstr("mixing_type broyden #plain; pulay; broyden")); EXPECT_THAT(output,testing::HasSubstr("mixing_beta 0.7 #mixing parameter: 0 means no new charge")); - EXPECT_THAT(output,testing::HasSubstr("mixing_ndim 8 #mixing dimension in pulay")); + EXPECT_THAT(output,testing::HasSubstr("mixing_ndim 8 #mixing dimension in pulay or broyden")); EXPECT_THAT(output,testing::HasSubstr("mixing_gg0 0 #mixing parameter in kerker")); EXPECT_THAT(output,testing::HasSubstr("mixing_tau 0 #whether to mix tau in mGGA calculation")); EXPECT_THAT(output,testing::HasSubstr("mixing_dftu 0 #whether to mix locale in DFT+U calculation")); diff --git a/source/module_io/write_input.cpp b/source/module_io/write_input.cpp index ad81d71b13..7ba5dbf273 100644 --- a/source/module_io/write_input.cpp +++ b/source/module_io/write_input.cpp @@ -242,7 +242,7 @@ ModuleBase::GlobalFunc::OUTP(ofs, "out_bandgap", out_bandgap, "if true, print ou ofs << "\n#Parameters (7.Charge Mixing)" << std::endl; ModuleBase::GlobalFunc::OUTP(ofs, "mixing_type", mixing_mode, "plain; pulay; broyden"); ModuleBase::GlobalFunc::OUTP(ofs, "mixing_beta", mixing_beta, "mixing parameter: 0 means no new charge"); - ModuleBase::GlobalFunc::OUTP(ofs, "mixing_ndim", mixing_ndim, "mixing dimension in pulay"); + ModuleBase::GlobalFunc::OUTP(ofs, "mixing_ndim", mixing_ndim, "mixing dimension in pulay or broyden"); ModuleBase::GlobalFunc::OUTP(ofs, "mixing_gg0", mixing_gg0, "mixing parameter in kerker"); ModuleBase::GlobalFunc::OUTP(ofs, "mixing_tau", mixing_tau, "whether to mix tau in mGGA calculation"); ModuleBase::GlobalFunc::OUTP(ofs, "mixing_dftu", mixing_dftu, "whether to mix locale in DFT+U calculation"); diff --git a/source/module_ri/CMakeLists.txt b/source/module_ri/CMakeLists.txt index 8ef3f56cc3..0bc54be3be 100644 --- a/source/module_ri/CMakeLists.txt +++ b/source/module_ri/CMakeLists.txt @@ -6,6 +6,7 @@ if (ENABLE_LIBRI) RI_2D_Comm.cpp exx_lip.cpp Mix_DMk_2D.cpp + Mix_Matrix.cpp ) if(ENABLE_LCAO) diff --git a/source/module_ri/Exx_LRI_interface.hpp b/source/module_ri/Exx_LRI_interface.hpp index 3a4317e98a..18df563c8b 100644 --- a/source/module_ri/Exx_LRI_interface.hpp +++ b/source/module_ri/Exx_LRI_interface.hpp @@ -58,22 +58,11 @@ void Exx_LRI_Interface::exx_beforescf(const K_Vectors& kv, const Charge_M exx_lri->mix_DMk_2D.set_nks(kv.nks, GlobalV::GAMMA_ONLY_LOCAL); if(GlobalC::exx_info.info_global.separate_loop) { - if(GlobalC::exx_info.info_global.mixing_beta_for_loop1==1.0) - exx_lri->mix_DMk_2D.set_mixing_mode(Mixing_Mode::No); - else - exx_lri->mix_DMk_2D.set_mixing_mode(Mixing_Mode::Plain) - .set_mixing_beta(GlobalC::exx_info.info_global.mixing_beta_for_loop1); + exx_lri->mix_DMk_2D.set_mixing(nullptr); } else { - if(chgmix.get_mixing_mode() == "plain") - exx_lri->mix_DMk_2D.set_mixing_mode(Mixing_Mode::Plain); - else if(chgmix.get_mixing_mode() == "pulay") - exx_lri->mix_DMk_2D.set_mixing_mode(Mixing_Mode::Pulay); - else - throw std::invalid_argument( - "mixing_mode = " + chgmix.get_mixing_mode() + ", mix_DMk_2D unsupported.\n" - + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + exx_lri->mix_DMk_2D.set_mixing(chgmix.mixing); } } // for exx two_level scf @@ -88,9 +77,6 @@ void Exx_LRI_Interface::exx_eachiterinit(const Local_Orbital_Charge& loc, { if (!GlobalC::exx_info.info_global.separate_loop && exx_lri->two_level_step) { - exx_lri->mix_DMk_2D.set_mixing_beta(chgmix.get_mixing_beta()); - if(chgmix.get_mixing_mode() == "pulay") - exx_lri->mix_DMk_2D.set_coef_pulay(iter, chgmix); const bool flag_restart = (iter==1) ? true : false; if(GlobalV::GAMMA_ONLY_LOCAL) exx_lri->mix_DMk_2D.mix(loc.dm_gamma, flag_restart); diff --git a/source/module_ri/Mix_DMk_2D.cpp b/source/module_ri/Mix_DMk_2D.cpp index ad56cdfdc6..ee11b27bb9 100644 --- a/source/module_ri/Mix_DMk_2D.cpp +++ b/source/module_ri/Mix_DMk_2D.cpp @@ -17,15 +17,15 @@ Mix_DMk_2D &Mix_DMk_2D::set_nks(const int nks, const bool gamma_only_in) return *this; } -Mix_DMk_2D &Mix_DMk_2D::set_mixing_mode(const Mixing_Mode mixing_mode) +Mix_DMk_2D &Mix_DMk_2D::set_mixing(Base_Mixing::Mixing* mixing_in) { - ModuleBase::TITLE("Mix_DMk_2D","set_mixing_mode"); + ModuleBase::TITLE("Mix_DMk_2D","set_mixing"); if(this->gamma_only) - for(Mix_Data &mix_one : this->mix_DMk_gamma) - mix_one.mixing_mode = mixing_mode; + for(Mix_Matrix &mix_one : this->mix_DMk_gamma) + mix_one.init(mixing_in); else - for(Mix_Data &mix_one : this->mix_DMk_k) - mix_one.mixing_mode = mixing_mode; + for(Mix_Matrix &mix_one : this->mix_DMk_k) + mix_one.init(mixing_in); return *this; } @@ -33,10 +33,10 @@ Mix_DMk_2D &Mix_DMk_2D::set_mixing_beta(const double mixing_beta) { ModuleBase::TITLE("Mix_DMk_2D","set_mixing_beta"); if(this->gamma_only) - for(Mix_Data &mix_one : this->mix_DMk_gamma) + for(Mix_Matrix &mix_one : this->mix_DMk_gamma) mix_one.mixing_beta = mixing_beta; else - for(Mix_Data &mix_one : this->mix_DMk_k) + for(Mix_Matrix &mix_one : this->mix_DMk_k) mix_one.mixing_beta = mixing_beta; return *this; } diff --git a/source/module_ri/Mix_DMk_2D.h b/source/module_ri/Mix_DMk_2D.h index 5c8d4114d6..2a8e0ce4bd 100644 --- a/source/module_ri/Mix_DMk_2D.h +++ b/source/module_ri/Mix_DMk_2D.h @@ -6,7 +6,8 @@ #ifndef MIX_DMK_2D_H #define MIX_DMK_2D_H -#include "Mix_Data.h" +#include "Mix_Matrix.h" +#include "module_base/module_mixing/mixing.h" #include "module_base/matrix.h" #include "module_base/complexmatrix.h" @@ -25,10 +26,10 @@ class Mix_DMk_2D /** * @brief Sets the mixing mode. - * @param mixing_mode Mixing mode. + * @param Mixing Mixing pointer. * @return Reference to the current object. */ - Mix_DMk_2D &set_mixing_mode(const Mixing_Mode mixing_mode); + Mix_DMk_2D &set_mixing(Base_Mixing::Mixing* mixing_in); /** * @brief Sets the mixing beta. @@ -37,16 +38,6 @@ class Mix_DMk_2D */ Mix_DMk_2D &set_mixing_beta(const double mixing_beta); - /** - * @brief Sets the pulay mixing coefficients from class Charge_Mixing. - * @tparam ChgMix Type of the charge mixing coefficient. - * @param iter Iteration step, start from 1. - * @param chr_mix Object of Charge_Mixing. - * @return Reference to the current object. - */ - template - Mix_DMk_2D &set_coef_pulay(const int iter, const ChgMix& chr_mix); - /** * @brief Mixes the double density matrix. * @param dm Double Density matrix. @@ -73,11 +64,9 @@ class Mix_DMk_2D std::vector get_DMk_k_out() const; private: - std::vector> mix_DMk_gamma; - std::vector> mix_DMk_k; + std::vector> mix_DMk_gamma; + std::vector> mix_DMk_k; bool gamma_only; }; -#include "Mix_DMk_2D.hpp" - #endif \ No newline at end of file diff --git a/source/module_ri/Mix_DMk_2D.hpp b/source/module_ri/Mix_DMk_2D.hpp deleted file mode 100644 index d24905fa15..0000000000 --- a/source/module_ri/Mix_DMk_2D.hpp +++ /dev/null @@ -1,25 +0,0 @@ -//======================= -// AUTHOR : Peize Lin -// DATE : 2023-05-09 -//======================= - -#include "Mix_DMk_2D.h" -#include "module_base/tool_title.h" - -#ifndef MIX_DMK_2D_HPP -#define MIX_DMK_2D_HPP - -template -Mix_DMk_2D& Mix_DMk_2D::set_coef_pulay(const int iter, const ChgMix& chr_mix) -{ - ModuleBase::TITLE("Mix_DMk_2D","set_coef_pulay"); - if(this->gamma_only) - for(Mix_Data &mix_one : this->mix_DMk_gamma) - mix_one.set_coef_pulay(iter, chr_mix); - else - for(Mix_Data &mix_one : this->mix_DMk_k) - mix_one.set_coef_pulay(iter, chr_mix); - return *this; -} - -#endif \ No newline at end of file diff --git a/source/module_ri/Mix_Data.h b/source/module_ri/Mix_Data.h deleted file mode 100644 index 8fd0339eed..0000000000 --- a/source/module_ri/Mix_Data.h +++ /dev/null @@ -1,50 +0,0 @@ -//======================= -// AUTHOR : Peize Lin -// DATE : 2023-05-09 -//======================= - -#ifndef MIX_DATA_H -#define MIX_DATA_H - -#include -#include - -enum class Mixing_Mode{No, Plain, Pulay}; - - class Charge_Mixing; - -template -class Mix_Data -{ -public: - Mixing_Mode mixing_mode = Mixing_Mode::No; - double mixing_beta = 1.0; - const Tdata &get_data_out() const { return this->data_out; } - - /** - * @brief Mixes the input data according to the set mixing mode. - * @param data_in Input data to be mixed. - * @param flag_restart Flag indicating whether restart mixing. - */ - void mix(const Tdata &data_in, const bool flag_restart); - - /** - * @brief Sets the pulay mixing coefficients from class Charge_Mixing. - * @tparam ChgMix Type of the charge mixing coefficient. - * @param iter Iteration step, start from 1. - * @param chr_mix Object of Charge_Mixing. - */ - template - void set_coef_pulay(const int iter, const ChgMix& chr_mix); - -private: - Tdata data_out; - std::deque data_pulay_list; - std::vector coef_pulay_list; - - void pulay_mixing(const Tdata &data_in, const bool flag_restart); -}; - -#include "Mix_Data.hpp" - -#endif \ No newline at end of file diff --git a/source/module_ri/Mix_Data.hpp b/source/module_ri/Mix_Data.hpp deleted file mode 100644 index cebd40b2fc..0000000000 --- a/source/module_ri/Mix_Data.hpp +++ /dev/null @@ -1,91 +0,0 @@ -//======================= -// AUTHOR : Peize Lin -// DATE : 2023-05-09 -//======================= - -#ifndef MIX_DATA_HPP -#define MIX_DATA_HPP - -#include "Mix_Data.h" -#include "module_base/tool_title.h" -#include "module_elecstate/module_charge/charge_mixing.h" - -template -void Mix_Data::mix(const Tdata &data_in, const bool flag_restart) -{ - ModuleBase::TITLE("Mix_Data","mix"); - switch(this->mixing_mode) - { - case Mixing_Mode::No: - this->data_out = data_in; - break; - case Mixing_Mode::Plain: - if(flag_restart) - this->data_out = data_in; - else - this->data_out = this->mixing_beta * data_in - + (1-this->mixing_beta) * this->data_out; - break; - case Mixing_Mode::Pulay: - this->pulay_mixing(data_in, flag_restart); - break; - default: - throw std::domain_error(std::string(__FILE__)+" line "+std::to_string(__LINE__)); break; - } -} - -template -void Mix_Data::pulay_mixing(const Tdata &data_in, const bool flag_restart) -{ - ModuleBase::TITLE("Mix_Data","pulay_mixing"); - if(flag_restart) - { - this->data_pulay_list.clear(); - this->data_out = data_in; - } - else - { - this->data_pulay_list.push_back( - this->mixing_beta * data_in - + (1-this->mixing_beta) * this->data_out); - //while(this->data_pulay_list.size() > this->coef_pulay_list.size()) - if(this->data_pulay_list.size() == 1+this->coef_pulay_list.size()) - this->data_pulay_list.pop_front(); - assert(this->data_pulay_list.size() == this->coef_pulay_list.size()); - assert(this->coef_pulay_list.size() > 0); - - this->data_out = this->coef_pulay_list[0] * this->data_pulay_list[0]; - for(std::size_t i=1; idata_pulay_list.size(); ++i) - this->data_out += this->coef_pulay_list[i] * this->data_pulay_list[i]; - } -} - -template -template -void Mix_Data::set_coef_pulay(const int iter, const ChgMix& chr_mix) -{ - ModuleBase::TITLE("Mix_Data","set_coef_pulay"); - const std::size_t coef_size = std::min(iter-1, chr_mix.get_mixing_ndim()); - assert(coef_size>=0); - this->coef_pulay_list.resize(coef_size); - if(coef_size==1) - { - this->coef_pulay_list[0] = 1; - } - else if(coef_size>1) - { - auto pos_mod = [](const int i, const int N) ->int { return (i%N+N)%N; }; - auto index = [&](const int i) -> int - { - const int alpha_size = coef_size-1; - const int alpha_begin = chr_mix.get_idstep() - alpha_size; - return pos_mod( alpha_begin+i, chr_mix.get_dstep() ); - }; - this->coef_pulay_list[0] = -chr_mix.get_alpha()[index(0)]; - for(std::size_t i=1; i<=coef_size-2; ++i) - this->coef_pulay_list[i] = ( chr_mix.get_alpha()[index(i-1)] - chr_mix.get_alpha()[index(i)] ); - this->coef_pulay_list[coef_size-1] = 1+chr_mix.get_alpha()[index(coef_size-2)]; - } -} - -#endif \ No newline at end of file diff --git a/source/module_ri/Mix_Matrix.cpp b/source/module_ri/Mix_Matrix.cpp new file mode 100644 index 0000000000..b93f0d7294 --- /dev/null +++ b/source/module_ri/Mix_Matrix.cpp @@ -0,0 +1,44 @@ +//======================= +// AUTHOR : Peize Lin +// DATE : 2023-05-09 +//======================= + +#ifndef MIX_DATA_HPP +#define MIX_DATA_HPP + +#include "Mix_Matrix.h" +#include "module_base/matrix.h" +#include "module_base/complexmatrix.h" +#include "module_base/tool_title.h" + +template +void Mix_Matrix::mix(const Tdata &data_in, const bool flag_restart) +{ + ModuleBase::TITLE("Mix_Matrix","mix"); + if(separate_loop) + { + this->mixing = new Base_Mixing::Plain_Mixing(this->mixing_beta); + } + + if(flag_restart) + { + this->data_out = data_in; + this->mixing->init_mixing_data(this->matrix_data, data_in.nc*data_in.nr, sizeof(*data_in.c)); + } + else + { + this->mixing->push_data(this->matrix_data, data_out.c, data_in.c, nullptr, false); + this->mixing->mix_data(this->matrix_data, data_out.c); + } + + if(separate_loop) + { + delete this->mixing; + this->mixing = nullptr; + } +} + +template class Mix_Matrix; +template class Mix_Matrix; + +#endif \ No newline at end of file diff --git a/source/module_ri/Mix_Matrix.h b/source/module_ri/Mix_Matrix.h new file mode 100644 index 0000000000..820a6c47f2 --- /dev/null +++ b/source/module_ri/Mix_Matrix.h @@ -0,0 +1,53 @@ +//======================= +// AUTHOR : Peize Lin +// DATE : 2023-05-09 +//======================= + +#ifndef MIX_MATRIX_H +#define MIX_MATRIX_H + +#include + +#include "module_base/module_mixing/mixing.h" +#include "module_base/module_mixing/plain_mixing.h" +template +class Mix_Matrix +{ + public: + /** + * @brief init Mix_Matrix with Mixing pointer + * + * @param mixing_in Mixing pointer + */ + void init(Base_Mixing::Mixing* mixing_in) + { + this->mixing = mixing_in; + if (this->mixing == nullptr) + this->separate_loop = true; + } + /** + * @brief Get the data out object + * + * @return const Tdata& + */ + const Tdata& get_data_out() const + { + return this->data_out; + } + + /** + * @brief Mixes the input data according to the set mixing mode. + * @param data_in Input data to be mixed. + * @param flag_restart Flag indicating whether restart mixing. + */ + void mix(const Tdata& data_in, const bool flag_restart); + + double mixing_beta = 1.0; + + private: + Tdata data_out; + Base_Mixing::Mixing* mixing = nullptr; + Base_Mixing::Mixing_Data matrix_data; + bool separate_loop = false; +}; +#endif \ No newline at end of file diff --git a/source/module_ri/RPA_LRI.hpp b/source/module_ri/RPA_LRI.hpp index a794b9b8f6..f6e57574fc 100644 --- a/source/module_ri/RPA_LRI.hpp +++ b/source/module_ri/RPA_LRI.hpp @@ -64,7 +64,7 @@ void RPA_LRI::cal_postSCF_exx(const Local_Orbital_Charge& loc, const Parallel_Orbitals& pv) { exx_lri_rpa.mix_DMk_2D.set_nks(kv.nks, GlobalV::GAMMA_ONLY_LOCAL); - exx_lri_rpa.mix_DMk_2D.set_mixing_mode(Mixing_Mode::No); + exx_lri_rpa.mix_DMk_2D.set_mixing(nullptr); if(GlobalV::GAMMA_ONLY_LOCAL) exx_lri_rpa.mix_DMk_2D.mix(loc.dm_gamma, true); else diff --git a/source/module_ri/test/CMakeLists.txt b/source/module_ri/test/CMakeLists.txt index 07b5e864d2..94c25481e3 100644 --- a/source/module_ri/test/CMakeLists.txt +++ b/source/module_ri/test/CMakeLists.txt @@ -4,5 +4,5 @@ remove_definitions(-D__ROCM) AddTest( TARGET dm_mixing_test LIBS base ${math_libs} device - SOURCES dm_mixing_test.cpp ../Mix_DMk_2D.cpp + SOURCES dm_mixing_test.cpp ../Mix_DMk_2D.cpp ../Mix_Matrix.cpp ) \ No newline at end of file diff --git a/source/module_ri/test/dm_mixing_test.cpp b/source/module_ri/test/dm_mixing_test.cpp index 6f0df94b4b..2274462324 100644 --- a/source/module_ri/test/dm_mixing_test.cpp +++ b/source/module_ri/test/dm_mixing_test.cpp @@ -1,269 +1,160 @@ -#include"gtest/gtest.h" #include "gmock/gmock.h" -#include "module_ri/Mix_Data.h" +#include "gtest/gtest.h" +#include "module_base/module_mixing/broyden_mixing.h" #include "module_ri/Mix_DMk_2D.h" - -class Mock_Charge_Mixing -{ -public: - MOCK_METHOD0(get_mixing_ndim, int()); - MOCK_METHOD0(get_idstep, int()); - MOCK_METHOD0(get_dstep, int()); - MOCK_METHOD0(get_alpha, double* ()); -}; - -class Charge_Mixing_Helper -{ -public: - Charge_Mixing_Helper(double mixing_beta, int mixing_ndim, int idstep, int dstep, double* alpha) : - mixing_beta(mixing_beta), mixing_ndim(mixing_ndim), idstep(idstep), dstep(dstep), alpha(alpha) {} - ~Charge_Mixing_Helper() {} - double mixing_beta; - int mixing_ndim; - int idstep; - int dstep; - double* alpha = nullptr; - int get_mixing_ndim() const { return this->mixing_ndim; } - int get_idstep() const { return this->idstep; } - int get_dstep() const { return this->dstep; } - void set_idstep(int idstep) { this->idstep = idstep; } - double* get_alpha() const { return this->alpha; } -}; - -class DM_Mixing_Test : public testing::Test -{ -protected: - int nbasis = 2; - int maxiter = 6; - // params for pulay mixing - double mixing_beta = 0.4; - int mixing_ndim = 4; - int dstep = 3; - double alpha[3] = {0.25, -0.5, 1 }; - - void init_test(); - - std::map> data_ref_double - = {std::make_pair(Mixing_Mode::No, std::vector{ ModuleBase::matrix(nbasis, nbasis)}), - std::make_pair(Mixing_Mode::Plain, std::vector{ ModuleBase::matrix(nbasis, nbasis)}), - std::make_pair(Mixing_Mode::Pulay, std::vector{ ModuleBase::matrix(nbasis, nbasis)})}; - - std::map> data_ref_complex - = { std::make_pair(Mixing_Mode::No, std::vector{ ModuleBase::ComplexMatrix(nbasis, nbasis)}), - std::make_pair(Mixing_Mode::Plain, std::vector{ ModuleBase::ComplexMatrix(nbasis, nbasis)}), - std::make_pair(Mixing_Mode::Pulay, std::vector{ ModuleBase::ComplexMatrix(nbasis, nbasis)}) }; - - // for distinguishing different iters - ModuleBase::matrix mat1_double = ModuleBase::matrix(nbasis, nbasis); - ModuleBase::ComplexMatrix mat1_complex = ModuleBase::ComplexMatrix(nbasis, nbasis); - - // for class Mix_Data - Mix_Data mix_data_double; - Mix_Data mix_data_complex; - - // for pulay mixing - std::vector simplemix_double; - std::vector simplemix_complex; -}; - -void DM_Mixing_Test::init_test() +#include "module_ri/Mix_Matrix.h" + +/************************************************ + * unit test of charge_mixing.cpp & Mix_DMk_2D.cpp + ***********************************************/ + +/** + * - Tested Functions: + * - Mix_Matrix::mix: + * mix the matrix data according to the set mixing mode. + * - Mix_DMk_2D::mix: + * mix the density matrix data according to the set mixing mode. + * + */ + +class DM_Mixing_Test : public ::testing::Test { - // set mixing_beta - this->mix_data_double.mixing_beta = this->mixing_beta; - this->mix_data_complex.mixing_beta = this->mixing_beta; - // allocate memory for each iter - for (auto mode : { Mixing_Mode::No, Mixing_Mode::Plain, Mixing_Mode::Pulay }) + public: + DM_Mixing_Test() { - this->data_ref_double[mode].resize(this->maxiter); - this->data_ref_double[mode][0] = ModuleBase::matrix(nbasis, nbasis); - this->data_ref_complex[mode].resize(this->maxiter); - this->data_ref_complex[mode][0] = ModuleBase::ComplexMatrix(nbasis, nbasis); - for (int i = 0;i < nbasis;++i) + mixing = new Base_Mixing::Broyden_Mixing(ndim, mixing_beta); + mix_data = std::vector(2); + mix_complexdata = std::vector(3); + mix_data[0].create(nr, nc); + mix_data[1].create(nr, nc); + for (int i = 0; i < nr; ++i) { - for(int j=0;jdata_ref_double[mode][0](i, j) = 0.1 * (i * nbasis + j + 1); - this->data_ref_complex[mode][0](i, j) = std::complex(0.1 * (i * nbasis + j + 1), -0.1 * (i * nbasis + j + 1)); - this->mat1_double(i, j) = 0.01; - this->mat1_complex(i, j) = std::complex(0.01, -0.01); + mix_data[0](i, j) = i * nc + j; + mix_data[1](i, j) = i * nc + j + 0.2; } } - } - - // init data_ref - for (int iter = 1;iter < this->maxiter;++iter) - { - ModuleBase::matrix& dm_in_double = this->data_ref_double[Mixing_Mode::No][iter]; - ModuleBase::ComplexMatrix& dm_in_complex = this->data_ref_complex[Mixing_Mode::No][iter]; - - // No: dm_in for each iter - dm_in_double = this->data_ref_double[Mixing_Mode::No][iter - 1] + mat1_double; - dm_in_complex = this->data_ref_complex[Mixing_Mode::No][iter - 1] + mat1_complex; - // Plain: beta*dm_in + (1-beta)*dm_out for each iter - this->data_ref_double[Mixing_Mode::Plain][iter] = dm_in_double * this->mixing_beta - + (1 - this->mixing_beta) * this->data_ref_double[Mixing_Mode::Plain][iter-1]; - this->data_ref_complex[Mixing_Mode::Plain][iter] = dm_in_complex * this->mixing_beta - + (1 - this->mixing_beta) * this->data_ref_complex[Mixing_Mode::Plain][iter-1]; - //Pulay: directly using alpha - this->simplemix_double.push_back(dm_in_double * this->mixing_beta - + (1 - this->mixing_beta) * this->data_ref_double[Mixing_Mode::Pulay][iter - 1]); - this->simplemix_complex.push_back(dm_in_complex * this->mixing_beta - + (1 - this->mixing_beta) * this->data_ref_complex[Mixing_Mode::Pulay][iter - 1]); - this->data_ref_double[Mixing_Mode::Pulay][iter] = this->simplemix_double[iter - 1]; - this->data_ref_complex[Mixing_Mode::Pulay][iter] = this->simplemix_complex[iter - 1]; - int mix_size = std::min(iter - 1, this->mixing_ndim); - int tmp_idstep = (iter + 1) % dstep; - for (int m = iter - 2;m > iter - 2 - mix_size;--m) + mix_complexdata[0].create(nr, nc); + mix_complexdata[1].create(nr, nc); + mix_complexdata[2].create(nr, nc); + for (int i = 0; i < nr; ++i) { - int alpha_index = (tmp_idstep + (dstep - mix_size)+ m ) % dstep; // dstep = mixing_ndim -1 - this->data_ref_double[Mixing_Mode::Pulay][iter] += this->alpha[alpha_index] * (this->simplemix_double[m + 1] - this->simplemix_double[m]); - this->data_ref_complex[Mixing_Mode::Pulay][iter] += this->alpha[alpha_index] * (this->simplemix_complex[m + 1] - this->simplemix_complex[m]); + for (int j = 0; j < nc; ++j) + { + mix_complexdata[0](i, j) = std::complex{double(i), double(j)}; + mix_complexdata[1](i, j) = std::complex{double(i), double(j) + 0.2}; + mix_complexdata[2](i, j) = std::complex{double(i) + 0.8, double(j)}; + } } - } -} - + }; + ~DM_Mixing_Test() + { + delete mixing; + }; + Base_Mixing::Mixing* mixing = nullptr; + const int nr = 2; + const int nc = 2; + const int ndim = 1; + const double mixing_beta = 0.3; + + protected: + std::vector mix_data; + std::vector mix_complexdata; +}; -// for class Mixing_data -TEST_F(DM_Mixing_Test, MixDataTest) +TEST_F(DM_Mixing_Test, Mix_Matrix) { - this->init_test(); - - // init mock - Charge_Mixing_Helper chr_mix(mixing_beta, mixing_ndim, 0, dstep, alpha); - Mock_Charge_Mixing mock_chr_mix; - - EXPECT_CALL(mock_chr_mix, get_mixing_ndim()).WillRepeatedly(testing::Invoke(&chr_mix, &Charge_Mixing_Helper::get_mixing_ndim)); - EXPECT_CALL(mock_chr_mix, get_idstep()).WillRepeatedly(testing::Invoke(&chr_mix, &Charge_Mixing_Helper::get_idstep)); - EXPECT_CALL(mock_chr_mix, get_dstep()).WillRepeatedly(testing::Invoke(&chr_mix, &Charge_Mixing_Helper::get_dstep)); - EXPECT_CALL(mock_chr_mix, get_alpha()).WillRepeatedly(testing::Invoke(&chr_mix, &Charge_Mixing_Helper::get_alpha)); + // Separete loop + Mix_Matrix mix_matrix; + mix_matrix.init(nullptr); + mix_matrix.mixing_beta = mixing_beta; + for (int istep = 0; istep < 2; ++istep) + { + mix_matrix.mix(mix_data[istep], (istep == 0)); + } - //1. double - for (auto mode : { Mixing_Mode::No, Mixing_Mode::Plain, Mixing_Mode::Pulay }) + ModuleBase::matrix data_out = mix_matrix.get_data_out(); + for (int i = 0; i < nr; ++i) { - this->mix_data_double.mixing_mode = mode; - for (int iter = 1;iter < this->maxiter;++iter) + for (int j = 0; j < nc; ++j) { - if (mode == Mixing_Mode::Pulay) - { - chr_mix.set_idstep(iter % dstep); - mix_data_double.set_coef_pulay(iter, chr_mix); - } - bool flag_restart = (iter == 1); - this->mix_data_double.mix(data_ref_double[Mixing_Mode::No][iter - 1], flag_restart); - ModuleBase::matrix data_out_double = mix_data_double.get_data_out(); - for (int i = 0;i < nbasis;++i) - for (int j = 0;j < nbasis;++j) - EXPECT_NEAR(data_out_double(i, j), data_ref_double[mode][iter - 1](i, j), 1e-8); + EXPECT_DOUBLE_EQ(data_out(i, j), (1 - mixing_beta) * mix_data[0](i, j) + mixing_beta * mix_data[1](i, j)); } } - // 2. complex - for (auto mode : { Mixing_Mode::No, Mixing_Mode::Plain, Mixing_Mode::Pulay }) + + // Broyden mix + Mix_Matrix mix_complexmatrix; + mix_complexmatrix.init(mixing); + mixing->coef = {1.1, -0.1}; + for (int istep = 0; istep < 3; ++istep) { - this->mix_data_complex.mixing_mode = mode; - for (int iter = 1;iter < this->maxiter;++iter) + mix_complexmatrix.mix(mix_complexdata[istep], (istep == 0)); + } + ModuleBase::ComplexMatrix com_data_out = mix_complexmatrix.get_data_out(); + for (int i = 0; i < nr; ++i) + { + for (int j = 0; j < nc; ++j) { - if (mode == Mixing_Mode::Pulay) - { - chr_mix.set_idstep(iter % dstep); - mix_data_complex.set_coef_pulay(iter, chr_mix); - } - bool flag_restart = (iter == 1); - this->mix_data_complex.mix(data_ref_complex[Mixing_Mode::No][iter - 1], flag_restart); - ModuleBase::ComplexMatrix data_out_complex = mix_data_complex.get_data_out(); - for (int i = 0;i < nbasis;++i) - for (int j = 0;j < nbasis;++j) - { - EXPECT_NEAR(data_out_complex(i, j).real(), data_ref_complex[mode][iter - 1](i, j).real(), 1e-8); - EXPECT_NEAR(data_out_complex(i, j).imag(), data_ref_complex[mode][iter - 1](i, j).imag(), 1e-8); - } - + std::complex first_step_result + = (1 - mixing_beta) * mix_complexdata[0](i, j) + mixing_beta * mix_complexdata[1](i, j); + std::complex second_step_result + = (1 - mixing_beta) * first_step_result + mixing_beta * mix_complexdata[2](i, j); + std::complex ref = second_step_result * mixing->coef[1] + first_step_result * mixing->coef[0]; + EXPECT_DOUBLE_EQ(com_data_out(i, j).real(), ref.real()); + EXPECT_DOUBLE_EQ(com_data_out(i, j).imag(), ref.imag()); } } - } -TEST_F(DM_Mixing_Test, MixDMk2D) +TEST_F(DM_Mixing_Test, Mix_DMk_2D) { - this->init_test(); - - // init mock - Charge_Mixing_Helper chr_mix(mixing_beta, mixing_ndim, 0, dstep, alpha); - Mock_Charge_Mixing mock_chr_mix; - - EXPECT_CALL(mock_chr_mix, get_mixing_ndim()).WillRepeatedly(testing::Invoke(&chr_mix, &Charge_Mixing_Helper::get_mixing_ndim)); - EXPECT_CALL(mock_chr_mix, get_idstep()).WillRepeatedly(testing::Invoke(&chr_mix, &Charge_Mixing_Helper::get_idstep)); - EXPECT_CALL(mock_chr_mix, get_dstep()).WillRepeatedly(testing::Invoke(&chr_mix, &Charge_Mixing_Helper::get_dstep)); - EXPECT_CALL(mock_chr_mix, get_alpha()).WillRepeatedly(testing::Invoke(&chr_mix, &Charge_Mixing_Helper::get_alpha)); - - //1. double - Mix_DMk_2D mix_dm_gamma_2d; - int nks = 1; - mix_dm_gamma_2d.set_nks(nks, true); - - for (auto mode : { Mixing_Mode::No, Mixing_Mode::Plain, Mixing_Mode::Pulay }) + //Gamma only + Mix_DMk_2D mix_dmk_gamma; + mix_dmk_gamma.set_nks(1, true); + mix_dmk_gamma.set_mixing(nullptr); + mix_dmk_gamma.set_mixing_beta(mixing_beta); + std::vector> dm_gamma(2); + dm_gamma[0] = std::vector(1); + dm_gamma[0][0] = mix_data[0]; + dm_gamma[1] = std::vector(1); + dm_gamma[1][0] = mix_data[1]; + for (int istep = 0; istep < 2; ++istep) { - mix_dm_gamma_2d.set_mixing_mode(mode); - mix_dm_gamma_2d.set_mixing_beta(this->mixing_beta); - for (int iter = 1;iter < this->maxiter;++iter) + mix_dmk_gamma.mix(dm_gamma[istep], (istep == 0)); + } + std::vector dm_gamma_out = mix_dmk_gamma.get_DMk_gamma_out(); + for (int i = 0; i < nr; ++i) + { + for (int j = 0; j < nc; ++j) { - if (mode == Mixing_Mode::Pulay) - { - chr_mix.set_idstep(iter % dstep); - mix_dm_gamma_2d.set_coef_pulay(iter, chr_mix); - } - - std::vector dm_gamma_in(nks); - for (int ik = 0;ik < nks;++ik) dm_gamma_in[ik] = this->data_ref_double[Mixing_Mode::No][iter-1]; - - bool flag_restart = (iter == 1); - mix_dm_gamma_2d.mix(dm_gamma_in, flag_restart); - - std::vector dm_gamma_out = mix_dm_gamma_2d.get_DMk_gamma_out(); - for (int ik = 0;ik < nks;++ik) - for (int i = 0;i < nbasis;++i) - for (int j = 0;j < nbasis;++j) - EXPECT_NEAR((*dm_gamma_out[ik])(i, j), data_ref_double[mode][iter - 1](i, j), 1e-8); + EXPECT_DOUBLE_EQ(dm_gamma_out[0][0](i, j), (1 - mixing_beta) * mix_data[0](i, j) + mixing_beta * mix_data[1](i, j)); } } - //2. complex - Mix_DMk_2D mix_dm_k_2d; - nks = 2; - mix_dm_k_2d.set_nks(nks, false); - - for (auto mode : { Mixing_Mode::No, Mixing_Mode::Plain, Mixing_Mode::Pulay }) + // not Gamma only + Mix_DMk_2D mix_dmk; + mix_dmk.set_nks(1, false); + mix_dmk.set_mixing(nullptr); + mix_dmk.set_mixing_beta(mixing_beta); + std::vector> dm(2); + dm[0] = std::vector(1); + dm[0][0] = mix_complexdata[0]; + dm[1] = std::vector(1); + dm[1][0] = mix_complexdata[1]; + for (int istep = 0; istep < 2; ++istep) { - mix_dm_k_2d.set_mixing_mode(mode); - mix_dm_k_2d.set_mixing_beta(this->mixing_beta); - for (int iter = 1;iter < this->maxiter;++iter) + mix_dmk.mix(dm[istep], (istep == 0)); + } + std::vector dm_out = mix_dmk.get_DMk_k_out(); + for (int i = 0; i < nr; ++i) + { + for (int j = 0; j < nc; ++j) { - if (mode == Mixing_Mode::Pulay) - { - chr_mix.set_idstep(iter % dstep); - mix_dm_k_2d.set_coef_pulay(iter, chr_mix); - } - - std::vector dm_k_in(nks); - for (int ik = 0;ik < nks;++ik) dm_k_in[ik] = this->data_ref_complex[Mixing_Mode::No][iter - 1]; - - bool flag_restart = (iter == 1); - mix_dm_k_2d.mix(dm_k_in, flag_restart); - - std::vector dm_k_out = mix_dm_k_2d.get_DMk_k_out(); - for (int ik = 0;ik < nks;++ik) - for (int i = 0;i < nbasis;++i) - for (int j = 0;j < nbasis;++j) - { - EXPECT_NEAR((*dm_k_out[ik])(i, j).real(), data_ref_complex[mode][iter - 1](i, j).real(), 1e-8); - EXPECT_NEAR((*dm_k_out[ik])(i, j).imag(), data_ref_complex[mode][iter - 1](i, j).imag(), 1e-8); - } + std::complex first_step_result + = (1 - mixing_beta) * mix_complexdata[0](i, j) + mixing_beta * mix_complexdata[1](i, j); + EXPECT_DOUBLE_EQ(dm_out[0][0](i, j).real(), first_step_result.real()); + EXPECT_DOUBLE_EQ(dm_out[0][0](i, j).imag(), first_step_result.imag()); } } - -} - -int main(int argc, char** argv) -{ - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/tests/deepks/601_PW_deepks_d_H2O/INPUT b/tests/deepks/601_PW_deepks_d_H2O/INPUT index ca3a961408..8cd4bf65e4 100644 --- a/tests/deepks/601_PW_deepks_d_H2O/INPUT +++ b/tests/deepks/601_PW_deepks_d_H2O/INPUT @@ -20,7 +20,7 @@ smearing_method gaussian smearing_sigma 0.1 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (6.File) diff --git a/tests/deepks/601_PW_deepks_d_H2O/README b/tests/deepks/601_PW_deepks_d_H2O/README index 9945e03bed..edbac8511e 100644 --- a/tests/deepks/601_PW_deepks_d_H2O/README +++ b/tests/deepks/601_PW_deepks_d_H2O/README @@ -6,5 +6,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay +*mixing_type broyden *mixing_beta 0.4 diff --git a/tests/deepks/601_PW_deepks_p_H2O/INPUT b/tests/deepks/601_PW_deepks_p_H2O/INPUT index f8137c5a34..93595ffd33 100644 --- a/tests/deepks/601_PW_deepks_p_H2O/INPUT +++ b/tests/deepks/601_PW_deepks_p_H2O/INPUT @@ -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.File) diff --git a/tests/deepks/601_PW_deepks_p_H2O/README b/tests/deepks/601_PW_deepks_p_H2O/README index 9945e03bed..edbac8511e 100644 --- a/tests/deepks/601_PW_deepks_p_H2O/README +++ b/tests/deepks/601_PW_deepks_p_H2O/README @@ -6,5 +6,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay +*mixing_type broyden *mixing_beta 0.4 diff --git a/tests/deepks/601_PW_deepks_s_H2O/INPUT b/tests/deepks/601_PW_deepks_s_H2O/INPUT index 4a0ad831db..9f8840ad7b 100644 --- a/tests/deepks/601_PW_deepks_s_H2O/INPUT +++ b/tests/deepks/601_PW_deepks_s_H2O/INPUT @@ -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.File) diff --git a/tests/deepks/601_PW_deepks_s_H2O/README b/tests/deepks/601_PW_deepks_s_H2O/README index 9945e03bed..edbac8511e 100644 --- a/tests/deepks/601_PW_deepks_s_H2O/README +++ b/tests/deepks/601_PW_deepks_s_H2O/README @@ -6,5 +6,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay +*mixing_type broyden *mixing_beta 0.4 diff --git a/tests/deepks/602_NO_deepks_d_H2O_scf_lda2pbe/INPUT b/tests/deepks/602_NO_deepks_d_H2O_scf_lda2pbe/INPUT index 8290c2d2c3..e83f234188 100644 --- a/tests/deepks/602_NO_deepks_d_H2O_scf_lda2pbe/INPUT +++ b/tests/deepks/602_NO_deepks_d_H2O_scf_lda2pbe/INPUT @@ -22,7 +22,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (6.File) diff --git a/tests/deepks/603_NO_deepks_CH4/INPUT b/tests/deepks/603_NO_deepks_CH4/INPUT index d68fcdae4c..88c140b038 100644 --- a/tests/deepks/603_NO_deepks_CH4/INPUT +++ b/tests/deepks/603_NO_deepks_CH4/INPUT @@ -26,7 +26,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 deepks_scf 1 diff --git a/tests/deepks/603_NO_deepks_H2O_bandgap/INPUT b/tests/deepks/603_NO_deepks_H2O_bandgap/INPUT index 5263cf9c8b..74ce7b0ba3 100644 --- a/tests/deepks/603_NO_deepks_H2O_bandgap/INPUT +++ b/tests/deepks/603_NO_deepks_H2O_bandgap/INPUT @@ -10,7 +10,7 @@ orbital_dir ../../PP_ORB basis_type lcao dft_functional pbe gamma_only 1 -mixing_type pulay +mixing_type broyden mixing_beta 0.400000 smearing_method gaussian smearing_sigma 0.020000 diff --git a/tests/deepks/603_NO_deepks_H2O_multik/INPUT b/tests/deepks/603_NO_deepks_H2O_multik/INPUT index f71b811609..18d203c96b 100644 --- a/tests/deepks/603_NO_deepks_H2O_multik/INPUT +++ b/tests/deepks/603_NO_deepks_H2O_multik/INPUT @@ -10,7 +10,7 @@ orbital_dir ../../PP_ORB basis_type lcao dft_functional pbe gamma_only 0 -mixing_type pulay +mixing_type broyden mixing_beta 0.400000 smearing_method gaussian smearing_sigma 0.020000 diff --git a/tests/deepks/603_NO_deepks_SiO2_bandgap_multik/INPUT b/tests/deepks/603_NO_deepks_SiO2_bandgap_multik/INPUT index a168f05633..fa62e537bb 100644 --- a/tests/deepks/603_NO_deepks_SiO2_bandgap_multik/INPUT +++ b/tests/deepks/603_NO_deepks_SiO2_bandgap_multik/INPUT @@ -10,7 +10,7 @@ scf_nmax 35 basis_type lcao dft_functional lda gamma_only 0 -mixing_type pulay +mixing_type broyden mixing_beta 0.400000 smearing_method gaussian smearing_sigma 0.020000 diff --git a/tests/deepks/603_NO_deepks_ethanol/INPUT b/tests/deepks/603_NO_deepks_ethanol/INPUT index 62a127fb94..05a4fc3595 100644 --- a/tests/deepks/603_NO_deepks_ethanol/INPUT +++ b/tests/deepks/603_NO_deepks_ethanol/INPUT @@ -23,7 +23,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (6.File) diff --git a/tests/deepks/603_NO_deepks_watertrimer/INPUT b/tests/deepks/603_NO_deepks_watertrimer/INPUT index 69ca690011..86e6cd48ea 100644 --- a/tests/deepks/603_NO_deepks_watertrimer/INPUT +++ b/tests/deepks/603_NO_deepks_watertrimer/INPUT @@ -10,7 +10,7 @@ scf_nmax 50 basis_type lcao dft_functional lda gamma_only 1 -mixing_type pulay +mixing_type broyden mixing_beta 0.400000 nbands 18 smearing_method gaussian diff --git a/tests/integrate/101_PW_15_f_pseudopots/INPUT b/tests/integrate/101_PW_15_f_pseudopots/INPUT index 1acfc35502..0e0bc273d2 100644 --- a/tests/integrate/101_PW_15_f_pseudopots/INPUT +++ b/tests/integrate/101_PW_15_f_pseudopots/INPUT @@ -20,6 +20,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/101_PW_15_f_pseudopots/README b/tests/integrate/101_PW_15_f_pseudopots/README index 773abcdc3c..a160db7610 100644 --- a/tests/integrate/101_PW_15_f_pseudopots/README +++ b/tests/integrate/101_PW_15_f_pseudopots/README @@ -1,5 +1,5 @@ This test for: *fcc Ce *SG15 pseudopotential containing f electron -*mixing_type pulay +*mixing_type broyden *mixing_beta 0.7 diff --git a/tests/integrate/101_PW_15_lowz/INPUT b/tests/integrate/101_PW_15_lowz/INPUT index 57ebe6fdfb..fda37553da 100644 --- a/tests/integrate/101_PW_15_lowz/INPUT +++ b/tests/integrate/101_PW_15_lowz/INPUT @@ -22,7 +22,7 @@ smearing_method fd smearing_sigma 0.1 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 nx 24 diff --git a/tests/integrate/101_PW_15_pseudopots/INPUT b/tests/integrate/101_PW_15_pseudopots/INPUT index d84cc13f3b..a2944455c4 100644 --- a/tests/integrate/101_PW_15_pseudopots/INPUT +++ b/tests/integrate/101_PW_15_pseudopots/INPUT @@ -21,5 +21,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/101_PW_15_pseudopots/README b/tests/integrate/101_PW_15_pseudopots/README index 8c54a94ef3..a90db711bb 100644 --- a/tests/integrate/101_PW_15_pseudopots/README +++ b/tests/integrate/101_PW_15_pseudopots/README @@ -1,5 +1,5 @@ This test for: *Si-diamond *sg15 pseudopotential -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/101_PW_15_pseudopots_LDA/INPUT b/tests/integrate/101_PW_15_pseudopots_LDA/INPUT index 63311248e6..d8d0178ab1 100644 --- a/tests/integrate/101_PW_15_pseudopots_LDA/INPUT +++ b/tests/integrate/101_PW_15_pseudopots_LDA/INPUT @@ -21,7 +21,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 dft_functional pz diff --git a/tests/integrate/101_PW_15_pseudopots_LDA/README b/tests/integrate/101_PW_15_pseudopots_LDA/README index 8c54a94ef3..a90db711bb 100644 --- a/tests/integrate/101_PW_15_pseudopots_LDA/README +++ b/tests/integrate/101_PW_15_pseudopots_LDA/README @@ -1,5 +1,5 @@ This test for: *Si-diamond *sg15 pseudopotential -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/101_PW_15_pseudopots_LibxcLDA/INPUT b/tests/integrate/101_PW_15_pseudopots_LibxcLDA/INPUT index bd7a0fd445..96a7d117e1 100644 --- a/tests/integrate/101_PW_15_pseudopots_LibxcLDA/INPUT +++ b/tests/integrate/101_PW_15_pseudopots_LibxcLDA/INPUT @@ -21,7 +21,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 dft_functional XC_LDA_X+XC_LDA_C_PZ diff --git a/tests/integrate/101_PW_15_pseudopots_LibxcLDA/README b/tests/integrate/101_PW_15_pseudopots_LibxcLDA/README index 8c54a94ef3..a90db711bb 100644 --- a/tests/integrate/101_PW_15_pseudopots_LibxcLDA/README +++ b/tests/integrate/101_PW_15_pseudopots_LibxcLDA/README @@ -1,5 +1,5 @@ This test for: *Si-diamond *sg15 pseudopotential -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/101_PW_OU_pseudopots/INPUT b/tests/integrate/101_PW_OU_pseudopots/INPUT index dbe06b09dd..94d4346330 100644 --- a/tests/integrate/101_PW_OU_pseudopots/INPUT +++ b/tests/integrate/101_PW_OU_pseudopots/INPUT @@ -21,7 +21,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 cal_force 1 diff --git a/tests/integrate/101_PW_VW_pseudopots/INPUT b/tests/integrate/101_PW_VW_pseudopots/INPUT index b8094f4126..746a32b8ce 100644 --- a/tests/integrate/101_PW_VW_pseudopots/INPUT +++ b/tests/integrate/101_PW_VW_pseudopots/INPUT @@ -21,6 +21,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/101_PW_blps_pseudopots/INPUT b/tests/integrate/101_PW_blps_pseudopots/INPUT index 2fc2e5c232..decaeb9d91 100644 --- a/tests/integrate/101_PW_blps_pseudopots/INPUT +++ b/tests/integrate/101_PW_blps_pseudopots/INPUT @@ -22,5 +22,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/101_PW_blps_pseudopots/README b/tests/integrate/101_PW_blps_pseudopots/README index c33728c7d3..30643c29d3 100644 --- a/tests/integrate/101_PW_blps_pseudopots/README +++ b/tests/integrate/101_PW_blps_pseudopots/README @@ -1,5 +1,5 @@ This test for: *Si-diamond *BLPS (Bulk local pseudopotential) -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/101_PW_upf100_Al_pseudopots/INPUT b/tests/integrate/101_PW_upf100_Al_pseudopots/INPUT index 64a463811f..459347bea3 100644 --- a/tests/integrate/101_PW_upf100_Al_pseudopots/INPUT +++ b/tests/integrate/101_PW_upf100_Al_pseudopots/INPUT @@ -21,5 +21,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/101_PW_upf201_Al_pseudopots/INPUT b/tests/integrate/101_PW_upf201_Al_pseudopots/INPUT index fd4f881197..8a3a962f7a 100644 --- a/tests/integrate/101_PW_upf201_Al_pseudopots/INPUT +++ b/tests/integrate/101_PW_upf201_Al_pseudopots/INPUT @@ -21,5 +21,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/101_PW_upf201_Al_pseudopots/README b/tests/integrate/101_PW_upf201_Al_pseudopots/README index aec0a51874..eb66dbf457 100644 --- a/tests/integrate/101_PW_upf201_Al_pseudopots/README +++ b/tests/integrate/101_PW_upf201_Al_pseudopots/README @@ -1,5 +1,5 @@ This test for: *Al-fcc *upf201 pseudopotential -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/101_PW_upf201_Eu_pseudopots/INPUT b/tests/integrate/101_PW_upf201_Eu_pseudopots/INPUT index bff204fd90..19bb36bf6a 100644 --- a/tests/integrate/101_PW_upf201_Eu_pseudopots/INPUT +++ b/tests/integrate/101_PW_upf201_Eu_pseudopots/INPUT @@ -14,5 +14,5 @@ basis_type pw smearing_method gauss smearing_sigma 0.002 -mixing_type pulay // about charge mixing +mixing_type broyden // about charge mixing mixing_beta 0.7 diff --git a/tests/integrate/101_PW_upf201_blps_pseudopots/INPUT b/tests/integrate/101_PW_upf201_blps_pseudopots/INPUT index 31855196ab..e53d3ae6d8 100644 --- a/tests/integrate/101_PW_upf201_blps_pseudopots/INPUT +++ b/tests/integrate/101_PW_upf201_blps_pseudopots/INPUT @@ -18,5 +18,5 @@ smearing_method gauss smearing_sigma 0.0074 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/101_PW_upf201_pseudopots/INPUT b/tests/integrate/101_PW_upf201_pseudopots/INPUT index d84cc13f3b..a2944455c4 100644 --- a/tests/integrate/101_PW_upf201_pseudopots/INPUT +++ b/tests/integrate/101_PW_upf201_pseudopots/INPUT @@ -21,5 +21,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/101_PW_upf201_pseudopots/README b/tests/integrate/101_PW_upf201_pseudopots/README index c67e544f9e..a122821854 100644 --- a/tests/integrate/101_PW_upf201_pseudopots/README +++ b/tests/integrate/101_PW_upf201_pseudopots/README @@ -1,5 +1,5 @@ This test for: *Si-diamond *upf201 pseudopotential -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/101_PW_upf201_upf100_pseudopots/INPUT b/tests/integrate/101_PW_upf201_upf100_pseudopots/INPUT index 31855196ab..e53d3ae6d8 100644 --- a/tests/integrate/101_PW_upf201_upf100_pseudopots/INPUT +++ b/tests/integrate/101_PW_upf201_upf100_pseudopots/INPUT @@ -18,5 +18,5 @@ smearing_method gauss smearing_sigma 0.0074 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/102_PW_BPCG/INPUT b/tests/integrate/102_PW_BPCG/INPUT index 40cd9894fc..e6e0327ceb 100644 --- a/tests/integrate/102_PW_BPCG/INPUT +++ b/tests/integrate/102_PW_BPCG/INPUT @@ -29,6 +29,6 @@ cal_force 1 cal_stress 1 #test_stress 1 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 mixing_gg0 1.5 diff --git a/tests/integrate/102_PW_BPCG/README b/tests/integrate/102_PW_BPCG/README index c0ee456189..b8f97be67a 100644 --- a/tests/integrate/102_PW_BPCG/README +++ b/tests/integrate/102_PW_BPCG/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver bpcg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.4 diff --git a/tests/integrate/103_PW_15_CS_CF/INPUT b/tests/integrate/103_PW_15_CS_CF/INPUT index 8793d0a6ce..c783334fe8 100644 --- a/tests/integrate/103_PW_15_CS_CF/INPUT +++ b/tests/integrate/103_PW_15_CS_CF/INPUT @@ -28,6 +28,6 @@ cal_force 1 cal_stress 1 #test_stress 1 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 mixing_gg0 1.5 diff --git a/tests/integrate/103_PW_15_CS_CF/README b/tests/integrate/103_PW_15_CS_CF/README index 841c845d53..84a084c7b0 100644 --- a/tests/integrate/103_PW_15_CS_CF/README +++ b/tests/integrate/103_PW_15_CS_CF/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.4 diff --git a/tests/integrate/103_PW_15_CS_CF_bspline/INPUT b/tests/integrate/103_PW_15_CS_CF_bspline/INPUT index fe96013582..b4034e604b 100644 --- a/tests/integrate/103_PW_15_CS_CF_bspline/INPUT +++ b/tests/integrate/103_PW_15_CS_CF_bspline/INPUT @@ -28,7 +28,7 @@ cal_force 1 cal_stress 1 #test_stress 1 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 mixing_gg0 1.5 nbspline 20 diff --git a/tests/integrate/103_PW_15_CS_CF_bspline/README b/tests/integrate/103_PW_15_CS_CF_bspline/README index aa31ae76af..eb210a33f3 100644 --- a/tests/integrate/103_PW_15_CS_CF_bspline/README +++ b/tests/integrate/103_PW_15_CS_CF_bspline/README @@ -6,6 +6,6 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.4 *nbspline 20 diff --git a/tests/integrate/103_PW_OU_CS_CF/INPUT b/tests/integrate/103_PW_OU_CS_CF/INPUT index dec437cf31..9b68f4388f 100644 --- a/tests/integrate/103_PW_OU_CS_CF/INPUT +++ b/tests/integrate/103_PW_OU_CS_CF/INPUT @@ -30,6 +30,6 @@ cal_force 1 cal_stress 1 #test_stress 1 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 mixing_gg0 1.5 diff --git a/tests/integrate/103_PW_OU_CS_CF/README b/tests/integrate/103_PW_OU_CS_CF/README index b7ab2304fe..85c92533a6 100644 --- a/tests/integrate/103_PW_OU_CS_CF/README +++ b/tests/integrate/103_PW_OU_CS_CF/README @@ -5,5 +5,5 @@ This test for: *dojo pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.4 diff --git a/tests/integrate/104_PW_AF_magnetic/INPUT b/tests/integrate/104_PW_AF_magnetic/INPUT index f387898f40..ce42b39b6d 100644 --- a/tests/integrate/104_PW_AF_magnetic/INPUT +++ b/tests/integrate/104_PW_AF_magnetic/INPUT @@ -18,7 +18,7 @@ out_chg 0 smearing_method gaussian smearing_sigma 0.07 -mixing_type pulay +mixing_type broyden mixing_beta 0.5 mixing_ndim 10 diff --git a/tests/integrate/104_PW_FM_magnetic/INPUT b/tests/integrate/104_PW_FM_magnetic/INPUT index f387898f40..ce42b39b6d 100644 --- a/tests/integrate/104_PW_FM_magnetic/INPUT +++ b/tests/integrate/104_PW_FM_magnetic/INPUT @@ -18,7 +18,7 @@ out_chg 0 smearing_method gaussian smearing_sigma 0.07 -mixing_type pulay +mixing_type broyden mixing_beta 0.5 mixing_ndim 10 diff --git a/tests/integrate/104_PW_NC_magnetic/INPUT b/tests/integrate/104_PW_NC_magnetic/INPUT index 0ef3d0b935..622af75b86 100644 --- a/tests/integrate/104_PW_NC_magnetic/INPUT +++ b/tests/integrate/104_PW_NC_magnetic/INPUT @@ -18,7 +18,7 @@ noncolin 1 smearing_method gaussian smearing_sigma 0.07 -mixing_type pulay +mixing_type broyden mixing_beta 0.5 mixing_ndim 10 diff --git a/tests/integrate/105_PW_FD_smearing/INPUT b/tests/integrate/105_PW_FD_smearing/INPUT index c77c8b4524..aea44c4a4c 100644 --- a/tests/integrate/105_PW_FD_smearing/INPUT +++ b/tests/integrate/105_PW_FD_smearing/INPUT @@ -21,6 +21,6 @@ smearing_method fd smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.6 mixing_gg0 2 diff --git a/tests/integrate/105_PW_GA_smearing/INPUT b/tests/integrate/105_PW_GA_smearing/INPUT index bb4dfa4d7c..149e0a585a 100644 --- a/tests/integrate/105_PW_GA_smearing/INPUT +++ b/tests/integrate/105_PW_GA_smearing/INPUT @@ -21,6 +21,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 mixing_gg0 1.5 diff --git a/tests/integrate/106_PW_PK_chargemixing/INPUT b/tests/integrate/106_PW_PK_chargemixing/INPUT index 18729bf78e..2132fca512 100644 --- a/tests/integrate/106_PW_PK_chargemixing/INPUT +++ b/tests/integrate/106_PW_PK_chargemixing/INPUT @@ -21,7 +21,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/106_PW_PU_chargemixing/INPUT b/tests/integrate/106_PW_PU_chargemixing/INPUT index ec1d7406d7..0a3df08fa0 100644 --- a/tests/integrate/106_PW_PU_chargemixing/INPUT +++ b/tests/integrate/106_PW_PU_chargemixing/INPUT @@ -21,6 +21,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type pulay mixing_beta 0.7 diff --git a/tests/integrate/107_PW_CHG_mismatch/INPUT b/tests/integrate/107_PW_CHG_mismatch/INPUT index 4a2a9c180f..343b74c6a3 100644 --- a/tests/integrate/107_PW_CHG_mismatch/INPUT +++ b/tests/integrate/107_PW_CHG_mismatch/INPUT @@ -25,5 +25,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/108_PW_RE/INPUT b/tests/integrate/108_PW_RE/INPUT index 08e194ee7d..d57d243047 100644 --- a/tests/integrate/108_PW_RE/INPUT +++ b/tests/integrate/108_PW_RE/INPUT @@ -19,7 +19,7 @@ cal_force 1 force_thr_ev 1.0e-3 ks_solver cg -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 pseudo_dir ../../PP_ORB diff --git a/tests/integrate/108_PW_RE_MB/INPUT b/tests/integrate/108_PW_RE_MB/INPUT index b3625749e9..b83dea68c6 100644 --- a/tests/integrate/108_PW_RE_MB/INPUT +++ b/tests/integrate/108_PW_RE_MB/INPUT @@ -26,7 +26,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (6.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.5 relax_new 0 diff --git a/tests/integrate/108_PW_RE_MB/README b/tests/integrate/108_PW_RE_MB/README index 2241bbce25..b7c389f4c2 100644 --- a/tests/integrate/108_PW_RE_MB/README +++ b/tests/integrate/108_PW_RE_MB/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *relax_method bfgs -*mixing_type pulay +*mixing_type broyden *mixing_beta 0.5 diff --git a/tests/integrate/108_PW_RE_MG/INPUT b/tests/integrate/108_PW_RE_MG/INPUT index 1a05ef9b48..af7cac0310 100644 --- a/tests/integrate/108_PW_RE_MG/INPUT +++ b/tests/integrate/108_PW_RE_MG/INPUT @@ -26,7 +26,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (6.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.5 relax_new 0 diff --git a/tests/integrate/108_PW_RE_MG/README b/tests/integrate/108_PW_RE_MG/README index a730aa68ef..c0dc3300a0 100644 --- a/tests/integrate/108_PW_RE_MG/README +++ b/tests/integrate/108_PW_RE_MG/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *relax_method cg -*mixing_type pulay +*mixing_type broyden *mixing_beta 0.5 diff --git a/tests/integrate/109_PW_CR/INPUT b/tests/integrate/109_PW_CR/INPUT index ddbbfa027a..7db59dbd28 100644 --- a/tests/integrate/109_PW_CR/INPUT +++ b/tests/integrate/109_PW_CR/INPUT @@ -19,6 +19,6 @@ cal_force 1 force_thr_ev 1.0e-3 #ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/109_PW_CR/README b/tests/integrate/109_PW_CR/README index 4cd6861ff1..2b9f8142c9 100644 --- a/tests/integrate/109_PW_CR/README +++ b/tests/integrate/109_PW_CR/README @@ -5,5 +5,5 @@ This test for: cell-relax *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/109_PW_CR_fix_a/INPUT b/tests/integrate/109_PW_CR_fix_a/INPUT index 26a6074964..cd52204c96 100644 --- a/tests/integrate/109_PW_CR_fix_a/INPUT +++ b/tests/integrate/109_PW_CR_fix_a/INPUT @@ -20,7 +20,7 @@ stress_thr 1e-6 cal_force 1 force_thr_ev 1.0e-3 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/109_PW_CR_fix_a/README b/tests/integrate/109_PW_CR_fix_a/README index 51f7f09791..ece822ecbf 100644 --- a/tests/integrate/109_PW_CR_fix_a/README +++ b/tests/integrate/109_PW_CR_fix_a/README @@ -6,5 +6,5 @@ This test for: cell-relax *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/109_PW_CR_fix_ab/INPUT b/tests/integrate/109_PW_CR_fix_ab/INPUT index 69589c30cf..4d9b90c73c 100644 --- a/tests/integrate/109_PW_CR_fix_ab/INPUT +++ b/tests/integrate/109_PW_CR_fix_ab/INPUT @@ -20,7 +20,7 @@ stress_thr 1e-6 cal_force 1 force_thr_ev 1.0e-3 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/109_PW_CR_fix_ab/README b/tests/integrate/109_PW_CR_fix_ab/README index 762919a64b..3e6942ba21 100644 --- a/tests/integrate/109_PW_CR_fix_ab/README +++ b/tests/integrate/109_PW_CR_fix_ab/README @@ -6,5 +6,5 @@ This test for: cell-relax *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/109_PW_CR_fix_abc/INPUT b/tests/integrate/109_PW_CR_fix_abc/INPUT index 06b2e68478..e858f70d25 100644 --- a/tests/integrate/109_PW_CR_fix_abc/INPUT +++ b/tests/integrate/109_PW_CR_fix_abc/INPUT @@ -19,7 +19,7 @@ stress_thr 1e-6 cal_force 1 force_thr_ev 1.0e-3 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/109_PW_CR_fix_abc/README b/tests/integrate/109_PW_CR_fix_abc/README index c167c14902..d09a61c0c9 100644 --- a/tests/integrate/109_PW_CR_fix_abc/README +++ b/tests/integrate/109_PW_CR_fix_abc/README @@ -6,5 +6,5 @@ This test for: cell-relax *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/109_PW_CR_fix_ac/INPUT b/tests/integrate/109_PW_CR_fix_ac/INPUT index b1952b873e..d765b5784a 100644 --- a/tests/integrate/109_PW_CR_fix_ac/INPUT +++ b/tests/integrate/109_PW_CR_fix_ac/INPUT @@ -20,7 +20,7 @@ stress_thr 1e-6 cal_force 1 force_thr_ev 1.0e-3 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/109_PW_CR_fix_ac/README b/tests/integrate/109_PW_CR_fix_ac/README index ecfa404b70..df229e0ae5 100644 --- a/tests/integrate/109_PW_CR_fix_ac/README +++ b/tests/integrate/109_PW_CR_fix_ac/README @@ -6,5 +6,5 @@ This test for: cell-relax *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/109_PW_CR_fix_b/INPUT b/tests/integrate/109_PW_CR_fix_b/INPUT index 2300954809..39d2fdde1e 100644 --- a/tests/integrate/109_PW_CR_fix_b/INPUT +++ b/tests/integrate/109_PW_CR_fix_b/INPUT @@ -20,7 +20,7 @@ stress_thr 1e-6 cal_force 1 force_thr_ev 1.0e-3 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/109_PW_CR_fix_b/README b/tests/integrate/109_PW_CR_fix_b/README index 752aa130fc..5d0b29cfee 100644 --- a/tests/integrate/109_PW_CR_fix_b/README +++ b/tests/integrate/109_PW_CR_fix_b/README @@ -6,5 +6,5 @@ This test for: cell-relax *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/109_PW_CR_fix_bc/INPUT b/tests/integrate/109_PW_CR_fix_bc/INPUT index f9b524f305..db2fbe29ed 100644 --- a/tests/integrate/109_PW_CR_fix_bc/INPUT +++ b/tests/integrate/109_PW_CR_fix_bc/INPUT @@ -20,7 +20,7 @@ stress_thr 1e-6 cal_force 1 force_thr_ev 1.0e-3 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/109_PW_CR_fix_bc/README b/tests/integrate/109_PW_CR_fix_bc/README index 0665411292..de1bc30164 100644 --- a/tests/integrate/109_PW_CR_fix_bc/README +++ b/tests/integrate/109_PW_CR_fix_bc/README @@ -6,5 +6,5 @@ This test for: cell-relax *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/109_PW_CR_fix_c/INPUT b/tests/integrate/109_PW_CR_fix_c/INPUT index 1a1bdb611d..8afb54dc27 100644 --- a/tests/integrate/109_PW_CR_fix_c/INPUT +++ b/tests/integrate/109_PW_CR_fix_c/INPUT @@ -20,7 +20,7 @@ stress_thr 1e-6 cal_force 1 force_thr_ev 1.0e-3 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/109_PW_CR_fix_c/README b/tests/integrate/109_PW_CR_fix_c/README index d516f9c54a..ea2abbebf3 100644 --- a/tests/integrate/109_PW_CR_fix_c/README +++ b/tests/integrate/109_PW_CR_fix_c/README @@ -6,5 +6,5 @@ This test for: cell-relax *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/109_PW_CR_moveatoms/INPUT b/tests/integrate/109_PW_CR_moveatoms/INPUT index c60b67e116..dd42ff24a0 100644 --- a/tests/integrate/109_PW_CR_moveatoms/INPUT +++ b/tests/integrate/109_PW_CR_moveatoms/INPUT @@ -19,6 +19,6 @@ cal_force 1 force_thr_ev 1.0e-1 #ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/109_PW_CR_moveatoms/README b/tests/integrate/109_PW_CR_moveatoms/README index 4cd6861ff1..2b9f8142c9 100644 --- a/tests/integrate/109_PW_CR_moveatoms/README +++ b/tests/integrate/109_PW_CR_moveatoms/README @@ -5,5 +5,5 @@ This test for: cell-relax *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/110_PW_SY/INPUT b/tests/integrate/110_PW_SY/INPUT index e016d49f6f..933789c832 100644 --- a/tests/integrate/110_PW_SY/INPUT +++ b/tests/integrate/110_PW_SY/INPUT @@ -18,7 +18,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 dft_functional XC_GGA_X_PBE+XC_GGA_C_PBE diff --git a/tests/integrate/110_PW_SY/jd b/tests/integrate/110_PW_SY/jd index 7ba78c0cf8..a6feca03d1 100644 --- a/tests/integrate/110_PW_SY/jd +++ b/tests/integrate/110_PW_SY/jd @@ -1 +1 @@ -Func:PW/mixing_type=pulay,symmetry=1; Sys:Si16 Ref:energy +Func:PW/mixing_type=broyden,symmetry=1; Sys:Si16 Ref:energy diff --git a/tests/integrate/112_PW_dipole/INPUT b/tests/integrate/112_PW_dipole/INPUT index 3045ed8999..d77b2b5de6 100644 --- a/tests/integrate/112_PW_dipole/INPUT +++ b/tests/integrate/112_PW_dipole/INPUT @@ -19,7 +19,7 @@ basis_type pw smearing_method fixed #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 efield_flag 1 diff --git a/tests/integrate/112_PW_dipole/README b/tests/integrate/112_PW_dipole/README index 909cac1f8b..904f934b7d 100644 --- a/tests/integrate/112_PW_dipole/README +++ b/tests/integrate/112_PW_dipole/README @@ -5,5 +5,5 @@ This test for: dipole correction *sg15 pseudopotential *smearing_method fixed *ks_solver cg -*mixing_type pulay +*mixing_type broyden *mixing_beta 0.7 diff --git a/tests/integrate/112_PW_efield/INPUT b/tests/integrate/112_PW_efield/INPUT index 70b063f7c7..f674fe18bb 100644 --- a/tests/integrate/112_PW_efield/INPUT +++ b/tests/integrate/112_PW_efield/INPUT @@ -19,7 +19,7 @@ basis_type pw smearing_method fixed #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 efield_amp 0.01 diff --git a/tests/integrate/112_PW_efield/README b/tests/integrate/112_PW_efield/README index 0cf758067c..5678dd6222 100644 --- a/tests/integrate/112_PW_efield/README +++ b/tests/integrate/112_PW_efield/README @@ -5,5 +5,5 @@ This test for: electric field *sg15 pseudopotential *smearing_method fixed *ks_solver cg -*mixing_type pulay +*mixing_type broyden *mixing_beta 0.7 diff --git a/tests/integrate/113_PW_gatefield/INPUT b/tests/integrate/113_PW_gatefield/INPUT index 672fa1f6a6..8d04668a9e 100644 --- a/tests/integrate/113_PW_gatefield/INPUT +++ b/tests/integrate/113_PW_gatefield/INPUT @@ -20,7 +20,7 @@ smearing_method gauss smearing_sigma 0.001 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 efield_flag 1 diff --git a/tests/integrate/113_PW_gatefield/README b/tests/integrate/113_PW_gatefield/README index c219403d21..d541335f3d 100644 --- a/tests/integrate/113_PW_gatefield/README +++ b/tests/integrate/113_PW_gatefield/README @@ -6,5 +6,5 @@ This test for: gate field (compensating charge) *smearing_method gauss *smearing_sigma 0.001 *ks_solver cg -*mixing_type pulay +*mixing_type broyden *mixing_beta 0.7 diff --git a/tests/integrate/116_PW_scan_Si2/INPUT b/tests/integrate/116_PW_scan_Si2/INPUT index 70d05f4f13..8135ff1341 100644 --- a/tests/integrate/116_PW_scan_Si2/INPUT +++ b/tests/integrate/116_PW_scan_Si2/INPUT @@ -21,7 +21,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 cal_force 1 diff --git a/tests/integrate/116_PW_scan_Si2_nspin2/INPUT b/tests/integrate/116_PW_scan_Si2_nspin2/INPUT index d50dedb413..50d31d350f 100644 --- a/tests/integrate/116_PW_scan_Si2_nspin2/INPUT +++ b/tests/integrate/116_PW_scan_Si2_nspin2/INPUT @@ -22,7 +22,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 cal_force 1 diff --git a/tests/integrate/117_PW_out_pot/INPUT b/tests/integrate/117_PW_out_pot/INPUT index aad2a79f1e..413f883fac 100644 --- a/tests/integrate/117_PW_out_pot/INPUT +++ b/tests/integrate/117_PW_out_pot/INPUT @@ -21,6 +21,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/117_PW_out_pot/README b/tests/integrate/117_PW_out_pot/README index 773abcdc3c..a160db7610 100644 --- a/tests/integrate/117_PW_out_pot/README +++ b/tests/integrate/117_PW_out_pot/README @@ -1,5 +1,5 @@ This test for: *fcc Ce *SG15 pseudopotential containing f electron -*mixing_type pulay +*mixing_type broyden *mixing_beta 0.7 diff --git a/tests/integrate/120_PW_KP_MD_MSST/INPUT b/tests/integrate/120_PW_KP_MD_MSST/INPUT index 7d4641f694..8d1269b65f 100644 --- a/tests/integrate/120_PW_KP_MD_MSST/INPUT +++ b/tests/integrate/120_PW_KP_MD_MSST/INPUT @@ -21,7 +21,7 @@ cal_stress 1 cal_force 1 ks_solver cg -mixing_type pulay +mixing_type broyden mixing_beta 0.7 md_type msst diff --git a/tests/integrate/120_PW_KP_MD_MSST_level2/INPUT b/tests/integrate/120_PW_KP_MD_MSST_level2/INPUT index 71a41a7fd3..a6864bdfa8 100644 --- a/tests/integrate/120_PW_KP_MD_MSST_level2/INPUT +++ b/tests/integrate/120_PW_KP_MD_MSST_level2/INPUT @@ -10,7 +10,7 @@ ecutwfc 20 scf_nmax 20 basis_type pw ks_solver cg -mixing_type pulay +mixing_type broyden mixing_beta 0.7 smearing_method gauss smearing_sigma 0.001 diff --git a/tests/integrate/120_PW_KP_MD_NPT/INPUT b/tests/integrate/120_PW_KP_MD_NPT/INPUT index 7adf791964..9b9f0cabc5 100644 --- a/tests/integrate/120_PW_KP_MD_NPT/INPUT +++ b/tests/integrate/120_PW_KP_MD_NPT/INPUT @@ -13,7 +13,7 @@ erf_sigma 2 scf_nmax 20 basis_type pw ks_solver cg -mixing_type pulay +mixing_type broyden mixing_beta 0.7 cal_stress 1 diff --git a/tests/integrate/120_PW_KP_MD_NVT/INPUT b/tests/integrate/120_PW_KP_MD_NVT/INPUT index 46284f395c..59ecaf90fa 100644 --- a/tests/integrate/120_PW_KP_MD_NVT/INPUT +++ b/tests/integrate/120_PW_KP_MD_NVT/INPUT @@ -20,7 +20,7 @@ cal_force 1 force_thr_ev 1.0e-3 ks_solver cg -mixing_type pulay +mixing_type broyden mixing_beta 0.7 md_tchain 4 diff --git a/tests/integrate/127_PW_15_PK_AF/INPUT b/tests/integrate/127_PW_15_PK_AF/INPUT index 72923e06ed..979a280f7b 100644 --- a/tests/integrate/127_PW_15_PK_AF/INPUT +++ b/tests/integrate/127_PW_15_PK_AF/INPUT @@ -22,7 +22,7 @@ smearing_sigma 0.07 #relax_method cg #relax_bfgs_init 0.5 -mixing_type pulay +mixing_type broyden mixing_beta 0.3 ks_solver cg diff --git a/tests/integrate/128_PW_zero_ntype/INPUT b/tests/integrate/128_PW_zero_ntype/INPUT index b303e401c9..6fe76d0d5e 100644 --- a/tests/integrate/128_PW_zero_ntype/INPUT +++ b/tests/integrate/128_PW_zero_ntype/INPUT @@ -17,5 +17,5 @@ smearing_method gauss smearing_sigma 0.0074 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/133_PW_DJ_PK/INPUT b/tests/integrate/133_PW_DJ_PK/INPUT index dd9627dd90..fd6ca418c7 100644 --- a/tests/integrate/133_PW_DJ_PK/INPUT +++ b/tests/integrate/133_PW_DJ_PK/INPUT @@ -15,6 +15,6 @@ relax_nmax 1 #init_wfc random ks_solver cg -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/133_PW_DJ_PK/README b/tests/integrate/133_PW_DJ_PK/README index c6b39b9155..c02bf41552 100644 --- a/tests/integrate/133_PW_DJ_PK/README +++ b/tests/integrate/133_PW_DJ_PK/README @@ -5,5 +5,5 @@ This test for: *dojo pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/135_PW_15_PK/INPUT b/tests/integrate/135_PW_15_PK/INPUT index a41fe09439..956bf7a4fe 100644 --- a/tests/integrate/135_PW_15_PK/INPUT +++ b/tests/integrate/135_PW_15_PK/INPUT @@ -33,7 +33,7 @@ out_dm 0 pw_diag_thr 0.00001 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 mixing_gg0 1.5 diff --git a/tests/integrate/135_PW_15_PK/README b/tests/integrate/135_PW_15_PK/README index ed6205ce8e..f0bf2abab4 100644 --- a/tests/integrate/135_PW_15_PK/README +++ b/tests/integrate/135_PW_15_PK/README @@ -5,5 +5,5 @@ This test for: *dojo pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.4 diff --git a/tests/integrate/140_PW_15_SO/INPUT b/tests/integrate/140_PW_15_SO/INPUT index 72f336d380..542d862194 100644 --- a/tests/integrate/140_PW_15_SO/INPUT +++ b/tests/integrate/140_PW_15_SO/INPUT @@ -36,6 +36,6 @@ chg_extrap second-order out_dm 0 pw_diag_thr 0.00001 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 mixing_gg0 1.5 diff --git a/tests/integrate/140_PW_15_SO/README b/tests/integrate/140_PW_15_SO/README index 7b3799a0aa..f91fcf91b3 100644 --- a/tests/integrate/140_PW_15_SO/README +++ b/tests/integrate/140_PW_15_SO/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.4 diff --git a/tests/integrate/140_PW_15_SO_average/INPUT b/tests/integrate/140_PW_15_SO_average/INPUT index 8e0127f373..f62758a50b 100644 --- a/tests/integrate/140_PW_15_SO_average/INPUT +++ b/tests/integrate/140_PW_15_SO_average/INPUT @@ -36,6 +36,6 @@ chg_extrap second-order out_dm 0 pw_diag_thr 0.00001 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 mixing_gg0 1.5 diff --git a/tests/integrate/140_PW_15_SO_average/README b/tests/integrate/140_PW_15_SO_average/README index 7b3799a0aa..f91fcf91b3 100644 --- a/tests/integrate/140_PW_15_SO_average/README +++ b/tests/integrate/140_PW_15_SO_average/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver cg -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.4 diff --git a/tests/integrate/150_PW_15_CR_VDW3/INPUT b/tests/integrate/150_PW_15_CR_VDW3/INPUT index 596cf0a736..75926221a8 100644 --- a/tests/integrate/150_PW_15_CR_VDW3/INPUT +++ b/tests/integrate/150_PW_15_CR_VDW3/INPUT @@ -8,7 +8,7 @@ ks_solver cg smearing_method gaussian relax_nmax 1 smearing_sigma 0.02 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 vdw_method d3_0 fixed_axes c diff --git a/tests/integrate/170_PW_MD_1O/INPUT b/tests/integrate/170_PW_MD_1O/INPUT index d9d2f72695..7cdcde35fe 100644 --- a/tests/integrate/170_PW_MD_1O/INPUT +++ b/tests/integrate/170_PW_MD_1O/INPUT @@ -18,7 +18,7 @@ stress_thr 1e-6 cal_force 1 force_thr_ev 1.0e-3 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 chg_extrap first-order diff --git a/tests/integrate/170_PW_MD_2O/INPUT b/tests/integrate/170_PW_MD_2O/INPUT index 078f72c4ce..f49e82d94d 100644 --- a/tests/integrate/170_PW_MD_2O/INPUT +++ b/tests/integrate/170_PW_MD_2O/INPUT @@ -18,7 +18,7 @@ stress_thr 1e-6 cal_force 1 force_thr_ev 1.0e-3 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 chg_extrap second-order diff --git a/tests/integrate/201_NO_15_f_pseudopots/INPUT b/tests/integrate/201_NO_15_f_pseudopots/INPUT index 8b054e922f..6b52938fe8 100644 --- a/tests/integrate/201_NO_15_f_pseudopots/INPUT +++ b/tests/integrate/201_NO_15_f_pseudopots/INPUT @@ -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_pot 2 diff --git a/tests/integrate/201_NO_15_pseudopots/INPUT b/tests/integrate/201_NO_15_pseudopots/INPUT index dd60ce3965..46db64be67 100644 --- a/tests/integrate/201_NO_15_pseudopots/INPUT +++ b/tests/integrate/201_NO_15_pseudopots/INPUT @@ -22,5 +22,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/integrate/201_NO_KP_15_CF_CS_Si/INPUT b/tests/integrate/201_NO_KP_15_CF_CS_Si/INPUT index d63528a211..4f0cca65d3 100644 --- a/tests/integrate/201_NO_KP_15_CF_CS_Si/INPUT +++ b/tests/integrate/201_NO_KP_15_CF_CS_Si/INPUT @@ -23,7 +23,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/201_NO_KP_15_CF_CS_Si/README b/tests/integrate/201_NO_KP_15_CF_CS_Si/README index c973dbb5ce..fb46934400 100644 --- a/tests/integrate/201_NO_KP_15_CF_CS_Si/README +++ b/tests/integrate/201_NO_KP_15_CF_CS_Si/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver genelpa -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/201_NO_KP_DJ_CF_CS_GaAs/INPUT b/tests/integrate/201_NO_KP_DJ_CF_CS_GaAs/INPUT index 0a5a4a3126..228224e2c1 100644 --- a/tests/integrate/201_NO_KP_DJ_CF_CS_GaAs/INPUT +++ b/tests/integrate/201_NO_KP_DJ_CF_CS_GaAs/INPUT @@ -30,7 +30,7 @@ chg_extrap second-order out_dm 0 pw_diag_thr 0.00001 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 mixing_ndim 5 diff --git a/tests/integrate/201_NO_KP_DJ_CF_CS_GaAs/README b/tests/integrate/201_NO_KP_DJ_CF_CS_GaAs/README index 66f621df34..1c9f12d2f6 100644 --- a/tests/integrate/201_NO_KP_DJ_CF_CS_GaAs/README +++ b/tests/integrate/201_NO_KP_DJ_CF_CS_GaAs/README @@ -4,5 +4,5 @@ This test for: *dojo pseudopotential *smearing_method gauss *ks_solver genelpa -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.4 diff --git a/tests/integrate/201_NO_KP_DJ_Si/INPUT b/tests/integrate/201_NO_KP_DJ_Si/INPUT index 0ec130e3ff..88679b14f2 100644 --- a/tests/integrate/201_NO_KP_DJ_Si/INPUT +++ b/tests/integrate/201_NO_KP_DJ_Si/INPUT @@ -15,6 +15,6 @@ basis_type lcao relax_nmax 1 ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/201_NO_KP_DJ_Si/README b/tests/integrate/201_NO_KP_DJ_Si/README index a1229776bb..2d43688284 100644 --- a/tests/integrate/201_NO_KP_DJ_Si/README +++ b/tests/integrate/201_NO_KP_DJ_Si/README @@ -5,5 +5,5 @@ This test for: *dojo pseudopotential *smearing_method gauss *ks_solver genelpa -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/201_NO_OU_pseudopots/INPUT b/tests/integrate/201_NO_OU_pseudopots/INPUT index 47288a7a3d..42f1db6e6c 100644 --- a/tests/integrate/201_NO_OU_pseudopots/INPUT +++ b/tests/integrate/201_NO_OU_pseudopots/INPUT @@ -22,7 +22,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 cal_force 1 diff --git a/tests/integrate/201_NO_upf201_pseudopots/INPUT b/tests/integrate/201_NO_upf201_pseudopots/INPUT index 5997bbe1d4..dc5939dfb8 100644 --- a/tests/integrate/201_NO_upf201_pseudopots/INPUT +++ b/tests/integrate/201_NO_upf201_pseudopots/INPUT @@ -20,7 +20,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 pseudo_dir ../../PP_ORB orbital_dir ../../PP_ORB diff --git a/tests/integrate/202_NO_KP_HP_hpseps/INPUT b/tests/integrate/202_NO_KP_HP_hpseps/INPUT index b279c1caaf..8c6d722930 100644 --- a/tests/integrate/202_NO_KP_HP_hpseps/INPUT +++ b/tests/integrate/202_NO_KP_HP_hpseps/INPUT @@ -22,7 +22,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 ks_solver hpseps diff --git a/tests/integrate/202_NO_KP_HP_hpseps/README b/tests/integrate/202_NO_KP_HP_hpseps/README index b148e0493d..824b1a6727 100644 --- a/tests/integrate/202_NO_KP_HP_hpseps/README +++ b/tests/integrate/202_NO_KP_HP_hpseps/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver hpseps -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/203_NO_bspline/INPUT b/tests/integrate/203_NO_bspline/INPUT index 074526ef58..5ab4795fcf 100644 --- a/tests/integrate/203_NO_bspline/INPUT +++ b/tests/integrate/203_NO_bspline/INPUT @@ -22,6 +22,6 @@ cal_force 1 cal_stress 1 #test_stress 1 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 nbspline 10 diff --git a/tests/integrate/204_NO_KP_AFM/INPUT b/tests/integrate/204_NO_KP_AFM/INPUT index 2a648684b2..b888b2af95 100644 --- a/tests/integrate/204_NO_KP_AFM/INPUT +++ b/tests/integrate/204_NO_KP_AFM/INPUT @@ -21,7 +21,7 @@ smearing_method gauss smearing_sigma 0.02 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 mixing_gg0 1.5 diff --git a/tests/integrate/204_NO_KP_FM/INPUT b/tests/integrate/204_NO_KP_FM/INPUT index 838850029e..5eb89d942c 100644 --- a/tests/integrate/204_NO_KP_FM/INPUT +++ b/tests/integrate/204_NO_KP_FM/INPUT @@ -23,6 +23,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/204_NO_NC_magnetic/INPUT b/tests/integrate/204_NO_NC_magnetic/INPUT index 30bcced8ad..d2f6350531 100644 --- a/tests/integrate/204_NO_NC_magnetic/INPUT +++ b/tests/integrate/204_NO_NC_magnetic/INPUT @@ -17,7 +17,7 @@ noncolin 1 smearing_method gaussian smearing_sigma 0.07 -mixing_type pulay +mixing_type broyden mixing_beta 0.5 mixing_ndim 10 diff --git a/tests/integrate/205_NO_FD_smearing/INPUT b/tests/integrate/205_NO_FD_smearing/INPUT index d0c2806ccb..42a28ffac1 100644 --- a/tests/integrate/205_NO_FD_smearing/INPUT +++ b/tests/integrate/205_NO_FD_smearing/INPUT @@ -22,6 +22,6 @@ smearing_method fd smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.6 mixing_gg0 2 \ No newline at end of file diff --git a/tests/integrate/205_NO_GA_smearing/INPUT b/tests/integrate/205_NO_GA_smearing/INPUT index a82ad28351..19fb4a1424 100644 --- a/tests/integrate/205_NO_GA_smearing/INPUT +++ b/tests/integrate/205_NO_GA_smearing/INPUT @@ -22,6 +22,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 mixing_gg0 1.5 diff --git a/tests/integrate/206_NO_PK_chargemixing/INPUT b/tests/integrate/206_NO_PK_chargemixing/INPUT index 1c8e57fbf5..679d6a1f77 100644 --- a/tests/integrate/206_NO_PK_chargemixing/INPUT +++ b/tests/integrate/206_NO_PK_chargemixing/INPUT @@ -22,6 +22,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/206_NO_PU_chargemixing/INPUT b/tests/integrate/206_NO_PU_chargemixing/INPUT index a1fc7bb20b..1d79c866f2 100644 --- a/tests/integrate/206_NO_PU_chargemixing/INPUT +++ b/tests/integrate/206_NO_PU_chargemixing/INPUT @@ -22,6 +22,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/207_NO_KP_OB/INPUT b/tests/integrate/207_NO_KP_OB/INPUT index 435743b219..af4926dee5 100644 --- a/tests/integrate/207_NO_KP_OB/INPUT +++ b/tests/integrate/207_NO_KP_OB/INPUT @@ -29,7 +29,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/207_NO_KP_OD/INPUT b/tests/integrate/207_NO_KP_OD/INPUT index 5024958bed..591771d87b 100644 --- a/tests/integrate/207_NO_KP_OD/INPUT +++ b/tests/integrate/207_NO_KP_OD/INPUT @@ -28,7 +28,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/207_NO_KP_OD/README b/tests/integrate/207_NO_KP_OD/README index 49687c22f5..d15ae35cef 100644 --- a/tests/integrate/207_NO_KP_OD/README +++ b/tests/integrate/207_NO_KP_OD/README @@ -5,7 +5,7 @@ This test for: DOS *sg15 pseudopotential *smearing_method gauss *ks_solver genelpa -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 *restart from 4*4*4kpoint consequence *do nscf diff --git a/tests/integrate/207_NO_KP_OH/INPUT b/tests/integrate/207_NO_KP_OH/INPUT index b68d796135..4cb6a73b1e 100644 --- a/tests/integrate/207_NO_KP_OH/INPUT +++ b/tests/integrate/207_NO_KP_OH/INPUT @@ -22,7 +22,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 diff --git a/tests/integrate/207_NO_KP_OH2/INPUT b/tests/integrate/207_NO_KP_OH2/INPUT index e7997ff0db..ac07aa5885 100644 --- a/tests/integrate/207_NO_KP_OH2/INPUT +++ b/tests/integrate/207_NO_KP_OH2/INPUT @@ -22,7 +22,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 diff --git a/tests/integrate/207_NO_OK/INPUT b/tests/integrate/207_NO_OK/INPUT index 2e37f31d52..31d95f7695 100644 --- a/tests/integrate/207_NO_OK/INPUT +++ b/tests/integrate/207_NO_OK/INPUT @@ -25,5 +25,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 diff --git a/tests/integrate/208_NO_KP_CF_RE/INPUT b/tests/integrate/208_NO_KP_CF_RE/INPUT index 2110fd712b..05fdf47166 100644 --- a/tests/integrate/208_NO_KP_CF_RE/INPUT +++ b/tests/integrate/208_NO_KP_CF_RE/INPUT @@ -19,7 +19,7 @@ cal_force 1 force_thr_ev 1.0e-3 ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.7 relax_new 0 diff --git a/tests/integrate/208_NO_KP_CF_RE/README b/tests/integrate/208_NO_KP_CF_RE/README index 05c65da82d..793d214b2a 100644 --- a/tests/integrate/208_NO_KP_CF_RE/README +++ b/tests/integrate/208_NO_KP_CF_RE/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver genelpa -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/208_NO_KP_CS_CR/INPUT b/tests/integrate/208_NO_KP_CS_CR/INPUT index 574b830cb4..16a7d1e2cd 100644 --- a/tests/integrate/208_NO_KP_CS_CR/INPUT +++ b/tests/integrate/208_NO_KP_CS_CR/INPUT @@ -19,7 +19,7 @@ cal_force 1 force_thr_ev 1.0e-3 ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.7 relax_new 0 diff --git a/tests/integrate/208_NO_KP_CS_CR/README b/tests/integrate/208_NO_KP_CS_CR/README index 1c0a8d2aef..45e2a90ce5 100644 --- a/tests/integrate/208_NO_KP_CS_CR/README +++ b/tests/integrate/208_NO_KP_CS_CR/README @@ -5,5 +5,5 @@ This test for: cell-relax *sg15 pseudopotential *smearing_method gauss *ks_solver genelpa -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/208_NO_KP_RE_MB/INPUT b/tests/integrate/208_NO_KP_RE_MB/INPUT index 65a03f691a..9569bc5165 100644 --- a/tests/integrate/208_NO_KP_RE_MB/INPUT +++ b/tests/integrate/208_NO_KP_RE_MB/INPUT @@ -27,7 +27,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (6.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.5 relax_new 0 diff --git a/tests/integrate/216_NO_scan_Si2/INPUT b/tests/integrate/216_NO_scan_Si2/INPUT index 44e7f2b05f..9d9b1ee4d9 100644 --- a/tests/integrate/216_NO_scan_Si2/INPUT +++ b/tests/integrate/216_NO_scan_Si2/INPUT @@ -21,7 +21,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 cal_force 1 diff --git a/tests/integrate/217_NO_out_pot/INPUT b/tests/integrate/217_NO_out_pot/INPUT index 5c5d6b5616..5c83920650 100644 --- a/tests/integrate/217_NO_out_pot/INPUT +++ b/tests/integrate/217_NO_out_pot/INPUT @@ -23,5 +23,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/integrate/220_NO_KP_MD_MSST/INPUT b/tests/integrate/220_NO_KP_MD_MSST/INPUT index ae4762dee7..4e0207e13c 100644 --- a/tests/integrate/220_NO_KP_MD_MSST/INPUT +++ b/tests/integrate/220_NO_KP_MD_MSST/INPUT @@ -19,7 +19,7 @@ cal_stress 1 cal_force 1 ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.7 smearing_method gauss smearing_sigma 0.001 diff --git a/tests/integrate/220_NO_KP_MD_MSST_level2/INPUT b/tests/integrate/220_NO_KP_MD_MSST_level2/INPUT index 95613e35a0..d0a2963f45 100644 --- a/tests/integrate/220_NO_KP_MD_MSST_level2/INPUT +++ b/tests/integrate/220_NO_KP_MD_MSST_level2/INPUT @@ -14,7 +14,7 @@ scf_nmax 20 basis_type lcao ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.7 smearing_method gauss diff --git a/tests/integrate/220_NO_KP_MD_NVT/INPUT b/tests/integrate/220_NO_KP_MD_NVT/INPUT index 01c9b1e130..a25cc88823 100644 --- a/tests/integrate/220_NO_KP_MD_NVT/INPUT +++ b/tests/integrate/220_NO_KP_MD_NVT/INPUT @@ -21,7 +21,7 @@ cal_force 1 force_thr_ev 1.0e-3 ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.7 md_tchain 4 diff --git a/tests/integrate/220_NO_KP_MD_wfc_out/INPUT b/tests/integrate/220_NO_KP_MD_wfc_out/INPUT index bf96b2cda8..88eff5100b 100644 --- a/tests/integrate/220_NO_KP_MD_wfc_out/INPUT +++ b/tests/integrate/220_NO_KP_MD_wfc_out/INPUT @@ -21,7 +21,7 @@ cal_force 1 force_thr_ev 1.0e-3 ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.7 out_wfc_lcao 1 diff --git a/tests/integrate/240_NO_KP_15_SO/INPUT b/tests/integrate/240_NO_KP_15_SO/INPUT index d3edeed426..2024919f1b 100644 --- a/tests/integrate/240_NO_KP_15_SO/INPUT +++ b/tests/integrate/240_NO_KP_15_SO/INPUT @@ -40,7 +40,7 @@ out_dm 0 pw_diag_thr 0.00001 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 mixing_gg0 1.5 diff --git a/tests/integrate/240_NO_KP_15_SO/README b/tests/integrate/240_NO_KP_15_SO/README index 56e6de07ab..ed80e27110 100644 --- a/tests/integrate/240_NO_KP_15_SO/README +++ b/tests/integrate/240_NO_KP_15_SO/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver genelpa -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.4 diff --git a/tests/integrate/240_NO_KP_15_SO_average/INPUT b/tests/integrate/240_NO_KP_15_SO_average/INPUT index 72f2cee21f..683544e484 100644 --- a/tests/integrate/240_NO_KP_15_SO_average/INPUT +++ b/tests/integrate/240_NO_KP_15_SO_average/INPUT @@ -40,7 +40,7 @@ out_dm 0 pw_diag_thr 0.00001 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 mixing_gg0 1.5 diff --git a/tests/integrate/240_NO_KP_15_SO_average/README b/tests/integrate/240_NO_KP_15_SO_average/README index 1a6b704cc2..42a23a912a 100644 --- a/tests/integrate/240_NO_KP_15_SO_average/README +++ b/tests/integrate/240_NO_KP_15_SO_average/README @@ -5,7 +5,7 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver genelpa -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.4 Compared with 240*SO, I added parameter soc_lambda = 0 to this test case, diff --git a/tests/integrate/250_NO_KP_CR_VDW2/INPUT b/tests/integrate/250_NO_KP_CR_VDW2/INPUT index 872bb6fb5c..e3d377da05 100644 --- a/tests/integrate/250_NO_KP_CR_VDW2/INPUT +++ b/tests/integrate/250_NO_KP_CR_VDW2/INPUT @@ -8,7 +8,7 @@ ks_solver scalapack_gvx smearing_method gaussian relax_nmax 1 smearing_sigma 0.02 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 vdw_method d2 fixed_axes c diff --git a/tests/integrate/250_NO_KP_CR_VDW3/INPUT b/tests/integrate/250_NO_KP_CR_VDW3/INPUT index ed2b9a090e..a78cb664fb 100644 --- a/tests/integrate/250_NO_KP_CR_VDW3/INPUT +++ b/tests/integrate/250_NO_KP_CR_VDW3/INPUT @@ -8,7 +8,7 @@ ks_solver scalapack_gvx smearing_method gaussian relax_nmax 1 smearing_sigma 0.02 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 vdw_method d3_0 fixed_axes c diff --git a/tests/integrate/250_NO_KP_CR_VDW3ABC/INPUT b/tests/integrate/250_NO_KP_CR_VDW3ABC/INPUT index 69eccef57b..7a1ecc4762 100644 --- a/tests/integrate/250_NO_KP_CR_VDW3ABC/INPUT +++ b/tests/integrate/250_NO_KP_CR_VDW3ABC/INPUT @@ -7,7 +7,7 @@ ks_solver scalapack_gvx smearing_method gaussian relax_nmax 1 smearing_sigma 0.02 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 vdw_method d3_0 vdw_abc 1 diff --git a/tests/integrate/250_NO_KP_CR_VDW3BJ/INPUT b/tests/integrate/250_NO_KP_CR_VDW3BJ/INPUT index 33a8908cf2..0fb4640f28 100644 --- a/tests/integrate/250_NO_KP_CR_VDW3BJ/INPUT +++ b/tests/integrate/250_NO_KP_CR_VDW3BJ/INPUT @@ -8,7 +8,7 @@ ks_solver scalapack_gvx smearing_method gaussian relax_nmax 1 smearing_sigma 0.02 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 vdw_method d3_bj fixed_axes c diff --git a/tests/integrate/260_NO_15_PK_PU_AF/INPUT b/tests/integrate/260_NO_15_PK_PU_AF/INPUT index c73ee9e4f9..b49841472d 100644 --- a/tests/integrate/260_NO_15_PK_PU_AF/INPUT +++ b/tests/integrate/260_NO_15_PK_PU_AF/INPUT @@ -22,7 +22,7 @@ smearing_sigma 0.07 #relax_method cg #relax_bfgs_init 0.5 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #mixing_gg0 1.5 diff --git a/tests/integrate/270_NO_MD_1O/INPUT b/tests/integrate/270_NO_MD_1O/INPUT index 474b4855ae..e461339601 100644 --- a/tests/integrate/270_NO_MD_1O/INPUT +++ b/tests/integrate/270_NO_MD_1O/INPUT @@ -20,7 +20,7 @@ force_thr_ev 1.0e-3 smearing_method gaussian smearing_sigma 0.002 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 md_tfirst 10 diff --git a/tests/integrate/270_NO_MD_2O/INPUT b/tests/integrate/270_NO_MD_2O/INPUT index 8c9821ccda..ef1b49219a 100644 --- a/tests/integrate/270_NO_MD_2O/INPUT +++ b/tests/integrate/270_NO_MD_2O/INPUT @@ -20,7 +20,7 @@ force_thr_ev 1.0e-3 smearing_method gaussian smearing_sigma 0.002 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 md_tfreq 0.1 diff --git a/tests/integrate/281_NO_KP_HSE/INPUT b/tests/integrate/281_NO_KP_HSE/INPUT index 6ef86684dd..909d639542 100644 --- a/tests/integrate/281_NO_KP_HSE/INPUT +++ b/tests/integrate/281_NO_KP_HSE/INPUT @@ -24,7 +24,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden #Parameters (7.Hybrid) dft_functional hse diff --git a/tests/integrate/282_NO_KP_HSE_complex/INPUT b/tests/integrate/282_NO_KP_HSE_complex/INPUT index 100832eede..886e3529eb 100644 --- a/tests/integrate/282_NO_KP_HSE_complex/INPUT +++ b/tests/integrate/282_NO_KP_HSE_complex/INPUT @@ -22,7 +22,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden #Parameters (7.Hybrid) dft_functional hse diff --git a/tests/integrate/283_NO_KP_HF/INPUT b/tests/integrate/283_NO_KP_HF/INPUT index b9a3432cc8..270c26ab10 100644 --- a/tests/integrate/283_NO_KP_HF/INPUT +++ b/tests/integrate/283_NO_KP_HF/INPUT @@ -22,7 +22,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden #Parameters (7.Hybrid) dft_functional hf diff --git a/tests/integrate/283_NO_restart/INPUT b/tests/integrate/283_NO_restart/INPUT index d56d82bbcf..03af018e36 100644 --- a/tests/integrate/283_NO_restart/INPUT +++ b/tests/integrate/283_NO_restart/INPUT @@ -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 diff --git a/tests/integrate/284_NO_KP_PBE0/INPUT b/tests/integrate/284_NO_KP_PBE0/INPUT index a4c9daf26c..dfd65c52a2 100644 --- a/tests/integrate/284_NO_KP_PBE0/INPUT +++ b/tests/integrate/284_NO_KP_PBE0/INPUT @@ -22,7 +22,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden #Parameters (7.Hybrid) dft_functional pbe0 diff --git a/tests/integrate/284_NO_KP_symmetry/INPUT b/tests/integrate/284_NO_KP_symmetry/INPUT index 46adcb0ef3..921d7a9617 100644 --- a/tests/integrate/284_NO_KP_symmetry/INPUT +++ b/tests/integrate/284_NO_KP_symmetry/INPUT @@ -22,6 +22,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.1 ks_solver genelpa \ No newline at end of file diff --git a/tests/integrate/285_NO_KP_RE_HSE/INPUT b/tests/integrate/285_NO_KP_RE_HSE/INPUT index aaf581eb7d..2e6611da04 100644 --- a/tests/integrate/285_NO_KP_RE_HSE/INPUT +++ b/tests/integrate/285_NO_KP_RE_HSE/INPUT @@ -23,7 +23,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden #Parameters (7.Hybrid) dft_functional hsE diff --git a/tests/integrate/286_NO_KP_CR_HSE/INPUT b/tests/integrate/286_NO_KP_CR_HSE/INPUT index 0885c393c9..d593db6568 100644 --- a/tests/integrate/286_NO_KP_CR_HSE/INPUT +++ b/tests/integrate/286_NO_KP_CR_HSE/INPUT @@ -23,7 +23,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden #Parameters (7.Hybrid) dft_functional hse diff --git a/tests/integrate/301_NO_GO_15_CF_CS/INPUT b/tests/integrate/301_NO_GO_15_CF_CS/INPUT index 328c26cdbf..6039d0d4a3 100644 --- a/tests/integrate/301_NO_GO_15_CF_CS/INPUT +++ b/tests/integrate/301_NO_GO_15_CF_CS/INPUT @@ -22,7 +22,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 ks_solver scalapack_gvx diff --git a/tests/integrate/301_NO_GO_15_CF_CS/README b/tests/integrate/301_NO_GO_15_CF_CS/README index b391f78193..ef80b143f3 100644 --- a/tests/integrate/301_NO_GO_15_CF_CS/README +++ b/tests/integrate/301_NO_GO_15_CF_CS/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver genelpa -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/301_NO_GO_DJ_Si/INPUT b/tests/integrate/301_NO_GO_DJ_Si/INPUT index 0e746be3f4..e1e56e9fb9 100644 --- a/tests/integrate/301_NO_GO_DJ_Si/INPUT +++ b/tests/integrate/301_NO_GO_DJ_Si/INPUT @@ -15,6 +15,6 @@ basis_type lcao relax_nmax 1 ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/301_NO_GO_DJ_Si/README b/tests/integrate/301_NO_GO_DJ_Si/README index a1229776bb..2d43688284 100644 --- a/tests/integrate/301_NO_GO_DJ_Si/README +++ b/tests/integrate/301_NO_GO_DJ_Si/README @@ -5,5 +5,5 @@ This test for: *dojo pseudopotential *smearing_method gauss *ks_solver genelpa -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/303_NO_GO_HP_15/INPUT b/tests/integrate/303_NO_GO_HP_15/INPUT index 83f2d82bd0..4acd748452 100644 --- a/tests/integrate/303_NO_GO_HP_15/INPUT +++ b/tests/integrate/303_NO_GO_HP_15/INPUT @@ -23,7 +23,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/303_NO_GO_HP_15/README b/tests/integrate/303_NO_GO_HP_15/README index 27edd892b0..3dd14f9007 100644 --- a/tests/integrate/303_NO_GO_HP_15/README +++ b/tests/integrate/303_NO_GO_HP_15/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver hpseps -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/304_NO_GO_AF/INPUT b/tests/integrate/304_NO_GO_AF/INPUT index 547c1bcdf0..3922d2a111 100644 --- a/tests/integrate/304_NO_GO_AF/INPUT +++ b/tests/integrate/304_NO_GO_AF/INPUT @@ -21,7 +21,7 @@ smearing_sigma 0.02 #relax_method cg #relax_bfgs_init 0.5 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 diff --git a/tests/integrate/304_NO_GO_AF_atommag/INPUT b/tests/integrate/304_NO_GO_AF_atommag/INPUT index 73136aab82..a8e580be14 100644 --- a/tests/integrate/304_NO_GO_AF_atommag/INPUT +++ b/tests/integrate/304_NO_GO_AF_atommag/INPUT @@ -22,7 +22,7 @@ smearing_sigma 0.02 #relax_method cg #relax_bfgs_init 0.5 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 diff --git a/tests/integrate/307_NO_GO_OH/INPUT b/tests/integrate/307_NO_GO_OH/INPUT index 2923245f33..b8f45d0fd4 100644 --- a/tests/integrate/307_NO_GO_OH/INPUT +++ b/tests/integrate/307_NO_GO_OH/INPUT @@ -25,7 +25,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 diff --git a/tests/integrate/308_NO_GO_CF_RE/INPUT b/tests/integrate/308_NO_GO_CF_RE/INPUT index 009cc3eee3..552f908890 100644 --- a/tests/integrate/308_NO_GO_CF_RE/INPUT +++ b/tests/integrate/308_NO_GO_CF_RE/INPUT @@ -28,7 +28,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (6.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.5 gamma_only 1 diff --git a/tests/integrate/308_NO_GO_CF_RE/README b/tests/integrate/308_NO_GO_CF_RE/README index 05c65da82d..793d214b2a 100644 --- a/tests/integrate/308_NO_GO_CF_RE/README +++ b/tests/integrate/308_NO_GO_CF_RE/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver genelpa -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/308_NO_GO_CS_CR/INPUT b/tests/integrate/308_NO_GO_CS_CR/INPUT index 53c6cedbb3..b630e4f87d 100644 --- a/tests/integrate/308_NO_GO_CS_CR/INPUT +++ b/tests/integrate/308_NO_GO_CS_CR/INPUT @@ -19,7 +19,7 @@ cal_force 1 force_thr_ev 1.0e-3 ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.7 gamma_only 1 diff --git a/tests/integrate/308_NO_GO_RE_MB/INPUT b/tests/integrate/308_NO_GO_RE_MB/INPUT index 86852ccf68..71cb9f7036 100644 --- a/tests/integrate/308_NO_GO_RE_MB/INPUT +++ b/tests/integrate/308_NO_GO_RE_MB/INPUT @@ -27,7 +27,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (6.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.5 gamma_only 1 diff --git a/tests/integrate/316_NO_scan_Si2/INPUT b/tests/integrate/316_NO_scan_Si2/INPUT index f4f19847eb..6fb49b54b0 100644 --- a/tests/integrate/316_NO_scan_Si2/INPUT +++ b/tests/integrate/316_NO_scan_Si2/INPUT @@ -22,7 +22,7 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 cal_force 1 diff --git a/tests/integrate/320_NO_GO_MD_MSST/INPUT b/tests/integrate/320_NO_GO_MD_MSST/INPUT index 0895a08a9a..bf0bde9d3c 100644 --- a/tests/integrate/320_NO_GO_MD_MSST/INPUT +++ b/tests/integrate/320_NO_GO_MD_MSST/INPUT @@ -23,7 +23,7 @@ cal_stress 1 cal_force 1 ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.3 md_type msst diff --git a/tests/integrate/320_NO_GO_MD_MSST_level2/INPUT b/tests/integrate/320_NO_GO_MD_MSST_level2/INPUT index 3fdaf29b09..e75e4d6324 100644 --- a/tests/integrate/320_NO_GO_MD_MSST_level2/INPUT +++ b/tests/integrate/320_NO_GO_MD_MSST_level2/INPUT @@ -15,7 +15,7 @@ gamma_only 1 basis_type lcao ks_solver scalapack_gvx -mixing_type pulay +mixing_type broyden mixing_beta 0.4 smearing_method gauss diff --git a/tests/integrate/320_NO_GO_MD_NVT/INPUT b/tests/integrate/320_NO_GO_MD_NVT/INPUT index 63bf2b93fa..1634c0d8a3 100644 --- a/tests/integrate/320_NO_GO_MD_NVT/INPUT +++ b/tests/integrate/320_NO_GO_MD_NVT/INPUT @@ -22,7 +22,7 @@ cal_force 1 force_thr_ev 1.0e-3 ks_solver genelpa -mixing_type pulay +mixing_type broyden mixing_beta 0.7 md_tchain 4 diff --git a/tests/integrate/360_NO_15_GO_PU_AF/INPUT b/tests/integrate/360_NO_15_GO_PU_AF/INPUT index 44ccc67d2a..583b5c9f2d 100644 --- a/tests/integrate/360_NO_15_GO_PU_AF/INPUT +++ b/tests/integrate/360_NO_15_GO_PU_AF/INPUT @@ -22,7 +22,7 @@ cal_stress 0 #relax_method cg #relax_bfgs_init 0.5 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #mixing_gg0 1.5 diff --git a/tests/integrate/381_NO_GO_S1_HSE/INPUT b/tests/integrate/381_NO_GO_S1_HSE/INPUT index 03fd12fddc..08c24a85c4 100644 --- a/tests/integrate/381_NO_GO_S1_HSE/INPUT +++ b/tests/integrate/381_NO_GO_S1_HSE/INPUT @@ -24,7 +24,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (7.Charge Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (14.exx) diff --git a/tests/integrate/382_NO_GO_S2_HSE/INPUT b/tests/integrate/382_NO_GO_S2_HSE/INPUT index a0ef5a24f4..9c9886ee57 100644 --- a/tests/integrate/382_NO_GO_S2_HSE/INPUT +++ b/tests/integrate/382_NO_GO_S2_HSE/INPUT @@ -24,7 +24,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (7.Charge Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (14.exx) diff --git a/tests/integrate/383_NO_GO_SO_HSE/INPUT b/tests/integrate/383_NO_GO_SO_HSE/INPUT index 6cfc5cb3d0..1f016e3bda 100644 --- a/tests/integrate/383_NO_GO_SO_HSE/INPUT +++ b/tests/integrate/383_NO_GO_SO_HSE/INPUT @@ -26,7 +26,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (7.Charge Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (14.exx) diff --git a/tests/integrate/384_NO_GO_S1_HSE_loop0_PU/INPUT b/tests/integrate/384_NO_GO_S1_HSE_loop0_PU/INPUT index 77c29cf9ed..271c8765a7 100644 --- a/tests/integrate/384_NO_GO_S1_HSE_loop0_PU/INPUT +++ b/tests/integrate/384_NO_GO_S1_HSE_loop0_PU/INPUT @@ -24,7 +24,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (7.Charge Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (14.exx) diff --git a/tests/integrate/385_NO_GO_RE_S1_HSE/INPUT b/tests/integrate/385_NO_GO_RE_S1_HSE/INPUT index 35b83abed6..4b5a1a1c4a 100644 --- a/tests/integrate/385_NO_GO_RE_S1_HSE/INPUT +++ b/tests/integrate/385_NO_GO_RE_S1_HSE/INPUT @@ -25,7 +25,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (7.Charge Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (14.exx) diff --git a/tests/integrate/386_NO_GO_MD_S1_HSE/INPUT b/tests/integrate/386_NO_GO_MD_S1_HSE/INPUT index b2b7881cfc..6a5a86e176 100644 --- a/tests/integrate/386_NO_GO_MD_S1_HSE/INPUT +++ b/tests/integrate/386_NO_GO_MD_S1_HSE/INPUT @@ -24,7 +24,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (7.Charge Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (9.Molecular dynamics) diff --git a/tests/integrate/401_NP_KP_sp/INPUT b/tests/integrate/401_NP_KP_sp/INPUT index 5dfd8739bc..9efb37c613 100644 --- a/tests/integrate/401_NP_KP_sp/INPUT +++ b/tests/integrate/401_NP_KP_sp/INPUT @@ -24,6 +24,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/401_NP_KP_sp/README b/tests/integrate/401_NP_KP_sp/README index 1276bbdcf0..427ae8f094 100644 --- a/tests/integrate/401_NP_KP_sp/README +++ b/tests/integrate/401_NP_KP_sp/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver lapack -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/401_NP_KP_spd/INPUT b/tests/integrate/401_NP_KP_spd/INPUT index 5dfd8739bc..9efb37c613 100644 --- a/tests/integrate/401_NP_KP_spd/INPUT +++ b/tests/integrate/401_NP_KP_spd/INPUT @@ -24,6 +24,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.7 mixing_gg0 1.5 diff --git a/tests/integrate/401_NP_KP_spd/README b/tests/integrate/401_NP_KP_spd/README index b42c28e809..0413052101 100644 --- a/tests/integrate/401_NP_KP_spd/README +++ b/tests/integrate/401_NP_KP_spd/README @@ -5,5 +5,5 @@ This test for: *sg15 pseudopotential *smearing_method gauss *ks_solver lapack -*mixing_type pulay-kerker +*mixing_type broyden-kerker *mixing_beta 0.7 diff --git a/tests/integrate/501_NO_neighboring_GaAs512/INPUT b/tests/integrate/501_NO_neighboring_GaAs512/INPUT index 7dd13c5a38..6e205ba58f 100644 --- a/tests/integrate/501_NO_neighboring_GaAs512/INPUT +++ b/tests/integrate/501_NO_neighboring_GaAs512/INPUT @@ -28,7 +28,7 @@ basis_type lcao chg_extrap second-order out_dm 0 -mixing_type pulay +mixing_type broyden mixing_beta 0.4 mixing_ndim 5 diff --git a/tests/integrate/601_NO_TDDFT_CO/INPUT b/tests/integrate/601_NO_TDDFT_CO/INPUT index 4be03b6c24..813d27bbde 100755 --- a/tests/integrate/601_NO_TDDFT_CO/INPUT +++ b/tests/integrate/601_NO_TDDFT_CO/INPUT @@ -17,7 +17,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_CO_occ/INPUT b/tests/integrate/601_NO_TDDFT_CO_occ/INPUT index 005c370a36..3c5f187fc4 100755 --- a/tests/integrate/601_NO_TDDFT_CO_occ/INPUT +++ b/tests/integrate/601_NO_TDDFT_CO_occ/INPUT @@ -18,7 +18,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 #out_alllog 1 diff --git a/tests/integrate/601_NO_TDDFT_H2/INPUT b/tests/integrate/601_NO_TDDFT_H2/INPUT index 29ec1e8a29..0571253908 100755 --- a/tests/integrate/601_NO_TDDFT_H2/INPUT +++ b/tests/integrate/601_NO_TDDFT_H2/INPUT @@ -17,7 +17,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_H2_etrs/INPUT b/tests/integrate/601_NO_TDDFT_H2_etrs/INPUT index ed03e4ec72..42c092f82e 100755 --- a/tests/integrate/601_NO_TDDFT_H2_etrs/INPUT +++ b/tests/integrate/601_NO_TDDFT_H2_etrs/INPUT @@ -17,7 +17,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_H2_kpoint/INPUT b/tests/integrate/601_NO_TDDFT_H2_kpoint/INPUT index a33bf2300a..9b0879d4ee 100755 --- a/tests/integrate/601_NO_TDDFT_H2_kpoint/INPUT +++ b/tests/integrate/601_NO_TDDFT_H2_kpoint/INPUT @@ -17,7 +17,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_H2_len_gauss/INPUT b/tests/integrate/601_NO_TDDFT_H2_len_gauss/INPUT index 90205524ec..7e9cfac1ec 100755 --- a/tests/integrate/601_NO_TDDFT_H2_len_gauss/INPUT +++ b/tests/integrate/601_NO_TDDFT_H2_len_gauss/INPUT @@ -16,7 +16,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_H2_len_gauss_dire/INPUT b/tests/integrate/601_NO_TDDFT_H2_len_gauss_dire/INPUT index 4deb3c98fc..29d554186c 100755 --- a/tests/integrate/601_NO_TDDFT_H2_len_gauss_dire/INPUT +++ b/tests/integrate/601_NO_TDDFT_H2_len_gauss_dire/INPUT @@ -17,7 +17,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_H2_len_heavi/INPUT b/tests/integrate/601_NO_TDDFT_H2_len_heavi/INPUT index 3f8cc99aee..c40954ccd4 100755 --- a/tests/integrate/601_NO_TDDFT_H2_len_heavi/INPUT +++ b/tests/integrate/601_NO_TDDFT_H2_len_heavi/INPUT @@ -17,7 +17,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_H2_len_hhg/INPUT b/tests/integrate/601_NO_TDDFT_H2_len_hhg/INPUT index bd6dceaf9e..d6e6360c0a 100755 --- a/tests/integrate/601_NO_TDDFT_H2_len_hhg/INPUT +++ b/tests/integrate/601_NO_TDDFT_H2_len_hhg/INPUT @@ -16,7 +16,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_H2_len_trape/INPUT b/tests/integrate/601_NO_TDDFT_H2_len_trape/INPUT index f07759286e..a57bb8a27b 100755 --- a/tests/integrate/601_NO_TDDFT_H2_len_trape/INPUT +++ b/tests/integrate/601_NO_TDDFT_H2_len_trape/INPUT @@ -16,7 +16,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_H2_len_trigo/INPUT b/tests/integrate/601_NO_TDDFT_H2_len_trigo/INPUT index 859e54bb0d..97acff3ac0 100755 --- a/tests/integrate/601_NO_TDDFT_H2_len_trigo/INPUT +++ b/tests/integrate/601_NO_TDDFT_H2_len_trigo/INPUT @@ -16,7 +16,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_H2_oldedm/INPUT b/tests/integrate/601_NO_TDDFT_H2_oldedm/INPUT index c54e6feeba..46017b24e9 100755 --- a/tests/integrate/601_NO_TDDFT_H2_oldedm/INPUT +++ b/tests/integrate/601_NO_TDDFT_H2_oldedm/INPUT @@ -17,7 +17,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_H2_restart/INPUT b/tests/integrate/601_NO_TDDFT_H2_restart/INPUT index 95ae764234..1d0af3ecf0 100755 --- a/tests/integrate/601_NO_TDDFT_H2_restart/INPUT +++ b/tests/integrate/601_NO_TDDFT_H2_restart/INPUT @@ -17,7 +17,7 @@ basis_type lcao gamma_only 0 md_nstep 7 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_H2_taylor/INPUT b/tests/integrate/601_NO_TDDFT_H2_taylor/INPUT index 52793a8880..4a9ad73c0a 100755 --- a/tests/integrate/601_NO_TDDFT_H2_taylor/INPUT +++ b/tests/integrate/601_NO_TDDFT_H2_taylor/INPUT @@ -17,7 +17,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_O3/INPUT b/tests/integrate/601_NO_TDDFT_O3/INPUT index d171b0d19f..2e35e0da3b 100755 --- a/tests/integrate/601_NO_TDDFT_O3/INPUT +++ b/tests/integrate/601_NO_TDDFT_O3/INPUT @@ -18,7 +18,7 @@ out_chg 1 gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/integrate/601_NO_TDDFT_graphene_kpoint/INPUT b/tests/integrate/601_NO_TDDFT_graphene_kpoint/INPUT index 8b9ec83971..2cb0516a56 100755 --- a/tests/integrate/601_NO_TDDFT_graphene_kpoint/INPUT +++ b/tests/integrate/601_NO_TDDFT_graphene_kpoint/INPUT @@ -20,7 +20,7 @@ basis_type lcao gamma_only 0 md_nstep 2 -mixing_type pulay +mixing_type broyden mixing_beta 0.7 scf_thr 1.0e-6 diff --git a/tests/performance/P000_si16_pw/INPUT b/tests/performance/P000_si16_pw/INPUT index 4f9efe946c..0b669f4e03 100644 --- a/tests/performance/P000_si16_pw/INPUT +++ b/tests/performance/P000_si16_pw/INPUT @@ -20,6 +20,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 ks_solver dav diff --git a/tests/performance/P001_si32_pw/INPUT b/tests/performance/P001_si32_pw/INPUT index 8ff7bad71c..783c0cb3dd 100644 --- a/tests/performance/P001_si32_pw/INPUT +++ b/tests/performance/P001_si32_pw/INPUT @@ -20,5 +20,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/performance/P002_si64_pw/INPUT b/tests/performance/P002_si64_pw/INPUT index 8ff7bad71c..783c0cb3dd 100644 --- a/tests/performance/P002_si64_pw/INPUT +++ b/tests/performance/P002_si64_pw/INPUT @@ -20,5 +20,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/performance/P003_si128_pw/INPUT b/tests/performance/P003_si128_pw/INPUT index 4f9efe946c..0b669f4e03 100644 --- a/tests/performance/P003_si128_pw/INPUT +++ b/tests/performance/P003_si128_pw/INPUT @@ -20,6 +20,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 ks_solver dav diff --git a/tests/performance/P004_cu4_pw/INPUT b/tests/performance/P004_cu4_pw/INPUT index 9ab9782a80..a92c76479c 100644 --- a/tests/performance/P004_cu4_pw/INPUT +++ b/tests/performance/P004_cu4_pw/INPUT @@ -20,5 +20,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/performance/P005_Bi2Se2Cu2O2_pw/INPUT b/tests/performance/P005_Bi2Se2Cu2O2_pw/INPUT index 074f13afca..b0c77edc4f 100644 --- a/tests/performance/P005_Bi2Se2Cu2O2_pw/INPUT +++ b/tests/performance/P005_Bi2Se2Cu2O2_pw/INPUT @@ -17,5 +17,5 @@ basis_type pw smearing_method fixed #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/performance/P006_Ge4As8_pw/INPUT b/tests/performance/P006_Ge4As8_pw/INPUT index 074f13afca..b0c77edc4f 100644 --- a/tests/performance/P006_Ge4As8_pw/INPUT +++ b/tests/performance/P006_Ge4As8_pw/INPUT @@ -17,5 +17,5 @@ basis_type pw smearing_method fixed #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/performance/P007_H2O_pw/INPUT b/tests/performance/P007_H2O_pw/INPUT index 02d76739d2..80bf96ddef 100644 --- a/tests/performance/P007_H2O_pw/INPUT +++ b/tests/performance/P007_H2O_pw/INPUT @@ -18,7 +18,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (6.Deepks) diff --git a/tests/performance/P008_C2H6O_pw/INPUT b/tests/performance/P008_C2H6O_pw/INPUT index 4b5757726e..3ea75302ce 100644 --- a/tests/performance/P008_C2H6O_pw/INPUT +++ b/tests/performance/P008_C2H6O_pw/INPUT @@ -18,7 +18,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (6.Deepks) diff --git a/tests/performance/P009_32H2O_pw/INPUT b/tests/performance/P009_32H2O_pw/INPUT index cb93be2174..aea806256f 100644 --- a/tests/performance/P009_32H2O_pw/INPUT +++ b/tests/performance/P009_32H2O_pw/INPUT @@ -21,7 +21,7 @@ smearing_method fixed #type of smearing_method: gauss; fd; #smearing_sigma 0.002 #energy range for smearing_method #Parameters (6.Charge Mixing) -mixing_type pulay #plain; kerker; pulay; pulay-kerker; broyden +mixing_type broyden #plain; kerker; pulay; pulay-kerker; broyden mixing_beta 0.7 #mixing parameter: 0 means no new charge bx 5 diff --git a/tests/performance/P010_si2_pw/INPUT b/tests/performance/P010_si2_pw/INPUT index 6113152228..056e5232c0 100644 --- a/tests/performance/P010_si2_pw/INPUT +++ b/tests/performance/P010_si2_pw/INPUT @@ -20,5 +20,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/performance/P100_si16_lcao/INPUT b/tests/performance/P100_si16_lcao/INPUT index 3381910218..824e290b9a 100644 --- a/tests/performance/P100_si16_lcao/INPUT +++ b/tests/performance/P100_si16_lcao/INPUT @@ -20,5 +20,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/performance/P101_si32_lcao/INPUT b/tests/performance/P101_si32_lcao/INPUT index 3381910218..824e290b9a 100644 --- a/tests/performance/P101_si32_lcao/INPUT +++ b/tests/performance/P101_si32_lcao/INPUT @@ -20,5 +20,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/performance/P102_si64_lcao/INPUT b/tests/performance/P102_si64_lcao/INPUT index ee10d2c793..98d12442f7 100644 --- a/tests/performance/P102_si64_lcao/INPUT +++ b/tests/performance/P102_si64_lcao/INPUT @@ -20,6 +20,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 ks_solver scalapack_gvx diff --git a/tests/performance/P103_si128_lcao/INPUT b/tests/performance/P103_si128_lcao/INPUT index ee10d2c793..98d12442f7 100644 --- a/tests/performance/P103_si128_lcao/INPUT +++ b/tests/performance/P103_si128_lcao/INPUT @@ -20,6 +20,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 ks_solver scalapack_gvx diff --git a/tests/performance/P104_si256_lcao/INPUT b/tests/performance/P104_si256_lcao/INPUT index ee10d2c793..98d12442f7 100644 --- a/tests/performance/P104_si256_lcao/INPUT +++ b/tests/performance/P104_si256_lcao/INPUT @@ -20,6 +20,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 ks_solver scalapack_gvx diff --git a/tests/performance/P105_si512_lcao/INPUT b/tests/performance/P105_si512_lcao/INPUT index ee10d2c793..98d12442f7 100644 --- a/tests/performance/P105_si512_lcao/INPUT +++ b/tests/performance/P105_si512_lcao/INPUT @@ -20,6 +20,6 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 ks_solver scalapack_gvx diff --git a/tests/performance/P106_Cu4_lcao/INPUT b/tests/performance/P106_Cu4_lcao/INPUT index 3381910218..824e290b9a 100644 --- a/tests/performance/P106_Cu4_lcao/INPUT +++ b/tests/performance/P106_Cu4_lcao/INPUT @@ -20,5 +20,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/performance/P107_Bi2Se2Cu2O2_lcao/INPUT b/tests/performance/P107_Bi2Se2Cu2O2_lcao/INPUT index ff96af960a..efce86ec99 100644 --- a/tests/performance/P107_Bi2Se2Cu2O2_lcao/INPUT +++ b/tests/performance/P107_Bi2Se2Cu2O2_lcao/INPUT @@ -19,5 +19,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/performance/P108_Ge4As8_lcao/INPUT b/tests/performance/P108_Ge4As8_lcao/INPUT index ff96af960a..efce86ec99 100644 --- a/tests/performance/P108_Ge4As8_lcao/INPUT +++ b/tests/performance/P108_Ge4As8_lcao/INPUT @@ -19,5 +19,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3 diff --git a/tests/performance/P109_H2O_lcao/INPUT b/tests/performance/P109_H2O_lcao/INPUT index 981b60857c..680100ca2e 100644 --- a/tests/performance/P109_H2O_lcao/INPUT +++ b/tests/performance/P109_H2O_lcao/INPUT @@ -18,7 +18,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (6.Deepks) diff --git a/tests/performance/P110_C2H6O_lcao/INPUT b/tests/performance/P110_C2H6O_lcao/INPUT index e74e0afb2c..c0a96e121b 100644 --- a/tests/performance/P110_C2H6O_lcao/INPUT +++ b/tests/performance/P110_C2H6O_lcao/INPUT @@ -18,7 +18,7 @@ smearing_method gaussian smearing_sigma 0.02 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.4 #Parameters (6.Deepks) diff --git a/tests/performance/P111_si32_lcaogo/INPUT b/tests/performance/P111_si32_lcaogo/INPUT index d1771f7390..a8f9f329b6 100644 --- a/tests/performance/P111_si32_lcaogo/INPUT +++ b/tests/performance/P111_si32_lcaogo/INPUT @@ -21,5 +21,5 @@ smearing_method gauss smearing_sigma 0.002 #Parameters (5.Mixing) -mixing_type pulay +mixing_type broyden mixing_beta 0.3