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

JDFTx IO module #4078

Open
wants to merge 114 commits into
base: master
Choose a base branch
from
Open

JDFTx IO module #4078

wants to merge 114 commits into from

Conversation

benrich37
Copy link

@benrich37 benrich37 commented Sep 24, 2024

Summary

Major changes:

  • Robust out file parsing for JDFTx
  • In file parsing, managing and writing for JDFTx
  • Testing (coverage at 97%)

Changes to existing code:
core.periodic_table

  • For both ElementBase and Species class, the code within the "valence" property was copy-pasted into a new "valences" property, with the error raised for ambiguous valence (more than one valence subshell) removed
    (if len(valence) > 1: raise ValueError(f"{self} has ambiguous valence"))
    and return signature changed from tuple[int | np.nan, int] to list[tuple[int | np.nan, int]] (return valence instead of return valence[0])
  • For both ElementBase and Species class, the "valence" property was re-written to reduce redundancy to raise the ambiguous valence ValueError if len(self.valences) > 1, and otherwise return self.valences[0]

(I have an idea of how to remove the redundancy between Species and ElementBase for valence, but I will hold off on this until the next PR)

Todos

  • Move out file parsing class to be held by a broader output manager capable of parsing other dumped files by JDFTx

… top of __getattr__ magic method so it is more clear to the user what variables are accessible from a jdftxoutfile object (and other downstream class objects)
…done 100% to work properly without circular imports, but the size of this repo causes refactor symbol movement to take literally minutes, so keeping the structure like so for now
…stuff + JDFTXInfile item setting safety nets, additional testing for infile, and more informative README
Problems on readme line breaks

Signed-off-by: benrich37 <[email protected]>
Problems on README

Signed-off-by: benrich37 <[email protected]>
Problems on README

Signed-off-by: benrich37 <[email protected]>
Problems on README

Signed-off-by: benrich37 <[email protected]>
Signed-off-by: benrich37 <[email protected]>
Signed-off-by: benrich37 <[email protected]>
Updated README for JDFTX io branch

Signed-off-by: benrich37 <[email protected]>
Added pyproject.toml to workflow dependencies

Signed-off-by: benrich37 <[email protected]>
…ymatgen fork as a dependency (anticipating the class objects not being kept in individual submodules for very long)
Adding imports to jdftx module's __init__ so I can start using this p…
@mkhorton
Copy link
Member

@benrich37 thanks for this PR and for your patience! Is the current branch up-to-date, and are there are specific areas of concern?

@benrich37
Copy link
Author

@benrich37 thanks for this PR and for your patience! Is the current branch up-to-date, and are there are specific areas of concern?

Hey! Thank you for your comments! Sorry I hadn't checked this PR in a few days. My main concern for this PR is its readability - I wrote the JDFTx output's data structure to be object oriented to help develop faster, but I can understand how the hierarchy of objects can make it difficult to understand what's going on. I feel confident with functionality itself though (aside from edge cases for JDFTx outputs that keep popping up)

@computron
Copy link
Member

From my side, can you explain the changes to periodic_table.py? Since it's a core class the changes should ideally be separated out from new functionality.

@shyuep
Copy link
Member

shyuep commented Oct 23, 2024

There is a failing test that I am pretty sure is related to the changes to periodic table.

@benrich37
Copy link
Author

benrich37 commented Oct 23, 2024

There is a failing test that I am pretty sure is related to the changes to periodic table.

Hi @shyuep ! Sorry yes - I thought it would be cleaner to have the Species valence(s) property defer to the Element valence(s) property, but I'm seeing now these need to be defined separately so that Species can incorporate oxidation state. Fixing right now.

Also @computron - that makes to me, I wasn't sure if it would be better to have internal redundancy to the periodic_table module in this PR or to update alongside this IO module. @mkhorton - would it be okay to go back to using the ad-hoc method in the io.jdftx.data module for the time being?

Edit: @computron sorry misread your comment - part of the JDFTx output parsing requires a method which can fetch the number of valence electrons for each element in a Structure. The original method that did this was redundant to data that could be fetched by periodic_table, but the valence property needed to do this would throw errors for mixed valence species. I'm okay with either a) Species and Element updated to include a valences property, or b) have my own method (for now) to get the number of valence electrons that works for mixed valence species. As long as there is consensus, I can roll back changes to periodic_table and re-introduce them in a new PR after this one is accepted.

@benrich37
Copy link
Author

benrich37 commented Oct 23, 2024

Quick update: some of the dataclasses are having issues calling attributes that used to work. Should be fixed soon.

Edit: Fixed now.

@mkhorton
Copy link
Member

I wasn't sure if it would be better to have internal redundancy to the periodic_table module in this PR or to update alongside this IO module.

Definitely let's try to minimize internal redundancy. That kind of thing can get out of control quickly and lead us towards a messy codebase.

I'll take another look at this soon, but if you want to arrange a quick call (~1hr) to review this PR I'm also open to that. I do not expect big issues but it might make it easier/quicker for us to get through it together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants