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 static calculation feature to matcalc/relaxation.py #29

Merged
merged 11 commits into from
Sep 6, 2024

Conversation

rul048
Copy link
Contributor

@rul048 rul048 commented Aug 12, 2024

In the original relaxation.py, users are allowed to do cell relaxation or atoms only relaxation. Static calculation is an important feature itself and also part of some complex applications (eg. QHA). As MatCalc provides a universal interface for different uMLIPs, how about we add this feature to RelaxCalc? The default is still cell relaxation, and user can set "relax_atoms" and "relax_cell" to False to do static calculation.

Summary

Major changes:

  • feature 1: ...
  • fix 1: ...

Todos

If this is work in progress, what else needs to be done?

  • feature 2: ...
  • fix 2:

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)

Tip: Install pre-commit hooks to auto-check types and linting before every commit:

pip install -U pre-commit
pre-commit install

In the original relaxation.py, users are allowed to do cell relaxation or atoms only relaxation. Static calculation is an important feature itself and also part of some complex applications (eg. QHA). As MatCalc provides a universal interface for different uMLIPs, how about we add this feature to RelaxCalc? The default is still cell relaxation, and user can set "relax_atoms" and "relax_cell" to False to do static calculation. 

Signed-off-by: Runze Liu <[email protected]>
Signed-off-by: Runze Liu <[email protected]>
Signed-off-by: Runze Liu <[email protected]>
@shyuep
Copy link
Contributor

shyuep commented Aug 30, 2024

This is good, but I will need unittests for all three different options.

Signed-off-by: Runze Liu <[email protected]>
Signed-off-by: Runze Liu <[email protected]>
@rul048
Copy link
Contributor Author

rul048 commented Sep 3, 2024

Okay, I think it should be fine now. Credit to Dr Ko, learn a lot about how to do unittests from MatGL.

forces: ArrayLike = result["forces"]
stresses: ArrayLike = result["stress"]

assert isinstance(energy, float)
Copy link
Contributor

Choose a reason for hiding this comment

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

These asserts should be based on value, not type.

Signed-off-by: Runze Liu <[email protected]>
Signed-off-by: Runze Liu <[email protected]>
Signed-off-by: Runze Liu <[email protected]>
@shyuep shyuep merged commit 00be81a into materialsvirtuallab:main Sep 6, 2024
4 checks passed
@rul048 rul048 deleted the patch-7 branch September 19, 2024 01:29
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.

2 participants