Skip to content

JDFTXOutfileSlice.trajectory revision #4425

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

Merged

Conversation

benrich37
Copy link
Contributor

Summary

Major changes:

  • feature 1: JDFTXOutfileSlice.trajectory is now initialized with frame_properties set
    -- JOutStructure.properties filled with relevant data for frame_properties
    -- More properties added to JOutStructure.site_properties

Todos

  • Remove class attributes in JOutStructure now redundant to data stored in JOutStructure.properties and JOutStructure.site_properties

@benrich37 benrich37 requested review from shyuep and mkhorton as code owners May 30, 2025 21:32
@shyuep
Copy link
Member

shyuep commented May 31, 2025

I think way too much complexity is being introduced here. Surely the slicing can be integrated as part of the usual out file parsing? E.g., Vasprun just integrates the ionic_step_skip rather than having one special module and class to do it. Not the mention that there is a lot of duplicated code.

@benrich37
Copy link
Contributor Author

I think way too much complexity is being introduced here. Surely the slicing can be integrated as part of the usual out file parsing? E.g., Vasprun just integrates the ionic_step_skip rather than having one special module and class to do it. Not the mention that there is a lot of duplicated code.

@shyuep For the duplicated code are you referring to the data stored insite_properties and properties that are also stored as regular io.jdftx.joutstructure.JOutStructure attributes? I was putting off removing the attributes as I believe some are referenced in atomate2, but I can do my due diligence / update those references in atomate2 to use the site_properties/properties instead.

I'm also not sure which slicing you're referring to (unless you're referring to the pre-existing none_slice_bools functionality in io.jdftx.outputs.JDFTXOutfile.from_file which is admittedly a bit overly convoluted)

@benrich37
Copy link
Contributor Author

@shyuep Sorry I think I understand what you mean now - I think JOutStructure can be entirely replaced by a regular Structure by moving the parsing functions to JOutStructures and all attributes to Structure.properties and Structure.site_properties. I just want to confirm this is what you mean before starting as this might take a bit of work

@@ -959,6 +961,22 @@ def _collect_generic_line(self, line_text: str, generic_lines: list[str]) -> tup
generic_lines.append(line_text)
return generic_lines, collecting, collected

def _fill_properties(self) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

This is so that JOutStructure.properties gets set automatically, e.g. so JOutStructure.as_dict() saves everything you want to be saved?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mkhorton Right now the purpose of JOutStructure_fill_properties is to fill JOutStructure.properties for using as frame properties in Trajectory construction inJDFTXOutfileSlice._set_trajectory. I am also hoping to fully move all possible JOutStructure attributes into JOutStructure.properties, so this function is a placeholder to allow JOutStructures and JDFTXOutfileSlice to fetch data from JOutStructure.properties instead of JOutStructure directly until a future PR where these current JOutStructure attributes are saved under JOutStructure.properties instead. I am hoping that using JOutStructure.properties will make the class a lot cleaner, while also making the process of adding new properties down the road a lot easier.

"""
if len(self) == 0:
return []
return [getattr(s, prop, None) for s in self.slices]
Copy link
Member

Choose a reason for hiding this comment

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

Since the list of properties is known, why allow this to fail and return None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mkhorton Sorry this is my bad - JOutStructures.get_frame_property_list is a vestigial function from an earlier version of this PR before I realized constructing frame properties for a Trajectory was a lot easier to do using Structure.properties. This function needs to be deleted.

@benrich37 benrich37 requested a review from mkhorton June 10, 2025 00:59
@shyuep shyuep enabled auto-merge (squash) June 10, 2025 14:05
@shyuep shyuep merged commit 234d115 into materialsproject:master Jun 10, 2025
42 checks passed
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.

3 participants