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 3 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
6 changes: 4 additions & 2 deletions pyiron_atomistics/sphinx/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,10 @@ def set_empty_states(self, n_empty_states=None):
# will be converted later; see load_default_groups
self.input["EmptyStates"] = "auto"
else:
if n_empty_states < 0:
raise ValueError("Number of empty states must be greater than 0")
if n_empty_states <= 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if n_empty_states <= 0:
if n_empty_states < 0:

0 should be ok

pmrv marked this conversation as resolved.
Show resolved Hide resolved
raise ValueError(
f"Number of empty states must be a positive integer, not {n_empty_states}!"
pmrv marked this conversation as resolved.
Show resolved Hide resolved
)
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if n_empty_states <= 0:
if n_empty_states < 0:

0 should be ok

pmrv marked this conversation as resolved.
Show resolved Hide resolved
raise ValueError(
f"Number of empty states must be a positive integer, not {n_empty_states}!"
pmrv marked this conversation as resolved.
Show resolved Hide resolved
)
self.input.incar["NBANDS"] = int(round(n_elect / 2)) + int(n_empty_states)

def get_nelect(self):
Expand Down
Loading