Skip to content

Conversation

@orionarcher
Copy link
Contributor

@orionarcher orionarcher commented Nov 11, 2024

Summary

Include a summary of major changes in bullet points:

  • Allows the OpenMM trajectories to report pymatgen trajectories

Additional dependencies introduced (if any)

Checklist

Work-in-progress pull requests are encouraged, but please put [WIP] in the pull request
title.

Before a pull request can be merged, the following items must be checked:

  • Code is in the standard Python style.
    The easiest way to handle this is to run the following in the correct sequence on
    your local machine. Start with running ruff and ruff format on your new code. This will
    automatically reformat your code to PEP8 conventions and fix many linting issues.
  • Doc strings have been added in the Numpy docstring format.
    Run ruff on your code.
  • Type annotations are highly encouraged. Run mypy to
    type check your code.
  • Tests have been added for any new functionality or bug fixes.
  • All linting and tests pass.

Note that the CI system will run all the above checks. But it will be much more
efficient if you already fix most errors prior to submitting the PR. It is highly
recommended that you use the pre-commit hook provided in the repository. Simply run
pre-commit install and a check will be run prior to allowing commits.

@orionarcher
Copy link
Contributor Author

Would you mind taking a look @janosh?

Copy link
Member

@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.

some variables use camelCase instead of snake_case to match OpenMM's style. i'd advocate for consistency with Python conventions. maybe @utf wants to weigh in what atomate's policy is

2 more suggestions:

  • could addi progress tracking for long trajectories
  • could add compression options for large trajectories


# Get energies in eV
kinetic_energy = (
state.getKineticEnergy()._value / ev_to_kj_per_mol # noqa: SLF001
Copy link
Member

Choose a reason for hiding this comment

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

is there no public openMM API to get these values? seems fragile to rely on _value here which i'm guessing has no backwards compat gurantees?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I was a bit more clever and fixed it.


self._nextModel += 1

def __del__(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.

what are the implications of using __del__ for file operations? afaik there's no guarantee when it will be called. maybe better to add a explicit save() method instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I was mirroring an external API and being a bit. I replaced it with a save method to be more robust.

The core problem is that the Reporters usually append to a file at each step but trajectory doesn't easily support that.

@janosh janosh added enhancement Improvements to existing features md Molecular dynamics labels Nov 11, 2024
@orionarcher
Copy link
Contributor Author

orionarcher commented Nov 11, 2024

There are other Reporters that all use the camelCase args. I think OpenMM call's some of the methods internally too, so it's not possible to change them. I'd advocate for sticking with that, even though I agree it's a bit heretical.

EDIT:

To be a little clearer. The Reporter is passed directly to the OpenMM simulation object, which I believe calls the report and describeNextReport methods internally.

@janosh janosh enabled auto-merge (squash) November 13, 2024 18:28
@janosh
Copy link
Member

janosh commented Nov 13, 2024

looks good! thanks @orionarcher 👍

@codecov
Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 0% with 56 lines in your changes missing coverage. Please review.

Project coverage is 4.15%. Comparing base (42bc7b8) to head (c72e87d).
Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
src/atomate2/openmm/utils.py 0.00% 45 Missing ⚠️
src/atomate2/openmm/jobs/base.py 0.00% 11 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #1053      +/-   ##
========================================
- Coverage   4.32%   4.15%   -0.18%     
========================================
  Files        178     187       +9     
  Lines      12911   13583     +672     
  Branches    1278    1360      +82     
========================================
+ Hits         559     564       +5     
- Misses     12321   12988     +667     
  Partials      31      31              
Files with missing lines Coverage Δ
src/atomate2/openmm/jobs/base.py 0.00% <0.00%> (ø)
src/atomate2/openmm/utils.py 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

auto-merge was automatically disabled November 13, 2024 21:27

Head branch was pushed to by a user without write access

@orionarcher
Copy link
Contributor Author

This will need one more loop back @janosh

@janosh janosh merged commit 0fb73a9 into materialsproject:main Nov 13, 2024
15 checks passed
hrushikesh-s pushed a commit to hrushikesh-s/atomate2 that referenced this pull request Nov 16, 2024
* Add trajectory reporter to openmm workflow

* respond to janosh review

* fix test

* slightly stricter asserts in test_trajectory_reporter

---------

Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvements to existing features md Molecular dynamics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants