Commit dd867f7
authored
fix(corrections): swap defect/bulk site potentials in get_efnv_correction (GH#219) (#226)
Lines 96-97 of kumagai.py had defect_potentials and bulk_potentials
sourced from the wrong structures. For antisite defects (defect.num_sites
== bulk.num_sites) the swap was silent but produced incorrect alignment;
for vacancies and interstitials it raised IndexError downstream in
pydefect's make_efnv_correction.
- Restore correct ordering: potentials are read from the structure they
describe.
- The pre-existing test_kumagai assertion (q=+1 correction > 0) was
effectively locking in the buggy behavior — the correct value with
proper ordering is approximately -0.49 eV. Updated to assert the new
reference value.
- Add test_kumagai_vacancy regression test that synthesizes a vacancy
(different num_sites between defect and bulk) and exercises the bug
directly. Without the fix this raises the same IndexError reported
in GH#219.
Reported by user in GH issue #219; the issue body identifies the swap
and the verified-against-legacy KumagaiCorrection value.1 parent 12c1f80 commit dd867f7
2 files changed
Lines changed: 47 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
| 96 | + | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
88 | 94 | | |
89 | 95 | | |
90 | 96 | | |
91 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
92 | 136 | | |
93 | 137 | | |
94 | 138 | | |
| |||
0 commit comments