Skip to content

Commit f4fe1c1

Browse files
committed
add occu_cutoff
1 parent 598fea9 commit f4fe1c1

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/pymatgen/io/vasp/inputs.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,11 +2126,17 @@ def __repr__(self) -> str:
21262126
TITEL, VRHFIN, n_valence_elec = (self.keywords.get(key) for key in ("TITEL", "VRHFIN", "ZVAL"))
21272127
return f"{cls_name}({symbol=}, {functional=}, {TITEL=}, {VRHFIN=}, {n_valence_elec=:.0f})"
21282128

2129-
@property
2130-
def electron_configuration(self) -> list[tuple[int, str, float]]:
2129+
def get_electron_configuration(
2130+
self,
2131+
occu_cutoff: float = 0.01,
2132+
) -> list[tuple[int, str, float]]:
21312133
"""Valence electronic configuration corresponding to the ZVAL,
21322134
read from the "Atomic configuration" section of POTCAR.
21332135
2136+
Args:
2137+
occu_cutoff (float): Occupancy cutoff below which an orbital
2138+
would be considered empty.
2139+
21342140
Returns:
21352141
list[tuple[int, str, float]]: A list of tuples containing:
21362142
- n (int): Principal quantum number.
@@ -2157,11 +2163,11 @@ def electron_configuration(self) -> list[tuple[int, str, float]]:
21572163

21582164
total_electrons = 0.0
21592165
valence_config: list[tuple[int, str, float]] = []
2160-
for line in lines[start_idx + 3 + num_entries - 1 : start_idx + 2 : -1]:
2166+
for line in lines[start_idx + 2 + num_entries : start_idx + 2 : -1]:
21612167
parts = line.split()
21622168
n, ang_moment, _j, _E, occ = int(parts[0]), int(parts[1]), float(parts[2]), float(parts[3]), float(parts[4])
21632169

2164-
if occ >= 0.01: # TODO: hard-coded occupancy cutoff
2170+
if occ >= occu_cutoff:
21652171
valence_config.append((n, l_map[ang_moment], occ))
21662172
total_electrons += occ
21672173

@@ -2170,6 +2176,19 @@ def electron_configuration(self) -> list[tuple[int, str, float]]:
21702176

21712177
return list(reversed(valence_config))
21722178

2179+
@property
2180+
def electron_configuration(self) -> list[tuple[int, str, float]]:
2181+
"""Valence electronic configuration corresponding to the ZVAL,
2182+
read from the "Atomic configuration" section of POTCAR.
2183+
2184+
Returns:
2185+
list[tuple[int, str, float]]: A list of tuples containing:
2186+
- n (int): Principal quantum number.
2187+
- subshell (str): Subshell notation (s, p, d, f).
2188+
- occ (float): Occupation number, limited to ZVAL.
2189+
"""
2190+
return self.get_electron_configuration()
2191+
21732192
@property
21742193
def element(self) -> str:
21752194
"""Attempt to return the atomic symbol based on the VRHFIN keyword."""

0 commit comments

Comments
 (0)