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

Conversation

pmrv
Copy link
Contributor

@pmrv pmrv commented Aug 26, 2024

No description provided.

@pmrv
Copy link
Contributor Author

pmrv commented Aug 26, 2024

Sphinx raised an error before, but I changed it to a warning. Vasp previously allowed to set negative numbers which could lead to negative NBANDS, which then of course crashed Vasp. In both cases I bump values <= 0 to 1, but we can discuss other defaults.

@pmrv
Copy link
Contributor Author

pmrv commented Aug 26, 2024

@samwaseda I see the sphinx unit tests check for the for the ValueError. What do you think, is it safer to raise the error or is setting "reasonable" value ok? I have no strong feelings either way.

@samwaseda
Copy link
Member

That doesn’t sound reasonable to me. For example, it makes sense for me to set a random LAMMPS potential: “you didn’t set a potential, so we set one for you”. In this case, on the other hand, what this PR is basically saying is “you did set a value, but we change it”. Or can you tell me what would be a reasonable situation for this?

@pmrv
Copy link
Contributor Author

pmrv commented Aug 27, 2024

I basically had I bug in my code that called job.set_empty_states(a_negative_number) and the vasp job let me do it, so I just want to avoid this situation. I cannot think of anything that would call for setting less states than electrons, so I figured bumping values <= 0 to 1 is reasonable, but a ValueError is less intrusive and I'll change it back in both cases then.

@pmrv pmrv added the integration Start the notebook integration tests for this PR label Aug 30, 2024
@pmrv pmrv changed the title Emit warning when trying to set negative number of empty bands in DFT Emit error when trying to set negative number of empty bands in DFT Sep 3, 2024
Copy link
Member

@jan-janssen jan-janssen left a comment

Choose a reason for hiding this comment

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

Looks good to me

pyiron_atomistics/sphinx/base.py Outdated Show resolved Hide resolved
pyiron_atomistics/vasp/base.py Outdated Show resolved Hide resolved
pyiron_atomistics/sphinx/base.py Outdated Show resolved Hide resolved
pyiron_atomistics/vasp/base.py Outdated Show resolved Hide resolved
@@ -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

@@ -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 pmrv merged commit 8fa6b31 into main Sep 6, 2024
24 checks passed
@pmrv pmrv deleted the bands branch September 6, 2024 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration Start the notebook integration tests for this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants