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

Only include necessary POTCARs #700

Closed
wants to merge 1 commit into from
Closed

Only include necessary POTCARs #700

wants to merge 1 commit into from

Conversation

pmrv
Copy link
Contributor

@pmrv pmrv commented Aug 3, 2022

It can happen that a structure defines more chemical elements on it than are actually present in it. For example Atoms(species=['Fe','Al'], indices=[1,1,1,1], ....) defines a structure with four aluminum inside. StructureStorage does this systematically to ensure that indices of structures from one container are consistent and but it can also happen after deleting atoms from a structure or something similar.

When a Vasp job sees such a structure it starts writing out POTCARs for all elements defined instead of those that are present. Since the POSCAR however only has one element present, the calculation ends up using the wrong pseudopotential.

I've made a quick fix by ensuring that only POTCARs of elements present in the structure are written, but it's a bit of a footgun waiting to happen again. I'm open for other suggestions how to fix this more cleanly.

@pmrv pmrv added bug Something isn't working help wanted Extra attention is needed labels Aug 3, 2022
@coveralls
Copy link

Pull Request Test Coverage Report for Build 2788941225

  • 4 of 4 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 68.617%

Totals Coverage Status
Change from base Build 2788281765: 0.02%
Covered Lines: 11846
Relevant Lines: 17264

💛 - Coveralls

@Leimeroth
Copy link
Member

Since this also messed with my calculations (See #718) already, I assume that the species property of the structures itself is dangerous right now. Maybe something like that maps:
np.unique(self.numbers)
to symbols would be better?

@stale
Copy link

stale bot commented Sep 21, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 21, 2022
@Leimeroth
Copy link
Member

Leimeroth commented Sep 21, 2022

bump

@stale stale bot removed the stale label Sep 21, 2022
@ligerzero-ai
Copy link
Contributor

ligerzero-ai commented Sep 24, 2022

A working/hacky solution would be to convert it to a pymatgen structure to avoid the chemical API completely.

Then call this function that I had for my prior workflows:

 struct = pyiron_to_pymatgen(structure)
 site_element_list = [site.species_string for site in struct]
 potcar_ele_list = [site_element_list[0]]

 for i, element in enumerate(site_element_list [1:]):
     if element != site_element_list[i]:
         potcar_ele_list.append(element)

It's not elegant, but it works, and fixes a dangerous error that's still lurking. The only issue I have with this is that this can get expensive for large structures, if ordering is preserved (which won't be the case for most users anyway). In this case it may be necessary to import a library, maybe itertools, which could be faster (I have no idea which one is faster right now.)

I am not so familiar with ASE so if there is an equivalent way to do this it may be preferable.

@stale
Copy link

stale bot commented Oct 15, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@pmrv
Copy link
Contributor Author

pmrv commented Nov 3, 2022

Obsolete by #799

@pmrv pmrv closed this Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants