Skip to content

Commit 1f98fa2

Browse files
kaifengZhengjanosh
andauthored
Fix absorbing_atom index misuse in feff inputs.py (#3256)
Signed-off-by: KaifengZheng <[email protected]> Co-authored-by: Janosh Riebesell <[email protected]>
1 parent 1cfc267 commit 1f98fa2

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

pymatgen/io/feff/inputs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,7 @@ def __init__(self, struct, absorbing_atom, radius):
407407
self.absorbing_atom, self.center_index = get_absorbing_atom_symbol_index(absorbing_atom, struct)
408408
self.radius = radius
409409
self._cluster = self._set_cluster()
410-
atom_sym = get_absorbing_atom_symbol_index(absorbing_atom, self._cluster)[0]
411-
self.pot_dict = get_atom_map(self._cluster, atom_sym)
410+
self.pot_dict = get_atom_map(self._cluster, self.absorbing_atom)
412411

413412
def _set_cluster(self):
414413
"""

tests/files/.pytest-split-durations

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,8 +1608,8 @@
16081608
"tests/io/feff/test_sets.py::TestFeffInputSet::test_get_feff_tags": 0.0002768750418908894,
16091609
"tests/io/feff/test_sets.py::TestFeffInputSet::test_large_systems": 0.0024949999642558396,
16101610
"tests/io/feff/test_sets.py::TestFeffInputSet::test_number_of_kpoints": 0.0026772500132210553,
1611-
"tests/io/feff/test_sets.py::TestFeffInputSet::test_post_distdiff": 0.08853158302372321,
1612-
"tests/io/feff/test_sets.py::TestFeffInputSet::test_postfeffset": 0.09011012403061613,
1611+
"tests/io/feff/test_sets.py::TestFeffInputSet::test_post_dist_diff": 0.08853158302372321,
1612+
"tests/io/feff/test_sets.py::TestFeffInputSet::test_post_feffset": 0.09011012403061613,
16131613
"tests/io/feff/test_sets.py::TestFeffInputSet::test_reciprocal_tags_and_input": 0.02034700004151091,
16141614
"tests/io/feff/test_sets.py::TestFeffInputSet::test_small_system_EXAFS": 0.0005435419734567404,
16151615
"tests/io/feff/test_sets.py::TestFeffInputSet::test_to_and_from_dict": 0.0007752509554848075,

tests/io/feff/test_sets.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def test_large_systems(self):
184184
assert "CIF" not in elnes.tags
185185
assert "TARGET" not in elnes.tags
186186

187-
def test_postfeffset(self):
187+
def test_post_feffset(self):
188188
self.mp_xanes.write_input(f"{self.tmp_path}/xanes_3")
189189
feff_dict_input = FEFFDictSet.from_directory(f"{self.tmp_path}/xanes_3")
190190
assert feff_dict_input.tags == Tags.from_file(f"{self.tmp_path}/xanes_3/feff.inp")
@@ -223,7 +223,7 @@ def test_postfeffset(self):
223223
struct_reci = Structure.from_file(f"{self.tmp_path}/Dup_reci/Co2O2.cif")
224224
assert struct_orig == struct_reci
225225

226-
def test_post_distdiff(self):
226+
def test_post_dist_diff(self):
227227
feff_dict_input = FEFFDictSet.from_directory(f"{TEST_FILES_DIR}/feff_dist_test")
228228
assert feff_dict_input.tags == Tags.from_file(f"{TEST_FILES_DIR}/feff_dist_test/feff.inp")
229229
assert str(feff_dict_input.header()) == str(Header.from_file(f"{TEST_FILES_DIR}/feff_dist_test/HEADER"))
@@ -259,3 +259,10 @@ def test_big_radius(self):
259259
},
260260
)
261261
assert str(dict_set) is not None
262+
263+
def test_cluster_index(self):
264+
# https://github.com/materialsproject/pymatgen/pull/3256
265+
cif_file = f"{TEST_FILES_DIR}/Fe3O4.cif"
266+
structure = CifParser(cif_file).get_structures()[0]
267+
for idx in range(len(structure.species)):
268+
assert Atoms(structure, idx, 3).cluster

0 commit comments

Comments
 (0)