Skip to content

Error of force calculation when atom number is 0 in ATOMIC_POSITIONS of STRU file #5672

@saltball

Description

@saltball

Describe the bug

(It happens when I try to use abacus for calculate many system with different elements)

See reproduce for details, there I offer a bug one and a reference one with comparable force results from running_scf.log

simliar problem when basis_type pw in INPUT,
so I guess it happens in module_hamilt_pw/hamilt_pwdft/forces.cpp or functions it used.

A error when readin INPUT or some changes when calculating force may be needed.

Expected behavior

ABACUS should calculate the force with same results even some atom is 0 in STRU, or raise error before calculation.

To Reproduce

bug one

INPUT file

INPUT_PARAMETERS
calculation scf
ntype 3
symmetry 0
scf_nmax 100
cal_force 1
cal_stress 1
basis_type lcao

STRU file

ATOMIC_SPECIES
C 12.011 C_ONCV_PBE-1.0.upf
H 1.008 H_ONCV_PBE-1.0.upf
O 15.999 O_ONCV_PBE-1.0.upf

NUMERICAL_ORBITAL
C_gga_7au_100Ry_2s2p1d.orb
H_gga_6au_100Ry_2s1p.orb
O_gga_7au_100Ry_2s2p1d.orb

LATTICE_CONSTANT
1.8897261246257702

LATTICE_VECTORS
3.23994501 0.0 0.0 
0.0 3.34809276 0.0 
0.0 -0.0 3.34809276 

ATOMIC_POSITIONS
Cartesian    # Cartesian(Unit is LATTICE_CONSTANT)
C
0.0
0
H
0.0
4
1.054894602991 1.120511728342 1.120511728342 1 1 1
1.054894602991 2.227581031658 2.227581031658 1 1 1
2.674867107991 0.553534651658 2.794558108342 1 1 1
2.674867107991 2.794558108342 0.553534651658 1 1 1
O
0.0
2
0.028577740564 0.000000000000 0.000000000000 1 1 1
1.648550245564 1.674046380000 1.674046380000 1 1 1

running_scf.log

...
------------------------------------------------------------------------------------------
 TOTAL-FORCE (eV/Angstrom)                                                                
------------------------------------------------------------------------------------------
                        H1    -70514.6367256015         4.2666958914         3.0005995736 
                        H2    -70514.6366366973        -3.0022018009        -4.2682981187 
                        H3    -70521.7385541953         3.7651275043        -3.7643264020 
                        H4    -70521.7385541953        -2.4959211587         2.4967222761 
                        O1    352590.7767670227        -3.1671491537         3.1679502711 
                        O2    -70518.0262963333         0.6334487176        -0.6326476002 
------------------------------------------------------------------------------------------
...

reference one

INPUT file

INPUT_PARAMETERS
calculation scf
ntype 2
symmetry 0
scf_nmax 100
cal_force 1
cal_stress 1
basis_type lcao

STRU file

ATOMIC_SPECIES
H 1.008 H_ONCV_PBE-1.0.upf
O 15.999 O_ONCV_PBE-1.0.upf

NUMERICAL_ORBITAL
H_gga_6au_100Ry_2s1p.orb
O_gga_7au_100Ry_2s2p1d.orb

LATTICE_CONSTANT
1.8897261246257702

LATTICE_VECTORS
3.23994501 0.0 0.0 
0.0 3.34809276 0.0 
0.0 -0.0 3.34809276 

ATOMIC_POSITIONS
Cartesian    # Cartesian(Unit is LATTICE_CONSTANT)
H
0.0
4
1.054894602991 1.120511728342 1.120511728342 1 1 1
1.054894602991 2.227581031658 2.227581031658 1 1 1
2.674867107991 0.553534651658 2.794558108342 1 1 1
2.674867107991 2.794558108342 0.553534651658 1 1 1
O
0.0
2
0.028577740564 0.000000000000 0.000000000000 1 1 1
1.648550245564 1.674046380000 1.674046380000 1 1 1

running_scf.log

...
------------------------------------------------------------------------------------------
 TOTAL-FORCE (eV/Angstrom)                                                                
------------------------------------------------------------------------------------------
                        H1        -0.2323950426        -0.1673506975        -0.1673506975 
                        H2        -0.2323950426         0.1673506975         0.1673506975 
                        H3        -0.2321606801         0.1674823173        -0.1674823173 
                        H4        -0.2321606801        -0.1674823173         0.1674823173 
                        O1         0.4750065264         0.0000000000         0.0000000000 
                        O2         0.4541049190         0.0000000000         0.0000000000 
------------------------------------------------------------------------------------------
...

Environment

abacus version: ABACUS version v3.8.3
[from conda-forge]
running_scf.log says Commit: 422ea34 (Tue Nov 19 12:27:17 2024 +0800)

Additional Context

No response

Task list for Issue attackers (only for developers)

  • Verify the issue is not a duplicate.
  • Describe the bug.
  • Steps to reproduce.
  • Expected behavior.
  • Error message.
  • Environment details.
  • Additional context.
  • Assign a priority level (low, medium, high, urgent).
  • Assign the issue to a team member.
  • Label the issue with relevant tags.
  • Identify possible related issues.
  • Create a unit test or automated test to reproduce the bug (if applicable).
  • Fix the bug.
  • Test the fix.
  • Update documentation (if necessary).
  • Close the issue and inform the reporter (if applicable).

Metadata

Metadata

Assignees

Labels

BugsBugs that only solvable with sufficient knowledge of DFT

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions