Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit error when trying to set negative number of empty bands in DFT #1542

Merged
merged 4 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pyiron_atomistics/sphinx/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,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 @@ -1333,6 +1333,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
Loading