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

Add NEBCalculator with M3GNet and CHGNet example notebook #13

Merged
merged 24 commits into from
Dec 11, 2023

Conversation

JiQi535
Copy link
Collaborator

@JiQi535 JiQi535 commented Dec 11, 2023

Summary

Added NEBCalc for NEB calculations with universal potentials. LiFePO4 is used as an example system, where M3GNet-MS, M3GNet-DIRECT, and CHGNet provide reasonable agreements to each other and to literature.

Major changes:

  • Added a NEBCalc to perform NEB calculations with ASE.
  • Included examples of path along b and c directions in LiFePO4 with M3GNet-MS, M3GNet-DIRECT, and CHGNet.
  • NEBCalc can be constructed with from_end_images method that utilize Structure.interpolate in pymatgen to create initial NEB images.

Checklist

  • Google format doc strings added. Check with ruff.
  • Type annotations included. Check with mypy.
  • Tests added for new features/fixes.
  • If applicable, new classes/functions/modules have duecredit @due.dcite decorators to reference relevant papers by DOI (example)

Copy link
Collaborator

@janosh janosh left a comment

Choose a reason for hiding this comment

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

Nice work @JiQi535, this looks great! 👍

I think we need to cut down on the amount of NEB_data before merging as there are several MB of (unused?) traj data in this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see you loading all these trajectory files in the test nor example notebook you added. Were they committed by accident?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These can be deleted. They are truly not used anywhere. I will remove them from the PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have removed the traj files, and users can reproduce them with the notebook if needed. Now the NEB_data is below 1MB that majorly comes from the two png files in the notebook. Let me know if we need to futher downsize it or not.

Copy link
Collaborator

@janosh janosh Dec 11, 2023

Choose a reason for hiding this comment

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

Could you replace the PNGs with vector graphics if those are smaller (PDF will be smaller but might not work in notebook, so could try SVG as well).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just tried and the pdf file (~2.5MB for each) extracted from VESTA would be >5 times larger than the png snapshot. Directly transferring the png snapshots to pdf version would not change the size much, e.g., from 284 to 276 KB. If the storage space is of concern, maybe we can just remove all NEB_data?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just use the PNG. Don't be silly. there are instances where vector formats are better and there are those where non-vector are better. this is one instance. Though 2.5 Mb is really nothing.

Copy link
Collaborator

@janosh janosh Dec 11, 2023

Choose a reason for hiding this comment

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

@JiQi535 I think keeping visuals is nice. I compressed the PNG to 15% of orig size with minimal quality loss in b4ccc73. We're good here!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@janosh Thanks!

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fd4d186) 99.11% compared to head (e3375e4) 100.00%.
Report is 5 commits behind head on main.

❗ Current head e3375e4 differs from pull request most recent head 7b45c91. Consider uploading reports for the commit 7b45c91 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##             main       #13      +/-   ##
===========================================
+ Coverage   99.11%   100.00%   +0.88%     
===========================================
  Files           7         8       +1     
  Lines         227       271      +44     
===========================================
+ Hits          225       271      +46     
+ Misses          2         0       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

if self.traj_folder is not None:
os.makedirs(self.traj_folder, exist_ok=True)
for i in range(len(self.images)):
self.optimizer.attach(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need some more tests for uncovered lines (see the codecov comments).

Screenshot 2023-12-11 at 9 53 38 AM

@janosh janosh added enhancement New feature or request neb Nudged elastic band needs testing Needs more test coverage labels Dec 11, 2023
@janosh janosh merged commit e099a3b into materialsvirtuallab:main Dec 11, 2023
2 checks passed
@janosh
Copy link
Collaborator

janosh commented Dec 11, 2023

Thanks @JiQi535, really nice contribution!

@janosh janosh changed the title NEB calculator with example of LiFePO4 by M3GNet-MS, M3GNet-DIRECT, and CHGNet Add NEBCalculator with M3GNet and CHGNet example notebook Dec 11, 2023
@JiQi535
Copy link
Collaborator Author

JiQi535 commented Dec 11, 2023

Thanks @JiQi535, really nice contribution!

@janosh My pleasure to make some contributions here. And thanks for the thorough inspections and improvements before merging it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request neb Nudged elastic band needs testing Needs more test coverage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants