Skip to content

[Code scan] Accumulate existing TMDC SOC hoppings instead of overwriting them #17

Description

@njzjz

This issue comes from a Codex global scan of deepmodeling/tbplas at commit 4d3652b.

Severity: Medium

The TMDC SOC builder retrieves an existing (0, 0, 0) hopping, adds soc_intensity into a local energy variable, and then discards that accumulated value. The final add_hopping() call writes only soc_intensity, so any existing hopping term is overwritten instead of updated.

Code reference:

try:
energy = cell.get_hopping((0, 0, 0), i, j)
except PCHopNotFoundError:
energy = 0.0
energy += soc_intensity
cell.add_hopping((0, 0, 0), i, j, soc_intensity)

Suggested fix: pass the accumulated energy value to add_hopping().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions