Skip to content

Commit

Permalink
Merge pull request #1542 from pyiron/bands
Browse files Browse the repository at this point in the history
Emit error when trying to set negative number of empty bands in DFT
  • Loading branch information
pmrv authored Sep 6, 2024
2 parents 0fe01f9 + dd98e78 commit 8fa6b31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyiron_atomistics/sphinx/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,9 @@ def set_empty_states(self, n_empty_states=None):
self.input["EmptyStates"] = "auto"
else:
if n_empty_states < 0:
raise ValueError("Number of empty states must be greater than 0")
raise ValueError(
f"Number of empty states must be a positive integer or zero, not {n_empty_states}!"
)
self.input["EmptyStates"] = n_empty_states
self.input.sphinx.PAWHamiltonian.nEmptyStates = self.input["EmptyStates"]

Expand Down
4 changes: 4 additions & 0 deletions pyiron_atomistics/vasp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,10 @@ def set_empty_states(self, n_empty_states=None):
"""
n_elect = self.get_nelect()
if n_empty_states is not None:
if n_empty_states < 0:
raise ValueError(
f"Number of empty states must be a positive integer or zero, not {n_empty_states}!"
)
self.input.incar["NBANDS"] = int(round(n_elect / 2)) + int(n_empty_states)

def get_nelect(self):
Expand Down

0 comments on commit 8fa6b31

Please sign in to comment.