Skip to content

[Bug]: inverted site potentials in EFNV corrections #219

@lorenzo-villa-hub

Description

@lorenzo-villa-hub

Code snippet

What happened?

Lines 96-97 in kumagai.py:
bulk_potentials = [site.properties["potential"] for site in defect_structure]
defect_potentials = [site.properties["potential"] for site in bulk_structure]

defect and bulk potentials are built from inverted structures. Did not return an error for interstitials but it did for vacancies. Swapping defect_potentials and bulk_potentials fixed the problem for vacancies and returned a value consistent with the one obtained from the old KumagaiCorrection object.

Version

2025.9.26

Which OS?

  • MacOS
  • Windows
  • Linux

Log output

File ~/miniforge3/envs/dev/lib/python3.13/site-packages/pymatgen/analysis/defects/corrections/kumagai.py:112, in get_efnv_correction(charge, defect_structure, bulk_structure, dielectric_tensor, **kwargs)
     99 defect_calc_results = CalcResults(
    100     structure=defect_structure,
    101     energy=math.inf,
    102     magnetization=math.inf,
    103     potentials=defect_potentials,
    104 )
    105 bulk_calc_results = CalcResults(
    106     structure=bulk_structure,
    107     energy=math.inf,
    108     magnetization=math.inf,
    109     potentials=bulk_potentials,
    110 )
--> 112 efnv_corr = make_efnv_correction(
    113     charge=charge,
    114     calc_results=defect_calc_results,
    115     perfect_calc_results=bulk_calc_results,
    116     dielectric_tensor=dielectric_tensor,
...
---> 88 pot = calc_results.potentials[d] - perfect_calc_results.potentials[p]
     89 sites.append(PotentialSite(specie, distance, pot, None))
     90 coord = calc_results.structure[d].frac_coords

IndexError: list index out of range

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