deepmodeling / abacus-develop

An electronic structure package based on either plane wave basis or numerical atomic orbitals.
http://abacus.ustc.edu.cn
GNU Lesser General Public License v3.0
174 stars 136 forks source link

Convergence Issue with Simple Structure Optimization #5373

Closed Angel-Jia closed 2 weeks ago

Angel-Jia commented 2 weeks ago

Describe the bug

While following the tutorial for surface energy calculations(https://bohrium.dp.tech/notebooks/45588412168), I encountered a potential convergence issue during structure optimization. Using the tutorial's recommended parameters, the structure converges within 6 ionic steps. However, when switching the optimization algorithm to CG (conjugate gradient), the structure fails to converge even after 200 steps. Examining the forces on the atoms in the 200th step reveals a significant force along the z-axis, showing no sign of convergence.

After extracting the structure from the 200th step and switching to the BFGS optimization algorithm, the structure fully converges in just 6 steps. However, with CG, even after an additional few dozen steps, convergence remains unattainable.

Given that this is a very simple structure, the CG algorithm should not encounter such difficulties with convergence. This may indicate a potential bug.

Expected behavior

No response

To Reproduce

The calculation parameters for the first 200 steps are as follows: STRU

ATOMIC_SPECIES
Pt 1 Pt_ONCV_PBE-1.0.upf

NUMERICAL_ORBITAL
Pt_gga_7au_100Ry_4s2p2d1f.orb

LATTICE_CONSTANT
1.8897261246257702

LATTICE_VECTORS
2.7745998170175787 0.0 0.0 
0.0 2.7745998170175787 0.0 
0.0 0.0 35.69559764590668 

ATOMIC_POSITIONS
Cartesian    # Cartesian(Unit is LATTICE_CONSTANT)
Pt
0.0
9
0.000000000000 0.000000000000 35.630697791400 1 1 1
0.000000000000 0.000000000000 3.895260943500 1 1 1
0.000000000000 0.000000000000 7.847677142500 0 0 0
0.000000000000 0.000000000000 11.799841619700 1 1 1
0.000000000000 0.000000000000 15.758166011200 1 1 1
1.387299908500 1.387299908500 1.895551999400 1 1 1
1.387299908500 1.387299908500 5.885847095800 0 0 0
1.387299908500 1.387299908500 9.809864145000 0 0 0
1.387299908500 1.387299908500 13.798520367400 1 1 1

KPT:

K_POINTS
0
Gamma
5 5 1 0 0 0

INPUT:

INPUT_PARAMETERS
suffix                  Pt9
ntype                   1
pseudo_dir              ../
orbital_dir             ../
smearing_method          mp
smearing_sigma           0.008

ecutwfc                 100         # Rydberg
scf_thr                 1e-4        # Rydberg
basis_type              lcao            
calculation             relax
relax_nmax              200
cal_force               1
cal_stress              1
out_stru                1

Then, using the structure from the 200th step, I continued the optimization with the following STRU and INPUT parameters, achieving convergence within 6 ionic steps. STRU:

ATOMIC_SPECIES
Pt   1.0000 Pt_ONCV_PBE-1.0.upf upf201

NUMERICAL_ORBITAL
Pt_gga_7au_100Ry_4s2p2d1f.orb

LATTICE_CONSTANT
1.8897261246

LATTICE_VECTORS
        2.7745998170        0.0000000000        0.0000000000
        0.0000000000        2.7745998170        0.0000000000
        0.0000000000        0.0000000000       35.6955976459

ATOMIC_POSITIONS
Direct

Pt #label
0.0000   #magnetism
9 #number of atoms
        1.0000000000        1.0000000000        0.9981295709 m 1 1 1
        1.0000000000        1.0000000000        0.1084572689 m 1 1 1
        0.0000000000        0.0000000000        0.2198500000 m 0 0 0
        1.0000000000        1.0000000000        0.3307174381 m 1 1 1
        1.0000000000        1.0000000000        0.4418441359 m 1 1 1
        0.5000000000        0.5000000000        0.0525815685 m 1 1 1
        0.5000000000        0.5000000000        0.1648900000 m 0 0 0
        0.5000000000        0.5000000000        0.2748200000 m 0 0 0
        0.5000000000        0.5000000000        0.3873514213 m 1 1 1

INPUT:

INPUT_PARAMETERS
pseudo_dir              ../
orbital_dir             ../

calculation             relax # scf relax cell-relax md
ecutwfc                 80
scf_thr                 1e-7
scf_nmax                300
relax_nmax              200
# relax_method            bfgs  # cg, bfgs, cg_bfgs, sd, "fire"
force_thr_ev            0.05  # ev
# stress_thr            5

basis_type              lcao  # lcao or pw

smearing_method         mp    # mp/gaussian/fd/fixed, mp for metal gau for semicon
smearing_sigma          0.008  # Rydberg, 0.008 for mp 0.001 for gau

cal_force          1
cal_stress         1
out_stru           1  # print STRU in OUT

However, if the relax_method is changed to cg or if scf_thr is set to 1e-4 (with relax_method=bfgs), the structure fails to converge.

Environment

Abacus 3.8.0

Additional Context

No response

Task list for Issue attackers (only for developers)

Angel-Jia commented 2 weeks ago

pseudo and orbital files: orb_upf.tar.gz

Angel-Jia commented 2 weeks ago

It appears that the issue is related to the parameter scf_thr=1e-4. After using the CG algorithm with scf_thr=1e-4, the structure optimization converged.

mohanchen commented 2 weeks ago

It appears that the issue is related to the parameter scf_thr=1e-4. After using the CG algorithm with scf_thr=1e-4, the structure optimization converged.

Excellent, but where did you get the value of scf_thr = 1e-4? It is too large.

Angel-Jia commented 2 weeks ago

It appears that the issue is related to the parameter scf_thr=1e-4. After using the CG algorithm with scf_thr=1e-4, the structure optimization converged.

Excellent, but where did you get the value of scf_thr = 1e-4? It is too large.

I found this in the tutorial:: https://bohrium.dp.tech/notebooks/7417640496 and I forgot to modify it afterward.