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

Refactor Volume class to support multiple data types #282

Merged
merged 14 commits into from
Mar 25, 2024
Merged

Conversation

stefsmeets
Copy link
Contributor

@stefsmeets stefsmeets commented Mar 7, 2024

This PR updates the Volume class to store multiple data volumes, mimicking pymatgen's VolumetricData. This makes some things a bit easier, like grouping similar data types and being able to write all data volumes to a vesta file in one go. The downside is that it needs a bit more management of the data keys (e.g. for plotting). Maybe that is something that can be simplified later.

I considered using VolumetricData as a base class, but it requires a structure, which we don't necessarily have.

Closes #281

TODO

  • Remove .resolution / calculate it on the fly
  • voxel_size is redundant with resolution
  • Implement function so save to vesta data

@stefsmeets stefsmeets marked this pull request as ready for review March 7, 2024 15:06
@stefsmeets
Copy link
Contributor Author

Hi @SCiarella , could you have a look at this PR and let me know what you think?

@stefsmeets stefsmeets requested a review from SCiarella March 7, 2024 15:12
@stefsmeets
Copy link
Contributor Author

stefsmeets commented Mar 7, 2024

Actually, I'm not sure if I like this implementation.

I think I'd maybe rather go for something simpler.

@dataclass
class Volume:
    data: dict[str, np.ndarray]
    lattice: Lattice
    label: str
    units: Optional[...]

A = Volume(data=..., lattice=...)
B = Volume(data=..., lattice=...)

A.to_vasp_volume(structure=structure, other={'vol_b':B})

An additional requirement is to then move find_peaks() out of find_best_perc_path() to avoid 2 different data types.

src/gemdat/path.py Outdated Show resolved Hide resolved
@stefsmeets
Copy link
Contributor Author

Hi @SCiarella Could you have another look? I ended up revising the Volume class to solve a bunch of outstanding issues. Some of it affects the paths module, but I think the result is cleaner overall.

@stefsmeets stefsmeets requested a review from SCiarella March 12, 2024 11:11
@stefsmeets
Copy link
Contributor Author

Hi @SCiarella , did you have a chance to look at this yet?

Copy link
Contributor

@SCiarella SCiarella left a comment

Choose a reason for hiding this comment

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

Looks superb! 👍

The only minor comment that I have is that the percolating path is now computed using:

    peaks = vasp_path_vol.find_peaks()
    F = vasp_path_vol.get_free_energy(temperature=650.0)
    path = find_best_perc_path(F,
                               peaks=peaks,
                               percolate_x=True,
                               percolate_y=False,
                               percolate_z=False)

maybe we can make the .find_peaks() automatic, such that the user does not always have to pass it to find_best_perc_path

@stefsmeets
Copy link
Contributor Author

Thanks! Yeah, that would be useful. The issue I ran into is that this would require passing both the volume and the free energy, and I wanted to not have to provide both here. I think passing peaks makes it more clear what is happening and allows users to pass their own set of peaks.

We could default to finding the peaks (when peaks==None) from the free energy. That requires a modification to the peak finding algorithm to find local minima.

@stefsmeets stefsmeets merged commit f73fc3e into main Mar 25, 2024
3 checks passed
@stefsmeets stefsmeets deleted the volume branch March 25, 2024 12:00
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.

Vesta add energy landscape to data file
2 participants