Skip to content

[BUG] ABACUS SCF reader inverts coordinates for left-handed cells without transforming forces #1061

Description

@swyang-lab

Bug summary

When the input STRU cell has a negative determinant, right_hand_rule() negates the cell and Cartesian coordinates. However, the SCF reader loads forces from running_scf.log without negating them.

The exported coordinates and forces therefore belong to inconsistent spatial representations. The trigger is cell handedness, not atom count.

dpdata Version

The same logic was also observed in GitHub master on September 20, 2026. The affected installation uses the older dpdata/abacus/ module path.

Input Files, Running Commands, Error Log, etc.

task.21.zip
calculation/
├── INPUT
├── STRU
└── OUT.ABACUS/running_scf.log

Read and export using:

import dpdata

system = dpdata.LabeledSystem("calculation", fmt="abacus/scf")
system.to_deepmd_npy("exported")

Observed values from an affected dataset:
eg:

Original Cartesian position ≈ [ 2.7337, 7.0893, 2.2321]
Exported coord.npy ≈ [-2.7337, -7.0891, -2.2320]

ABACUS TOTAL-FORCE = [-0.0020299593, 2.3578977033, 0.3664125131]
Exported force.npy ≈ [-0.002, 2.3579, 0.3664]

The coordinates are approximately negated, while the force signs remain unchanged. This is a silent data-consistency error rather than a parsing exception.

Steps to Reproduce

Prepare a converged ABACUS SCF calculation whose input STRU cell has det(cell) < 0 and whose output contains nonzero forces.

Read the calculation with dpdata.LabeledSystem(..., fmt="abacus/scf").

Compare the parsed cell and Cartesian coordinates with the original STRU.

Compare the parsed forces with the corresponding TOTAL-FORCE block.

Actual: Cell and coordinates are negated; forces retain their original signs.

Expected: If coordinates undergo spatial inversion, forces must also be negated. Energy, stress, and virial should remain unchanged under this inversion.

Further Information, Files, and Links

Relevant source code:

stru.py::right_hand_rule() negates only the cell and coordinates:

if np.linalg.det(cell) < 0:
cell = -cell
coord = -coord

get_frame_from_stru() calls this function without returning an inversion flag.

scf.py::get_force() reads forces without a spatial transformation.

scf.py::get_frame() combines the transformed structure with the untransformed forces.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions